babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1058. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1059. */
  1060. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1061. /**
  1062. * Constant used to retrieve the position texture index in the textures array in the prepass
  1063. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1064. */
  1065. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1066. /**
  1067. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1069. */
  1070. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1073. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1074. */
  1075. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1078. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1079. */
  1080. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve albedo index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1091. }
  1092. }
  1093. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1094. import { Nullable } from "babylonjs/types";
  1095. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1096. /**
  1097. * This represents the required contract to create a new type of texture loader.
  1098. */
  1099. export interface IInternalTextureLoader {
  1100. /**
  1101. * Defines wether the loader supports cascade loading the different faces.
  1102. */
  1103. supportCascades: boolean;
  1104. /**
  1105. * This returns if the loader support the current file information.
  1106. * @param extension defines the file extension of the file being loaded
  1107. * @param mimeType defines the optional mime type of the file being loaded
  1108. * @returns true if the loader can load the specified file
  1109. */
  1110. canLoad(extension: string, mimeType?: string): boolean;
  1111. /**
  1112. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1113. * @param data contains the texture data
  1114. * @param texture defines the BabylonJS internal texture
  1115. * @param createPolynomials will be true if polynomials have been requested
  1116. * @param onLoad defines the callback to trigger once the texture is ready
  1117. * @param onError defines the callback to trigger in case of error
  1118. */
  1119. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1120. /**
  1121. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1122. * @param data contains the texture data
  1123. * @param texture defines the BabylonJS internal texture
  1124. * @param callback defines the method to call once ready to upload
  1125. */
  1126. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1127. }
  1128. }
  1129. declare module "babylonjs/Engines/IPipelineContext" {
  1130. /**
  1131. * Class used to store and describe the pipeline context associated with an effect
  1132. */
  1133. export interface IPipelineContext {
  1134. /**
  1135. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1136. */
  1137. isAsync: boolean;
  1138. /**
  1139. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1140. */
  1141. isReady: boolean;
  1142. /** @hidden */
  1143. _getVertexShaderCode(): string | null;
  1144. /** @hidden */
  1145. _getFragmentShaderCode(): string | null;
  1146. /** @hidden */
  1147. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1148. }
  1149. }
  1150. declare module "babylonjs/Meshes/dataBuffer" {
  1151. /**
  1152. * Class used to store gfx data (like WebGLBuffer)
  1153. */
  1154. export class DataBuffer {
  1155. /**
  1156. * Gets or sets the number of objects referencing this buffer
  1157. */
  1158. references: number;
  1159. /** Gets or sets the size of the underlying buffer */
  1160. capacity: number;
  1161. /**
  1162. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1163. */
  1164. is32Bits: boolean;
  1165. /**
  1166. * Gets the underlying buffer
  1167. */
  1168. get underlyingResource(): any;
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1172. /** @hidden */
  1173. export interface IShaderProcessor {
  1174. attributeProcessor?: (attribute: string) => string;
  1175. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1176. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1177. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1178. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1179. lineProcessor?: (line: string, isFragment: boolean) => string;
  1180. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1181. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1185. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1186. /** @hidden */
  1187. export interface ProcessingOptions {
  1188. defines: string[];
  1189. indexParameters: any;
  1190. isFragment: boolean;
  1191. shouldUseHighPrecisionShader: boolean;
  1192. supportsUniformBuffers: boolean;
  1193. shadersRepository: string;
  1194. includesShadersStore: {
  1195. [key: string]: string;
  1196. };
  1197. processor?: IShaderProcessor;
  1198. version: string;
  1199. platformName: string;
  1200. lookForClosingBracketForUniformBuffer?: boolean;
  1201. }
  1202. }
  1203. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1204. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1205. /** @hidden */
  1206. export class ShaderCodeNode {
  1207. line: string;
  1208. children: ShaderCodeNode[];
  1209. additionalDefineKey?: string;
  1210. additionalDefineValue?: string;
  1211. isValid(preprocessors: {
  1212. [key: string]: string;
  1213. }): boolean;
  1214. process(preprocessors: {
  1215. [key: string]: string;
  1216. }, options: ProcessingOptions): string;
  1217. }
  1218. }
  1219. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1220. /** @hidden */
  1221. export class ShaderCodeCursor {
  1222. private _lines;
  1223. lineIndex: number;
  1224. get currentLine(): string;
  1225. get canRead(): boolean;
  1226. set lines(value: string[]);
  1227. }
  1228. }
  1229. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1230. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1231. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1232. /** @hidden */
  1233. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1234. process(preprocessors: {
  1235. [key: string]: string;
  1236. }, options: ProcessingOptions): string;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1240. /** @hidden */
  1241. export class ShaderDefineExpression {
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. private static _OperatorPriority;
  1246. private static _Stack;
  1247. static postfixToInfix(postfix: string[]): string;
  1248. static infixToPostfix(infix: string): string[];
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1252. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. not: boolean;
  1268. constructor(define: string, not?: boolean);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1275. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1276. /** @hidden */
  1277. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1278. leftOperand: ShaderDefineExpression;
  1279. rightOperand: ShaderDefineExpression;
  1280. isTrue(preprocessors: {
  1281. [key: string]: string;
  1282. }): boolean;
  1283. }
  1284. }
  1285. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1286. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1287. /** @hidden */
  1288. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1289. leftOperand: ShaderDefineExpression;
  1290. rightOperand: ShaderDefineExpression;
  1291. isTrue(preprocessors: {
  1292. [key: string]: string;
  1293. }): boolean;
  1294. }
  1295. }
  1296. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1297. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1298. /** @hidden */
  1299. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1300. define: string;
  1301. operand: string;
  1302. testValue: string;
  1303. constructor(define: string, operand: string, testValue: string);
  1304. isTrue(preprocessors: {
  1305. [key: string]: string;
  1306. }): boolean;
  1307. }
  1308. }
  1309. declare module "babylonjs/Offline/IOfflineProvider" {
  1310. /**
  1311. * Class used to enable access to offline support
  1312. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1313. */
  1314. export interface IOfflineProvider {
  1315. /**
  1316. * Gets a boolean indicating if scene must be saved in the database
  1317. */
  1318. enableSceneOffline: boolean;
  1319. /**
  1320. * Gets a boolean indicating if textures must be saved in the database
  1321. */
  1322. enableTexturesOffline: boolean;
  1323. /**
  1324. * Open the offline support and make it available
  1325. * @param successCallback defines the callback to call on success
  1326. * @param errorCallback defines the callback to call on error
  1327. */
  1328. open(successCallback: () => void, errorCallback: () => void): void;
  1329. /**
  1330. * Loads an image from the offline support
  1331. * @param url defines the url to load from
  1332. * @param image defines the target DOM image
  1333. */
  1334. loadImage(url: string, image: HTMLImageElement): void;
  1335. /**
  1336. * Loads a file from offline support
  1337. * @param url defines the URL to load from
  1338. * @param sceneLoaded defines a callback to call on success
  1339. * @param progressCallBack defines a callback to call when progress changed
  1340. * @param errorCallback defines a callback to call on error
  1341. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1342. */
  1343. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1344. }
  1345. }
  1346. declare module "babylonjs/Misc/filesInputStore" {
  1347. /**
  1348. * Class used to help managing file picking and drag'n'drop
  1349. * File Storage
  1350. */
  1351. export class FilesInputStore {
  1352. /**
  1353. * List of files ready to be loaded
  1354. */
  1355. static FilesToLoad: {
  1356. [key: string]: File;
  1357. };
  1358. }
  1359. }
  1360. declare module "babylonjs/Misc/retryStrategy" {
  1361. import { WebRequest } from "babylonjs/Misc/webRequest";
  1362. /**
  1363. * Class used to define a retry strategy when error happens while loading assets
  1364. */
  1365. export class RetryStrategy {
  1366. /**
  1367. * Function used to defines an exponential back off strategy
  1368. * @param maxRetries defines the maximum number of retries (3 by default)
  1369. * @param baseInterval defines the interval between retries
  1370. * @returns the strategy function to use
  1371. */
  1372. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1373. }
  1374. }
  1375. declare module "babylonjs/Misc/baseError" {
  1376. /**
  1377. * @ignore
  1378. * Application error to support additional information when loading a file
  1379. */
  1380. export abstract class BaseError extends Error {
  1381. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1382. }
  1383. }
  1384. declare module "babylonjs/Misc/fileTools" {
  1385. import { WebRequest } from "babylonjs/Misc/webRequest";
  1386. import { Nullable } from "babylonjs/types";
  1387. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1388. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1389. import { BaseError } from "babylonjs/Misc/baseError";
  1390. /** @ignore */
  1391. export class LoadFileError extends BaseError {
  1392. request?: WebRequest;
  1393. file?: File;
  1394. /**
  1395. * Creates a new LoadFileError
  1396. * @param message defines the message of the error
  1397. * @param request defines the optional web request
  1398. * @param file defines the optional file
  1399. */
  1400. constructor(message: string, object?: WebRequest | File);
  1401. }
  1402. /** @ignore */
  1403. export class RequestFileError extends BaseError {
  1404. request: WebRequest;
  1405. /**
  1406. * Creates a new LoadFileError
  1407. * @param message defines the message of the error
  1408. * @param request defines the optional web request
  1409. */
  1410. constructor(message: string, request: WebRequest);
  1411. }
  1412. /** @ignore */
  1413. export class ReadFileError extends BaseError {
  1414. file: File;
  1415. /**
  1416. * Creates a new ReadFileError
  1417. * @param message defines the message of the error
  1418. * @param file defines the optional file
  1419. */
  1420. constructor(message: string, file: File);
  1421. }
  1422. /**
  1423. * @hidden
  1424. */
  1425. export class FileTools {
  1426. /**
  1427. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1428. */
  1429. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1430. /**
  1431. * Gets or sets the base URL to use to load assets
  1432. */
  1433. static BaseUrl: string;
  1434. /**
  1435. * Default behaviour for cors in the application.
  1436. * It can be a string if the expected behavior is identical in the entire app.
  1437. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1438. */
  1439. static CorsBehavior: string | ((url: string | string[]) => string);
  1440. /**
  1441. * Gets or sets a function used to pre-process url before using them to load assets
  1442. */
  1443. static PreprocessUrl: (url: string) => string;
  1444. /**
  1445. * Removes unwanted characters from an url
  1446. * @param url defines the url to clean
  1447. * @returns the cleaned url
  1448. */
  1449. private static _CleanUrl;
  1450. /**
  1451. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1452. * @param url define the url we are trying
  1453. * @param element define the dom element where to configure the cors policy
  1454. */
  1455. static SetCorsBehavior(url: string | string[], element: {
  1456. crossOrigin: string | null;
  1457. }): void;
  1458. /**
  1459. * Loads an image as an HTMLImageElement.
  1460. * @param input url string, ArrayBuffer, or Blob to load
  1461. * @param onLoad callback called when the image successfully loads
  1462. * @param onError callback called when the image fails to load
  1463. * @param offlineProvider offline provider for caching
  1464. * @param mimeType optional mime type
  1465. * @returns the HTMLImageElement of the loaded image
  1466. */
  1467. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1468. /**
  1469. * Reads a file from a File object
  1470. * @param file defines the file to load
  1471. * @param onSuccess defines the callback to call when data is loaded
  1472. * @param onProgress defines the callback to call during loading process
  1473. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1474. * @param onError defines the callback to call when an error occurs
  1475. * @returns a file request object
  1476. */
  1477. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1478. /**
  1479. * Loads a file from a url
  1480. * @param url url to load
  1481. * @param onSuccess callback called when the file successfully loads
  1482. * @param onProgress callback called while file is loading (if the server supports this mode)
  1483. * @param offlineProvider defines the offline provider for caching
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @returns a file request object
  1487. */
  1488. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1489. /**
  1490. * Loads a file
  1491. * @param url url to load
  1492. * @param onSuccess callback called when the file successfully loads
  1493. * @param onProgress callback called while file is loading (if the server supports this mode)
  1494. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1495. * @param onError callback called when the file fails to load
  1496. * @param onOpened callback called when the web request is opened
  1497. * @returns a file request object
  1498. */
  1499. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1500. /**
  1501. * Checks if the loaded document was accessed via `file:`-Protocol.
  1502. * @returns boolean
  1503. */
  1504. static IsFileURL(): boolean;
  1505. }
  1506. }
  1507. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1508. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1509. import { WebRequest } from "babylonjs/Misc/webRequest";
  1510. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1511. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1512. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1513. /** @hidden */
  1514. export class ShaderProcessor {
  1515. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1516. private static _ProcessPrecision;
  1517. private static _ExtractOperation;
  1518. private static _BuildSubExpression;
  1519. private static _BuildExpression;
  1520. private static _MoveCursorWithinIf;
  1521. private static _MoveCursor;
  1522. private static _EvaluatePreProcessors;
  1523. private static _PreparePreProcessors;
  1524. private static _ProcessShaderConversion;
  1525. private static _ProcessIncludes;
  1526. /**
  1527. * Loads a file from a url
  1528. * @param url url to load
  1529. * @param onSuccess callback called when the file successfully loads
  1530. * @param onProgress callback called while file is loading (if the server supports this mode)
  1531. * @param offlineProvider defines the offline provider for caching
  1532. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1533. * @param onError callback called when the file fails to load
  1534. * @returns a file request object
  1535. * @hidden
  1536. */
  1537. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1538. }
  1539. }
  1540. declare module "babylonjs/Maths/math.like" {
  1541. import { float, int, DeepImmutable } from "babylonjs/types";
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IColor4Like {
  1546. r: float;
  1547. g: float;
  1548. b: float;
  1549. a: float;
  1550. }
  1551. /**
  1552. * @hidden
  1553. */
  1554. export interface IColor3Like {
  1555. r: float;
  1556. g: float;
  1557. b: float;
  1558. }
  1559. /**
  1560. * @hidden
  1561. */
  1562. export interface IVector4Like {
  1563. x: float;
  1564. y: float;
  1565. z: float;
  1566. w: float;
  1567. }
  1568. /**
  1569. * @hidden
  1570. */
  1571. export interface IVector3Like {
  1572. x: float;
  1573. y: float;
  1574. z: float;
  1575. }
  1576. /**
  1577. * @hidden
  1578. */
  1579. export interface IVector2Like {
  1580. x: float;
  1581. y: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IMatrixLike {
  1587. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1588. updateFlag: int;
  1589. }
  1590. /**
  1591. * @hidden
  1592. */
  1593. export interface IViewportLike {
  1594. x: float;
  1595. y: float;
  1596. width: float;
  1597. height: float;
  1598. }
  1599. /**
  1600. * @hidden
  1601. */
  1602. export interface IPlaneLike {
  1603. normal: IVector3Like;
  1604. d: float;
  1605. normalize(): void;
  1606. }
  1607. }
  1608. declare module "babylonjs/Materials/iEffectFallbacks" {
  1609. import { Effect } from "babylonjs/Materials/effect";
  1610. /**
  1611. * Interface used to define common properties for effect fallbacks
  1612. */
  1613. export interface IEffectFallbacks {
  1614. /**
  1615. * Removes the defines that should be removed when falling back.
  1616. * @param currentDefines defines the current define statements for the shader.
  1617. * @param effect defines the current effect we try to compile
  1618. * @returns The resulting defines with defines of the current rank removed.
  1619. */
  1620. reduce(currentDefines: string, effect: Effect): string;
  1621. /**
  1622. * Removes the fallback from the bound mesh.
  1623. */
  1624. unBindMesh(): void;
  1625. /**
  1626. * Checks to see if more fallbacks are still availible.
  1627. */
  1628. hasMoreFallbacks: boolean;
  1629. }
  1630. }
  1631. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1632. /**
  1633. * Class used to evalaute queries containing `and` and `or` operators
  1634. */
  1635. export class AndOrNotEvaluator {
  1636. /**
  1637. * Evaluate a query
  1638. * @param query defines the query to evaluate
  1639. * @param evaluateCallback defines the callback used to filter result
  1640. * @returns true if the query matches
  1641. */
  1642. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1643. private static _HandleParenthesisContent;
  1644. private static _SimplifyNegation;
  1645. }
  1646. }
  1647. declare module "babylonjs/Misc/tags" {
  1648. /**
  1649. * Class used to store custom tags
  1650. */
  1651. export class Tags {
  1652. /**
  1653. * Adds support for tags on the given object
  1654. * @param obj defines the object to use
  1655. */
  1656. static EnableFor(obj: any): void;
  1657. /**
  1658. * Removes tags support
  1659. * @param obj defines the object to use
  1660. */
  1661. static DisableFor(obj: any): void;
  1662. /**
  1663. * Gets a boolean indicating if the given object has tags
  1664. * @param obj defines the object to use
  1665. * @returns a boolean
  1666. */
  1667. static HasTags(obj: any): boolean;
  1668. /**
  1669. * Gets the tags available on a given object
  1670. * @param obj defines the object to use
  1671. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1672. * @returns the tags
  1673. */
  1674. static GetTags(obj: any, asString?: boolean): any;
  1675. /**
  1676. * Adds tags to an object
  1677. * @param obj defines the object to use
  1678. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1679. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1680. */
  1681. static AddTagsTo(obj: any, tagsString: string): void;
  1682. /**
  1683. * @hidden
  1684. */
  1685. static _AddTagTo(obj: any, tag: string): void;
  1686. /**
  1687. * Removes specific tags from a specific object
  1688. * @param obj defines the object to use
  1689. * @param tagsString defines the tags to remove
  1690. */
  1691. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1692. /**
  1693. * @hidden
  1694. */
  1695. static _RemoveTagFrom(obj: any, tag: string): void;
  1696. /**
  1697. * Defines if tags hosted on an object match a given query
  1698. * @param obj defines the object to use
  1699. * @param tagsQuery defines the tag query
  1700. * @returns a boolean
  1701. */
  1702. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1703. }
  1704. }
  1705. declare module "babylonjs/Maths/math.scalar" {
  1706. /**
  1707. * Scalar computation library
  1708. */
  1709. export class Scalar {
  1710. /**
  1711. * Two pi constants convenient for computation.
  1712. */
  1713. static TwoPi: number;
  1714. /**
  1715. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1716. * @param a number
  1717. * @param b number
  1718. * @param epsilon (default = 1.401298E-45)
  1719. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1720. */
  1721. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1722. /**
  1723. * Returns a string : the upper case translation of the number i to hexadecimal.
  1724. * @param i number
  1725. * @returns the upper case translation of the number i to hexadecimal.
  1726. */
  1727. static ToHex(i: number): string;
  1728. /**
  1729. * Returns -1 if value is negative and +1 is value is positive.
  1730. * @param value the value
  1731. * @returns the value itself if it's equal to zero.
  1732. */
  1733. static Sign(value: number): number;
  1734. /**
  1735. * Returns the value itself if it's between min and max.
  1736. * Returns min if the value is lower than min.
  1737. * Returns max if the value is greater than max.
  1738. * @param value the value to clmap
  1739. * @param min the min value to clamp to (default: 0)
  1740. * @param max the max value to clamp to (default: 1)
  1741. * @returns the clamped value
  1742. */
  1743. static Clamp(value: number, min?: number, max?: number): number;
  1744. /**
  1745. * the log2 of value.
  1746. * @param value the value to compute log2 of
  1747. * @returns the log2 of value.
  1748. */
  1749. static Log2(value: number): number;
  1750. /**
  1751. * Loops the value, so that it is never larger than length and never smaller than 0.
  1752. *
  1753. * This is similar to the modulo operator but it works with floating point numbers.
  1754. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1755. * With t = 5 and length = 2.5, the result would be 0.0.
  1756. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1757. * @param value the value
  1758. * @param length the length
  1759. * @returns the looped value
  1760. */
  1761. static Repeat(value: number, length: number): number;
  1762. /**
  1763. * Normalize the value between 0.0 and 1.0 using min and max values
  1764. * @param value value to normalize
  1765. * @param min max to normalize between
  1766. * @param max min to normalize between
  1767. * @returns the normalized value
  1768. */
  1769. static Normalize(value: number, min: number, max: number): number;
  1770. /**
  1771. * Denormalize the value from 0.0 and 1.0 using min and max values
  1772. * @param normalized value to denormalize
  1773. * @param min max to denormalize between
  1774. * @param max min to denormalize between
  1775. * @returns the denormalized value
  1776. */
  1777. static Denormalize(normalized: number, min: number, max: number): number;
  1778. /**
  1779. * Calculates the shortest difference between two given angles given in degrees.
  1780. * @param current current angle in degrees
  1781. * @param target target angle in degrees
  1782. * @returns the delta
  1783. */
  1784. static DeltaAngle(current: number, target: number): number;
  1785. /**
  1786. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1787. * @param tx value
  1788. * @param length length
  1789. * @returns The returned value will move back and forth between 0 and length
  1790. */
  1791. static PingPong(tx: number, length: number): number;
  1792. /**
  1793. * Interpolates between min and max with smoothing at the limits.
  1794. *
  1795. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1796. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1797. * @param from from
  1798. * @param to to
  1799. * @param tx value
  1800. * @returns the smooth stepped value
  1801. */
  1802. static SmoothStep(from: number, to: number, tx: number): number;
  1803. /**
  1804. * Moves a value current towards target.
  1805. *
  1806. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1807. * Negative values of maxDelta pushes the value away from target.
  1808. * @param current current value
  1809. * @param target target value
  1810. * @param maxDelta max distance to move
  1811. * @returns resulting value
  1812. */
  1813. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1814. /**
  1815. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. *
  1817. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1818. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1819. * @param current current value
  1820. * @param target target value
  1821. * @param maxDelta max distance to move
  1822. * @returns resulting angle
  1823. */
  1824. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1825. /**
  1826. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1827. * @param start start value
  1828. * @param end target value
  1829. * @param amount amount to lerp between
  1830. * @returns the lerped value
  1831. */
  1832. static Lerp(start: number, end: number, amount: number): number;
  1833. /**
  1834. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1835. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1836. * @param start start value
  1837. * @param end target value
  1838. * @param amount amount to lerp between
  1839. * @returns the lerped value
  1840. */
  1841. static LerpAngle(start: number, end: number, amount: number): number;
  1842. /**
  1843. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1844. * @param a start value
  1845. * @param b target value
  1846. * @param value value between a and b
  1847. * @returns the inverseLerp value
  1848. */
  1849. static InverseLerp(a: number, b: number, value: number): number;
  1850. /**
  1851. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1852. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1853. * @param value1 spline value
  1854. * @param tangent1 spline value
  1855. * @param value2 spline value
  1856. * @param tangent2 spline value
  1857. * @param amount input value
  1858. * @returns hermite result
  1859. */
  1860. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1861. /**
  1862. * Returns a random float number between and min and max values
  1863. * @param min min value of random
  1864. * @param max max value of random
  1865. * @returns random value
  1866. */
  1867. static RandomRange(min: number, max: number): number;
  1868. /**
  1869. * This function returns percentage of a number in a given range.
  1870. *
  1871. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1872. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1873. * @param number to convert to percentage
  1874. * @param min min range
  1875. * @param max max range
  1876. * @returns the percentage
  1877. */
  1878. static RangeToPercent(number: number, min: number, max: number): number;
  1879. /**
  1880. * This function returns number that corresponds to the percentage in a given range.
  1881. *
  1882. * PercentToRange(0.34,0,100) will return 34.
  1883. * @param percent to convert to number
  1884. * @param min min range
  1885. * @param max max range
  1886. * @returns the number
  1887. */
  1888. static PercentToRange(percent: number, min: number, max: number): number;
  1889. /**
  1890. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1891. * @param angle The angle to normalize in radian.
  1892. * @return The converted angle.
  1893. */
  1894. static NormalizeRadians(angle: number): number;
  1895. }
  1896. }
  1897. declare module "babylonjs/Maths/math.constants" {
  1898. /**
  1899. * Constant used to convert a value to gamma space
  1900. * @ignorenaming
  1901. */
  1902. export const ToGammaSpace: number;
  1903. /**
  1904. * Constant used to convert a value to linear space
  1905. * @ignorenaming
  1906. */
  1907. export const ToLinearSpace = 2.2;
  1908. /**
  1909. * Constant used to define the minimal number value in Babylon.js
  1910. * @ignorenaming
  1911. */
  1912. let Epsilon: number;
  1913. export { Epsilon };
  1914. }
  1915. declare module "babylonjs/Maths/math.viewport" {
  1916. /**
  1917. * Class used to represent a viewport on screen
  1918. */
  1919. export class Viewport {
  1920. /** viewport left coordinate */
  1921. x: number;
  1922. /** viewport top coordinate */
  1923. y: number;
  1924. /**viewport width */
  1925. width: number;
  1926. /** viewport height */
  1927. height: number;
  1928. /**
  1929. * Creates a Viewport object located at (x, y) and sized (width, height)
  1930. * @param x defines viewport left coordinate
  1931. * @param y defines viewport top coordinate
  1932. * @param width defines the viewport width
  1933. * @param height defines the viewport height
  1934. */
  1935. constructor(
  1936. /** viewport left coordinate */
  1937. x: number,
  1938. /** viewport top coordinate */
  1939. y: number,
  1940. /**viewport width */
  1941. width: number,
  1942. /** viewport height */
  1943. height: number);
  1944. /**
  1945. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1946. * @param renderWidth defines the rendering width
  1947. * @param renderHeight defines the rendering height
  1948. * @returns a new Viewport
  1949. */
  1950. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1951. /**
  1952. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1953. * @param renderWidth defines the rendering width
  1954. * @param renderHeight defines the rendering height
  1955. * @param ref defines the target viewport
  1956. * @returns the current viewport
  1957. */
  1958. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1959. /**
  1960. * Returns a new Viewport copied from the current one
  1961. * @returns a new Viewport
  1962. */
  1963. clone(): Viewport;
  1964. }
  1965. }
  1966. declare module "babylonjs/Misc/arrayTools" {
  1967. /**
  1968. * Class containing a set of static utilities functions for arrays.
  1969. */
  1970. export class ArrayTools {
  1971. /**
  1972. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1973. * @param size the number of element to construct and put in the array
  1974. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1975. * @returns a new array filled with new objects
  1976. */
  1977. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1978. }
  1979. }
  1980. declare module "babylonjs/Maths/math.plane" {
  1981. import { DeepImmutable } from "babylonjs/types";
  1982. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1983. /**
  1984. * Represents a plane by the equation ax + by + cz + d = 0
  1985. */
  1986. export class Plane {
  1987. private static _TmpMatrix;
  1988. /**
  1989. * Normal of the plane (a,b,c)
  1990. */
  1991. normal: Vector3;
  1992. /**
  1993. * d component of the plane
  1994. */
  1995. d: number;
  1996. /**
  1997. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1998. * @param a a component of the plane
  1999. * @param b b component of the plane
  2000. * @param c c component of the plane
  2001. * @param d d component of the plane
  2002. */
  2003. constructor(a: number, b: number, c: number, d: number);
  2004. /**
  2005. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2006. */
  2007. asArray(): number[];
  2008. /**
  2009. * @returns a new plane copied from the current Plane.
  2010. */
  2011. clone(): Plane;
  2012. /**
  2013. * @returns the string "Plane".
  2014. */
  2015. getClassName(): string;
  2016. /**
  2017. * @returns the Plane hash code.
  2018. */
  2019. getHashCode(): number;
  2020. /**
  2021. * Normalize the current Plane in place.
  2022. * @returns the updated Plane.
  2023. */
  2024. normalize(): Plane;
  2025. /**
  2026. * Applies a transformation the plane and returns the result
  2027. * @param transformation the transformation matrix to be applied to the plane
  2028. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2029. */
  2030. transform(transformation: DeepImmutable<Matrix>): Plane;
  2031. /**
  2032. * Compute the dot product between the point and the plane normal
  2033. * @param point point to calculate the dot product with
  2034. * @returns the dot product (float) of the point coordinates and the plane normal.
  2035. */
  2036. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2037. /**
  2038. * Updates the current Plane from the plane defined by the three given points.
  2039. * @param point1 one of the points used to contruct the plane
  2040. * @param point2 one of the points used to contruct the plane
  2041. * @param point3 one of the points used to contruct the plane
  2042. * @returns the updated Plane.
  2043. */
  2044. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2045. /**
  2046. * Checks if the plane is facing a given direction
  2047. * @param direction the direction to check if the plane is facing
  2048. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2049. * @returns True is the vector "direction" is the same side than the plane normal.
  2050. */
  2051. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2052. /**
  2053. * Calculates the distance to a point
  2054. * @param point point to calculate distance to
  2055. * @returns the signed distance (float) from the given point to the Plane.
  2056. */
  2057. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2058. /**
  2059. * Creates a plane from an array
  2060. * @param array the array to create a plane from
  2061. * @returns a new Plane from the given array.
  2062. */
  2063. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2064. /**
  2065. * Creates a plane from three points
  2066. * @param point1 point used to create the plane
  2067. * @param point2 point used to create the plane
  2068. * @param point3 point used to create the plane
  2069. * @returns a new Plane defined by the three given points.
  2070. */
  2071. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2072. /**
  2073. * Creates a plane from an origin point and a normal
  2074. * @param origin origin of the plane to be constructed
  2075. * @param normal normal of the plane to be constructed
  2076. * @returns a new Plane the normal vector to this plane at the given origin point.
  2077. * Note : the vector "normal" is updated because normalized.
  2078. */
  2079. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2080. /**
  2081. * Calculates the distance from a plane and a point
  2082. * @param origin origin of the plane to be constructed
  2083. * @param normal normal of the plane to be constructed
  2084. * @param point point to calculate distance to
  2085. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2086. */
  2087. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2088. }
  2089. }
  2090. declare module "babylonjs/Engines/performanceConfigurator" {
  2091. /** @hidden */
  2092. export class PerformanceConfigurator {
  2093. /** @hidden */
  2094. static MatrixUse64Bits: boolean;
  2095. /** @hidden */
  2096. static MatrixTrackPrecisionChange: boolean;
  2097. /** @hidden */
  2098. static MatrixCurrentType: any;
  2099. /** @hidden */
  2100. static MatrixTrackedMatrices: Array<any> | null;
  2101. /** @hidden */
  2102. static SetMatrixPrecision(use64bits: boolean): void;
  2103. }
  2104. }
  2105. declare module "babylonjs/Maths/math.vector" {
  2106. import { Viewport } from "babylonjs/Maths/math.viewport";
  2107. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2108. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2109. import { Plane } from "babylonjs/Maths/math.plane";
  2110. /**
  2111. * Class representing a vector containing 2 coordinates
  2112. */
  2113. export class Vector2 {
  2114. /** defines the first coordinate */
  2115. x: number;
  2116. /** defines the second coordinate */
  2117. y: number;
  2118. /**
  2119. * Creates a new Vector2 from the given x and y coordinates
  2120. * @param x defines the first coordinate
  2121. * @param y defines the second coordinate
  2122. */
  2123. constructor(
  2124. /** defines the first coordinate */
  2125. x?: number,
  2126. /** defines the second coordinate */
  2127. y?: number);
  2128. /**
  2129. * Gets a string with the Vector2 coordinates
  2130. * @returns a string with the Vector2 coordinates
  2131. */
  2132. toString(): string;
  2133. /**
  2134. * Gets class name
  2135. * @returns the string "Vector2"
  2136. */
  2137. getClassName(): string;
  2138. /**
  2139. * Gets current vector hash code
  2140. * @returns the Vector2 hash code as a number
  2141. */
  2142. getHashCode(): number;
  2143. /**
  2144. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2145. * @param array defines the source array
  2146. * @param index defines the offset in source array
  2147. * @returns the current Vector2
  2148. */
  2149. toArray(array: FloatArray, index?: number): Vector2;
  2150. /**
  2151. * Update the current vector from an array
  2152. * @param array defines the destination array
  2153. * @param index defines the offset in the destination array
  2154. * @returns the current Vector3
  2155. */
  2156. fromArray(array: FloatArray, index?: number): Vector2;
  2157. /**
  2158. * Copy the current vector to an array
  2159. * @returns a new array with 2 elements: the Vector2 coordinates.
  2160. */
  2161. asArray(): number[];
  2162. /**
  2163. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2164. * @param source defines the source Vector2
  2165. * @returns the current updated Vector2
  2166. */
  2167. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2168. /**
  2169. * Sets the Vector2 coordinates with the given floats
  2170. * @param x defines the first coordinate
  2171. * @param y defines the second coordinate
  2172. * @returns the current updated Vector2
  2173. */
  2174. copyFromFloats(x: number, y: number): Vector2;
  2175. /**
  2176. * Sets the Vector2 coordinates with the given floats
  2177. * @param x defines the first coordinate
  2178. * @param y defines the second coordinate
  2179. * @returns the current updated Vector2
  2180. */
  2181. set(x: number, y: number): Vector2;
  2182. /**
  2183. * Add another vector with the current one
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2186. */
  2187. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2190. * @param otherVector defines the other vector
  2191. * @param result defines the target vector
  2192. * @returns the unmodified current Vector2
  2193. */
  2194. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2195. /**
  2196. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2197. * @param otherVector defines the other vector
  2198. * @returns the current updated Vector2
  2199. */
  2200. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2201. /**
  2202. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns a new Vector2
  2205. */
  2206. addVector3(otherVector: Vector3): Vector2;
  2207. /**
  2208. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2209. * @param otherVector defines the other vector
  2210. * @returns a new Vector2
  2211. */
  2212. subtract(otherVector: Vector2): Vector2;
  2213. /**
  2214. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2215. * @param otherVector defines the other vector
  2216. * @param result defines the target vector
  2217. * @returns the unmodified current Vector2
  2218. */
  2219. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2220. /**
  2221. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2222. * @param otherVector defines the other vector
  2223. * @returns the current updated Vector2
  2224. */
  2225. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Multiplies in place the current Vector2 coordinates by the given ones
  2228. * @param otherVector defines the other vector
  2229. * @returns the current updated Vector2
  2230. */
  2231. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2232. /**
  2233. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @returns a new Vector2
  2236. */
  2237. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2238. /**
  2239. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2240. * @param otherVector defines the other vector
  2241. * @param result defines the target vector
  2242. * @returns the unmodified current Vector2
  2243. */
  2244. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2247. * @param x defines the first coordinate
  2248. * @param y defines the second coordinate
  2249. * @returns a new Vector2
  2250. */
  2251. multiplyByFloats(x: number, y: number): Vector2;
  2252. /**
  2253. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2254. * @param otherVector defines the other vector
  2255. * @returns a new Vector2
  2256. */
  2257. divide(otherVector: Vector2): Vector2;
  2258. /**
  2259. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2260. * @param otherVector defines the other vector
  2261. * @param result defines the target vector
  2262. * @returns the unmodified current Vector2
  2263. */
  2264. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2265. /**
  2266. * Divides the current Vector2 coordinates by the given ones
  2267. * @param otherVector defines the other vector
  2268. * @returns the current updated Vector2
  2269. */
  2270. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2271. /**
  2272. * Gets a new Vector2 with current Vector2 negated coordinates
  2273. * @returns a new Vector2
  2274. */
  2275. negate(): Vector2;
  2276. /**
  2277. * Negate this vector in place
  2278. * @returns this
  2279. */
  2280. negateInPlace(): Vector2;
  2281. /**
  2282. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2283. * @param result defines the Vector3 object where to store the result
  2284. * @returns the current Vector2
  2285. */
  2286. negateToRef(result: Vector2): Vector2;
  2287. /**
  2288. * Multiply the Vector2 coordinates by scale
  2289. * @param scale defines the scaling factor
  2290. * @returns the current updated Vector2
  2291. */
  2292. scaleInPlace(scale: number): Vector2;
  2293. /**
  2294. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2295. * @param scale defines the scaling factor
  2296. * @returns a new Vector2
  2297. */
  2298. scale(scale: number): Vector2;
  2299. /**
  2300. * Scale the current Vector2 values by a factor to a given Vector2
  2301. * @param scale defines the scale factor
  2302. * @param result defines the Vector2 object where to store the result
  2303. * @returns the unmodified current Vector2
  2304. */
  2305. scaleToRef(scale: number, result: Vector2): Vector2;
  2306. /**
  2307. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2308. * @param scale defines the scale factor
  2309. * @param result defines the Vector2 object where to store the result
  2310. * @returns the unmodified current Vector2
  2311. */
  2312. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2313. /**
  2314. * Gets a boolean if two vectors are equals
  2315. * @param otherVector defines the other vector
  2316. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2317. */
  2318. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2319. /**
  2320. * Gets a boolean if two vectors are equals (using an epsilon value)
  2321. * @param otherVector defines the other vector
  2322. * @param epsilon defines the minimal distance to consider equality
  2323. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2324. */
  2325. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2326. /**
  2327. * Gets a new Vector2 from current Vector2 floored values
  2328. * @returns a new Vector2
  2329. */
  2330. floor(): Vector2;
  2331. /**
  2332. * Gets a new Vector2 from current Vector2 floored values
  2333. * @returns a new Vector2
  2334. */
  2335. fract(): Vector2;
  2336. /**
  2337. * Gets the length of the vector
  2338. * @returns the vector length (float)
  2339. */
  2340. length(): number;
  2341. /**
  2342. * Gets the vector squared length
  2343. * @returns the vector squared length (float)
  2344. */
  2345. lengthSquared(): number;
  2346. /**
  2347. * Normalize the vector
  2348. * @returns the current updated Vector2
  2349. */
  2350. normalize(): Vector2;
  2351. /**
  2352. * Gets a new Vector2 copied from the Vector2
  2353. * @returns a new Vector2
  2354. */
  2355. clone(): Vector2;
  2356. /**
  2357. * Gets a new Vector2(0, 0)
  2358. * @returns a new Vector2
  2359. */
  2360. static Zero(): Vector2;
  2361. /**
  2362. * Gets a new Vector2(1, 1)
  2363. * @returns a new Vector2
  2364. */
  2365. static One(): Vector2;
  2366. /**
  2367. * Gets a new Vector2 set from the given index element of the given array
  2368. * @param array defines the data source
  2369. * @param offset defines the offset in the data source
  2370. * @returns a new Vector2
  2371. */
  2372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2373. /**
  2374. * Sets "result" from the given index element of the given array
  2375. * @param array defines the data source
  2376. * @param offset defines the offset in the data source
  2377. * @param result defines the target vector
  2378. */
  2379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2380. /**
  2381. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2382. * @param value1 defines 1st point of control
  2383. * @param value2 defines 2nd point of control
  2384. * @param value3 defines 3rd point of control
  2385. * @param value4 defines 4th point of control
  2386. * @param amount defines the interpolation factor
  2387. * @returns a new Vector2
  2388. */
  2389. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2390. /**
  2391. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2392. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2393. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2394. * @param value defines the value to clamp
  2395. * @param min defines the lower limit
  2396. * @param max defines the upper limit
  2397. * @returns a new Vector2
  2398. */
  2399. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2400. /**
  2401. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2402. * @param value1 defines the 1st control point
  2403. * @param tangent1 defines the outgoing tangent
  2404. * @param value2 defines the 2nd control point
  2405. * @param tangent2 defines the incoming tangent
  2406. * @param amount defines the interpolation factor
  2407. * @returns a new Vector2
  2408. */
  2409. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2410. /**
  2411. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2412. * @param start defines the start vector
  2413. * @param end defines the end vector
  2414. * @param amount defines the interpolation factor
  2415. * @returns a new Vector2
  2416. */
  2417. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2418. /**
  2419. * Gets the dot product of the vector "left" and the vector "right"
  2420. * @param left defines first vector
  2421. * @param right defines second vector
  2422. * @returns the dot product (float)
  2423. */
  2424. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2425. /**
  2426. * Returns a new Vector2 equal to the normalized given vector
  2427. * @param vector defines the vector to normalize
  2428. * @returns a new Vector2
  2429. */
  2430. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2431. /**
  2432. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2433. * @param left defines 1st vector
  2434. * @param right defines 2nd vector
  2435. * @returns a new Vector2
  2436. */
  2437. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2438. /**
  2439. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2440. * @param left defines 1st vector
  2441. * @param right defines 2nd vector
  2442. * @returns a new Vector2
  2443. */
  2444. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2445. /**
  2446. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2447. * @param vector defines the vector to transform
  2448. * @param transformation defines the matrix to apply
  2449. * @returns a new Vector2
  2450. */
  2451. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2452. /**
  2453. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2454. * @param vector defines the vector to transform
  2455. * @param transformation defines the matrix to apply
  2456. * @param result defines the target vector
  2457. */
  2458. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2459. /**
  2460. * Determines if a given vector is included in a triangle
  2461. * @param p defines the vector to test
  2462. * @param p0 defines 1st triangle point
  2463. * @param p1 defines 2nd triangle point
  2464. * @param p2 defines 3rd triangle point
  2465. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2466. */
  2467. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2468. /**
  2469. * Gets the distance between the vectors "value1" and "value2"
  2470. * @param value1 defines first vector
  2471. * @param value2 defines second vector
  2472. * @returns the distance between vectors
  2473. */
  2474. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2475. /**
  2476. * Returns the squared distance between the vectors "value1" and "value2"
  2477. * @param value1 defines first vector
  2478. * @param value2 defines second vector
  2479. * @returns the squared distance between vectors
  2480. */
  2481. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2482. /**
  2483. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2484. * @param value1 defines first vector
  2485. * @param value2 defines second vector
  2486. * @returns a new Vector2
  2487. */
  2488. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2489. /**
  2490. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2491. * @param p defines the middle point
  2492. * @param segA defines one point of the segment
  2493. * @param segB defines the other point of the segment
  2494. * @returns the shortest distance
  2495. */
  2496. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2497. }
  2498. /**
  2499. * Class used to store (x,y,z) vector representation
  2500. * A Vector3 is the main object used in 3D geometry
  2501. * It can represent etiher the coordinates of a point the space, either a direction
  2502. * Reminder: js uses a left handed forward facing system
  2503. */
  2504. export class Vector3 {
  2505. private static _UpReadOnly;
  2506. private static _ZeroReadOnly;
  2507. /** @hidden */
  2508. _x: number;
  2509. /** @hidden */
  2510. _y: number;
  2511. /** @hidden */
  2512. _z: number;
  2513. /** @hidden */
  2514. _isDirty: boolean;
  2515. /** Gets or sets the x coordinate */
  2516. get x(): number;
  2517. set x(value: number);
  2518. /** Gets or sets the y coordinate */
  2519. get y(): number;
  2520. set y(value: number);
  2521. /** Gets or sets the z coordinate */
  2522. get z(): number;
  2523. set z(value: number);
  2524. /**
  2525. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2526. * @param x defines the first coordinates (on X axis)
  2527. * @param y defines the second coordinates (on Y axis)
  2528. * @param z defines the third coordinates (on Z axis)
  2529. */
  2530. constructor(x?: number, y?: number, z?: number);
  2531. /**
  2532. * Creates a string representation of the Vector3
  2533. * @returns a string with the Vector3 coordinates.
  2534. */
  2535. toString(): string;
  2536. /**
  2537. * Gets the class name
  2538. * @returns the string "Vector3"
  2539. */
  2540. getClassName(): string;
  2541. /**
  2542. * Creates the Vector3 hash code
  2543. * @returns a number which tends to be unique between Vector3 instances
  2544. */
  2545. getHashCode(): number;
  2546. /**
  2547. * Creates an array containing three elements : the coordinates of the Vector3
  2548. * @returns a new array of numbers
  2549. */
  2550. asArray(): number[];
  2551. /**
  2552. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2553. * @param array defines the destination array
  2554. * @param index defines the offset in the destination array
  2555. * @returns the current Vector3
  2556. */
  2557. toArray(array: FloatArray, index?: number): Vector3;
  2558. /**
  2559. * Update the current vector from an array
  2560. * @param array defines the destination array
  2561. * @param index defines the offset in the destination array
  2562. * @returns the current Vector3
  2563. */
  2564. fromArray(array: FloatArray, index?: number): Vector3;
  2565. /**
  2566. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2567. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2568. */
  2569. toQuaternion(): Quaternion;
  2570. /**
  2571. * Adds the given vector to the current Vector3
  2572. * @param otherVector defines the second operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2576. /**
  2577. * Adds the given coordinates to the current Vector3
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Subtract the given vector from the current Vector3
  2599. * @param otherVector defines the second operand
  2600. * @returns the current updated Vector3
  2601. */
  2602. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2603. /**
  2604. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2605. * @param otherVector defines the second operand
  2606. * @returns the resulting Vector3
  2607. */
  2608. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2609. /**
  2610. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2611. * @param otherVector defines the second operand
  2612. * @param result defines the Vector3 object where to store the result
  2613. * @returns the current Vector3
  2614. */
  2615. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2618. * @param x defines the x coordinate of the operand
  2619. * @param y defines the y coordinate of the operand
  2620. * @param z defines the z coordinate of the operand
  2621. * @returns the resulting Vector3
  2622. */
  2623. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2624. /**
  2625. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2626. * @param x defines the x coordinate of the operand
  2627. * @param y defines the y coordinate of the operand
  2628. * @param z defines the z coordinate of the operand
  2629. * @param result defines the Vector3 object where to store the result
  2630. * @returns the current Vector3
  2631. */
  2632. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2633. /**
  2634. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2635. * @returns a new Vector3
  2636. */
  2637. negate(): Vector3;
  2638. /**
  2639. * Negate this vector in place
  2640. * @returns this
  2641. */
  2642. negateInPlace(): Vector3;
  2643. /**
  2644. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. negateToRef(result: Vector3): Vector3;
  2649. /**
  2650. * Multiplies the Vector3 coordinates by the float "scale"
  2651. * @param scale defines the multiplier factor
  2652. * @returns the current updated Vector3
  2653. */
  2654. scaleInPlace(scale: number): Vector3;
  2655. /**
  2656. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2657. * @param scale defines the multiplier factor
  2658. * @returns a new Vector3
  2659. */
  2660. scale(scale: number): Vector3;
  2661. /**
  2662. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2663. * @param scale defines the multiplier factor
  2664. * @param result defines the Vector3 object where to store the result
  2665. * @returns the current Vector3
  2666. */
  2667. scaleToRef(scale: number, result: Vector3): Vector3;
  2668. /**
  2669. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2670. * @param scale defines the scale factor
  2671. * @param result defines the Vector3 object where to store the result
  2672. * @returns the unmodified current Vector3
  2673. */
  2674. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2675. /**
  2676. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2677. * @param origin defines the origin of the projection ray
  2678. * @param plane defines the plane to project to
  2679. * @returns the projected vector3
  2680. */
  2681. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2682. /**
  2683. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2684. * @param origin defines the origin of the projection ray
  2685. * @param plane defines the plane to project to
  2686. * @param result defines the Vector3 where to store the result
  2687. */
  2688. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2689. /**
  2690. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2691. * @param otherVector defines the second operand
  2692. * @returns true if both vectors are equals
  2693. */
  2694. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2695. /**
  2696. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2697. * @param otherVector defines the second operand
  2698. * @param epsilon defines the minimal distance to define values as equals
  2699. * @returns true if both vectors are distant less than epsilon
  2700. */
  2701. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2702. /**
  2703. * Returns true if the current Vector3 coordinates equals the given floats
  2704. * @param x defines the x coordinate of the operand
  2705. * @param y defines the y coordinate of the operand
  2706. * @param z defines the z coordinate of the operand
  2707. * @returns true if both vectors are equals
  2708. */
  2709. equalsToFloats(x: number, y: number, z: number): boolean;
  2710. /**
  2711. * Multiplies the current Vector3 coordinates by the given ones
  2712. * @param otherVector defines the second operand
  2713. * @returns the current updated Vector3
  2714. */
  2715. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2716. /**
  2717. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2718. * @param otherVector defines the second operand
  2719. * @returns the new Vector3
  2720. */
  2721. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2722. /**
  2723. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2724. * @param otherVector defines the second operand
  2725. * @param result defines the Vector3 object where to store the result
  2726. * @returns the current Vector3
  2727. */
  2728. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2729. /**
  2730. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2731. * @param x defines the x coordinate of the operand
  2732. * @param y defines the y coordinate of the operand
  2733. * @param z defines the z coordinate of the operand
  2734. * @returns the new Vector3
  2735. */
  2736. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2739. * @param otherVector defines the second operand
  2740. * @returns the new Vector3
  2741. */
  2742. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2745. * @param otherVector defines the second operand
  2746. * @param result defines the Vector3 object where to store the result
  2747. * @returns the current Vector3
  2748. */
  2749. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2750. /**
  2751. * Divides the current Vector3 coordinates by the given ones.
  2752. * @param otherVector defines the second operand
  2753. * @returns the current updated Vector3
  2754. */
  2755. divideInPlace(otherVector: Vector3): Vector3;
  2756. /**
  2757. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2758. * @param other defines the second operand
  2759. * @returns the current updated Vector3
  2760. */
  2761. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2762. /**
  2763. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2764. * @param other defines the second operand
  2765. * @returns the current updated Vector3
  2766. */
  2767. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2768. /**
  2769. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2770. * @param x defines the x coordinate of the operand
  2771. * @param y defines the y coordinate of the operand
  2772. * @param z defines the z coordinate of the operand
  2773. * @returns the current updated Vector3
  2774. */
  2775. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2776. /**
  2777. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2778. * @param x defines the x coordinate of the operand
  2779. * @param y defines the y coordinate of the operand
  2780. * @param z defines the z coordinate of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2784. /**
  2785. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2786. * Check if is non uniform within a certain amount of decimal places to account for this
  2787. * @param epsilon the amount the values can differ
  2788. * @returns if the the vector is non uniform to a certain number of decimal places
  2789. */
  2790. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2791. /**
  2792. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2793. */
  2794. get isNonUniform(): boolean;
  2795. /**
  2796. * Gets a new Vector3 from current Vector3 floored values
  2797. * @returns a new Vector3
  2798. */
  2799. floor(): Vector3;
  2800. /**
  2801. * Gets a new Vector3 from current Vector3 floored values
  2802. * @returns a new Vector3
  2803. */
  2804. fract(): Vector3;
  2805. /**
  2806. * Gets the length of the Vector3
  2807. * @returns the length of the Vector3
  2808. */
  2809. length(): number;
  2810. /**
  2811. * Gets the squared length of the Vector3
  2812. * @returns squared length of the Vector3
  2813. */
  2814. lengthSquared(): number;
  2815. /**
  2816. * Normalize the current Vector3.
  2817. * Please note that this is an in place operation.
  2818. * @returns the current updated Vector3
  2819. */
  2820. normalize(): Vector3;
  2821. /**
  2822. * Reorders the x y z properties of the vector in place
  2823. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2824. * @returns the current updated vector
  2825. */
  2826. reorderInPlace(order: string): this;
  2827. /**
  2828. * Rotates the vector around 0,0,0 by a quaternion
  2829. * @param quaternion the rotation quaternion
  2830. * @param result vector to store the result
  2831. * @returns the resulting vector
  2832. */
  2833. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2834. /**
  2835. * Rotates a vector around a given point
  2836. * @param quaternion the rotation quaternion
  2837. * @param point the point to rotate around
  2838. * @param result vector to store the result
  2839. * @returns the resulting vector
  2840. */
  2841. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2842. /**
  2843. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2844. * The cross product is then orthogonal to both current and "other"
  2845. * @param other defines the right operand
  2846. * @returns the cross product
  2847. */
  2848. cross(other: Vector3): Vector3;
  2849. /**
  2850. * Normalize the current Vector3 with the given input length.
  2851. * Please note that this is an in place operation.
  2852. * @param len the length of the vector
  2853. * @returns the current updated Vector3
  2854. */
  2855. normalizeFromLength(len: number): Vector3;
  2856. /**
  2857. * Normalize the current Vector3 to a new vector
  2858. * @returns the new Vector3
  2859. */
  2860. normalizeToNew(): Vector3;
  2861. /**
  2862. * Normalize the current Vector3 to the reference
  2863. * @param reference define the Vector3 to update
  2864. * @returns the updated Vector3
  2865. */
  2866. normalizeToRef(reference: Vector3): Vector3;
  2867. /**
  2868. * Creates a new Vector3 copied from the current Vector3
  2869. * @returns the new Vector3
  2870. */
  2871. clone(): Vector3;
  2872. /**
  2873. * Copies the given vector coordinates to the current Vector3 ones
  2874. * @param source defines the source Vector3
  2875. * @returns the current updated Vector3
  2876. */
  2877. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2878. /**
  2879. * Copies the given floats to the current Vector3 coordinates
  2880. * @param x defines the x coordinate of the operand
  2881. * @param y defines the y coordinate of the operand
  2882. * @param z defines the z coordinate of the operand
  2883. * @returns the current updated Vector3
  2884. */
  2885. copyFromFloats(x: number, y: number, z: number): Vector3;
  2886. /**
  2887. * Copies the given floats to the current Vector3 coordinates
  2888. * @param x defines the x coordinate of the operand
  2889. * @param y defines the y coordinate of the operand
  2890. * @param z defines the z coordinate of the operand
  2891. * @returns the current updated Vector3
  2892. */
  2893. set(x: number, y: number, z: number): Vector3;
  2894. /**
  2895. * Copies the given float to the current Vector3 coordinates
  2896. * @param v defines the x, y and z coordinates of the operand
  2897. * @returns the current updated Vector3
  2898. */
  2899. setAll(v: number): Vector3;
  2900. /**
  2901. * Get the clip factor between two vectors
  2902. * @param vector0 defines the first operand
  2903. * @param vector1 defines the second operand
  2904. * @param axis defines the axis to use
  2905. * @param size defines the size along the axis
  2906. * @returns the clip factor
  2907. */
  2908. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2909. /**
  2910. * Get angle between two vectors
  2911. * @param vector0 angle between vector0 and vector1
  2912. * @param vector1 angle between vector0 and vector1
  2913. * @param normal direction of the normal
  2914. * @return the angle between vector0 and vector1
  2915. */
  2916. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2917. /**
  2918. * Returns a new Vector3 set from the index "offset" of the given array
  2919. * @param array defines the source array
  2920. * @param offset defines the offset in the source array
  2921. * @returns the new Vector3
  2922. */
  2923. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2924. /**
  2925. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2926. * @param array defines the source array
  2927. * @param offset defines the offset in the source array
  2928. * @returns the new Vector3
  2929. * @deprecated Please use FromArray instead.
  2930. */
  2931. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2932. /**
  2933. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2934. * @param array defines the source array
  2935. * @param offset defines the offset in the source array
  2936. * @param result defines the Vector3 where to store the result
  2937. */
  2938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2939. /**
  2940. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2941. * @param array defines the source array
  2942. * @param offset defines the offset in the source array
  2943. * @param result defines the Vector3 where to store the result
  2944. * @deprecated Please use FromArrayToRef instead.
  2945. */
  2946. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2947. /**
  2948. * Sets the given vector "result" with the given floats.
  2949. * @param x defines the x coordinate of the source
  2950. * @param y defines the y coordinate of the source
  2951. * @param z defines the z coordinate of the source
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2955. /**
  2956. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2957. * @returns a new empty Vector3
  2958. */
  2959. static Zero(): Vector3;
  2960. /**
  2961. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2962. * @returns a new unit Vector3
  2963. */
  2964. static One(): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2967. * @returns a new up Vector3
  2968. */
  2969. static Up(): Vector3;
  2970. /**
  2971. * Gets a up Vector3 that must not be updated
  2972. */
  2973. static get UpReadOnly(): DeepImmutable<Vector3>;
  2974. /**
  2975. * Gets a zero Vector3 that must not be updated
  2976. */
  2977. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2978. /**
  2979. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2980. * @returns a new down Vector3
  2981. */
  2982. static Down(): Vector3;
  2983. /**
  2984. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2985. * @param rightHandedSystem is the scene right-handed (negative z)
  2986. * @returns a new forward Vector3
  2987. */
  2988. static Forward(rightHandedSystem?: boolean): Vector3;
  2989. /**
  2990. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2991. * @param rightHandedSystem is the scene right-handed (negative-z)
  2992. * @returns a new forward Vector3
  2993. */
  2994. static Backward(rightHandedSystem?: boolean): Vector3;
  2995. /**
  2996. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2997. * @returns a new right Vector3
  2998. */
  2999. static Right(): Vector3;
  3000. /**
  3001. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3002. * @returns a new left Vector3
  3003. */
  3004. static Left(): Vector3;
  3005. /**
  3006. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3007. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3008. * @param vector defines the Vector3 to transform
  3009. * @param transformation defines the transformation matrix
  3010. * @returns the transformed Vector3
  3011. */
  3012. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3013. /**
  3014. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3015. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3016. * @param vector defines the Vector3 to transform
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3023. * This method computes tranformed coordinates only, not transformed direction vectors
  3024. * @param x define the x coordinate of the source vector
  3025. * @param y define the y coordinate of the source vector
  3026. * @param z define the z coordinate of the source vector
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3033. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3034. * @param vector defines the Vector3 to transform
  3035. * @param transformation defines the transformation matrix
  3036. * @returns the new Vector3
  3037. */
  3038. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3039. /**
  3040. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3041. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3042. * @param vector defines the Vector3 to transform
  3043. * @param transformation defines the transformation matrix
  3044. * @param result defines the Vector3 where to store the result
  3045. */
  3046. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3047. /**
  3048. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3049. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3050. * @param x define the x coordinate of the source vector
  3051. * @param y define the y coordinate of the source vector
  3052. * @param z define the z coordinate of the source vector
  3053. * @param transformation defines the transformation matrix
  3054. * @param result defines the Vector3 where to store the result
  3055. */
  3056. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3057. /**
  3058. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3059. * @param value1 defines the first control point
  3060. * @param value2 defines the second control point
  3061. * @param value3 defines the third control point
  3062. * @param value4 defines the fourth control point
  3063. * @param amount defines the amount on the spline to use
  3064. * @returns the new Vector3
  3065. */
  3066. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3067. /**
  3068. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3069. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3070. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3071. * @param value defines the current value
  3072. * @param min defines the lower range value
  3073. * @param max defines the upper range value
  3074. * @returns the new Vector3
  3075. */
  3076. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3077. /**
  3078. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3079. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3080. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3081. * @param value defines the current value
  3082. * @param min defines the lower range value
  3083. * @param max defines the upper range value
  3084. * @param result defines the Vector3 where to store the result
  3085. */
  3086. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3087. /**
  3088. * Checks if a given vector is inside a specific range
  3089. * @param v defines the vector to test
  3090. * @param min defines the minimum range
  3091. * @param max defines the maximum range
  3092. */
  3093. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3094. /**
  3095. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3096. * @param value1 defines the first control point
  3097. * @param tangent1 defines the first tangent vector
  3098. * @param value2 defines the second control point
  3099. * @param tangent2 defines the second tangent vector
  3100. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3101. * @returns the new Vector3
  3102. */
  3103. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3104. /**
  3105. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3106. * @param start defines the start value
  3107. * @param end defines the end value
  3108. * @param amount max defines amount between both (between 0 and 1)
  3109. * @returns the new Vector3
  3110. */
  3111. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3112. /**
  3113. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3114. * @param start defines the start value
  3115. * @param end defines the end value
  3116. * @param amount max defines amount between both (between 0 and 1)
  3117. * @param result defines the Vector3 where to store the result
  3118. */
  3119. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3120. /**
  3121. * Returns the dot product (float) between the vectors "left" and "right"
  3122. * @param left defines the left operand
  3123. * @param right defines the right operand
  3124. * @returns the dot product
  3125. */
  3126. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3127. /**
  3128. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3129. * The cross product is then orthogonal to both "left" and "right"
  3130. * @param left defines the left operand
  3131. * @param right defines the right operand
  3132. * @returns the cross product
  3133. */
  3134. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3135. /**
  3136. * Sets the given vector "result" with the cross product of "left" and "right"
  3137. * The cross product is then orthogonal to both "left" and "right"
  3138. * @param left defines the left operand
  3139. * @param right defines the right operand
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3143. /**
  3144. * Returns a new Vector3 as the normalization of the given vector
  3145. * @param vector defines the Vector3 to normalize
  3146. * @returns the new Vector3
  3147. */
  3148. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Sets the given vector "result" with the normalization of the given first vector
  3151. * @param vector defines the Vector3 to normalize
  3152. * @param result defines the Vector3 where to store the result
  3153. */
  3154. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3155. /**
  3156. * Project a Vector3 onto screen space
  3157. * @param vector defines the Vector3 to project
  3158. * @param world defines the world matrix to use
  3159. * @param transform defines the transform (view x projection) matrix to use
  3160. * @param viewport defines the screen viewport to use
  3161. * @returns the new Vector3
  3162. */
  3163. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3164. /** @hidden */
  3165. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3166. /**
  3167. * Unproject from screen space to object space
  3168. * @param source defines the screen space Vector3 to use
  3169. * @param viewportWidth defines the current width of the viewport
  3170. * @param viewportHeight defines the current height of the viewport
  3171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3172. * @param transform defines the transform (view x projection) matrix to use
  3173. * @returns the new Vector3
  3174. */
  3175. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3176. /**
  3177. * Unproject from screen space to object space
  3178. * @param source defines the screen space Vector3 to use
  3179. * @param viewportWidth defines the current width of the viewport
  3180. * @param viewportHeight defines the current height of the viewport
  3181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3182. * @param view defines the view matrix to use
  3183. * @param projection defines the projection matrix to use
  3184. * @returns the new Vector3
  3185. */
  3186. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3187. /**
  3188. * Unproject from screen space to object space
  3189. * @param source defines the screen space Vector3 to use
  3190. * @param viewportWidth defines the current width of the viewport
  3191. * @param viewportHeight defines the current height of the viewport
  3192. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3193. * @param view defines the view matrix to use
  3194. * @param projection defines the projection matrix to use
  3195. * @param result defines the Vector3 where to store the result
  3196. */
  3197. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3198. /**
  3199. * Unproject from screen space to object space
  3200. * @param sourceX defines the screen space x coordinate to use
  3201. * @param sourceY defines the screen space y coordinate to use
  3202. * @param sourceZ defines the screen space z coordinate to use
  3203. * @param viewportWidth defines the current width of the viewport
  3204. * @param viewportHeight defines the current height of the viewport
  3205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3206. * @param view defines the view matrix to use
  3207. * @param projection defines the projection matrix to use
  3208. * @param result defines the Vector3 where to store the result
  3209. */
  3210. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3211. /**
  3212. * Gets the minimal coordinate values between two Vector3
  3213. * @param left defines the first operand
  3214. * @param right defines the second operand
  3215. * @returns the new Vector3
  3216. */
  3217. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3218. /**
  3219. * Gets the maximal coordinate values between two Vector3
  3220. * @param left defines the first operand
  3221. * @param right defines the second operand
  3222. * @returns the new Vector3
  3223. */
  3224. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3225. /**
  3226. * Returns the distance between the vectors "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the distance
  3230. */
  3231. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3232. /**
  3233. * Returns the squared distance between the vectors "value1" and "value2"
  3234. * @param value1 defines the first operand
  3235. * @param value2 defines the second operand
  3236. * @returns the squared distance
  3237. */
  3238. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3239. /**
  3240. * Returns a new Vector3 located at the center between "value1" and "value2"
  3241. * @param value1 defines the first operand
  3242. * @param value2 defines the second operand
  3243. * @returns the new Vector3
  3244. */
  3245. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3246. /**
  3247. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3248. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3249. * to something in order to rotate it from its local system to the given target system
  3250. * Note: axis1, axis2 and axis3 are normalized during this operation
  3251. * @param axis1 defines the first axis
  3252. * @param axis2 defines the second axis
  3253. * @param axis3 defines the third axis
  3254. * @returns a new Vector3
  3255. */
  3256. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3257. /**
  3258. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3259. * @param axis1 defines the first axis
  3260. * @param axis2 defines the second axis
  3261. * @param axis3 defines the third axis
  3262. * @param ref defines the Vector3 where to store the result
  3263. */
  3264. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3265. }
  3266. /**
  3267. * Vector4 class created for EulerAngle class conversion to Quaternion
  3268. */
  3269. export class Vector4 {
  3270. /** x value of the vector */
  3271. x: number;
  3272. /** y value of the vector */
  3273. y: number;
  3274. /** z value of the vector */
  3275. z: number;
  3276. /** w value of the vector */
  3277. w: number;
  3278. /**
  3279. * Creates a Vector4 object from the given floats.
  3280. * @param x x value of the vector
  3281. * @param y y value of the vector
  3282. * @param z z value of the vector
  3283. * @param w w value of the vector
  3284. */
  3285. constructor(
  3286. /** x value of the vector */
  3287. x: number,
  3288. /** y value of the vector */
  3289. y: number,
  3290. /** z value of the vector */
  3291. z: number,
  3292. /** w value of the vector */
  3293. w: number);
  3294. /**
  3295. * Returns the string with the Vector4 coordinates.
  3296. * @returns a string containing all the vector values
  3297. */
  3298. toString(): string;
  3299. /**
  3300. * Returns the string "Vector4".
  3301. * @returns "Vector4"
  3302. */
  3303. getClassName(): string;
  3304. /**
  3305. * Returns the Vector4 hash code.
  3306. * @returns a unique hash code
  3307. */
  3308. getHashCode(): number;
  3309. /**
  3310. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3311. * @returns the resulting array
  3312. */
  3313. asArray(): number[];
  3314. /**
  3315. * Populates the given array from the given index with the Vector4 coordinates.
  3316. * @param array array to populate
  3317. * @param index index of the array to start at (default: 0)
  3318. * @returns the Vector4.
  3319. */
  3320. toArray(array: FloatArray, index?: number): Vector4;
  3321. /**
  3322. * Update the current vector from an array
  3323. * @param array defines the destination array
  3324. * @param index defines the offset in the destination array
  3325. * @returns the current Vector3
  3326. */
  3327. fromArray(array: FloatArray, index?: number): Vector4;
  3328. /**
  3329. * Adds the given vector to the current Vector4.
  3330. * @param otherVector the vector to add
  3331. * @returns the updated Vector4.
  3332. */
  3333. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3336. * @param otherVector the vector to add
  3337. * @returns the resulting vector
  3338. */
  3339. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3342. * @param otherVector the vector to add
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Subtract in place the given vector from the current Vector4.
  3349. * @param otherVector the vector to subtract
  3350. * @returns the updated Vector4.
  3351. */
  3352. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3353. /**
  3354. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3355. * @param otherVector the vector to add
  3356. * @returns the new vector with the result
  3357. */
  3358. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3361. * @param otherVector the vector to subtract
  3362. * @param result the vector to store the result
  3363. * @returns the current Vector4.
  3364. */
  3365. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3366. /**
  3367. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3368. */
  3369. /**
  3370. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3371. * @param x value to subtract
  3372. * @param y value to subtract
  3373. * @param z value to subtract
  3374. * @param w value to subtract
  3375. * @returns new vector containing the result
  3376. */
  3377. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3378. /**
  3379. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3380. * @param x value to subtract
  3381. * @param y value to subtract
  3382. * @param z value to subtract
  3383. * @param w value to subtract
  3384. * @param result the vector to store the result in
  3385. * @returns the current Vector4.
  3386. */
  3387. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3388. /**
  3389. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3390. * @returns a new vector with the negated values
  3391. */
  3392. negate(): Vector4;
  3393. /**
  3394. * Negate this vector in place
  3395. * @returns this
  3396. */
  3397. negateInPlace(): Vector4;
  3398. /**
  3399. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3400. * @param result defines the Vector3 object where to store the result
  3401. * @returns the current Vector4
  3402. */
  3403. negateToRef(result: Vector4): Vector4;
  3404. /**
  3405. * Multiplies the current Vector4 coordinates by scale (float).
  3406. * @param scale the number to scale with
  3407. * @returns the updated Vector4.
  3408. */
  3409. scaleInPlace(scale: number): Vector4;
  3410. /**
  3411. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3412. * @param scale the number to scale with
  3413. * @returns a new vector with the result
  3414. */
  3415. scale(scale: number): Vector4;
  3416. /**
  3417. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3418. * @param scale the number to scale with
  3419. * @param result a vector to store the result in
  3420. * @returns the current Vector4.
  3421. */
  3422. scaleToRef(scale: number, result: Vector4): Vector4;
  3423. /**
  3424. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3425. * @param scale defines the scale factor
  3426. * @param result defines the Vector4 object where to store the result
  3427. * @returns the unmodified current Vector4
  3428. */
  3429. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3430. /**
  3431. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3432. * @param otherVector the vector to compare against
  3433. * @returns true if they are equal
  3434. */
  3435. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3436. /**
  3437. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3438. * @param otherVector vector to compare against
  3439. * @param epsilon (Default: very small number)
  3440. * @returns true if they are equal
  3441. */
  3442. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3443. /**
  3444. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3445. * @param x x value to compare against
  3446. * @param y y value to compare against
  3447. * @param z z value to compare against
  3448. * @param w w value to compare against
  3449. * @returns true if equal
  3450. */
  3451. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3452. /**
  3453. * Multiplies in place the current Vector4 by the given one.
  3454. * @param otherVector vector to multiple with
  3455. * @returns the updated Vector4.
  3456. */
  3457. multiplyInPlace(otherVector: Vector4): Vector4;
  3458. /**
  3459. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3460. * @param otherVector vector to multiple with
  3461. * @returns resulting new vector
  3462. */
  3463. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3464. /**
  3465. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3466. * @param otherVector vector to multiple with
  3467. * @param result vector to store the result
  3468. * @returns the current Vector4.
  3469. */
  3470. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3471. /**
  3472. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3473. * @param x x value multiply with
  3474. * @param y y value multiply with
  3475. * @param z z value multiply with
  3476. * @param w w value multiply with
  3477. * @returns resulting new vector
  3478. */
  3479. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3480. /**
  3481. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3482. * @param otherVector vector to devide with
  3483. * @returns resulting new vector
  3484. */
  3485. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3488. * @param otherVector vector to devide with
  3489. * @param result vector to store the result
  3490. * @returns the current Vector4.
  3491. */
  3492. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3493. /**
  3494. * Divides the current Vector3 coordinates by the given ones.
  3495. * @param otherVector vector to devide with
  3496. * @returns the updated Vector3.
  3497. */
  3498. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3499. /**
  3500. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3501. * @param other defines the second operand
  3502. * @returns the current updated Vector4
  3503. */
  3504. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3505. /**
  3506. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3507. * @param other defines the second operand
  3508. * @returns the current updated Vector4
  3509. */
  3510. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3511. /**
  3512. * Gets a new Vector4 from current Vector4 floored values
  3513. * @returns a new Vector4
  3514. */
  3515. floor(): Vector4;
  3516. /**
  3517. * Gets a new Vector4 from current Vector3 floored values
  3518. * @returns a new Vector4
  3519. */
  3520. fract(): Vector4;
  3521. /**
  3522. * Returns the Vector4 length (float).
  3523. * @returns the length
  3524. */
  3525. length(): number;
  3526. /**
  3527. * Returns the Vector4 squared length (float).
  3528. * @returns the length squared
  3529. */
  3530. lengthSquared(): number;
  3531. /**
  3532. * Normalizes in place the Vector4.
  3533. * @returns the updated Vector4.
  3534. */
  3535. normalize(): Vector4;
  3536. /**
  3537. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3538. * @returns this converted to a new vector3
  3539. */
  3540. toVector3(): Vector3;
  3541. /**
  3542. * Returns a new Vector4 copied from the current one.
  3543. * @returns the new cloned vector
  3544. */
  3545. clone(): Vector4;
  3546. /**
  3547. * Updates the current Vector4 with the given one coordinates.
  3548. * @param source the source vector to copy from
  3549. * @returns the updated Vector4.
  3550. */
  3551. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3552. /**
  3553. * Updates the current Vector4 coordinates with the given floats.
  3554. * @param x float to copy from
  3555. * @param y float to copy from
  3556. * @param z float to copy from
  3557. * @param w float to copy from
  3558. * @returns the updated Vector4.
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3561. /**
  3562. * Updates the current Vector4 coordinates with the given floats.
  3563. * @param x float to set from
  3564. * @param y float to set from
  3565. * @param z float to set from
  3566. * @param w float to set from
  3567. * @returns the updated Vector4.
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Vector4;
  3570. /**
  3571. * Copies the given float to the current Vector3 coordinates
  3572. * @param v defines the x, y, z and w coordinates of the operand
  3573. * @returns the current updated Vector3
  3574. */
  3575. setAll(v: number): Vector4;
  3576. /**
  3577. * Returns a new Vector4 set from the starting index of the given array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @returns the new vector
  3581. */
  3582. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3583. /**
  3584. * Updates the given vector "result" from the starting index of the given array.
  3585. * @param array the array to pull values from
  3586. * @param offset the offset into the array to start at
  3587. * @param result the vector to store the result in
  3588. */
  3589. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3590. /**
  3591. * Updates the given vector "result" from the starting index of the given Float32Array.
  3592. * @param array the array to pull values from
  3593. * @param offset the offset into the array to start at
  3594. * @param result the vector to store the result in
  3595. */
  3596. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3597. /**
  3598. * Updates the given vector "result" coordinates from the given floats.
  3599. * @param x float to set from
  3600. * @param y float to set from
  3601. * @param z float to set from
  3602. * @param w float to set from
  3603. * @param result the vector to the floats in
  3604. */
  3605. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3606. /**
  3607. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3608. * @returns the new vector
  3609. */
  3610. static Zero(): Vector4;
  3611. /**
  3612. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3613. * @returns the new vector
  3614. */
  3615. static One(): Vector4;
  3616. /**
  3617. * Returns a new normalized Vector4 from the given one.
  3618. * @param vector the vector to normalize
  3619. * @returns the vector
  3620. */
  3621. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3622. /**
  3623. * Updates the given vector "result" from the normalization of the given one.
  3624. * @param vector the vector to normalize
  3625. * @param result the vector to store the result in
  3626. */
  3627. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3628. /**
  3629. * Returns a vector with the minimum values from the left and right vectors
  3630. * @param left left vector to minimize
  3631. * @param right right vector to minimize
  3632. * @returns a new vector with the minimum of the left and right vector values
  3633. */
  3634. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3635. /**
  3636. * Returns a vector with the maximum values from the left and right vectors
  3637. * @param left left vector to maximize
  3638. * @param right right vector to maximize
  3639. * @returns a new vector with the maximum of the left and right vector values
  3640. */
  3641. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3642. /**
  3643. * Returns the distance (float) between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the distance between
  3645. * @param value2 value to calulate the distance between
  3646. * @return the distance between the two vectors
  3647. */
  3648. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3649. /**
  3650. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3651. * @param value1 value to calulate the distance between
  3652. * @param value2 value to calulate the distance between
  3653. * @return the distance between the two vectors squared
  3654. */
  3655. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3656. /**
  3657. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3658. * @param value1 value to calulate the center between
  3659. * @param value2 value to calulate the center between
  3660. * @return the center between the two vectors
  3661. */
  3662. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3663. /**
  3664. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3665. * This methods computes transformed normalized direction vectors only.
  3666. * @param vector the vector to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @returns the new vector
  3669. */
  3670. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3671. /**
  3672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3673. * This methods computes transformed normalized direction vectors only.
  3674. * @param vector the vector to transform
  3675. * @param transformation the transformation matrix to apply
  3676. * @param result the vector to store the result in
  3677. */
  3678. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3679. /**
  3680. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3681. * This methods computes transformed normalized direction vectors only.
  3682. * @param x value to transform
  3683. * @param y value to transform
  3684. * @param z value to transform
  3685. * @param w value to transform
  3686. * @param transformation the transformation matrix to apply
  3687. * @param result the vector to store the results in
  3688. */
  3689. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3690. /**
  3691. * Creates a new Vector4 from a Vector3
  3692. * @param source defines the source data
  3693. * @param w defines the 4th component (default is 0)
  3694. * @returns a new Vector4
  3695. */
  3696. static FromVector3(source: Vector3, w?: number): Vector4;
  3697. }
  3698. /**
  3699. * Class used to store quaternion data
  3700. * @see https://en.wikipedia.org/wiki/Quaternion
  3701. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3702. */
  3703. export class Quaternion {
  3704. /** @hidden */
  3705. _x: number;
  3706. /** @hidden */
  3707. _y: number;
  3708. /** @hidden */
  3709. _z: number;
  3710. /** @hidden */
  3711. _w: number;
  3712. /** @hidden */
  3713. _isDirty: boolean;
  3714. /** Gets or sets the x coordinate */
  3715. get x(): number;
  3716. set x(value: number);
  3717. /** Gets or sets the y coordinate */
  3718. get y(): number;
  3719. set y(value: number);
  3720. /** Gets or sets the z coordinate */
  3721. get z(): number;
  3722. set z(value: number);
  3723. /** Gets or sets the w coordinate */
  3724. get w(): number;
  3725. set w(value: number);
  3726. /**
  3727. * Creates a new Quaternion from the given floats
  3728. * @param x defines the first component (0 by default)
  3729. * @param y defines the second component (0 by default)
  3730. * @param z defines the third component (0 by default)
  3731. * @param w defines the fourth component (1.0 by default)
  3732. */
  3733. constructor(x?: number, y?: number, z?: number, w?: number);
  3734. /**
  3735. * Gets a string representation for the current quaternion
  3736. * @returns a string with the Quaternion coordinates
  3737. */
  3738. toString(): string;
  3739. /**
  3740. * Gets the class name of the quaternion
  3741. * @returns the string "Quaternion"
  3742. */
  3743. getClassName(): string;
  3744. /**
  3745. * Gets a hash code for this quaternion
  3746. * @returns the quaternion hash code
  3747. */
  3748. getHashCode(): number;
  3749. /**
  3750. * Copy the quaternion to an array
  3751. * @returns a new array populated with 4 elements from the quaternion coordinates
  3752. */
  3753. asArray(): number[];
  3754. /**
  3755. * Check if two quaternions are equals
  3756. * @param otherQuaternion defines the second operand
  3757. * @return true if the current quaternion and the given one coordinates are strictly equals
  3758. */
  3759. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3760. /**
  3761. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3762. * @param otherQuaternion defines the other quaternion
  3763. * @param epsilon defines the minimal distance to consider equality
  3764. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3765. */
  3766. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3767. /**
  3768. * Clone the current quaternion
  3769. * @returns a new quaternion copied from the current one
  3770. */
  3771. clone(): Quaternion;
  3772. /**
  3773. * Copy a quaternion to the current one
  3774. * @param other defines the other quaternion
  3775. * @returns the updated current quaternion
  3776. */
  3777. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3778. /**
  3779. * Updates the current quaternion with the given float coordinates
  3780. * @param x defines the x coordinate
  3781. * @param y defines the y coordinate
  3782. * @param z defines the z coordinate
  3783. * @param w defines the w coordinate
  3784. * @returns the updated current quaternion
  3785. */
  3786. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3787. /**
  3788. * Updates the current quaternion from the given float coordinates
  3789. * @param x defines the x coordinate
  3790. * @param y defines the y coordinate
  3791. * @param z defines the z coordinate
  3792. * @param w defines the w coordinate
  3793. * @returns the updated current quaternion
  3794. */
  3795. set(x: number, y: number, z: number, w: number): Quaternion;
  3796. /**
  3797. * Adds two quaternions
  3798. * @param other defines the second operand
  3799. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3800. */
  3801. add(other: DeepImmutable<Quaternion>): Quaternion;
  3802. /**
  3803. * Add a quaternion to the current one
  3804. * @param other defines the quaternion to add
  3805. * @returns the current quaternion
  3806. */
  3807. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3808. /**
  3809. * Subtract two quaternions
  3810. * @param other defines the second operand
  3811. * @returns a new quaternion as the subtraction result of the given one from the current one
  3812. */
  3813. subtract(other: Quaternion): Quaternion;
  3814. /**
  3815. * Multiplies the current quaternion by a scale factor
  3816. * @param value defines the scale factor
  3817. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3818. */
  3819. scale(value: number): Quaternion;
  3820. /**
  3821. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3822. * @param scale defines the scale factor
  3823. * @param result defines the Quaternion object where to store the result
  3824. * @returns the unmodified current quaternion
  3825. */
  3826. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3827. /**
  3828. * Multiplies in place the current quaternion by a scale factor
  3829. * @param value defines the scale factor
  3830. * @returns the current modified quaternion
  3831. */
  3832. scaleInPlace(value: number): Quaternion;
  3833. /**
  3834. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3835. * @param scale defines the scale factor
  3836. * @param result defines the Quaternion object where to store the result
  3837. * @returns the unmodified current quaternion
  3838. */
  3839. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3840. /**
  3841. * Multiplies two quaternions
  3842. * @param q1 defines the second operand
  3843. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3844. */
  3845. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3846. /**
  3847. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3848. * @param q1 defines the second operand
  3849. * @param result defines the target quaternion
  3850. * @returns the current quaternion
  3851. */
  3852. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3853. /**
  3854. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3855. * @param q1 defines the second operand
  3856. * @returns the currentupdated quaternion
  3857. */
  3858. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3859. /**
  3860. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3861. * @param ref defines the target quaternion
  3862. * @returns the current quaternion
  3863. */
  3864. conjugateToRef(ref: Quaternion): Quaternion;
  3865. /**
  3866. * Conjugates in place (1-q) the current quaternion
  3867. * @returns the current updated quaternion
  3868. */
  3869. conjugateInPlace(): Quaternion;
  3870. /**
  3871. * Conjugates in place (1-q) the current quaternion
  3872. * @returns a new quaternion
  3873. */
  3874. conjugate(): Quaternion;
  3875. /**
  3876. * Gets length of current quaternion
  3877. * @returns the quaternion length (float)
  3878. */
  3879. length(): number;
  3880. /**
  3881. * Normalize in place the current quaternion
  3882. * @returns the current updated quaternion
  3883. */
  3884. normalize(): Quaternion;
  3885. /**
  3886. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3887. * @param order is a reserved parameter and is ignored for now
  3888. * @returns a new Vector3 containing the Euler angles
  3889. */
  3890. toEulerAngles(order?: string): Vector3;
  3891. /**
  3892. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3893. * @param result defines the vector which will be filled with the Euler angles
  3894. * @returns the current unchanged quaternion
  3895. */
  3896. toEulerAnglesToRef(result: Vector3): Quaternion;
  3897. /**
  3898. * Updates the given rotation matrix with the current quaternion values
  3899. * @param result defines the target matrix
  3900. * @returns the current unchanged quaternion
  3901. */
  3902. toRotationMatrix(result: Matrix): Quaternion;
  3903. /**
  3904. * Updates the current quaternion from the given rotation matrix values
  3905. * @param matrix defines the source matrix
  3906. * @returns the current updated quaternion
  3907. */
  3908. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from a rotation matrix
  3911. * @param matrix defines the source matrix
  3912. * @returns a new quaternion created from the given rotation matrix values
  3913. */
  3914. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3915. /**
  3916. * Updates the given quaternion with the given rotation matrix values
  3917. * @param matrix defines the source matrix
  3918. * @param result defines the target quaternion
  3919. */
  3920. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3921. /**
  3922. * Returns the dot product (float) between the quaternions "left" and "right"
  3923. * @param left defines the left operand
  3924. * @param right defines the right operand
  3925. * @returns the dot product
  3926. */
  3927. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3928. /**
  3929. * Checks if the two quaternions are close to each other
  3930. * @param quat0 defines the first quaternion to check
  3931. * @param quat1 defines the second quaternion to check
  3932. * @returns true if the two quaternions are close to each other
  3933. */
  3934. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3935. /**
  3936. * Creates an empty quaternion
  3937. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3938. */
  3939. static Zero(): Quaternion;
  3940. /**
  3941. * Inverse a given quaternion
  3942. * @param q defines the source quaternion
  3943. * @returns a new quaternion as the inverted current quaternion
  3944. */
  3945. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3946. /**
  3947. * Inverse a given quaternion
  3948. * @param q defines the source quaternion
  3949. * @param result the quaternion the result will be stored in
  3950. * @returns the result quaternion
  3951. */
  3952. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates an identity quaternion
  3955. * @returns the identity quaternion
  3956. */
  3957. static Identity(): Quaternion;
  3958. /**
  3959. * Gets a boolean indicating if the given quaternion is identity
  3960. * @param quaternion defines the quaternion to check
  3961. * @returns true if the quaternion is identity
  3962. */
  3963. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3964. /**
  3965. * Creates a quaternion from a rotation around an axis
  3966. * @param axis defines the axis to use
  3967. * @param angle defines the angle to use
  3968. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3969. */
  3970. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3971. /**
  3972. * Creates a rotation around an axis and stores it into the given quaternion
  3973. * @param axis defines the axis to use
  3974. * @param angle defines the angle to use
  3975. * @param result defines the target quaternion
  3976. * @returns the target quaternion
  3977. */
  3978. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3979. /**
  3980. * Creates a new quaternion from data stored into an array
  3981. * @param array defines the data source
  3982. * @param offset defines the offset in the source array where the data starts
  3983. * @returns a new quaternion
  3984. */
  3985. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3986. /**
  3987. * Updates the given quaternion "result" from the starting index of the given array.
  3988. * @param array the array to pull values from
  3989. * @param offset the offset into the array to start at
  3990. * @param result the quaternion to store the result in
  3991. */
  3992. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3993. /**
  3994. * Create a quaternion from Euler rotation angles
  3995. * @param x Pitch
  3996. * @param y Yaw
  3997. * @param z Roll
  3998. * @returns the new Quaternion
  3999. */
  4000. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4001. /**
  4002. * Updates a quaternion from Euler rotation angles
  4003. * @param x Pitch
  4004. * @param y Yaw
  4005. * @param z Roll
  4006. * @param result the quaternion to store the result
  4007. * @returns the updated quaternion
  4008. */
  4009. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4010. /**
  4011. * Create a quaternion from Euler rotation vector
  4012. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4013. * @returns the new Quaternion
  4014. */
  4015. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4016. /**
  4017. * Updates a quaternion from Euler rotation vector
  4018. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4019. * @param result the quaternion to store the result
  4020. * @returns the updated quaternion
  4021. */
  4022. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4023. /**
  4024. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4025. * @param yaw defines the rotation around Y axis
  4026. * @param pitch defines the rotation around X axis
  4027. * @param roll defines the rotation around Z axis
  4028. * @returns the new quaternion
  4029. */
  4030. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4031. /**
  4032. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4033. * @param yaw defines the rotation around Y axis
  4034. * @param pitch defines the rotation around X axis
  4035. * @param roll defines the rotation around Z axis
  4036. * @param result defines the target quaternion
  4037. */
  4038. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4039. /**
  4040. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4041. * @param alpha defines the rotation around first axis
  4042. * @param beta defines the rotation around second axis
  4043. * @param gamma defines the rotation around third axis
  4044. * @returns the new quaternion
  4045. */
  4046. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4047. /**
  4048. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4049. * @param alpha defines the rotation around first axis
  4050. * @param beta defines the rotation around second axis
  4051. * @param gamma defines the rotation around third axis
  4052. * @param result defines the target quaternion
  4053. */
  4054. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4055. /**
  4056. * 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)
  4057. * @param axis1 defines the first axis
  4058. * @param axis2 defines the second axis
  4059. * @param axis3 defines the third axis
  4060. * @returns the new quaternion
  4061. */
  4062. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4063. /**
  4064. * 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
  4065. * @param axis1 defines the first axis
  4066. * @param axis2 defines the second axis
  4067. * @param axis3 defines the third axis
  4068. * @param ref defines the target quaternion
  4069. */
  4070. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4071. /**
  4072. * Interpolates between two quaternions
  4073. * @param left defines first quaternion
  4074. * @param right defines second quaternion
  4075. * @param amount defines the gradient to use
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. /**
  4080. * Interpolates between two quaternions and stores it into a target quaternion
  4081. * @param left defines first quaternion
  4082. * @param right defines second quaternion
  4083. * @param amount defines the gradient to use
  4084. * @param result defines the target quaternion
  4085. */
  4086. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4087. /**
  4088. * Interpolate between two quaternions using Hermite interpolation
  4089. * @param value1 defines first quaternion
  4090. * @param tangent1 defines the incoming tangent
  4091. * @param value2 defines second quaternion
  4092. * @param tangent2 defines the outgoing tangent
  4093. * @param amount defines the target quaternion
  4094. * @returns the new interpolated quaternion
  4095. */
  4096. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4097. }
  4098. /**
  4099. * Class used to store matrix data (4x4)
  4100. */
  4101. export class Matrix {
  4102. /**
  4103. * Gets the precision of matrix computations
  4104. */
  4105. static get Use64Bits(): boolean;
  4106. private static _updateFlagSeed;
  4107. private static _identityReadOnly;
  4108. private _isIdentity;
  4109. private _isIdentityDirty;
  4110. private _isIdentity3x2;
  4111. private _isIdentity3x2Dirty;
  4112. /**
  4113. * Gets the update flag of the matrix which is an unique number for the matrix.
  4114. * It will be incremented every time the matrix data change.
  4115. * You can use it to speed the comparison between two versions of the same matrix.
  4116. */
  4117. updateFlag: number;
  4118. private readonly _m;
  4119. /**
  4120. * Gets the internal data of the matrix
  4121. */
  4122. get m(): DeepImmutable<Float32Array | Array<number>>;
  4123. /** @hidden */
  4124. _markAsUpdated(): void;
  4125. /** @hidden */
  4126. private _updateIdentityStatus;
  4127. /**
  4128. * Creates an empty matrix (filled with zeros)
  4129. */
  4130. constructor();
  4131. /**
  4132. * Check if the current matrix is identity
  4133. * @returns true is the matrix is the identity matrix
  4134. */
  4135. isIdentity(): boolean;
  4136. /**
  4137. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4138. * @returns true is the matrix is the identity matrix
  4139. */
  4140. isIdentityAs3x2(): boolean;
  4141. /**
  4142. * Gets the determinant of the matrix
  4143. * @returns the matrix determinant
  4144. */
  4145. determinant(): number;
  4146. /**
  4147. * Returns the matrix as a Float32Array or Array<number>
  4148. * @returns the matrix underlying array
  4149. */
  4150. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4151. /**
  4152. * Returns the matrix as a Float32Array or Array<number>
  4153. * @returns the matrix underlying array.
  4154. */
  4155. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4156. /**
  4157. * Inverts the current matrix in place
  4158. * @returns the current inverted matrix
  4159. */
  4160. invert(): Matrix;
  4161. /**
  4162. * Sets all the matrix elements to zero
  4163. * @returns the current matrix
  4164. */
  4165. reset(): Matrix;
  4166. /**
  4167. * Adds the current matrix with a second one
  4168. * @param other defines the matrix to add
  4169. * @returns a new matrix as the addition of the current matrix and the given one
  4170. */
  4171. add(other: DeepImmutable<Matrix>): Matrix;
  4172. /**
  4173. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4174. * @param other defines the matrix to add
  4175. * @param result defines the target matrix
  4176. * @returns the current matrix
  4177. */
  4178. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4179. /**
  4180. * Adds in place the given matrix to the current matrix
  4181. * @param other defines the second operand
  4182. * @returns the current updated matrix
  4183. */
  4184. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4185. /**
  4186. * Sets the given matrix to the current inverted Matrix
  4187. * @param other defines the target matrix
  4188. * @returns the unmodified current matrix
  4189. */
  4190. invertToRef(other: Matrix): Matrix;
  4191. /**
  4192. * add a value at the specified position in the current Matrix
  4193. * @param index the index of the value within the matrix. between 0 and 15.
  4194. * @param value the value to be added
  4195. * @returns the current updated matrix
  4196. */
  4197. addAtIndex(index: number, value: number): Matrix;
  4198. /**
  4199. * mutiply the specified position in the current Matrix by a value
  4200. * @param index the index of the value within the matrix. between 0 and 15.
  4201. * @param value the value to be added
  4202. * @returns the current updated matrix
  4203. */
  4204. multiplyAtIndex(index: number, value: number): Matrix;
  4205. /**
  4206. * Inserts the translation vector (using 3 floats) in the current matrix
  4207. * @param x defines the 1st component of the translation
  4208. * @param y defines the 2nd component of the translation
  4209. * @param z defines the 3rd component of the translation
  4210. * @returns the current updated matrix
  4211. */
  4212. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4213. /**
  4214. * Adds the translation vector (using 3 floats) in the current matrix
  4215. * @param x defines the 1st component of the translation
  4216. * @param y defines the 2nd component of the translation
  4217. * @param z defines the 3rd component of the translation
  4218. * @returns the current updated matrix
  4219. */
  4220. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4221. /**
  4222. * Inserts the translation vector in the current matrix
  4223. * @param vector3 defines the translation to insert
  4224. * @returns the current updated matrix
  4225. */
  4226. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4227. /**
  4228. * Gets the translation value of the current matrix
  4229. * @returns a new Vector3 as the extracted translation from the matrix
  4230. */
  4231. getTranslation(): Vector3;
  4232. /**
  4233. * Fill a Vector3 with the extracted translation from the matrix
  4234. * @param result defines the Vector3 where to store the translation
  4235. * @returns the current matrix
  4236. */
  4237. getTranslationToRef(result: Vector3): Matrix;
  4238. /**
  4239. * Remove rotation and scaling part from the matrix
  4240. * @returns the updated matrix
  4241. */
  4242. removeRotationAndScaling(): Matrix;
  4243. /**
  4244. * Multiply two matrices
  4245. * @param other defines the second operand
  4246. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4247. */
  4248. multiply(other: DeepImmutable<Matrix>): Matrix;
  4249. /**
  4250. * Copy the current matrix from the given one
  4251. * @param other defines the source matrix
  4252. * @returns the current updated matrix
  4253. */
  4254. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4255. /**
  4256. * Populates the given array from the starting index with the current matrix values
  4257. * @param array defines the target array
  4258. * @param offset defines the offset in the target array where to start storing values
  4259. * @returns the current matrix
  4260. */
  4261. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4262. /**
  4263. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4264. * @param other defines the second operand
  4265. * @param result defines the matrix where to store the multiplication
  4266. * @returns the current matrix
  4267. */
  4268. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4269. /**
  4270. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4271. * @param other defines the second operand
  4272. * @param result defines the array where to store the multiplication
  4273. * @param offset defines the offset in the target array where to start storing values
  4274. * @returns the current matrix
  4275. */
  4276. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4277. /**
  4278. * Check equality between this matrix and a second one
  4279. * @param value defines the second matrix to compare
  4280. * @returns true is the current matrix and the given one values are strictly equal
  4281. */
  4282. equals(value: DeepImmutable<Matrix>): boolean;
  4283. /**
  4284. * Clone the current matrix
  4285. * @returns a new matrix from the current matrix
  4286. */
  4287. clone(): Matrix;
  4288. /**
  4289. * Returns the name of the current matrix class
  4290. * @returns the string "Matrix"
  4291. */
  4292. getClassName(): string;
  4293. /**
  4294. * Gets the hash code of the current matrix
  4295. * @returns the hash code
  4296. */
  4297. getHashCode(): number;
  4298. /**
  4299. * Decomposes the current Matrix into a translation, rotation and scaling components
  4300. * @param scale defines the scale vector3 given as a reference to update
  4301. * @param rotation defines the rotation quaternion given as a reference to update
  4302. * @param translation defines the translation vector3 given as a reference to update
  4303. * @returns true if operation was successful
  4304. */
  4305. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4306. /**
  4307. * Gets specific row of the matrix
  4308. * @param index defines the number of the row to get
  4309. * @returns the index-th row of the current matrix as a new Vector4
  4310. */
  4311. getRow(index: number): Nullable<Vector4>;
  4312. /**
  4313. * Sets the index-th row of the current matrix to the vector4 values
  4314. * @param index defines the number of the row to set
  4315. * @param row defines the target vector4
  4316. * @returns the updated current matrix
  4317. */
  4318. setRow(index: number, row: Vector4): Matrix;
  4319. /**
  4320. * Compute the transpose of the matrix
  4321. * @returns the new transposed matrix
  4322. */
  4323. transpose(): Matrix;
  4324. /**
  4325. * Compute the transpose of the matrix and store it in a given matrix
  4326. * @param result defines the target matrix
  4327. * @returns the current matrix
  4328. */
  4329. transposeToRef(result: Matrix): Matrix;
  4330. /**
  4331. * Sets the index-th row of the current matrix with the given 4 x float values
  4332. * @param index defines the row index
  4333. * @param x defines the x component to set
  4334. * @param y defines the y component to set
  4335. * @param z defines the z component to set
  4336. * @param w defines the w component to set
  4337. * @returns the updated current matrix
  4338. */
  4339. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4340. /**
  4341. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4342. * @param scale defines the scale factor
  4343. * @returns a new matrix
  4344. */
  4345. scale(scale: number): Matrix;
  4346. /**
  4347. * Scale the current matrix values by a factor to a given result matrix
  4348. * @param scale defines the scale factor
  4349. * @param result defines the matrix to store the result
  4350. * @returns the current matrix
  4351. */
  4352. scaleToRef(scale: number, result: Matrix): Matrix;
  4353. /**
  4354. * Scale the current matrix values by a factor and add the result to a given matrix
  4355. * @param scale defines the scale factor
  4356. * @param result defines the Matrix to store the result
  4357. * @returns the current matrix
  4358. */
  4359. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4360. /**
  4361. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4362. * @param ref matrix to store the result
  4363. */
  4364. toNormalMatrix(ref: Matrix): void;
  4365. /**
  4366. * Gets only rotation part of the current matrix
  4367. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4368. */
  4369. getRotationMatrix(): Matrix;
  4370. /**
  4371. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4372. * @param result defines the target matrix to store data to
  4373. * @returns the current matrix
  4374. */
  4375. getRotationMatrixToRef(result: Matrix): Matrix;
  4376. /**
  4377. * Toggles model matrix from being right handed to left handed in place and vice versa
  4378. */
  4379. toggleModelMatrixHandInPlace(): void;
  4380. /**
  4381. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4382. */
  4383. toggleProjectionMatrixHandInPlace(): void;
  4384. /**
  4385. * Creates a matrix from an array
  4386. * @param array defines the source array
  4387. * @param offset defines an offset in the source array
  4388. * @returns a new Matrix set from the starting index of the given array
  4389. */
  4390. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4391. /**
  4392. * Copy the content of an array into a given matrix
  4393. * @param array defines the source array
  4394. * @param offset defines an offset in the source array
  4395. * @param result defines the target matrix
  4396. */
  4397. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4398. /**
  4399. * Stores an array into a matrix after having multiplied each component by a given factor
  4400. * @param array defines the source array
  4401. * @param offset defines the offset in the source array
  4402. * @param scale defines the scaling factor
  4403. * @param result defines the target matrix
  4404. */
  4405. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4406. /**
  4407. * Gets an identity matrix that must not be updated
  4408. */
  4409. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4410. /**
  4411. * Stores a list of values (16) inside a given matrix
  4412. * @param initialM11 defines 1st value of 1st row
  4413. * @param initialM12 defines 2nd value of 1st row
  4414. * @param initialM13 defines 3rd value of 1st row
  4415. * @param initialM14 defines 4th value of 1st row
  4416. * @param initialM21 defines 1st value of 2nd row
  4417. * @param initialM22 defines 2nd value of 2nd row
  4418. * @param initialM23 defines 3rd value of 2nd row
  4419. * @param initialM24 defines 4th value of 2nd row
  4420. * @param initialM31 defines 1st value of 3rd row
  4421. * @param initialM32 defines 2nd value of 3rd row
  4422. * @param initialM33 defines 3rd value of 3rd row
  4423. * @param initialM34 defines 4th value of 3rd row
  4424. * @param initialM41 defines 1st value of 4th row
  4425. * @param initialM42 defines 2nd value of 4th row
  4426. * @param initialM43 defines 3rd value of 4th row
  4427. * @param initialM44 defines 4th value of 4th row
  4428. * @param result defines the target matrix
  4429. */
  4430. 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;
  4431. /**
  4432. * Creates new matrix from a list of values (16)
  4433. * @param initialM11 defines 1st value of 1st row
  4434. * @param initialM12 defines 2nd value of 1st row
  4435. * @param initialM13 defines 3rd value of 1st row
  4436. * @param initialM14 defines 4th value of 1st row
  4437. * @param initialM21 defines 1st value of 2nd row
  4438. * @param initialM22 defines 2nd value of 2nd row
  4439. * @param initialM23 defines 3rd value of 2nd row
  4440. * @param initialM24 defines 4th value of 2nd row
  4441. * @param initialM31 defines 1st value of 3rd row
  4442. * @param initialM32 defines 2nd value of 3rd row
  4443. * @param initialM33 defines 3rd value of 3rd row
  4444. * @param initialM34 defines 4th value of 3rd row
  4445. * @param initialM41 defines 1st value of 4th row
  4446. * @param initialM42 defines 2nd value of 4th row
  4447. * @param initialM43 defines 3rd value of 4th row
  4448. * @param initialM44 defines 4th value of 4th row
  4449. * @returns the new matrix
  4450. */
  4451. 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;
  4452. /**
  4453. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4454. * @param scale defines the scale vector3
  4455. * @param rotation defines the rotation quaternion
  4456. * @param translation defines the translation vector3
  4457. * @returns a new matrix
  4458. */
  4459. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4460. /**
  4461. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4462. * @param scale defines the scale vector3
  4463. * @param rotation defines the rotation quaternion
  4464. * @param translation defines the translation vector3
  4465. * @param result defines the target matrix
  4466. */
  4467. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4468. /**
  4469. * Creates a new identity matrix
  4470. * @returns a new identity matrix
  4471. */
  4472. static Identity(): Matrix;
  4473. /**
  4474. * Creates a new identity matrix and stores the result in a given matrix
  4475. * @param result defines the target matrix
  4476. */
  4477. static IdentityToRef(result: Matrix): void;
  4478. /**
  4479. * Creates a new zero matrix
  4480. * @returns a new zero matrix
  4481. */
  4482. static Zero(): Matrix;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the X axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationX(angle: number): Matrix;
  4489. /**
  4490. * Creates a new matrix as the invert of a given matrix
  4491. * @param source defines the source matrix
  4492. * @returns the new matrix
  4493. */
  4494. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4497. * @param angle defines the angle (in radians) to use
  4498. * @param result defines the target matrix
  4499. */
  4500. static RotationXToRef(angle: number, result: Matrix): void;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Y axis
  4503. * @param angle defines the angle (in radians) to use
  4504. * @return the new matrix
  4505. */
  4506. static RotationY(angle: number): Matrix;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4509. * @param angle defines the angle (in radians) to use
  4510. * @param result defines the target matrix
  4511. */
  4512. static RotationYToRef(angle: number, result: Matrix): void;
  4513. /**
  4514. * Creates a new rotation matrix for "angle" radians around the Z axis
  4515. * @param angle defines the angle (in radians) to use
  4516. * @return the new matrix
  4517. */
  4518. static RotationZ(angle: number): Matrix;
  4519. /**
  4520. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationZToRef(angle: number, result: Matrix): void;
  4525. /**
  4526. * Creates a new rotation matrix for "angle" radians around the given axis
  4527. * @param axis defines the axis to use
  4528. * @param angle defines the angle (in radians) to use
  4529. * @return the new matrix
  4530. */
  4531. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4532. /**
  4533. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4534. * @param axis defines the axis to use
  4535. * @param angle defines the angle (in radians) to use
  4536. * @param result defines the target matrix
  4537. */
  4538. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4539. /**
  4540. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4541. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4542. * @param from defines the vector to align
  4543. * @param to defines the vector to align to
  4544. * @param result defines the target matrix
  4545. */
  4546. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4547. /**
  4548. * Creates a rotation matrix
  4549. * @param yaw defines the yaw angle in radians (Y axis)
  4550. * @param pitch defines the pitch angle in radians (X axis)
  4551. * @param roll defines the roll angle in radians (Z axis)
  4552. * @returns the new rotation matrix
  4553. */
  4554. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4555. /**
  4556. * Creates a rotation matrix and stores it in a given matrix
  4557. * @param yaw defines the yaw angle in radians (Y axis)
  4558. * @param pitch defines the pitch angle in radians (X axis)
  4559. * @param roll defines the roll angle in radians (Z axis)
  4560. * @param result defines the target matrix
  4561. */
  4562. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4563. /**
  4564. * Creates a scaling matrix
  4565. * @param x defines the scale factor on X axis
  4566. * @param y defines the scale factor on Y axis
  4567. * @param z defines the scale factor on Z axis
  4568. * @returns the new matrix
  4569. */
  4570. static Scaling(x: number, y: number, z: number): Matrix;
  4571. /**
  4572. * Creates a scaling matrix and stores it in a given matrix
  4573. * @param x defines the scale factor on X axis
  4574. * @param y defines the scale factor on Y axis
  4575. * @param z defines the scale factor on Z axis
  4576. * @param result defines the target matrix
  4577. */
  4578. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4579. /**
  4580. * Creates a translation matrix
  4581. * @param x defines the translation on X axis
  4582. * @param y defines the translation on Y axis
  4583. * @param z defines the translationon Z axis
  4584. * @returns the new matrix
  4585. */
  4586. static Translation(x: number, y: number, z: number): Matrix;
  4587. /**
  4588. * Creates a translation matrix and stores it in a given matrix
  4589. * @param x defines the translation on X axis
  4590. * @param y defines the translation on Y axis
  4591. * @param z defines the translationon Z axis
  4592. * @param result defines the target matrix
  4593. */
  4594. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4595. /**
  4596. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4597. * @param startValue defines the start value
  4598. * @param endValue defines the end value
  4599. * @param gradient defines the gradient factor
  4600. * @returns the new matrix
  4601. */
  4602. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4603. /**
  4604. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4605. * @param startValue defines the start value
  4606. * @param endValue defines the end value
  4607. * @param gradient defines the gradient factor
  4608. * @param result defines the Matrix object where to store data
  4609. */
  4610. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4611. /**
  4612. * Builds a new matrix whose values are computed by:
  4613. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4614. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4615. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4616. * @param startValue defines the first matrix
  4617. * @param endValue defines the second matrix
  4618. * @param gradient defines the gradient between the two matrices
  4619. * @returns the new matrix
  4620. */
  4621. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4622. /**
  4623. * Update a matrix to values which are computed by:
  4624. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4625. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4626. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4627. * @param startValue defines the first matrix
  4628. * @param endValue defines the second matrix
  4629. * @param gradient defines the gradient between the two matrices
  4630. * @param result defines the target matrix
  4631. */
  4632. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4633. /**
  4634. * 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"
  4635. * This function works in left handed mode
  4636. * @param eye defines the final position of the entity
  4637. * @param target defines where the entity should look at
  4638. * @param up defines the up vector for the entity
  4639. * @returns the new matrix
  4640. */
  4641. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4642. /**
  4643. * 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".
  4644. * This function works in left handed mode
  4645. * @param eye defines the final position of the entity
  4646. * @param target defines where the entity should look at
  4647. * @param up defines the up vector for the entity
  4648. * @param result defines the target matrix
  4649. */
  4650. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * 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"
  4653. * This function works in right handed mode
  4654. * @param eye defines the final position of the entity
  4655. * @param target defines where the entity should look at
  4656. * @param up defines the up vector for the entity
  4657. * @returns the new matrix
  4658. */
  4659. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4660. /**
  4661. * 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".
  4662. * This function works in right handed mode
  4663. * @param eye defines the final position of the entity
  4664. * @param target defines where the entity should look at
  4665. * @param up defines the up vector for the entity
  4666. * @param result defines the target matrix
  4667. */
  4668. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param width defines the viewport width
  4672. * @param height defines the viewport height
  4673. * @param znear defines the near clip plane
  4674. * @param zfar defines the far clip plane
  4675. * @returns a new matrix as a left-handed orthographic projection matrix
  4676. */
  4677. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4678. /**
  4679. * Store a left-handed orthographic projection to a given matrix
  4680. * @param width defines the viewport width
  4681. * @param height defines the viewport height
  4682. * @param znear defines the near clip plane
  4683. * @param zfar defines the far clip plane
  4684. * @param result defines the target matrix
  4685. */
  4686. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4687. /**
  4688. * Create a left-handed orthographic projection matrix
  4689. * @param left defines the viewport left coordinate
  4690. * @param right defines the viewport right coordinate
  4691. * @param bottom defines the viewport bottom coordinate
  4692. * @param top defines the viewport top coordinate
  4693. * @param znear defines the near clip plane
  4694. * @param zfar defines the far clip plane
  4695. * @returns a new matrix as a left-handed orthographic projection matrix
  4696. */
  4697. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4698. /**
  4699. * Stores a left-handed orthographic projection into a given matrix
  4700. * @param left defines the viewport left coordinate
  4701. * @param right defines the viewport right coordinate
  4702. * @param bottom defines the viewport bottom coordinate
  4703. * @param top defines the viewport top coordinate
  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 OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4709. /**
  4710. * Creates a right-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 right-handed orthographic projection matrix
  4718. */
  4719. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4720. /**
  4721. * Stores a right-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 OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4731. /**
  4732. * Creates a left-handed perspective projection matrix
  4733. * @param width defines the viewport width
  4734. * @param height defines the viewport height
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @returns a new matrix as a left-handed perspective projection matrix
  4738. */
  4739. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4740. /**
  4741. * Creates a left-handed perspective projection matrix
  4742. * @param fov defines the horizontal field of view
  4743. * @param aspect defines the aspect ratio
  4744. * @param znear defines the near clip plane
  4745. * @param zfar defines the far clip plane
  4746. * @returns a new matrix as a left-handed perspective projection matrix
  4747. */
  4748. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4749. /**
  4750. * Stores a left-handed perspective projection into a given matrix
  4751. * @param fov defines the horizontal field of view
  4752. * @param aspect defines the aspect ratio
  4753. * @param znear defines the near clip plane
  4754. * @param zfar defines the far clip plane
  4755. * @param result defines the target matrix
  4756. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4757. */
  4758. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4759. /**
  4760. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4761. * @param fov defines the horizontal field of view
  4762. * @param aspect defines the aspect ratio
  4763. * @param znear defines the near clip plane
  4764. * @param zfar not used as infinity is used as far clip
  4765. * @param result defines the target matrix
  4766. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4767. */
  4768. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4769. /**
  4770. * Creates a right-handed perspective projection matrix
  4771. * @param fov defines the horizontal field of view
  4772. * @param aspect defines the aspect ratio
  4773. * @param znear defines the near clip plane
  4774. * @param zfar defines the far clip plane
  4775. * @returns a new matrix as a right-handed perspective projection matrix
  4776. */
  4777. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4778. /**
  4779. * Stores a right-handed perspective projection into a given matrix
  4780. * @param fov defines the horizontal field of view
  4781. * @param aspect defines the aspect ratio
  4782. * @param znear defines the near clip plane
  4783. * @param zfar defines the far clip plane
  4784. * @param result defines the target matrix
  4785. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4786. */
  4787. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4788. /**
  4789. * Stores a right-handed perspective projection into a given matrix
  4790. * @param fov defines the horizontal field of view
  4791. * @param aspect defines the aspect ratio
  4792. * @param znear defines the near clip plane
  4793. * @param zfar not used as infinity is used as far clip
  4794. * @param result defines the target matrix
  4795. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4796. */
  4797. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4798. /**
  4799. * Stores a perspective projection for WebVR info a given matrix
  4800. * @param fov defines the field of view
  4801. * @param znear defines the near clip plane
  4802. * @param zfar defines the far clip plane
  4803. * @param result defines the target matrix
  4804. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4805. */
  4806. static PerspectiveFovWebVRToRef(fov: {
  4807. upDegrees: number;
  4808. downDegrees: number;
  4809. leftDegrees: number;
  4810. rightDegrees: number;
  4811. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4812. /**
  4813. * Computes a complete transformation matrix
  4814. * @param viewport defines the viewport to use
  4815. * @param world defines the world matrix
  4816. * @param view defines the view matrix
  4817. * @param projection defines the projection matrix
  4818. * @param zmin defines the near clip plane
  4819. * @param zmax defines the far clip plane
  4820. * @returns the transformation matrix
  4821. */
  4822. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4823. /**
  4824. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4825. * @param matrix defines the matrix to use
  4826. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4827. */
  4828. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4829. /**
  4830. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4831. * @param matrix defines the matrix to use
  4832. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4833. */
  4834. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4835. /**
  4836. * Compute the transpose of a given matrix
  4837. * @param matrix defines the matrix to transpose
  4838. * @returns the new matrix
  4839. */
  4840. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4841. /**
  4842. * Compute the transpose of a matrix and store it in a target matrix
  4843. * @param matrix defines the matrix to transpose
  4844. * @param result defines the target matrix
  4845. */
  4846. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4847. /**
  4848. * Computes a reflection matrix from a plane
  4849. * @param plane defines the reflection plane
  4850. * @returns a new matrix
  4851. */
  4852. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4853. /**
  4854. * Computes a reflection matrix from a plane
  4855. * @param plane defines the reflection plane
  4856. * @param result defines the target matrix
  4857. */
  4858. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4859. /**
  4860. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4861. * @param xaxis defines the value of the 1st axis
  4862. * @param yaxis defines the value of the 2nd axis
  4863. * @param zaxis defines the value of the 3rd axis
  4864. * @param result defines the target matrix
  4865. */
  4866. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4867. /**
  4868. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4869. * @param quat defines the quaternion to use
  4870. * @param result defines the target matrix
  4871. */
  4872. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4873. }
  4874. /**
  4875. * @hidden
  4876. */
  4877. export class TmpVectors {
  4878. static Vector2: Vector2[];
  4879. static Vector3: Vector3[];
  4880. static Vector4: Vector4[];
  4881. static Quaternion: Quaternion[];
  4882. static Matrix: Matrix[];
  4883. }
  4884. }
  4885. declare module "babylonjs/Maths/math.path" {
  4886. import { DeepImmutable, Nullable } from "babylonjs/types";
  4887. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4888. /**
  4889. * Defines potential orientation for back face culling
  4890. */
  4891. export enum Orientation {
  4892. /**
  4893. * Clockwise
  4894. */
  4895. CW = 0,
  4896. /** Counter clockwise */
  4897. CCW = 1
  4898. }
  4899. /** Class used to represent a Bezier curve */
  4900. export class BezierCurve {
  4901. /**
  4902. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4903. * @param t defines the time
  4904. * @param x1 defines the left coordinate on X axis
  4905. * @param y1 defines the left coordinate on Y axis
  4906. * @param x2 defines the right coordinate on X axis
  4907. * @param y2 defines the right coordinate on Y axis
  4908. * @returns the interpolated value
  4909. */
  4910. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4911. }
  4912. /**
  4913. * Defines angle representation
  4914. */
  4915. export class Angle {
  4916. private _radians;
  4917. /**
  4918. * Creates an Angle object of "radians" radians (float).
  4919. * @param radians the angle in radians
  4920. */
  4921. constructor(radians: number);
  4922. /**
  4923. * Get value in degrees
  4924. * @returns the Angle value in degrees (float)
  4925. */
  4926. degrees(): number;
  4927. /**
  4928. * Get value in radians
  4929. * @returns the Angle value in radians (float)
  4930. */
  4931. radians(): number;
  4932. /**
  4933. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4934. * @param a defines first point as the origin
  4935. * @param b defines point
  4936. * @returns a new Angle
  4937. */
  4938. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4939. /**
  4940. * Gets a new Angle object from the given float in radians
  4941. * @param radians defines the angle value in radians
  4942. * @returns a new Angle
  4943. */
  4944. static FromRadians(radians: number): Angle;
  4945. /**
  4946. * Gets a new Angle object from the given float in degrees
  4947. * @param degrees defines the angle value in degrees
  4948. * @returns a new Angle
  4949. */
  4950. static FromDegrees(degrees: number): Angle;
  4951. }
  4952. /**
  4953. * This represents an arc in a 2d space.
  4954. */
  4955. export class Arc2 {
  4956. /** Defines the start point of the arc */
  4957. startPoint: Vector2;
  4958. /** Defines the mid point of the arc */
  4959. midPoint: Vector2;
  4960. /** Defines the end point of the arc */
  4961. endPoint: Vector2;
  4962. /**
  4963. * Defines the center point of the arc.
  4964. */
  4965. centerPoint: Vector2;
  4966. /**
  4967. * Defines the radius of the arc.
  4968. */
  4969. radius: number;
  4970. /**
  4971. * Defines the angle of the arc (from mid point to end point).
  4972. */
  4973. angle: Angle;
  4974. /**
  4975. * Defines the start angle of the arc (from start point to middle point).
  4976. */
  4977. startAngle: Angle;
  4978. /**
  4979. * Defines the orientation of the arc (clock wise/counter clock wise).
  4980. */
  4981. orientation: Orientation;
  4982. /**
  4983. * Creates an Arc object from the three given points : start, middle and end.
  4984. * @param startPoint Defines the start point of the arc
  4985. * @param midPoint Defines the midlle point of the arc
  4986. * @param endPoint Defines the end point of the arc
  4987. */
  4988. constructor(
  4989. /** Defines the start point of the arc */
  4990. startPoint: Vector2,
  4991. /** Defines the mid point of the arc */
  4992. midPoint: Vector2,
  4993. /** Defines the end point of the arc */
  4994. endPoint: Vector2);
  4995. }
  4996. /**
  4997. * Represents a 2D path made up of multiple 2D points
  4998. */
  4999. export class Path2 {
  5000. private _points;
  5001. private _length;
  5002. /**
  5003. * If the path start and end point are the same
  5004. */
  5005. closed: boolean;
  5006. /**
  5007. * Creates a Path2 object from the starting 2D coordinates x and y.
  5008. * @param x the starting points x value
  5009. * @param y the starting points y value
  5010. */
  5011. constructor(x: number, y: number);
  5012. /**
  5013. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5014. * @param x the added points x value
  5015. * @param y the added points y value
  5016. * @returns the updated Path2.
  5017. */
  5018. addLineTo(x: number, y: number): Path2;
  5019. /**
  5020. * 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.
  5021. * @param midX middle point x value
  5022. * @param midY middle point y value
  5023. * @param endX end point x value
  5024. * @param endY end point y value
  5025. * @param numberOfSegments (default: 36)
  5026. * @returns the updated Path2.
  5027. */
  5028. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5029. /**
  5030. * Closes the Path2.
  5031. * @returns the Path2.
  5032. */
  5033. close(): Path2;
  5034. /**
  5035. * Gets the sum of the distance between each sequential point in the path
  5036. * @returns the Path2 total length (float).
  5037. */
  5038. length(): number;
  5039. /**
  5040. * Gets the points which construct the path
  5041. * @returns the Path2 internal array of points.
  5042. */
  5043. getPoints(): Vector2[];
  5044. /**
  5045. * Retreives the point at the distance aways from the starting point
  5046. * @param normalizedLengthPosition the length along the path to retreive the point from
  5047. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5048. */
  5049. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5050. /**
  5051. * Creates a new path starting from an x and y position
  5052. * @param x starting x value
  5053. * @param y starting y value
  5054. * @returns a new Path2 starting at the coordinates (x, y).
  5055. */
  5056. static StartingAt(x: number, y: number): Path2;
  5057. }
  5058. /**
  5059. * Represents a 3D path made up of multiple 3D points
  5060. */
  5061. export class Path3D {
  5062. /**
  5063. * an array of Vector3, the curve axis of the Path3D
  5064. */
  5065. path: Vector3[];
  5066. private _curve;
  5067. private _distances;
  5068. private _tangents;
  5069. private _normals;
  5070. private _binormals;
  5071. private _raw;
  5072. private _alignTangentsWithPath;
  5073. private readonly _pointAtData;
  5074. /**
  5075. * new Path3D(path, normal, raw)
  5076. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5077. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5078. * @param path an array of Vector3, the curve axis of the Path3D
  5079. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5080. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5081. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5082. */
  5083. constructor(
  5084. /**
  5085. * an array of Vector3, the curve axis of the Path3D
  5086. */
  5087. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5088. /**
  5089. * Returns the Path3D array of successive Vector3 designing its curve.
  5090. * @returns the Path3D array of successive Vector3 designing its curve.
  5091. */
  5092. getCurve(): Vector3[];
  5093. /**
  5094. * Returns the Path3D array of successive Vector3 designing its curve.
  5095. * @returns the Path3D array of successive Vector3 designing its curve.
  5096. */
  5097. getPoints(): Vector3[];
  5098. /**
  5099. * @returns the computed length (float) of the path.
  5100. */
  5101. length(): number;
  5102. /**
  5103. * Returns an array populated with tangent vectors on each Path3D curve point.
  5104. * @returns an array populated with tangent vectors on each Path3D curve point.
  5105. */
  5106. getTangents(): Vector3[];
  5107. /**
  5108. * Returns an array populated with normal vectors on each Path3D curve point.
  5109. * @returns an array populated with normal vectors on each Path3D curve point.
  5110. */
  5111. getNormals(): Vector3[];
  5112. /**
  5113. * Returns an array populated with binormal vectors on each Path3D curve point.
  5114. * @returns an array populated with binormal vectors on each Path3D curve point.
  5115. */
  5116. getBinormals(): Vector3[];
  5117. /**
  5118. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5119. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5120. */
  5121. getDistances(): number[];
  5122. /**
  5123. * Returns an interpolated point along this path
  5124. * @param position the position of the point along this path, from 0.0 to 1.0
  5125. * @returns a new Vector3 as the point
  5126. */
  5127. getPointAt(position: number): Vector3;
  5128. /**
  5129. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5130. * @param position the position of the point along this path, from 0.0 to 1.0
  5131. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5132. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5133. */
  5134. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5135. /**
  5136. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5137. * @param position the position of the point along this path, from 0.0 to 1.0
  5138. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5139. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5140. */
  5141. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5142. /**
  5143. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5144. * @param position the position of the point along this path, from 0.0 to 1.0
  5145. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5146. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5147. */
  5148. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5149. /**
  5150. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5151. * @param position the position of the point along this path, from 0.0 to 1.0
  5152. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5153. */
  5154. getDistanceAt(position: number): number;
  5155. /**
  5156. * Returns the array index of the previous point of an interpolated point along this path
  5157. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5158. * @returns the array index
  5159. */
  5160. getPreviousPointIndexAt(position: number): number;
  5161. /**
  5162. * 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)
  5163. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5164. * @returns the sub position
  5165. */
  5166. getSubPositionAt(position: number): number;
  5167. /**
  5168. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5169. * @param target the vector of which to get the closest position to
  5170. * @returns the position of the closest virtual point on this path to the target vector
  5171. */
  5172. getClosestPositionTo(target: Vector3): number;
  5173. /**
  5174. * Returns a sub path (slice) of this path
  5175. * @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
  5176. * @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
  5177. * @returns a sub path (slice) of this path
  5178. */
  5179. slice(start?: number, end?: number): Path3D;
  5180. /**
  5181. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5182. * @param path path which all values are copied into the curves points
  5183. * @param firstNormal which should be projected onto the curve
  5184. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5185. * @returns the same object updated.
  5186. */
  5187. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5188. private _compute;
  5189. private _getFirstNonNullVector;
  5190. private _getLastNonNullVector;
  5191. private _normalVector;
  5192. /**
  5193. * Updates the point at data for an interpolated point along this curve
  5194. * @param position the position of the point along this curve, from 0.0 to 1.0
  5195. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5196. * @returns the (updated) point at data
  5197. */
  5198. private _updatePointAtData;
  5199. /**
  5200. * Updates the point at data from the specified parameters
  5201. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5202. * @param point the interpolated point
  5203. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5204. */
  5205. private _setPointAtData;
  5206. /**
  5207. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5208. */
  5209. private _updateInterpolationMatrix;
  5210. }
  5211. /**
  5212. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5213. * A Curve3 is designed from a series of successive Vector3.
  5214. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5215. */
  5216. export class Curve3 {
  5217. private _points;
  5218. private _length;
  5219. /**
  5220. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5221. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5222. * @param v1 (Vector3) the control point
  5223. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5224. * @param nbPoints (integer) the wanted number of points in the curve
  5225. * @returns the created Curve3
  5226. */
  5227. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5228. /**
  5229. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5230. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5231. * @param v1 (Vector3) the first control point
  5232. * @param v2 (Vector3) the second control point
  5233. * @param v3 (Vector3) the end point of the Cubic Bezier
  5234. * @param nbPoints (integer) the wanted number of points in the curve
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5238. /**
  5239. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5240. * @param p1 (Vector3) the origin point of the Hermite Spline
  5241. * @param t1 (Vector3) the tangent vector at the origin point
  5242. * @param p2 (Vector3) the end point of the Hermite Spline
  5243. * @param t2 (Vector3) the tangent vector at the end point
  5244. * @param nbPoints (integer) the wanted number of points in the curve
  5245. * @returns the created Curve3
  5246. */
  5247. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5248. /**
  5249. * Returns a Curve3 object along a CatmullRom Spline curve :
  5250. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5251. * @param nbPoints (integer) the wanted number of points between each curve control points
  5252. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5253. * @returns the created Curve3
  5254. */
  5255. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5256. /**
  5257. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5258. * A Curve3 is designed from a series of successive Vector3.
  5259. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5260. * @param points points which make up the curve
  5261. */
  5262. constructor(points: Vector3[]);
  5263. /**
  5264. * @returns the Curve3 stored array of successive Vector3
  5265. */
  5266. getPoints(): Vector3[];
  5267. /**
  5268. * @returns the computed length (float) of the curve.
  5269. */
  5270. length(): number;
  5271. /**
  5272. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5273. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5274. * curveA and curveB keep unchanged.
  5275. * @param curve the curve to continue from this curve
  5276. * @returns the newly constructed curve
  5277. */
  5278. continue(curve: DeepImmutable<Curve3>): Curve3;
  5279. private _computeLength;
  5280. }
  5281. }
  5282. declare module "babylonjs/Animations/easing" {
  5283. /**
  5284. * This represents the main contract an easing function should follow.
  5285. * Easing functions are used throughout the animation system.
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export interface IEasingFunction {
  5289. /**
  5290. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5291. * of the easing function.
  5292. * The link below provides some of the most common examples of easing functions.
  5293. * @see https://easings.net/
  5294. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5295. * @returns the corresponding value on the curve defined by the easing function
  5296. */
  5297. ease(gradient: number): number;
  5298. }
  5299. /**
  5300. * Base class used for every default easing function.
  5301. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5302. */
  5303. export class EasingFunction implements IEasingFunction {
  5304. /**
  5305. * Interpolation follows the mathematical formula associated with the easing function.
  5306. */
  5307. static readonly EASINGMODE_EASEIN: number;
  5308. /**
  5309. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5310. */
  5311. static readonly EASINGMODE_EASEOUT: number;
  5312. /**
  5313. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5314. */
  5315. static readonly EASINGMODE_EASEINOUT: number;
  5316. private _easingMode;
  5317. /**
  5318. * Sets the easing mode of the current function.
  5319. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5320. */
  5321. setEasingMode(easingMode: number): void;
  5322. /**
  5323. * Gets the current easing mode.
  5324. * @returns the easing mode
  5325. */
  5326. getEasingMode(): number;
  5327. /**
  5328. * @hidden
  5329. */
  5330. easeInCore(gradient: number): number;
  5331. /**
  5332. * Given an input gradient between 0 and 1, this returns the corresponding value
  5333. * of the easing function.
  5334. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5335. * @returns the corresponding value on the curve defined by the easing function
  5336. */
  5337. ease(gradient: number): number;
  5338. }
  5339. /**
  5340. * Easing function with a circle shape (see link below).
  5341. * @see https://easings.net/#easeInCirc
  5342. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5343. */
  5344. export class CircleEase extends EasingFunction implements IEasingFunction {
  5345. /** @hidden */
  5346. easeInCore(gradient: number): number;
  5347. }
  5348. /**
  5349. * Easing function with a ease back shape (see link below).
  5350. * @see https://easings.net/#easeInBack
  5351. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5352. */
  5353. export class BackEase extends EasingFunction implements IEasingFunction {
  5354. /** Defines the amplitude of the function */
  5355. amplitude: number;
  5356. /**
  5357. * Instantiates a back ease easing
  5358. * @see https://easings.net/#easeInBack
  5359. * @param amplitude Defines the amplitude of the function
  5360. */
  5361. constructor(
  5362. /** Defines the amplitude of the function */
  5363. amplitude?: number);
  5364. /** @hidden */
  5365. easeInCore(gradient: number): number;
  5366. }
  5367. /**
  5368. * Easing function with a bouncing shape (see link below).
  5369. * @see https://easings.net/#easeInBounce
  5370. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5371. */
  5372. export class BounceEase extends EasingFunction implements IEasingFunction {
  5373. /** Defines the number of bounces */
  5374. bounces: number;
  5375. /** Defines the amplitude of the bounce */
  5376. bounciness: number;
  5377. /**
  5378. * Instantiates a bounce easing
  5379. * @see https://easings.net/#easeInBounce
  5380. * @param bounces Defines the number of bounces
  5381. * @param bounciness Defines the amplitude of the bounce
  5382. */
  5383. constructor(
  5384. /** Defines the number of bounces */
  5385. bounces?: number,
  5386. /** Defines the amplitude of the bounce */
  5387. bounciness?: number);
  5388. /** @hidden */
  5389. easeInCore(gradient: number): number;
  5390. }
  5391. /**
  5392. * Easing function with a power of 3 shape (see link below).
  5393. * @see https://easings.net/#easeInCubic
  5394. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5395. */
  5396. export class CubicEase extends EasingFunction implements IEasingFunction {
  5397. /** @hidden */
  5398. easeInCore(gradient: number): number;
  5399. }
  5400. /**
  5401. * Easing function with an elastic shape (see link below).
  5402. * @see https://easings.net/#easeInElastic
  5403. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5404. */
  5405. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5406. /** Defines the number of oscillations*/
  5407. oscillations: number;
  5408. /** Defines the amplitude of the oscillations*/
  5409. springiness: number;
  5410. /**
  5411. * Instantiates an elastic easing function
  5412. * @see https://easings.net/#easeInElastic
  5413. * @param oscillations Defines the number of oscillations
  5414. * @param springiness Defines the amplitude of the oscillations
  5415. */
  5416. constructor(
  5417. /** Defines the number of oscillations*/
  5418. oscillations?: number,
  5419. /** Defines the amplitude of the oscillations*/
  5420. springiness?: number);
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with an exponential shape (see link below).
  5426. * @see https://easings.net/#easeInExpo
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the exponent of the function */
  5431. exponent: number;
  5432. /**
  5433. * Instantiates an exponential easing function
  5434. * @see https://easings.net/#easeInExpo
  5435. * @param exponent Defines the exponent of the function
  5436. */
  5437. constructor(
  5438. /** Defines the exponent of the function */
  5439. exponent?: number);
  5440. /** @hidden */
  5441. easeInCore(gradient: number): number;
  5442. }
  5443. /**
  5444. * Easing function with a power shape (see link below).
  5445. * @see https://easings.net/#easeInQuad
  5446. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5447. */
  5448. export class PowerEase extends EasingFunction implements IEasingFunction {
  5449. /** Defines the power of the function */
  5450. power: number;
  5451. /**
  5452. * Instantiates an power base easing function
  5453. * @see https://easings.net/#easeInQuad
  5454. * @param power Defines the power of the function
  5455. */
  5456. constructor(
  5457. /** Defines the power of the function */
  5458. power?: number);
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 2 shape (see link below).
  5464. * @see https://easings.net/#easeInQuad
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a power of 4 shape (see link below).
  5473. * @see https://easings.net/#easeInQuart
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a power of 5 shape (see link below).
  5482. * @see https://easings.net/#easeInQuint
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5486. /** @hidden */
  5487. easeInCore(gradient: number): number;
  5488. }
  5489. /**
  5490. * Easing function with a sin shape (see link below).
  5491. * @see https://easings.net/#easeInSine
  5492. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5493. */
  5494. export class SineEase extends EasingFunction implements IEasingFunction {
  5495. /** @hidden */
  5496. easeInCore(gradient: number): number;
  5497. }
  5498. /**
  5499. * Easing function with a bezier shape (see link below).
  5500. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5501. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5502. */
  5503. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5504. /** Defines the x component of the start tangent in the bezier curve */
  5505. x1: number;
  5506. /** Defines the y component of the start tangent in the bezier curve */
  5507. y1: number;
  5508. /** Defines the x component of the end tangent in the bezier curve */
  5509. x2: number;
  5510. /** Defines the y component of the end tangent in the bezier curve */
  5511. y2: number;
  5512. /**
  5513. * Instantiates a bezier function
  5514. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5515. * @param x1 Defines the x component of the start tangent in the bezier curve
  5516. * @param y1 Defines the y component of the start tangent in the bezier curve
  5517. * @param x2 Defines the x component of the end tangent in the bezier curve
  5518. * @param y2 Defines the y component of the end tangent in the bezier curve
  5519. */
  5520. constructor(
  5521. /** Defines the x component of the start tangent in the bezier curve */
  5522. x1?: number,
  5523. /** Defines the y component of the start tangent in the bezier curve */
  5524. y1?: number,
  5525. /** Defines the x component of the end tangent in the bezier curve */
  5526. x2?: number,
  5527. /** Defines the y component of the end tangent in the bezier curve */
  5528. y2?: number);
  5529. /** @hidden */
  5530. easeInCore(gradient: number): number;
  5531. }
  5532. }
  5533. declare module "babylonjs/Maths/math.color" {
  5534. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5535. /**
  5536. * Class used to hold a RBG color
  5537. */
  5538. export class Color3 {
  5539. /**
  5540. * Defines the red component (between 0 and 1, default is 0)
  5541. */
  5542. r: number;
  5543. /**
  5544. * Defines the green component (between 0 and 1, default is 0)
  5545. */
  5546. g: number;
  5547. /**
  5548. * Defines the blue component (between 0 and 1, default is 0)
  5549. */
  5550. b: number;
  5551. /**
  5552. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5553. * @param r defines the red component (between 0 and 1, default is 0)
  5554. * @param g defines the green component (between 0 and 1, default is 0)
  5555. * @param b defines the blue component (between 0 and 1, default is 0)
  5556. */
  5557. constructor(
  5558. /**
  5559. * Defines the red component (between 0 and 1, default is 0)
  5560. */
  5561. r?: number,
  5562. /**
  5563. * Defines the green component (between 0 and 1, default is 0)
  5564. */
  5565. g?: number,
  5566. /**
  5567. * Defines the blue component (between 0 and 1, default is 0)
  5568. */
  5569. b?: number);
  5570. /**
  5571. * Creates a string with the Color3 current values
  5572. * @returns the string representation of the Color3 object
  5573. */
  5574. toString(): string;
  5575. /**
  5576. * Returns the string "Color3"
  5577. * @returns "Color3"
  5578. */
  5579. getClassName(): string;
  5580. /**
  5581. * Compute the Color3 hash code
  5582. * @returns an unique number that can be used to hash Color3 objects
  5583. */
  5584. getHashCode(): number;
  5585. /**
  5586. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5587. * @param array defines the array where to store the r,g,b components
  5588. * @param index defines an optional index in the target array to define where to start storing values
  5589. * @returns the current Color3 object
  5590. */
  5591. toArray(array: FloatArray, index?: number): Color3;
  5592. /**
  5593. * Update the current color with values stored in an array from the starting index of the given array
  5594. * @param array defines the source array
  5595. * @param offset defines an offset in the source array
  5596. * @returns the current Color3 object
  5597. */
  5598. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5599. /**
  5600. * Returns a new Color4 object from the current Color3 and the given alpha
  5601. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5602. * @returns a new Color4 object
  5603. */
  5604. toColor4(alpha?: number): Color4;
  5605. /**
  5606. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5607. * @returns the new array
  5608. */
  5609. asArray(): number[];
  5610. /**
  5611. * Returns the luminance value
  5612. * @returns a float value
  5613. */
  5614. toLuminance(): number;
  5615. /**
  5616. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5617. * @param otherColor defines the second operand
  5618. * @returns the new Color3 object
  5619. */
  5620. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5621. /**
  5622. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5623. * @param otherColor defines the second operand
  5624. * @param result defines the Color3 object where to store the result
  5625. * @returns the current Color3
  5626. */
  5627. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5628. /**
  5629. * Determines equality between Color3 objects
  5630. * @param otherColor defines the second operand
  5631. * @returns true if the rgb values are equal to the given ones
  5632. */
  5633. equals(otherColor: DeepImmutable<Color3>): boolean;
  5634. /**
  5635. * Determines equality between the current Color3 object and a set of r,b,g values
  5636. * @param r defines the red component to check
  5637. * @param g defines the green component to check
  5638. * @param b defines the blue component to check
  5639. * @returns true if the rgb values are equal to the given ones
  5640. */
  5641. equalsFloats(r: number, g: number, b: number): boolean;
  5642. /**
  5643. * Multiplies in place each rgb value by scale
  5644. * @param scale defines the scaling factor
  5645. * @returns the updated Color3
  5646. */
  5647. scale(scale: number): Color3;
  5648. /**
  5649. * Multiplies the rgb values by scale and stores the result into "result"
  5650. * @param scale defines the scaling factor
  5651. * @param result defines the Color3 object where to store the result
  5652. * @returns the unmodified current Color3
  5653. */
  5654. scaleToRef(scale: number, result: Color3): Color3;
  5655. /**
  5656. * Scale the current Color3 values by a factor and add the result to a given Color3
  5657. * @param scale defines the scale factor
  5658. * @param result defines color to store the result into
  5659. * @returns the unmodified current Color3
  5660. */
  5661. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5662. /**
  5663. * Clamps the rgb values by the min and max values and stores the result into "result"
  5664. * @param min defines minimum clamping value (default is 0)
  5665. * @param max defines maximum clamping value (default is 1)
  5666. * @param result defines color to store the result into
  5667. * @returns the original Color3
  5668. */
  5669. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5670. /**
  5671. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5672. * @param otherColor defines the second operand
  5673. * @returns the new Color3
  5674. */
  5675. add(otherColor: DeepImmutable<Color3>): Color3;
  5676. /**
  5677. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5678. * @param otherColor defines the second operand
  5679. * @param result defines Color3 object to store the result into
  5680. * @returns the unmodified current Color3
  5681. */
  5682. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5683. /**
  5684. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5685. * @param otherColor defines the second operand
  5686. * @returns the new Color3
  5687. */
  5688. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5691. * @param otherColor defines the second operand
  5692. * @param result defines Color3 object to store the result into
  5693. * @returns the unmodified current Color3
  5694. */
  5695. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5696. /**
  5697. * Copy the current object
  5698. * @returns a new Color3 copied the current one
  5699. */
  5700. clone(): Color3;
  5701. /**
  5702. * Copies the rgb values from the source in the current Color3
  5703. * @param source defines the source Color3 object
  5704. * @returns the updated Color3 object
  5705. */
  5706. copyFrom(source: DeepImmutable<Color3>): Color3;
  5707. /**
  5708. * Updates the Color3 rgb values from the given floats
  5709. * @param r defines the red component to read from
  5710. * @param g defines the green component to read from
  5711. * @param b defines the blue component to read from
  5712. * @returns the current Color3 object
  5713. */
  5714. copyFromFloats(r: number, g: number, b: number): Color3;
  5715. /**
  5716. * Updates the Color3 rgb values from the given floats
  5717. * @param r defines the red component to read from
  5718. * @param g defines the green component to read from
  5719. * @param b defines the blue component to read from
  5720. * @returns the current Color3 object
  5721. */
  5722. set(r: number, g: number, b: number): Color3;
  5723. /**
  5724. * Compute the Color3 hexadecimal code as a string
  5725. * @returns a string containing the hexadecimal representation of the Color3 object
  5726. */
  5727. toHexString(): string;
  5728. /**
  5729. * Computes a new Color3 converted from the current one to linear space
  5730. * @returns a new Color3 object
  5731. */
  5732. toLinearSpace(): Color3;
  5733. /**
  5734. * Converts current color in rgb space to HSV values
  5735. * @returns a new color3 representing the HSV values
  5736. */
  5737. toHSV(): Color3;
  5738. /**
  5739. * Converts current color in rgb space to HSV values
  5740. * @param result defines the Color3 where to store the HSV values
  5741. */
  5742. toHSVToRef(result: Color3): void;
  5743. /**
  5744. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5745. * @param convertedColor defines the Color3 object where to store the linear space version
  5746. * @returns the unmodified Color3
  5747. */
  5748. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5749. /**
  5750. * Computes a new Color3 converted from the current one to gamma space
  5751. * @returns a new Color3 object
  5752. */
  5753. toGammaSpace(): Color3;
  5754. /**
  5755. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5756. * @param convertedColor defines the Color3 object where to store the gamma space version
  5757. * @returns the unmodified Color3
  5758. */
  5759. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5760. private static _BlackReadOnly;
  5761. /**
  5762. * Convert Hue, saturation and value to a Color3 (RGB)
  5763. * @param hue defines the hue
  5764. * @param saturation defines the saturation
  5765. * @param value defines the value
  5766. * @param result defines the Color3 where to store the RGB values
  5767. */
  5768. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5769. /**
  5770. * Creates a new Color3 from the string containing valid hexadecimal values
  5771. * @param hex defines a string containing valid hexadecimal values
  5772. * @returns a new Color3 object
  5773. */
  5774. static FromHexString(hex: string): Color3;
  5775. /**
  5776. * Creates a new Color3 from the starting index of the given array
  5777. * @param array defines the source array
  5778. * @param offset defines an offset in the source array
  5779. * @returns a new Color3 object
  5780. */
  5781. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5782. /**
  5783. * Creates a new Color3 from the starting index element of the given array
  5784. * @param array defines the source array to read from
  5785. * @param offset defines the offset in the source array
  5786. * @param result defines the target Color3 object
  5787. */
  5788. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5789. /**
  5790. * Creates a new Color3 from integer values (< 256)
  5791. * @param r defines the red component to read from (value between 0 and 255)
  5792. * @param g defines the green component to read from (value between 0 and 255)
  5793. * @param b defines the blue component to read from (value between 0 and 255)
  5794. * @returns a new Color3 object
  5795. */
  5796. static FromInts(r: number, g: number, b: number): Color3;
  5797. /**
  5798. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5799. * @param start defines the start Color3 value
  5800. * @param end defines the end Color3 value
  5801. * @param amount defines the gradient value between start and end
  5802. * @returns a new Color3 object
  5803. */
  5804. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5805. /**
  5806. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5807. * @param left defines the start value
  5808. * @param right defines the end value
  5809. * @param amount defines the gradient factor
  5810. * @param result defines the Color3 object where to store the result
  5811. */
  5812. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5813. /**
  5814. * Returns a Color3 value containing a red color
  5815. * @returns a new Color3 object
  5816. */
  5817. static Red(): Color3;
  5818. /**
  5819. * Returns a Color3 value containing a green color
  5820. * @returns a new Color3 object
  5821. */
  5822. static Green(): Color3;
  5823. /**
  5824. * Returns a Color3 value containing a blue color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Blue(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a black color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Black(): Color3;
  5833. /**
  5834. * Gets a Color3 value containing a black color that must not be updated
  5835. */
  5836. static get BlackReadOnly(): DeepImmutable<Color3>;
  5837. /**
  5838. * Returns a Color3 value containing a white color
  5839. * @returns a new Color3 object
  5840. */
  5841. static White(): Color3;
  5842. /**
  5843. * Returns a Color3 value containing a purple color
  5844. * @returns a new Color3 object
  5845. */
  5846. static Purple(): Color3;
  5847. /**
  5848. * Returns a Color3 value containing a magenta color
  5849. * @returns a new Color3 object
  5850. */
  5851. static Magenta(): Color3;
  5852. /**
  5853. * Returns a Color3 value containing a yellow color
  5854. * @returns a new Color3 object
  5855. */
  5856. static Yellow(): Color3;
  5857. /**
  5858. * Returns a Color3 value containing a gray color
  5859. * @returns a new Color3 object
  5860. */
  5861. static Gray(): Color3;
  5862. /**
  5863. * Returns a Color3 value containing a teal color
  5864. * @returns a new Color3 object
  5865. */
  5866. static Teal(): Color3;
  5867. /**
  5868. * Returns a Color3 value containing a random color
  5869. * @returns a new Color3 object
  5870. */
  5871. static Random(): Color3;
  5872. }
  5873. /**
  5874. * Class used to hold a RBGA color
  5875. */
  5876. export class Color4 {
  5877. /**
  5878. * Defines the red component (between 0 and 1, default is 0)
  5879. */
  5880. r: number;
  5881. /**
  5882. * Defines the green component (between 0 and 1, default is 0)
  5883. */
  5884. g: number;
  5885. /**
  5886. * Defines the blue component (between 0 and 1, default is 0)
  5887. */
  5888. b: number;
  5889. /**
  5890. * Defines the alpha component (between 0 and 1, default is 1)
  5891. */
  5892. a: number;
  5893. /**
  5894. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5895. * @param r defines the red component (between 0 and 1, default is 0)
  5896. * @param g defines the green component (between 0 and 1, default is 0)
  5897. * @param b defines the blue component (between 0 and 1, default is 0)
  5898. * @param a defines the alpha component (between 0 and 1, default is 1)
  5899. */
  5900. constructor(
  5901. /**
  5902. * Defines the red component (between 0 and 1, default is 0)
  5903. */
  5904. r?: number,
  5905. /**
  5906. * Defines the green component (between 0 and 1, default is 0)
  5907. */
  5908. g?: number,
  5909. /**
  5910. * Defines the blue component (between 0 and 1, default is 0)
  5911. */
  5912. b?: number,
  5913. /**
  5914. * Defines the alpha component (between 0 and 1, default is 1)
  5915. */
  5916. a?: number);
  5917. /**
  5918. * Adds in place the given Color4 values to the current Color4 object
  5919. * @param right defines the second operand
  5920. * @returns the current updated Color4 object
  5921. */
  5922. addInPlace(right: DeepImmutable<Color4>): Color4;
  5923. /**
  5924. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5925. * @returns the new array
  5926. */
  5927. asArray(): number[];
  5928. /**
  5929. * Stores from the starting index in the given array the Color4 successive values
  5930. * @param array defines the array where to store the r,g,b components
  5931. * @param index defines an optional index in the target array to define where to start storing values
  5932. * @returns the current Color4 object
  5933. */
  5934. toArray(array: number[], index?: number): Color4;
  5935. /**
  5936. * Update the current color with values stored in an array from the starting index of the given array
  5937. * @param array defines the source array
  5938. * @param offset defines an offset in the source array
  5939. * @returns the current Color4 object
  5940. */
  5941. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5942. /**
  5943. * Determines equality between Color4 objects
  5944. * @param otherColor defines the second operand
  5945. * @returns true if the rgba values are equal to the given ones
  5946. */
  5947. equals(otherColor: DeepImmutable<Color4>): boolean;
  5948. /**
  5949. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5950. * @param right defines the second operand
  5951. * @returns a new Color4 object
  5952. */
  5953. add(right: DeepImmutable<Color4>): Color4;
  5954. /**
  5955. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5956. * @param right defines the second operand
  5957. * @returns a new Color4 object
  5958. */
  5959. subtract(right: DeepImmutable<Color4>): Color4;
  5960. /**
  5961. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5962. * @param right defines the second operand
  5963. * @param result defines the Color4 object where to store the result
  5964. * @returns the current Color4 object
  5965. */
  5966. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5967. /**
  5968. * Creates a new Color4 with the current Color4 values multiplied by scale
  5969. * @param scale defines the scaling factor to apply
  5970. * @returns a new Color4 object
  5971. */
  5972. scale(scale: number): Color4;
  5973. /**
  5974. * Multiplies the current Color4 values by scale and stores the result in "result"
  5975. * @param scale defines the scaling factor to apply
  5976. * @param result defines the Color4 object where to store the result
  5977. * @returns the current unmodified Color4
  5978. */
  5979. scaleToRef(scale: number, result: Color4): Color4;
  5980. /**
  5981. * Scale the current Color4 values by a factor and add the result to a given Color4
  5982. * @param scale defines the scale factor
  5983. * @param result defines the Color4 object where to store the result
  5984. * @returns the unmodified current Color4
  5985. */
  5986. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5987. /**
  5988. * Clamps the rgb values by the min and max values and stores the result into "result"
  5989. * @param min defines minimum clamping value (default is 0)
  5990. * @param max defines maximum clamping value (default is 1)
  5991. * @param result defines color to store the result into.
  5992. * @returns the cuurent Color4
  5993. */
  5994. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5995. /**
  5996. * Multipy an Color4 value by another and return a new Color4 object
  5997. * @param color defines the Color4 value to multiply by
  5998. * @returns a new Color4 object
  5999. */
  6000. multiply(color: Color4): Color4;
  6001. /**
  6002. * Multipy a Color4 value by another and push the result in a reference value
  6003. * @param color defines the Color4 value to multiply by
  6004. * @param result defines the Color4 to fill the result in
  6005. * @returns the result Color4
  6006. */
  6007. multiplyToRef(color: Color4, result: Color4): Color4;
  6008. /**
  6009. * Creates a string with the Color4 current values
  6010. * @returns the string representation of the Color4 object
  6011. */
  6012. toString(): string;
  6013. /**
  6014. * Returns the string "Color4"
  6015. * @returns "Color4"
  6016. */
  6017. getClassName(): string;
  6018. /**
  6019. * Compute the Color4 hash code
  6020. * @returns an unique number that can be used to hash Color4 objects
  6021. */
  6022. getHashCode(): number;
  6023. /**
  6024. * Creates a new Color4 copied from the current one
  6025. * @returns a new Color4 object
  6026. */
  6027. clone(): Color4;
  6028. /**
  6029. * Copies the given Color4 values into the current one
  6030. * @param source defines the source Color4 object
  6031. * @returns the current updated Color4 object
  6032. */
  6033. copyFrom(source: Color4): Color4;
  6034. /**
  6035. * Copies the given float values into the current one
  6036. * @param r defines the red component to read from
  6037. * @param g defines the green component to read from
  6038. * @param b defines the blue component to read from
  6039. * @param a defines the alpha component to read from
  6040. * @returns the current updated Color4 object
  6041. */
  6042. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6043. /**
  6044. * Copies the given float values into the current one
  6045. * @param r defines the red component to read from
  6046. * @param g defines the green component to read from
  6047. * @param b defines the blue component to read from
  6048. * @param a defines the alpha component to read from
  6049. * @returns the current updated Color4 object
  6050. */
  6051. set(r: number, g: number, b: number, a: number): Color4;
  6052. /**
  6053. * Compute the Color4 hexadecimal code as a string
  6054. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6055. * @returns a string containing the hexadecimal representation of the Color4 object
  6056. */
  6057. toHexString(returnAsColor3?: boolean): string;
  6058. /**
  6059. * Computes a new Color4 converted from the current one to linear space
  6060. * @returns a new Color4 object
  6061. */
  6062. toLinearSpace(): Color4;
  6063. /**
  6064. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6065. * @param convertedColor defines the Color4 object where to store the linear space version
  6066. * @returns the unmodified Color4
  6067. */
  6068. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6069. /**
  6070. * Computes a new Color4 converted from the current one to gamma space
  6071. * @returns a new Color4 object
  6072. */
  6073. toGammaSpace(): Color4;
  6074. /**
  6075. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6076. * @param convertedColor defines the Color4 object where to store the gamma space version
  6077. * @returns the unmodified Color4
  6078. */
  6079. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6080. /**
  6081. * Creates a new Color4 from the string containing valid hexadecimal values
  6082. * @param hex defines a string containing valid hexadecimal values
  6083. * @returns a new Color4 object
  6084. */
  6085. static FromHexString(hex: string): Color4;
  6086. /**
  6087. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6088. * @param left defines the start value
  6089. * @param right defines the end value
  6090. * @param amount defines the gradient factor
  6091. * @returns a new Color4 object
  6092. */
  6093. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6094. /**
  6095. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6096. * @param left defines the start value
  6097. * @param right defines the end value
  6098. * @param amount defines the gradient factor
  6099. * @param result defines the Color4 object where to store data
  6100. */
  6101. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6102. /**
  6103. * Creates a new Color4 from a Color3 and an alpha value
  6104. * @param color3 defines the source Color3 to read from
  6105. * @param alpha defines the alpha component (1.0 by default)
  6106. * @returns a new Color4 object
  6107. */
  6108. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6109. /**
  6110. * Creates a new Color4 from the starting index element of the given array
  6111. * @param array defines the source array to read from
  6112. * @param offset defines the offset in the source array
  6113. * @returns a new Color4 object
  6114. */
  6115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6116. /**
  6117. * Creates a new Color4 from the starting index element of the given array
  6118. * @param array defines the source array to read from
  6119. * @param offset defines the offset in the source array
  6120. * @param result defines the target Color4 object
  6121. */
  6122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6123. /**
  6124. * Creates a new Color3 from integer values (< 256)
  6125. * @param r defines the red component to read from (value between 0 and 255)
  6126. * @param g defines the green component to read from (value between 0 and 255)
  6127. * @param b defines the blue component to read from (value between 0 and 255)
  6128. * @param a defines the alpha component to read from (value between 0 and 255)
  6129. * @returns a new Color3 object
  6130. */
  6131. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6132. /**
  6133. * Check the content of a given array and convert it to an array containing RGBA data
  6134. * If the original array was already containing count * 4 values then it is returned directly
  6135. * @param colors defines the array to check
  6136. * @param count defines the number of RGBA data to expect
  6137. * @returns an array containing count * 4 values (RGBA)
  6138. */
  6139. static CheckColors4(colors: number[], count: number): number[];
  6140. }
  6141. /**
  6142. * @hidden
  6143. */
  6144. export class TmpColors {
  6145. static Color3: Color3[];
  6146. static Color4: Color4[];
  6147. }
  6148. }
  6149. declare module "babylonjs/Animations/animationKey" {
  6150. /**
  6151. * Defines an interface which represents an animation key frame
  6152. */
  6153. export interface IAnimationKey {
  6154. /**
  6155. * Frame of the key frame
  6156. */
  6157. frame: number;
  6158. /**
  6159. * Value at the specifies key frame
  6160. */
  6161. value: any;
  6162. /**
  6163. * The input tangent for the cubic hermite spline
  6164. */
  6165. inTangent?: any;
  6166. /**
  6167. * The output tangent for the cubic hermite spline
  6168. */
  6169. outTangent?: any;
  6170. /**
  6171. * The animation interpolation type
  6172. */
  6173. interpolation?: AnimationKeyInterpolation;
  6174. }
  6175. /**
  6176. * Enum for the animation key frame interpolation type
  6177. */
  6178. export enum AnimationKeyInterpolation {
  6179. /**
  6180. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6181. */
  6182. STEP = 1
  6183. }
  6184. }
  6185. declare module "babylonjs/Animations/animationRange" {
  6186. /**
  6187. * Represents the range of an animation
  6188. */
  6189. export class AnimationRange {
  6190. /**The name of the animation range**/
  6191. name: string;
  6192. /**The starting frame of the animation */
  6193. from: number;
  6194. /**The ending frame of the animation*/
  6195. to: number;
  6196. /**
  6197. * Initializes the range of an animation
  6198. * @param name The name of the animation range
  6199. * @param from The starting frame of the animation
  6200. * @param to The ending frame of the animation
  6201. */
  6202. constructor(
  6203. /**The name of the animation range**/
  6204. name: string,
  6205. /**The starting frame of the animation */
  6206. from: number,
  6207. /**The ending frame of the animation*/
  6208. to: number);
  6209. /**
  6210. * Makes a copy of the animation range
  6211. * @returns A copy of the animation range
  6212. */
  6213. clone(): AnimationRange;
  6214. }
  6215. }
  6216. declare module "babylonjs/Animations/animationEvent" {
  6217. /**
  6218. * Composed of a frame, and an action function
  6219. */
  6220. export class AnimationEvent {
  6221. /** The frame for which the event is triggered **/
  6222. frame: number;
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void;
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined;
  6227. /**
  6228. * Specifies if the animation event is done
  6229. */
  6230. isDone: boolean;
  6231. /**
  6232. * Initializes the animation event
  6233. * @param frame The frame for which the event is triggered
  6234. * @param action The event to perform when triggered
  6235. * @param onlyOnce Specifies if the event should be triggered only once
  6236. */
  6237. constructor(
  6238. /** The frame for which the event is triggered **/
  6239. frame: number,
  6240. /** The event to perform when triggered **/
  6241. action: (currentFrame: number) => void,
  6242. /** Specifies if the event should be triggered only once**/
  6243. onlyOnce?: boolean | undefined);
  6244. /** @hidden */
  6245. _clone(): AnimationEvent;
  6246. }
  6247. }
  6248. declare module "babylonjs/Behaviors/behavior" {
  6249. import { Nullable } from "babylonjs/types";
  6250. /**
  6251. * Interface used to define a behavior
  6252. */
  6253. export interface Behavior<T> {
  6254. /** gets or sets behavior's name */
  6255. name: string;
  6256. /**
  6257. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6258. */
  6259. init(): void;
  6260. /**
  6261. * Called when the behavior is attached to a target
  6262. * @param target defines the target where the behavior is attached to
  6263. */
  6264. attach(target: T): void;
  6265. /**
  6266. * Called when the behavior is detached from its target
  6267. */
  6268. detach(): void;
  6269. }
  6270. /**
  6271. * Interface implemented by classes supporting behaviors
  6272. */
  6273. export interface IBehaviorAware<T> {
  6274. /**
  6275. * Attach a behavior
  6276. * @param behavior defines the behavior to attach
  6277. * @returns the current host
  6278. */
  6279. addBehavior(behavior: Behavior<T>): T;
  6280. /**
  6281. * Remove a behavior from the current object
  6282. * @param behavior defines the behavior to detach
  6283. * @returns the current host
  6284. */
  6285. removeBehavior(behavior: Behavior<T>): T;
  6286. /**
  6287. * Gets a behavior using its name to search
  6288. * @param name defines the name to search
  6289. * @returns the behavior or null if not found
  6290. */
  6291. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6292. }
  6293. }
  6294. declare module "babylonjs/Misc/smartArray" {
  6295. /**
  6296. * Defines an array and its length.
  6297. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6298. */
  6299. export interface ISmartArrayLike<T> {
  6300. /**
  6301. * The data of the array.
  6302. */
  6303. data: Array<T>;
  6304. /**
  6305. * The active length of the array.
  6306. */
  6307. length: number;
  6308. }
  6309. /**
  6310. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6311. */
  6312. export class SmartArray<T> implements ISmartArrayLike<T> {
  6313. /**
  6314. * The full set of data from the array.
  6315. */
  6316. data: Array<T>;
  6317. /**
  6318. * The active length of the array.
  6319. */
  6320. length: number;
  6321. protected _id: number;
  6322. /**
  6323. * Instantiates a Smart Array.
  6324. * @param capacity defines the default capacity of the array.
  6325. */
  6326. constructor(capacity: number);
  6327. /**
  6328. * Pushes a value at the end of the active data.
  6329. * @param value defines the object to push in the array.
  6330. */
  6331. push(value: T): void;
  6332. /**
  6333. * Iterates over the active data and apply the lambda to them.
  6334. * @param func defines the action to apply on each value.
  6335. */
  6336. forEach(func: (content: T) => void): void;
  6337. /**
  6338. * Sorts the full sets of data.
  6339. * @param compareFn defines the comparison function to apply.
  6340. */
  6341. sort(compareFn: (a: T, b: T) => number): void;
  6342. /**
  6343. * Resets the active data to an empty array.
  6344. */
  6345. reset(): void;
  6346. /**
  6347. * Releases all the data from the array as well as the array.
  6348. */
  6349. dispose(): void;
  6350. /**
  6351. * Concats the active data with a given array.
  6352. * @param array defines the data to concatenate with.
  6353. */
  6354. concat(array: any): void;
  6355. /**
  6356. * Returns the position of a value in the active data.
  6357. * @param value defines the value to find the index for
  6358. * @returns the index if found in the active data otherwise -1
  6359. */
  6360. indexOf(value: T): number;
  6361. /**
  6362. * Returns whether an element is part of the active data.
  6363. * @param value defines the value to look for
  6364. * @returns true if found in the active data otherwise false
  6365. */
  6366. contains(value: T): boolean;
  6367. private static _GlobalId;
  6368. }
  6369. /**
  6370. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6371. * The data in this array can only be present once
  6372. */
  6373. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6374. private _duplicateId;
  6375. /**
  6376. * Pushes a value at the end of the active data.
  6377. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6378. * @param value defines the object to push in the array.
  6379. */
  6380. push(value: T): void;
  6381. /**
  6382. * Pushes a value at the end of the active data.
  6383. * If the data is already present, it won t be added again
  6384. * @param value defines the object to push in the array.
  6385. * @returns true if added false if it was already present
  6386. */
  6387. pushNoDuplicate(value: T): boolean;
  6388. /**
  6389. * Resets the active data to an empty array.
  6390. */
  6391. reset(): void;
  6392. /**
  6393. * Concats the active data with a given array.
  6394. * This ensures no dupplicate will be present in the result.
  6395. * @param array defines the data to concatenate with.
  6396. */
  6397. concatWithNoDuplicate(array: any): void;
  6398. }
  6399. }
  6400. declare module "babylonjs/Cameras/cameraInputsManager" {
  6401. import { Nullable } from "babylonjs/types";
  6402. import { Camera } from "babylonjs/Cameras/camera";
  6403. /**
  6404. * @ignore
  6405. * This is a list of all the different input types that are available in the application.
  6406. * Fo instance: ArcRotateCameraGamepadInput...
  6407. */
  6408. export var CameraInputTypes: {};
  6409. /**
  6410. * This is the contract to implement in order to create a new input class.
  6411. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6412. */
  6413. export interface ICameraInput<TCamera extends Camera> {
  6414. /**
  6415. * Defines the camera the input is attached to.
  6416. */
  6417. camera: Nullable<TCamera>;
  6418. /**
  6419. * Gets the class name of the current intput.
  6420. * @returns the class name
  6421. */
  6422. getClassName(): string;
  6423. /**
  6424. * Get the friendly name associated with the input class.
  6425. * @returns the input friendly name
  6426. */
  6427. getSimpleName(): string;
  6428. /**
  6429. * Attach the input controls to a specific dom element to get the input from.
  6430. * @param element Defines the element the controls should be listened from
  6431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6432. */
  6433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6434. /**
  6435. * Detach the current controls from the specified dom element.
  6436. * @param element Defines the element to stop listening the inputs from
  6437. */
  6438. detachControl(element: Nullable<HTMLElement>): void;
  6439. /**
  6440. * Update the current camera state depending on the inputs that have been used this frame.
  6441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6442. */
  6443. checkInputs?: () => void;
  6444. }
  6445. /**
  6446. * Represents a map of input types to input instance or input index to input instance.
  6447. */
  6448. export interface CameraInputsMap<TCamera extends Camera> {
  6449. /**
  6450. * Accessor to the input by input type.
  6451. */
  6452. [name: string]: ICameraInput<TCamera>;
  6453. /**
  6454. * Accessor to the input by input index.
  6455. */
  6456. [idx: number]: ICameraInput<TCamera>;
  6457. }
  6458. /**
  6459. * This represents the input manager used within a camera.
  6460. * It helps dealing with all the different kind of input attached to a camera.
  6461. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6462. */
  6463. export class CameraInputsManager<TCamera extends Camera> {
  6464. /**
  6465. * Defines the list of inputs attahed to the camera.
  6466. */
  6467. attached: CameraInputsMap<TCamera>;
  6468. /**
  6469. * Defines the dom element the camera is collecting inputs from.
  6470. * This is null if the controls have not been attached.
  6471. */
  6472. attachedElement: Nullable<HTMLElement>;
  6473. /**
  6474. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6475. */
  6476. noPreventDefault: boolean;
  6477. /**
  6478. * Defined the camera the input manager belongs to.
  6479. */
  6480. camera: TCamera;
  6481. /**
  6482. * Update the current camera state depending on the inputs that have been used this frame.
  6483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6484. */
  6485. checkInputs: () => void;
  6486. /**
  6487. * Instantiate a new Camera Input Manager.
  6488. * @param camera Defines the camera the input manager blongs to
  6489. */
  6490. constructor(camera: TCamera);
  6491. /**
  6492. * Add an input method to a camera
  6493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6494. * @param input camera input method
  6495. */
  6496. add(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Remove a specific input method from a camera
  6499. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6500. * @param inputToRemove camera input method
  6501. */
  6502. remove(inputToRemove: ICameraInput<TCamera>): void;
  6503. /**
  6504. * Remove a specific input type from a camera
  6505. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6506. * @param inputType the type of the input to remove
  6507. */
  6508. removeByType(inputType: string): void;
  6509. private _addCheckInputs;
  6510. /**
  6511. * Attach the input controls to the currently attached dom element to listen the events from.
  6512. * @param input Defines the input to attach
  6513. */
  6514. attachInput(input: ICameraInput<TCamera>): void;
  6515. /**
  6516. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6517. * @param element Defines the dom element to collect the events from
  6518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6519. */
  6520. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6521. /**
  6522. * Detach the current manager inputs controls from a specific dom element.
  6523. * @param element Defines the dom element to collect the events from
  6524. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6525. */
  6526. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6527. /**
  6528. * Rebuild the dynamic inputCheck function from the current list of
  6529. * defined inputs in the manager.
  6530. */
  6531. rebuildInputCheck(): void;
  6532. /**
  6533. * Remove all attached input methods from a camera
  6534. */
  6535. clear(): void;
  6536. /**
  6537. * Serialize the current input manager attached to a camera.
  6538. * This ensures than once parsed,
  6539. * the input associated to the camera will be identical to the current ones
  6540. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6541. */
  6542. serialize(serializedCamera: any): void;
  6543. /**
  6544. * Parses an input manager serialized JSON to restore the previous list of inputs
  6545. * and states associated to a camera.
  6546. * @param parsedCamera Defines the JSON to parse
  6547. */
  6548. parse(parsedCamera: any): void;
  6549. }
  6550. }
  6551. declare module "babylonjs/Meshes/buffer" {
  6552. import { Nullable, DataArray } from "babylonjs/types";
  6553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6554. /**
  6555. * Class used to store data that will be store in GPU memory
  6556. */
  6557. export class Buffer {
  6558. private _engine;
  6559. private _buffer;
  6560. /** @hidden */
  6561. _data: Nullable<DataArray>;
  6562. private _updatable;
  6563. private _instanced;
  6564. private _divisor;
  6565. /**
  6566. * Gets the byte stride.
  6567. */
  6568. readonly byteStride: number;
  6569. /**
  6570. * Constructor
  6571. * @param engine the engine
  6572. * @param data the data to use for this buffer
  6573. * @param updatable whether the data is updatable
  6574. * @param stride the stride (optional)
  6575. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6576. * @param instanced whether the buffer is instanced (optional)
  6577. * @param useBytes set to true if the stride in in bytes (optional)
  6578. * @param divisor sets an optional divisor for instances (1 by default)
  6579. */
  6580. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6581. /**
  6582. * Create a new VertexBuffer based on the current buffer
  6583. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6584. * @param offset defines offset in the buffer (0 by default)
  6585. * @param size defines the size in floats of attributes (position is 3 for instance)
  6586. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6587. * @param instanced defines if the vertex buffer contains indexed data
  6588. * @param useBytes defines if the offset and stride are in bytes *
  6589. * @param divisor sets an optional divisor for instances (1 by default)
  6590. * @returns the new vertex buffer
  6591. */
  6592. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6593. /**
  6594. * Gets a boolean indicating if the Buffer is updatable?
  6595. * @returns true if the buffer is updatable
  6596. */
  6597. isUpdatable(): boolean;
  6598. /**
  6599. * Gets current buffer's data
  6600. * @returns a DataArray or null
  6601. */
  6602. getData(): Nullable<DataArray>;
  6603. /**
  6604. * Gets underlying native buffer
  6605. * @returns underlying native buffer
  6606. */
  6607. getBuffer(): Nullable<DataBuffer>;
  6608. /**
  6609. * Gets the stride in float32 units (i.e. byte stride / 4).
  6610. * May not be an integer if the byte stride is not divisible by 4.
  6611. * @returns the stride in float32 units
  6612. * @deprecated Please use byteStride instead.
  6613. */
  6614. getStrideSize(): number;
  6615. /**
  6616. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6617. * @param data defines the data to store
  6618. */
  6619. create(data?: Nullable<DataArray>): void;
  6620. /** @hidden */
  6621. _rebuild(): void;
  6622. /**
  6623. * Update current buffer data
  6624. * @param data defines the data to store
  6625. */
  6626. update(data: DataArray): void;
  6627. /**
  6628. * Updates the data directly.
  6629. * @param data the new data
  6630. * @param offset the new offset
  6631. * @param vertexCount the vertex count (optional)
  6632. * @param useBytes set to true if the offset is in bytes
  6633. */
  6634. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6635. /**
  6636. * Release all resources
  6637. */
  6638. dispose(): void;
  6639. }
  6640. /**
  6641. * Specialized buffer used to store vertex data
  6642. */
  6643. export class VertexBuffer {
  6644. /** @hidden */
  6645. _buffer: Buffer;
  6646. private _kind;
  6647. private _size;
  6648. private _ownsBuffer;
  6649. private _instanced;
  6650. private _instanceDivisor;
  6651. /**
  6652. * The byte type.
  6653. */
  6654. static readonly BYTE: number;
  6655. /**
  6656. * The unsigned byte type.
  6657. */
  6658. static readonly UNSIGNED_BYTE: number;
  6659. /**
  6660. * The short type.
  6661. */
  6662. static readonly SHORT: number;
  6663. /**
  6664. * The unsigned short type.
  6665. */
  6666. static readonly UNSIGNED_SHORT: number;
  6667. /**
  6668. * The integer type.
  6669. */
  6670. static readonly INT: number;
  6671. /**
  6672. * The unsigned integer type.
  6673. */
  6674. static readonly UNSIGNED_INT: number;
  6675. /**
  6676. * The float type.
  6677. */
  6678. static readonly FLOAT: number;
  6679. /**
  6680. * Gets or sets the instance divisor when in instanced mode
  6681. */
  6682. get instanceDivisor(): number;
  6683. set instanceDivisor(value: number);
  6684. /**
  6685. * Gets the byte stride.
  6686. */
  6687. readonly byteStride: number;
  6688. /**
  6689. * Gets the byte offset.
  6690. */
  6691. readonly byteOffset: number;
  6692. /**
  6693. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6694. */
  6695. readonly normalized: boolean;
  6696. /**
  6697. * Gets the data type of each component in the array.
  6698. */
  6699. readonly type: number;
  6700. /**
  6701. * Constructor
  6702. * @param engine the engine
  6703. * @param data the data to use for this vertex buffer
  6704. * @param kind the vertex buffer kind
  6705. * @param updatable whether the data is updatable
  6706. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6707. * @param stride the stride (optional)
  6708. * @param instanced whether the buffer is instanced (optional)
  6709. * @param offset the offset of the data (optional)
  6710. * @param size the number of components (optional)
  6711. * @param type the type of the component (optional)
  6712. * @param normalized whether the data contains normalized data (optional)
  6713. * @param useBytes set to true if stride and offset are in bytes (optional)
  6714. * @param divisor defines the instance divisor to use (1 by default)
  6715. */
  6716. 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);
  6717. /** @hidden */
  6718. _rebuild(): void;
  6719. /**
  6720. * Returns the kind of the VertexBuffer (string)
  6721. * @returns a string
  6722. */
  6723. getKind(): string;
  6724. /**
  6725. * Gets a boolean indicating if the VertexBuffer is updatable?
  6726. * @returns true if the buffer is updatable
  6727. */
  6728. isUpdatable(): boolean;
  6729. /**
  6730. * Gets current buffer's data
  6731. * @returns a DataArray or null
  6732. */
  6733. getData(): Nullable<DataArray>;
  6734. /**
  6735. * Gets underlying native buffer
  6736. * @returns underlying native buffer
  6737. */
  6738. getBuffer(): Nullable<DataBuffer>;
  6739. /**
  6740. * Gets the stride in float32 units (i.e. byte stride / 4).
  6741. * May not be an integer if the byte stride is not divisible by 4.
  6742. * @returns the stride in float32 units
  6743. * @deprecated Please use byteStride instead.
  6744. */
  6745. getStrideSize(): number;
  6746. /**
  6747. * Returns the offset as a multiple of the type byte length.
  6748. * @returns the offset in bytes
  6749. * @deprecated Please use byteOffset instead.
  6750. */
  6751. getOffset(): number;
  6752. /**
  6753. * Returns the number of components per vertex attribute (integer)
  6754. * @returns the size in float
  6755. */
  6756. getSize(): number;
  6757. /**
  6758. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6759. * @returns true if this buffer is instanced
  6760. */
  6761. getIsInstanced(): boolean;
  6762. /**
  6763. * Returns the instancing divisor, zero for non-instanced (integer).
  6764. * @returns a number
  6765. */
  6766. getInstanceDivisor(): number;
  6767. /**
  6768. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6769. * @param data defines the data to store
  6770. */
  6771. create(data?: DataArray): void;
  6772. /**
  6773. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6774. * This function will create a new buffer if the current one is not updatable
  6775. * @param data defines the data to store
  6776. */
  6777. update(data: DataArray): void;
  6778. /**
  6779. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6780. * Returns the directly updated WebGLBuffer.
  6781. * @param data the new data
  6782. * @param offset the new offset
  6783. * @param useBytes set to true if the offset is in bytes
  6784. */
  6785. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6786. /**
  6787. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6788. */
  6789. dispose(): void;
  6790. /**
  6791. * Enumerates each value of this vertex buffer as numbers.
  6792. * @param count the number of values to enumerate
  6793. * @param callback the callback function called for each value
  6794. */
  6795. forEach(count: number, callback: (value: number, index: number) => void): void;
  6796. /**
  6797. * Positions
  6798. */
  6799. static readonly PositionKind: string;
  6800. /**
  6801. * Normals
  6802. */
  6803. static readonly NormalKind: string;
  6804. /**
  6805. * Tangents
  6806. */
  6807. static readonly TangentKind: string;
  6808. /**
  6809. * Texture coordinates
  6810. */
  6811. static readonly UVKind: string;
  6812. /**
  6813. * Texture coordinates 2
  6814. */
  6815. static readonly UV2Kind: string;
  6816. /**
  6817. * Texture coordinates 3
  6818. */
  6819. static readonly UV3Kind: string;
  6820. /**
  6821. * Texture coordinates 4
  6822. */
  6823. static readonly UV4Kind: string;
  6824. /**
  6825. * Texture coordinates 5
  6826. */
  6827. static readonly UV5Kind: string;
  6828. /**
  6829. * Texture coordinates 6
  6830. */
  6831. static readonly UV6Kind: string;
  6832. /**
  6833. * Colors
  6834. */
  6835. static readonly ColorKind: string;
  6836. /**
  6837. * Matrix indices (for bones)
  6838. */
  6839. static readonly MatricesIndicesKind: string;
  6840. /**
  6841. * Matrix weights (for bones)
  6842. */
  6843. static readonly MatricesWeightsKind: string;
  6844. /**
  6845. * Additional matrix indices (for bones)
  6846. */
  6847. static readonly MatricesIndicesExtraKind: string;
  6848. /**
  6849. * Additional matrix weights (for bones)
  6850. */
  6851. static readonly MatricesWeightsExtraKind: string;
  6852. /**
  6853. * Deduces the stride given a kind.
  6854. * @param kind The kind string to deduce
  6855. * @returns The deduced stride
  6856. */
  6857. static DeduceStride(kind: string): number;
  6858. /**
  6859. * Gets the byte length of the given type.
  6860. * @param type the type
  6861. * @returns the number of bytes
  6862. */
  6863. static GetTypeByteLength(type: number): number;
  6864. /**
  6865. * Enumerates each value of the given parameters as numbers.
  6866. * @param data the data to enumerate
  6867. * @param byteOffset the byte offset of the data
  6868. * @param byteStride the byte stride of the data
  6869. * @param componentCount the number of components per element
  6870. * @param componentType the type of the component
  6871. * @param count the number of values to enumerate
  6872. * @param normalized whether the data is normalized
  6873. * @param callback the callback function called for each value
  6874. */
  6875. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6876. private static _GetFloatValue;
  6877. }
  6878. }
  6879. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6880. import { Vector3 } from "babylonjs/Maths/math.vector";
  6881. import { Mesh } from "babylonjs/Meshes/mesh";
  6882. /**
  6883. * The options Interface for creating a Capsule Mesh
  6884. */
  6885. export interface ICreateCapsuleOptions {
  6886. /** The Orientation of the capsule. Default : Vector3.Up() */
  6887. orientation?: Vector3;
  6888. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6889. subdivisions: number;
  6890. /** Number of cylindrical segments on the capsule. */
  6891. tessellation: number;
  6892. /** Height or Length of the capsule. */
  6893. height: number;
  6894. /** Radius of the capsule. */
  6895. radius: number;
  6896. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6897. capSubdivisions: number;
  6898. /** Overwrite for the top radius. */
  6899. radiusTop?: number;
  6900. /** Overwrite for the bottom radius. */
  6901. radiusBottom?: number;
  6902. /** Overwrite for the top capSubdivisions. */
  6903. topCapSubdivisions?: number;
  6904. /** Overwrite for the bottom capSubdivisions. */
  6905. bottomCapSubdivisions?: number;
  6906. }
  6907. /**
  6908. * Class containing static functions to help procedurally build meshes
  6909. */
  6910. export class CapsuleBuilder {
  6911. /**
  6912. * Creates a capsule or a pill mesh
  6913. * @param name defines the name of the mesh
  6914. * @param options The constructors options.
  6915. * @param scene The scene the mesh is scoped to.
  6916. * @returns Capsule Mesh
  6917. */
  6918. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6919. }
  6920. }
  6921. declare module "babylonjs/Collisions/intersectionInfo" {
  6922. import { Nullable } from "babylonjs/types";
  6923. /**
  6924. * @hidden
  6925. */
  6926. export class IntersectionInfo {
  6927. bu: Nullable<number>;
  6928. bv: Nullable<number>;
  6929. distance: number;
  6930. faceId: number;
  6931. subMeshId: number;
  6932. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6933. }
  6934. }
  6935. declare module "babylonjs/Culling/boundingSphere" {
  6936. import { DeepImmutable } from "babylonjs/types";
  6937. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6938. import { Plane } from "babylonjs/Maths/math.plane";
  6939. /**
  6940. * Class used to store bounding sphere information
  6941. */
  6942. export class BoundingSphere {
  6943. /**
  6944. * Gets the center of the bounding sphere in local space
  6945. */
  6946. readonly center: Vector3;
  6947. /**
  6948. * Radius of the bounding sphere in local space
  6949. */
  6950. radius: number;
  6951. /**
  6952. * Gets the center of the bounding sphere in world space
  6953. */
  6954. readonly centerWorld: Vector3;
  6955. /**
  6956. * Radius of the bounding sphere in world space
  6957. */
  6958. radiusWorld: number;
  6959. /**
  6960. * Gets the minimum vector in local space
  6961. */
  6962. readonly minimum: Vector3;
  6963. /**
  6964. * Gets the maximum vector in local space
  6965. */
  6966. readonly maximum: Vector3;
  6967. private _worldMatrix;
  6968. private static readonly TmpVector3;
  6969. /**
  6970. * Creates a new bounding sphere
  6971. * @param min defines the minimum vector (in local space)
  6972. * @param max defines the maximum vector (in local space)
  6973. * @param worldMatrix defines the new world matrix
  6974. */
  6975. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6976. /**
  6977. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6978. * @param min defines the new minimum vector (in local space)
  6979. * @param max defines the new maximum vector (in local space)
  6980. * @param worldMatrix defines the new world matrix
  6981. */
  6982. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6983. /**
  6984. * Scale the current bounding sphere by applying a scale factor
  6985. * @param factor defines the scale factor to apply
  6986. * @returns the current bounding box
  6987. */
  6988. scale(factor: number): BoundingSphere;
  6989. /**
  6990. * Gets the world matrix of the bounding box
  6991. * @returns a matrix
  6992. */
  6993. getWorldMatrix(): DeepImmutable<Matrix>;
  6994. /** @hidden */
  6995. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6996. /**
  6997. * Tests if the bounding sphere is intersecting the frustum planes
  6998. * @param frustumPlanes defines the frustum planes to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /**
  7003. * Tests if the bounding sphere center is in between the frustum planes.
  7004. * Used for optimistic fast inclusion.
  7005. * @param frustumPlanes defines the frustum planes to test
  7006. * @returns true if the sphere center is in between the frustum planes
  7007. */
  7008. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7009. /**
  7010. * Tests if a point is inside the bounding sphere
  7011. * @param point defines the point to test
  7012. * @returns true if the point is inside the bounding sphere
  7013. */
  7014. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7015. /**
  7016. * Checks if two sphere intersct
  7017. * @param sphere0 sphere 0
  7018. * @param sphere1 sphere 1
  7019. * @returns true if the speres intersect
  7020. */
  7021. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7022. }
  7023. }
  7024. declare module "babylonjs/Culling/boundingBox" {
  7025. import { DeepImmutable } from "babylonjs/types";
  7026. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7027. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7028. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7029. import { Plane } from "babylonjs/Maths/math.plane";
  7030. /**
  7031. * Class used to store bounding box information
  7032. */
  7033. export class BoundingBox implements ICullable {
  7034. /**
  7035. * Gets the 8 vectors representing the bounding box in local space
  7036. */
  7037. readonly vectors: Vector3[];
  7038. /**
  7039. * Gets the center of the bounding box in local space
  7040. */
  7041. readonly center: Vector3;
  7042. /**
  7043. * Gets the center of the bounding box in world space
  7044. */
  7045. readonly centerWorld: Vector3;
  7046. /**
  7047. * Gets the extend size in local space
  7048. */
  7049. readonly extendSize: Vector3;
  7050. /**
  7051. * Gets the extend size in world space
  7052. */
  7053. readonly extendSizeWorld: Vector3;
  7054. /**
  7055. * Gets the OBB (object bounding box) directions
  7056. */
  7057. readonly directions: Vector3[];
  7058. /**
  7059. * Gets the 8 vectors representing the bounding box in world space
  7060. */
  7061. readonly vectorsWorld: Vector3[];
  7062. /**
  7063. * Gets the minimum vector in world space
  7064. */
  7065. readonly minimumWorld: Vector3;
  7066. /**
  7067. * Gets the maximum vector in world space
  7068. */
  7069. readonly maximumWorld: Vector3;
  7070. /**
  7071. * Gets the minimum vector in local space
  7072. */
  7073. readonly minimum: Vector3;
  7074. /**
  7075. * Gets the maximum vector in local space
  7076. */
  7077. readonly maximum: Vector3;
  7078. private _worldMatrix;
  7079. private static readonly TmpVector3;
  7080. /**
  7081. * @hidden
  7082. */
  7083. _tag: number;
  7084. /**
  7085. * Creates a new bounding box
  7086. * @param min defines the minimum vector (in local space)
  7087. * @param max defines the maximum vector (in local space)
  7088. * @param worldMatrix defines the new world matrix
  7089. */
  7090. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7091. /**
  7092. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7093. * @param min defines the new minimum vector (in local space)
  7094. * @param max defines the new maximum vector (in local space)
  7095. * @param worldMatrix defines the new world matrix
  7096. */
  7097. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * Scale the current bounding box by applying a scale factor
  7100. * @param factor defines the scale factor to apply
  7101. * @returns the current bounding box
  7102. */
  7103. scale(factor: number): BoundingBox;
  7104. /**
  7105. * Gets the world matrix of the bounding box
  7106. * @returns a matrix
  7107. */
  7108. getWorldMatrix(): DeepImmutable<Matrix>;
  7109. /** @hidden */
  7110. _update(world: DeepImmutable<Matrix>): void;
  7111. /**
  7112. * Tests if the bounding box is intersecting the frustum planes
  7113. * @param frustumPlanes defines the frustum planes to test
  7114. * @returns true if there is an intersection
  7115. */
  7116. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7117. /**
  7118. * Tests if the bounding box is entirely inside the frustum planes
  7119. * @param frustumPlanes defines the frustum planes to test
  7120. * @returns true if there is an inclusion
  7121. */
  7122. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7123. /**
  7124. * Tests if a point is inside the bounding box
  7125. * @param point defines the point to test
  7126. * @returns true if the point is inside the bounding box
  7127. */
  7128. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7129. /**
  7130. * Tests if the bounding box intersects with a bounding sphere
  7131. * @param sphere defines the sphere to test
  7132. * @returns true if there is an intersection
  7133. */
  7134. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7135. /**
  7136. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7137. * @param min defines the min vector to use
  7138. * @param max defines the max vector to use
  7139. * @returns true if there is an intersection
  7140. */
  7141. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7142. /**
  7143. * Tests if two bounding boxes are intersections
  7144. * @param box0 defines the first box to test
  7145. * @param box1 defines the second box to test
  7146. * @returns true if there is an intersection
  7147. */
  7148. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7149. /**
  7150. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7151. * @param minPoint defines the minimum vector of the bounding box
  7152. * @param maxPoint defines the maximum vector of the bounding box
  7153. * @param sphereCenter defines the sphere center
  7154. * @param sphereRadius defines the sphere radius
  7155. * @returns true if there is an intersection
  7156. */
  7157. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7158. /**
  7159. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7160. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7161. * @param frustumPlanes defines the frustum planes to test
  7162. * @return true if there is an inclusion
  7163. */
  7164. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /**
  7166. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7167. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7168. * @param frustumPlanes defines the frustum planes to test
  7169. * @return true if there is an intersection
  7170. */
  7171. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7172. }
  7173. }
  7174. declare module "babylonjs/Collisions/collider" {
  7175. import { Nullable, IndicesArray } from "babylonjs/types";
  7176. import { Vector3 } from "babylonjs/Maths/math.vector";
  7177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7178. import { Plane } from "babylonjs/Maths/math.plane";
  7179. /** @hidden */
  7180. export class Collider {
  7181. /** Define if a collision was found */
  7182. collisionFound: boolean;
  7183. /**
  7184. * Define last intersection point in local space
  7185. */
  7186. intersectionPoint: Vector3;
  7187. /**
  7188. * Define last collided mesh
  7189. */
  7190. collidedMesh: Nullable<AbstractMesh>;
  7191. private _collisionPoint;
  7192. private _planeIntersectionPoint;
  7193. private _tempVector;
  7194. private _tempVector2;
  7195. private _tempVector3;
  7196. private _tempVector4;
  7197. private _edge;
  7198. private _baseToVertex;
  7199. private _destinationPoint;
  7200. private _slidePlaneNormal;
  7201. private _displacementVector;
  7202. /** @hidden */
  7203. _radius: Vector3;
  7204. /** @hidden */
  7205. _retry: number;
  7206. private _velocity;
  7207. private _basePoint;
  7208. private _epsilon;
  7209. /** @hidden */
  7210. _velocityWorldLength: number;
  7211. /** @hidden */
  7212. _basePointWorld: Vector3;
  7213. private _velocityWorld;
  7214. private _normalizedVelocity;
  7215. /** @hidden */
  7216. _initialVelocity: Vector3;
  7217. /** @hidden */
  7218. _initialPosition: Vector3;
  7219. private _nearestDistance;
  7220. private _collisionMask;
  7221. get collisionMask(): number;
  7222. set collisionMask(mask: number);
  7223. /**
  7224. * Gets the plane normal used to compute the sliding response (in local space)
  7225. */
  7226. get slidePlaneNormal(): Vector3;
  7227. /** @hidden */
  7228. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7229. /** @hidden */
  7230. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7231. /** @hidden */
  7232. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7233. /** @hidden */
  7234. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7235. /** @hidden */
  7236. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7237. /** @hidden */
  7238. _getResponse(pos: Vector3, vel: Vector3): void;
  7239. }
  7240. }
  7241. declare module "babylonjs/Culling/boundingInfo" {
  7242. import { DeepImmutable } from "babylonjs/types";
  7243. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7244. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7245. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7246. import { Plane } from "babylonjs/Maths/math.plane";
  7247. import { Collider } from "babylonjs/Collisions/collider";
  7248. /**
  7249. * Interface for cullable objects
  7250. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7251. */
  7252. export interface ICullable {
  7253. /**
  7254. * Checks if the object or part of the object is in the frustum
  7255. * @param frustumPlanes Camera near/planes
  7256. * @returns true if the object is in frustum otherwise false
  7257. */
  7258. isInFrustum(frustumPlanes: Plane[]): boolean;
  7259. /**
  7260. * Checks if a cullable object (mesh...) is in the camera frustum
  7261. * Unlike isInFrustum this cheks the full bounding box
  7262. * @param frustumPlanes Camera near/planes
  7263. * @returns true if the object is in frustum otherwise false
  7264. */
  7265. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7266. }
  7267. /**
  7268. * Info for a bounding data of a mesh
  7269. */
  7270. export class BoundingInfo implements ICullable {
  7271. /**
  7272. * Bounding box for the mesh
  7273. */
  7274. readonly boundingBox: BoundingBox;
  7275. /**
  7276. * Bounding sphere for the mesh
  7277. */
  7278. readonly boundingSphere: BoundingSphere;
  7279. private _isLocked;
  7280. private static readonly TmpVector3;
  7281. /**
  7282. * Constructs bounding info
  7283. * @param minimum min vector of the bounding box/sphere
  7284. * @param maximum max vector of the bounding box/sphere
  7285. * @param worldMatrix defines the new world matrix
  7286. */
  7287. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7288. /**
  7289. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7290. * @param min defines the new minimum vector (in local space)
  7291. * @param max defines the new maximum vector (in local space)
  7292. * @param worldMatrix defines the new world matrix
  7293. */
  7294. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7295. /**
  7296. * min vector of the bounding box/sphere
  7297. */
  7298. get minimum(): Vector3;
  7299. /**
  7300. * max vector of the bounding box/sphere
  7301. */
  7302. get maximum(): Vector3;
  7303. /**
  7304. * If the info is locked and won't be updated to avoid perf overhead
  7305. */
  7306. get isLocked(): boolean;
  7307. set isLocked(value: boolean);
  7308. /**
  7309. * Updates the bounding sphere and box
  7310. * @param world world matrix to be used to update
  7311. */
  7312. update(world: DeepImmutable<Matrix>): void;
  7313. /**
  7314. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7315. * @param center New center of the bounding info
  7316. * @param extend New extend of the bounding info
  7317. * @returns the current bounding info
  7318. */
  7319. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7320. /**
  7321. * Scale the current bounding info by applying a scale factor
  7322. * @param factor defines the scale factor to apply
  7323. * @returns the current bounding info
  7324. */
  7325. scale(factor: number): BoundingInfo;
  7326. /**
  7327. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7328. * @param frustumPlanes defines the frustum to test
  7329. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7330. * @returns true if the bounding info is in the frustum planes
  7331. */
  7332. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7333. /**
  7334. * Gets the world distance between the min and max points of the bounding box
  7335. */
  7336. get diagonalLength(): number;
  7337. /**
  7338. * Checks if a cullable object (mesh...) is in the camera frustum
  7339. * Unlike isInFrustum this cheks the full bounding box
  7340. * @param frustumPlanes Camera near/planes
  7341. * @returns true if the object is in frustum otherwise false
  7342. */
  7343. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7344. /** @hidden */
  7345. _checkCollision(collider: Collider): boolean;
  7346. /**
  7347. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7348. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7349. * @param point the point to check intersection with
  7350. * @returns if the point intersects
  7351. */
  7352. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7353. /**
  7354. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7355. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7356. * @param boundingInfo the bounding info to check intersection with
  7357. * @param precise if the intersection should be done using OBB
  7358. * @returns if the bounding info intersects
  7359. */
  7360. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7361. }
  7362. }
  7363. declare module "babylonjs/Maths/math.functions" {
  7364. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7365. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7366. /**
  7367. * Extracts minimum and maximum values from a list of indexed positions
  7368. * @param positions defines the positions to use
  7369. * @param indices defines the indices to the positions
  7370. * @param indexStart defines the start index
  7371. * @param indexCount defines the end index
  7372. * @param bias defines bias value to add to the result
  7373. * @return minimum and maximum values
  7374. */
  7375. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7376. minimum: Vector3;
  7377. maximum: Vector3;
  7378. };
  7379. /**
  7380. * Extracts minimum and maximum values from a list of positions
  7381. * @param positions defines the positions to use
  7382. * @param start defines the start index in the positions array
  7383. * @param count defines the number of positions to handle
  7384. * @param bias defines bias value to add to the result
  7385. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7386. * @return minimum and maximum values
  7387. */
  7388. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7389. minimum: Vector3;
  7390. maximum: Vector3;
  7391. };
  7392. }
  7393. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7394. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7395. /** @hidden */
  7396. export class WebGLDataBuffer extends DataBuffer {
  7397. private _buffer;
  7398. constructor(resource: WebGLBuffer);
  7399. get underlyingResource(): any;
  7400. }
  7401. }
  7402. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7403. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7404. import { Nullable } from "babylonjs/types";
  7405. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7406. /** @hidden */
  7407. export class WebGLPipelineContext implements IPipelineContext {
  7408. engine: ThinEngine;
  7409. program: Nullable<WebGLProgram>;
  7410. context?: WebGLRenderingContext;
  7411. vertexShader?: WebGLShader;
  7412. fragmentShader?: WebGLShader;
  7413. isParallelCompiled: boolean;
  7414. onCompiled?: () => void;
  7415. transformFeedback?: WebGLTransformFeedback | null;
  7416. vertexCompilationError: Nullable<string>;
  7417. fragmentCompilationError: Nullable<string>;
  7418. programLinkError: Nullable<string>;
  7419. programValidationError: Nullable<string>;
  7420. get isAsync(): boolean;
  7421. get isReady(): boolean;
  7422. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7423. _getVertexShaderCode(): string | null;
  7424. _getFragmentShaderCode(): string | null;
  7425. }
  7426. }
  7427. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7428. import { FloatArray, Nullable } from "babylonjs/types";
  7429. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7430. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7431. module "babylonjs/Engines/thinEngine" {
  7432. interface ThinEngine {
  7433. /**
  7434. * Create an uniform buffer
  7435. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7436. * @param elements defines the content of the uniform buffer
  7437. * @returns the webGL uniform buffer
  7438. */
  7439. createUniformBuffer(elements: FloatArray): DataBuffer;
  7440. /**
  7441. * Create a dynamic uniform buffer
  7442. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7443. * @param elements defines the content of the uniform buffer
  7444. * @returns the webGL uniform buffer
  7445. */
  7446. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7447. /**
  7448. * Update an existing uniform buffer
  7449. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7450. * @param uniformBuffer defines the target uniform buffer
  7451. * @param elements defines the content to update
  7452. * @param offset defines the offset in the uniform buffer where update should start
  7453. * @param count defines the size of the data to update
  7454. */
  7455. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7456. /**
  7457. * Bind an uniform buffer to the current webGL context
  7458. * @param buffer defines the buffer to bind
  7459. */
  7460. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7461. /**
  7462. * Bind a buffer to the current webGL context at a given location
  7463. * @param buffer defines the buffer to bind
  7464. * @param location defines the index where to bind the buffer
  7465. */
  7466. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7467. /**
  7468. * Bind a specific block at a given index in a specific shader program
  7469. * @param pipelineContext defines the pipeline context to use
  7470. * @param blockName defines the block name
  7471. * @param index defines the index where to bind the block
  7472. */
  7473. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7474. }
  7475. }
  7476. }
  7477. declare module "babylonjs/Materials/uniformBuffer" {
  7478. import { Nullable, FloatArray } from "babylonjs/types";
  7479. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7480. import { Engine } from "babylonjs/Engines/engine";
  7481. import { Effect } from "babylonjs/Materials/effect";
  7482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7483. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7484. import { Color3 } from "babylonjs/Maths/math.color";
  7485. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7486. /**
  7487. * Uniform buffer objects.
  7488. *
  7489. * Handles blocks of uniform on the GPU.
  7490. *
  7491. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7492. *
  7493. * For more information, please refer to :
  7494. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7495. */
  7496. export class UniformBuffer {
  7497. private _engine;
  7498. private _buffer;
  7499. private _data;
  7500. private _bufferData;
  7501. private _dynamic?;
  7502. private _uniformLocations;
  7503. private _uniformSizes;
  7504. private _uniformLocationPointer;
  7505. private _needSync;
  7506. private _noUBO;
  7507. private _currentEffect;
  7508. /** @hidden */
  7509. _alreadyBound: boolean;
  7510. private static _MAX_UNIFORM_SIZE;
  7511. private static _tempBuffer;
  7512. /**
  7513. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7514. * This is dynamic to allow compat with webgl 1 and 2.
  7515. * You will need to pass the name of the uniform as well as the value.
  7516. */
  7517. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7518. /**
  7519. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7520. * This is dynamic to allow compat with webgl 1 and 2.
  7521. * You will need to pass the name of the uniform as well as the value.
  7522. */
  7523. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7524. /**
  7525. * Lambda to Update a single float in a uniform buffer.
  7526. * This is dynamic to allow compat with webgl 1 and 2.
  7527. * You will need to pass the name of the uniform as well as the value.
  7528. */
  7529. updateFloat: (name: string, x: number) => void;
  7530. /**
  7531. * Lambda to Update a vec2 of float in a uniform buffer.
  7532. * This is dynamic to allow compat with webgl 1 and 2.
  7533. * You will need to pass the name of the uniform as well as the value.
  7534. */
  7535. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7536. /**
  7537. * Lambda to Update a vec3 of float in a uniform buffer.
  7538. * This is dynamic to allow compat with webgl 1 and 2.
  7539. * You will need to pass the name of the uniform as well as the value.
  7540. */
  7541. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7542. /**
  7543. * Lambda to Update a vec4 of float in a uniform buffer.
  7544. * This is dynamic to allow compat with webgl 1 and 2.
  7545. * You will need to pass the name of the uniform as well as the value.
  7546. */
  7547. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7548. /**
  7549. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7550. * This is dynamic to allow compat with webgl 1 and 2.
  7551. * You will need to pass the name of the uniform as well as the value.
  7552. */
  7553. updateMatrix: (name: string, mat: Matrix) => void;
  7554. /**
  7555. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7556. * This is dynamic to allow compat with webgl 1 and 2.
  7557. * You will need to pass the name of the uniform as well as the value.
  7558. */
  7559. updateVector3: (name: string, vector: Vector3) => void;
  7560. /**
  7561. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7562. * This is dynamic to allow compat with webgl 1 and 2.
  7563. * You will need to pass the name of the uniform as well as the value.
  7564. */
  7565. updateVector4: (name: string, vector: Vector4) => void;
  7566. /**
  7567. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7568. * This is dynamic to allow compat with webgl 1 and 2.
  7569. * You will need to pass the name of the uniform as well as the value.
  7570. */
  7571. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7572. /**
  7573. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7574. * This is dynamic to allow compat with webgl 1 and 2.
  7575. * You will need to pass the name of the uniform as well as the value.
  7576. */
  7577. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7578. /**
  7579. * Instantiates a new Uniform buffer objects.
  7580. *
  7581. * Handles blocks of uniform on the GPU.
  7582. *
  7583. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7584. *
  7585. * For more information, please refer to :
  7586. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7587. * @param engine Define the engine the buffer is associated with
  7588. * @param data Define the data contained in the buffer
  7589. * @param dynamic Define if the buffer is updatable
  7590. */
  7591. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7592. /**
  7593. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7594. * or just falling back on setUniformXXX calls.
  7595. */
  7596. get useUbo(): boolean;
  7597. /**
  7598. * Indicates if the WebGL underlying uniform buffer is in sync
  7599. * with the javascript cache data.
  7600. */
  7601. get isSync(): boolean;
  7602. /**
  7603. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7604. * Also, a dynamic UniformBuffer will disable cache verification and always
  7605. * update the underlying WebGL uniform buffer to the GPU.
  7606. * @returns if Dynamic, otherwise false
  7607. */
  7608. isDynamic(): boolean;
  7609. /**
  7610. * The data cache on JS side.
  7611. * @returns the underlying data as a float array
  7612. */
  7613. getData(): Float32Array;
  7614. /**
  7615. * The underlying WebGL Uniform buffer.
  7616. * @returns the webgl buffer
  7617. */
  7618. getBuffer(): Nullable<DataBuffer>;
  7619. /**
  7620. * std140 layout specifies how to align data within an UBO structure.
  7621. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7622. * for specs.
  7623. */
  7624. private _fillAlignment;
  7625. /**
  7626. * Adds an uniform in the buffer.
  7627. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7628. * for the layout to be correct !
  7629. * @param name Name of the uniform, as used in the uniform block in the shader.
  7630. * @param size Data size, or data directly.
  7631. */
  7632. addUniform(name: string, size: number | number[]): void;
  7633. /**
  7634. * Adds a Matrix 4x4 to the uniform buffer.
  7635. * @param name Name of the uniform, as used in the uniform block in the shader.
  7636. * @param mat A 4x4 matrix.
  7637. */
  7638. addMatrix(name: string, mat: Matrix): void;
  7639. /**
  7640. * Adds a vec2 to the uniform buffer.
  7641. * @param name Name of the uniform, as used in the uniform block in the shader.
  7642. * @param x Define the x component value of the vec2
  7643. * @param y Define the y component value of the vec2
  7644. */
  7645. addFloat2(name: string, x: number, y: number): void;
  7646. /**
  7647. * Adds a vec3 to the uniform buffer.
  7648. * @param name Name of the uniform, as used in the uniform block in the shader.
  7649. * @param x Define the x component value of the vec3
  7650. * @param y Define the y component value of the vec3
  7651. * @param z Define the z component value of the vec3
  7652. */
  7653. addFloat3(name: string, x: number, y: number, z: number): void;
  7654. /**
  7655. * Adds a vec3 to the uniform buffer.
  7656. * @param name Name of the uniform, as used in the uniform block in the shader.
  7657. * @param color Define the vec3 from a Color
  7658. */
  7659. addColor3(name: string, color: Color3): void;
  7660. /**
  7661. * Adds a vec4 to the uniform buffer.
  7662. * @param name Name of the uniform, as used in the uniform block in the shader.
  7663. * @param color Define the rgb components from a Color
  7664. * @param alpha Define the a component of the vec4
  7665. */
  7666. addColor4(name: string, color: Color3, alpha: number): void;
  7667. /**
  7668. * Adds a vec3 to the uniform buffer.
  7669. * @param name Name of the uniform, as used in the uniform block in the shader.
  7670. * @param vector Define the vec3 components from a Vector
  7671. */
  7672. addVector3(name: string, vector: Vector3): void;
  7673. /**
  7674. * Adds a Matrix 3x3 to the uniform buffer.
  7675. * @param name Name of the uniform, as used in the uniform block in the shader.
  7676. */
  7677. addMatrix3x3(name: string): void;
  7678. /**
  7679. * Adds a Matrix 2x2 to the uniform buffer.
  7680. * @param name Name of the uniform, as used in the uniform block in the shader.
  7681. */
  7682. addMatrix2x2(name: string): void;
  7683. /**
  7684. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7685. */
  7686. create(): void;
  7687. /** @hidden */
  7688. _rebuild(): void;
  7689. /**
  7690. * Updates the WebGL Uniform Buffer on the GPU.
  7691. * If the `dynamic` flag is set to true, no cache comparison is done.
  7692. * Otherwise, the buffer will be updated only if the cache differs.
  7693. */
  7694. update(): void;
  7695. /**
  7696. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7697. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7698. * @param data Define the flattened data
  7699. * @param size Define the size of the data.
  7700. */
  7701. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7702. private _valueCache;
  7703. private _cacheMatrix;
  7704. private _updateMatrix3x3ForUniform;
  7705. private _updateMatrix3x3ForEffect;
  7706. private _updateMatrix2x2ForEffect;
  7707. private _updateMatrix2x2ForUniform;
  7708. private _updateFloatForEffect;
  7709. private _updateFloatForUniform;
  7710. private _updateFloat2ForEffect;
  7711. private _updateFloat2ForUniform;
  7712. private _updateFloat3ForEffect;
  7713. private _updateFloat3ForUniform;
  7714. private _updateFloat4ForEffect;
  7715. private _updateFloat4ForUniform;
  7716. private _updateMatrixForEffect;
  7717. private _updateMatrixForUniform;
  7718. private _updateVector3ForEffect;
  7719. private _updateVector3ForUniform;
  7720. private _updateVector4ForEffect;
  7721. private _updateVector4ForUniform;
  7722. private _updateColor3ForEffect;
  7723. private _updateColor3ForUniform;
  7724. private _updateColor4ForEffect;
  7725. private _updateColor4ForUniform;
  7726. /**
  7727. * Sets a sampler uniform on the effect.
  7728. * @param name Define the name of the sampler.
  7729. * @param texture Define the texture to set in the sampler
  7730. */
  7731. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7732. /**
  7733. * Directly updates the value of the uniform in the cache AND on the GPU.
  7734. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7735. * @param data Define the flattened data
  7736. */
  7737. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7738. /**
  7739. * Binds this uniform buffer to an effect.
  7740. * @param effect Define the effect to bind the buffer to
  7741. * @param name Name of the uniform block in the shader.
  7742. */
  7743. bindToEffect(effect: Effect, name: string): void;
  7744. /**
  7745. * Disposes the uniform buffer.
  7746. */
  7747. dispose(): void;
  7748. }
  7749. }
  7750. declare module "babylonjs/Misc/iInspectable" {
  7751. /**
  7752. * Enum that determines the text-wrapping mode to use.
  7753. */
  7754. export enum InspectableType {
  7755. /**
  7756. * Checkbox for booleans
  7757. */
  7758. Checkbox = 0,
  7759. /**
  7760. * Sliders for numbers
  7761. */
  7762. Slider = 1,
  7763. /**
  7764. * Vector3
  7765. */
  7766. Vector3 = 2,
  7767. /**
  7768. * Quaternions
  7769. */
  7770. Quaternion = 3,
  7771. /**
  7772. * Color3
  7773. */
  7774. Color3 = 4,
  7775. /**
  7776. * String
  7777. */
  7778. String = 5
  7779. }
  7780. /**
  7781. * Interface used to define custom inspectable properties.
  7782. * This interface is used by the inspector to display custom property grids
  7783. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7784. */
  7785. export interface IInspectable {
  7786. /**
  7787. * Gets the label to display
  7788. */
  7789. label: string;
  7790. /**
  7791. * Gets the name of the property to edit
  7792. */
  7793. propertyName: string;
  7794. /**
  7795. * Gets the type of the editor to use
  7796. */
  7797. type: InspectableType;
  7798. /**
  7799. * Gets the minimum value of the property when using in "slider" mode
  7800. */
  7801. min?: number;
  7802. /**
  7803. * Gets the maximum value of the property when using in "slider" mode
  7804. */
  7805. max?: number;
  7806. /**
  7807. * Gets the setp to use when using in "slider" mode
  7808. */
  7809. step?: number;
  7810. }
  7811. }
  7812. declare module "babylonjs/Misc/timingTools" {
  7813. /**
  7814. * Class used to provide helper for timing
  7815. */
  7816. export class TimingTools {
  7817. /**
  7818. * Polyfill for setImmediate
  7819. * @param action defines the action to execute after the current execution block
  7820. */
  7821. static SetImmediate(action: () => void): void;
  7822. }
  7823. }
  7824. declare module "babylonjs/Misc/instantiationTools" {
  7825. /**
  7826. * Class used to enable instatition of objects by class name
  7827. */
  7828. export class InstantiationTools {
  7829. /**
  7830. * Use this object to register external classes like custom textures or material
  7831. * to allow the laoders to instantiate them
  7832. */
  7833. static RegisteredExternalClasses: {
  7834. [key: string]: Object;
  7835. };
  7836. /**
  7837. * Tries to instantiate a new object from a given class name
  7838. * @param className defines the class name to instantiate
  7839. * @returns the new object or null if the system was not able to do the instantiation
  7840. */
  7841. static Instantiate(className: string): any;
  7842. }
  7843. }
  7844. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7845. /**
  7846. * Define options used to create a depth texture
  7847. */
  7848. export class DepthTextureCreationOptions {
  7849. /** Specifies whether or not a stencil should be allocated in the texture */
  7850. generateStencil?: boolean;
  7851. /** Specifies whether or not bilinear filtering is enable on the texture */
  7852. bilinearFiltering?: boolean;
  7853. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7854. comparisonFunction?: number;
  7855. /** Specifies if the created texture is a cube texture */
  7856. isCube?: boolean;
  7857. }
  7858. }
  7859. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7860. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7861. import { Nullable } from "babylonjs/types";
  7862. import { Scene } from "babylonjs/scene";
  7863. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7864. module "babylonjs/Engines/thinEngine" {
  7865. interface ThinEngine {
  7866. /**
  7867. * Creates a depth stencil cube texture.
  7868. * This is only available in WebGL 2.
  7869. * @param size The size of face edge in the cube texture.
  7870. * @param options The options defining the cube texture.
  7871. * @returns The cube texture
  7872. */
  7873. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7874. /**
  7875. * Creates a cube texture
  7876. * @param rootUrl defines the url where the files to load is located
  7877. * @param scene defines the current scene
  7878. * @param files defines the list of files to load (1 per face)
  7879. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7880. * @param onLoad defines an optional callback raised when the texture is loaded
  7881. * @param onError defines an optional callback raised if there is an issue to load the texture
  7882. * @param format defines the format of the data
  7883. * @param forcedExtension defines the extension to use to pick the right loader
  7884. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7885. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7886. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7887. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7888. * @returns the cube texture as an InternalTexture
  7889. */
  7890. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7891. /**
  7892. * Creates a cube texture
  7893. * @param rootUrl defines the url where the files to load is located
  7894. * @param scene defines the current scene
  7895. * @param files defines the list of files to load (1 per face)
  7896. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7897. * @param onLoad defines an optional callback raised when the texture is loaded
  7898. * @param onError defines an optional callback raised if there is an issue to load the texture
  7899. * @param format defines the format of the data
  7900. * @param forcedExtension defines the extension to use to pick the right loader
  7901. * @returns the cube texture as an InternalTexture
  7902. */
  7903. 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;
  7904. /**
  7905. * Creates a cube texture
  7906. * @param rootUrl defines the url where the files to load is located
  7907. * @param scene defines the current scene
  7908. * @param files defines the list of files to load (1 per face)
  7909. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7910. * @param onLoad defines an optional callback raised when the texture is loaded
  7911. * @param onError defines an optional callback raised if there is an issue to load the texture
  7912. * @param format defines the format of the data
  7913. * @param forcedExtension defines the extension to use to pick the right loader
  7914. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7915. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7916. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7917. * @returns the cube texture as an InternalTexture
  7918. */
  7919. 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;
  7920. /** @hidden */
  7921. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7922. /** @hidden */
  7923. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7924. /** @hidden */
  7925. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7926. /** @hidden */
  7927. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7928. /**
  7929. * @hidden
  7930. */
  7931. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7932. }
  7933. }
  7934. }
  7935. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7936. import { Nullable } from "babylonjs/types";
  7937. import { Scene } from "babylonjs/scene";
  7938. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7940. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7941. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7942. import { Observable } from "babylonjs/Misc/observable";
  7943. /**
  7944. * Class for creating a cube texture
  7945. */
  7946. export class CubeTexture extends BaseTexture {
  7947. private _delayedOnLoad;
  7948. /**
  7949. * Observable triggered once the texture has been loaded.
  7950. */
  7951. onLoadObservable: Observable<CubeTexture>;
  7952. /**
  7953. * The url of the texture
  7954. */
  7955. url: string;
  7956. /**
  7957. * Gets or sets the center of the bounding box associated with the cube texture.
  7958. * It must define where the camera used to render the texture was set
  7959. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7960. */
  7961. boundingBoxPosition: Vector3;
  7962. private _boundingBoxSize;
  7963. /**
  7964. * Gets or sets the size of the bounding box associated with the cube texture
  7965. * When defined, the cubemap will switch to local mode
  7966. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7967. * @example https://www.babylonjs-playground.com/#RNASML
  7968. */
  7969. set boundingBoxSize(value: Vector3);
  7970. /**
  7971. * Returns the bounding box size
  7972. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7973. */
  7974. get boundingBoxSize(): Vector3;
  7975. protected _rotationY: number;
  7976. /**
  7977. * Sets texture matrix rotation angle around Y axis in radians.
  7978. */
  7979. set rotationY(value: number);
  7980. /**
  7981. * Gets texture matrix rotation angle around Y axis radians.
  7982. */
  7983. get rotationY(): number;
  7984. /**
  7985. * Are mip maps generated for this texture or not.
  7986. */
  7987. get noMipmap(): boolean;
  7988. private _noMipmap;
  7989. private _files;
  7990. protected _forcedExtension: Nullable<string>;
  7991. private _extensions;
  7992. private _textureMatrix;
  7993. private _format;
  7994. private _createPolynomials;
  7995. /**
  7996. * Creates a cube texture from an array of image urls
  7997. * @param files defines an array of image urls
  7998. * @param scene defines the hosting scene
  7999. * @param noMipmap specifies if mip maps are not used
  8000. * @returns a cube texture
  8001. */
  8002. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8003. /**
  8004. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8005. * @param url defines the url of the prefiltered texture
  8006. * @param scene defines the scene the texture is attached to
  8007. * @param forcedExtension defines the extension of the file if different from the url
  8008. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8009. * @return the prefiltered texture
  8010. */
  8011. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8012. /**
  8013. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8014. * as prefiltered data.
  8015. * @param rootUrl defines the url of the texture or the root name of the six images
  8016. * @param null defines the scene or engine the texture is attached to
  8017. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8018. * @param noMipmap defines if mipmaps should be created or not
  8019. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8020. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8021. * @param onError defines a callback triggered in case of error during load
  8022. * @param format defines the internal format to use for the texture once loaded
  8023. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8024. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8025. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8026. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8027. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8028. * @return the cube texture
  8029. */
  8030. 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);
  8031. /**
  8032. * Get the current class name of the texture useful for serialization or dynamic coding.
  8033. * @returns "CubeTexture"
  8034. */
  8035. getClassName(): string;
  8036. /**
  8037. * Update the url (and optional buffer) of this texture if url was null during construction.
  8038. * @param url the url of the texture
  8039. * @param forcedExtension defines the extension to use
  8040. * @param onLoad callback called when the texture is loaded (defaults to null)
  8041. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8042. */
  8043. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8044. /**
  8045. * Delays loading of the cube texture
  8046. * @param forcedExtension defines the extension to use
  8047. */
  8048. delayLoad(forcedExtension?: string): void;
  8049. /**
  8050. * Returns the reflection texture matrix
  8051. * @returns the reflection texture matrix
  8052. */
  8053. getReflectionTextureMatrix(): Matrix;
  8054. /**
  8055. * Sets the reflection texture matrix
  8056. * @param value Reflection texture matrix
  8057. */
  8058. setReflectionTextureMatrix(value: Matrix): void;
  8059. /**
  8060. * Parses text to create a cube texture
  8061. * @param parsedTexture define the serialized text to read from
  8062. * @param scene defines the hosting scene
  8063. * @param rootUrl defines the root url of the cube texture
  8064. * @returns a cube texture
  8065. */
  8066. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8067. /**
  8068. * Makes a clone, or deep copy, of the cube texture
  8069. * @returns a new cube texture
  8070. */
  8071. clone(): CubeTexture;
  8072. }
  8073. }
  8074. declare module "babylonjs/Materials/materialDefines" {
  8075. /**
  8076. * Manages the defines for the Material
  8077. */
  8078. export class MaterialDefines {
  8079. /** @hidden */
  8080. protected _keys: string[];
  8081. private _isDirty;
  8082. /** @hidden */
  8083. _renderId: number;
  8084. /** @hidden */
  8085. _areLightsDirty: boolean;
  8086. /** @hidden */
  8087. _areLightsDisposed: boolean;
  8088. /** @hidden */
  8089. _areAttributesDirty: boolean;
  8090. /** @hidden */
  8091. _areTexturesDirty: boolean;
  8092. /** @hidden */
  8093. _areFresnelDirty: boolean;
  8094. /** @hidden */
  8095. _areMiscDirty: boolean;
  8096. /** @hidden */
  8097. _areImageProcessingDirty: boolean;
  8098. /** @hidden */
  8099. _normals: boolean;
  8100. /** @hidden */
  8101. _uvs: boolean;
  8102. /** @hidden */
  8103. _needNormals: boolean;
  8104. /** @hidden */
  8105. _needUVs: boolean;
  8106. [id: string]: any;
  8107. /**
  8108. * Specifies if the material needs to be re-calculated
  8109. */
  8110. get isDirty(): boolean;
  8111. /**
  8112. * Marks the material to indicate that it has been re-calculated
  8113. */
  8114. markAsProcessed(): void;
  8115. /**
  8116. * Marks the material to indicate that it needs to be re-calculated
  8117. */
  8118. markAsUnprocessed(): void;
  8119. /**
  8120. * Marks the material to indicate all of its defines need to be re-calculated
  8121. */
  8122. markAllAsDirty(): void;
  8123. /**
  8124. * Marks the material to indicate that image processing needs to be re-calculated
  8125. */
  8126. markAsImageProcessingDirty(): void;
  8127. /**
  8128. * Marks the material to indicate the lights need to be re-calculated
  8129. * @param disposed Defines whether the light is dirty due to dispose or not
  8130. */
  8131. markAsLightDirty(disposed?: boolean): void;
  8132. /**
  8133. * Marks the attribute state as changed
  8134. */
  8135. markAsAttributesDirty(): void;
  8136. /**
  8137. * Marks the texture state as changed
  8138. */
  8139. markAsTexturesDirty(): void;
  8140. /**
  8141. * Marks the fresnel state as changed
  8142. */
  8143. markAsFresnelDirty(): void;
  8144. /**
  8145. * Marks the misc state as changed
  8146. */
  8147. markAsMiscDirty(): void;
  8148. /**
  8149. * Rebuilds the material defines
  8150. */
  8151. rebuild(): void;
  8152. /**
  8153. * Specifies if two material defines are equal
  8154. * @param other - A material define instance to compare to
  8155. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8156. */
  8157. isEqual(other: MaterialDefines): boolean;
  8158. /**
  8159. * Clones this instance's defines to another instance
  8160. * @param other - material defines to clone values to
  8161. */
  8162. cloneTo(other: MaterialDefines): void;
  8163. /**
  8164. * Resets the material define values
  8165. */
  8166. reset(): void;
  8167. /**
  8168. * Converts the material define values to a string
  8169. * @returns - String of material define information
  8170. */
  8171. toString(): string;
  8172. }
  8173. }
  8174. declare module "babylonjs/Materials/colorCurves" {
  8175. import { Effect } from "babylonjs/Materials/effect";
  8176. /**
  8177. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8178. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8179. * 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;
  8180. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8181. */
  8182. export class ColorCurves {
  8183. private _dirty;
  8184. private _tempColor;
  8185. private _globalCurve;
  8186. private _highlightsCurve;
  8187. private _midtonesCurve;
  8188. private _shadowsCurve;
  8189. private _positiveCurve;
  8190. private _negativeCurve;
  8191. private _globalHue;
  8192. private _globalDensity;
  8193. private _globalSaturation;
  8194. private _globalExposure;
  8195. /**
  8196. * Gets the global Hue value.
  8197. * 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).
  8198. */
  8199. get globalHue(): number;
  8200. /**
  8201. * Sets the global Hue value.
  8202. * 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).
  8203. */
  8204. set globalHue(value: number);
  8205. /**
  8206. * Gets the global Density value.
  8207. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. get globalDensity(): number;
  8211. /**
  8212. * Sets the global Density value.
  8213. * 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.
  8214. * Values less than zero provide a filter of opposite hue.
  8215. */
  8216. set globalDensity(value: number);
  8217. /**
  8218. * Gets the global Saturation value.
  8219. * 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.
  8220. */
  8221. get globalSaturation(): number;
  8222. /**
  8223. * Sets the global Saturation value.
  8224. * 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.
  8225. */
  8226. set globalSaturation(value: number);
  8227. /**
  8228. * Gets the global Exposure value.
  8229. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8230. */
  8231. get globalExposure(): number;
  8232. /**
  8233. * Sets the global Exposure value.
  8234. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8235. */
  8236. set globalExposure(value: number);
  8237. private _highlightsHue;
  8238. private _highlightsDensity;
  8239. private _highlightsSaturation;
  8240. private _highlightsExposure;
  8241. /**
  8242. * Gets the highlights Hue value.
  8243. * 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).
  8244. */
  8245. get highlightsHue(): number;
  8246. /**
  8247. * Sets the highlights Hue value.
  8248. * 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).
  8249. */
  8250. set highlightsHue(value: number);
  8251. /**
  8252. * Gets the highlights Density value.
  8253. * 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.
  8254. * Values less than zero provide a filter of opposite hue.
  8255. */
  8256. get highlightsDensity(): number;
  8257. /**
  8258. * Sets the highlights Density value.
  8259. * 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.
  8260. * Values less than zero provide a filter of opposite hue.
  8261. */
  8262. set highlightsDensity(value: number);
  8263. /**
  8264. * Gets the highlights Saturation 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 saturation and negative values decrease saturation.
  8266. */
  8267. get highlightsSaturation(): number;
  8268. /**
  8269. * Sets the highlights Saturation value.
  8270. * 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.
  8271. */
  8272. set highlightsSaturation(value: number);
  8273. /**
  8274. * Gets the highlights Exposure value.
  8275. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8276. */
  8277. get highlightsExposure(): number;
  8278. /**
  8279. * Sets the highlights Exposure value.
  8280. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8281. */
  8282. set highlightsExposure(value: number);
  8283. private _midtonesHue;
  8284. private _midtonesDensity;
  8285. private _midtonesSaturation;
  8286. private _midtonesExposure;
  8287. /**
  8288. * Gets the midtones Hue value.
  8289. * 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).
  8290. */
  8291. get midtonesHue(): number;
  8292. /**
  8293. * Sets the midtones Hue value.
  8294. * 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).
  8295. */
  8296. set midtonesHue(value: number);
  8297. /**
  8298. * Gets the midtones Density value.
  8299. * 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.
  8300. * Values less than zero provide a filter of opposite hue.
  8301. */
  8302. get midtonesDensity(): number;
  8303. /**
  8304. * Sets the midtones Density value.
  8305. * 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.
  8306. * Values less than zero provide a filter of opposite hue.
  8307. */
  8308. set midtonesDensity(value: number);
  8309. /**
  8310. * Gets the midtones Saturation 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 saturation and negative values decrease saturation.
  8312. */
  8313. get midtonesSaturation(): number;
  8314. /**
  8315. * Sets the midtones Saturation value.
  8316. * 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.
  8317. */
  8318. set midtonesSaturation(value: number);
  8319. /**
  8320. * Gets the midtones Exposure value.
  8321. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8322. */
  8323. get midtonesExposure(): number;
  8324. /**
  8325. * Sets the midtones Exposure value.
  8326. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8327. */
  8328. set midtonesExposure(value: number);
  8329. private _shadowsHue;
  8330. private _shadowsDensity;
  8331. private _shadowsSaturation;
  8332. private _shadowsExposure;
  8333. /**
  8334. * Gets the shadows Hue value.
  8335. * 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).
  8336. */
  8337. get shadowsHue(): number;
  8338. /**
  8339. * Sets the shadows Hue value.
  8340. * 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).
  8341. */
  8342. set shadowsHue(value: number);
  8343. /**
  8344. * Gets the shadows Density value.
  8345. * 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.
  8346. * Values less than zero provide a filter of opposite hue.
  8347. */
  8348. get shadowsDensity(): number;
  8349. /**
  8350. * Sets the shadows Density value.
  8351. * 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.
  8352. * Values less than zero provide a filter of opposite hue.
  8353. */
  8354. set shadowsDensity(value: number);
  8355. /**
  8356. * Gets the shadows Saturation 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 saturation and negative values decrease saturation.
  8358. */
  8359. get shadowsSaturation(): number;
  8360. /**
  8361. * Sets the shadows Saturation value.
  8362. * 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.
  8363. */
  8364. set shadowsSaturation(value: number);
  8365. /**
  8366. * Gets the shadows Exposure value.
  8367. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8368. */
  8369. get shadowsExposure(): number;
  8370. /**
  8371. * Sets the shadows Exposure value.
  8372. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8373. */
  8374. set shadowsExposure(value: number);
  8375. /**
  8376. * Returns the class name
  8377. * @returns The class name
  8378. */
  8379. getClassName(): string;
  8380. /**
  8381. * Binds the color curves to the shader.
  8382. * @param colorCurves The color curve to bind
  8383. * @param effect The effect to bind to
  8384. * @param positiveUniform The positive uniform shader parameter
  8385. * @param neutralUniform The neutral uniform shader parameter
  8386. * @param negativeUniform The negative uniform shader parameter
  8387. */
  8388. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8389. /**
  8390. * Prepare the list of uniforms associated with the ColorCurves effects.
  8391. * @param uniformsList The list of uniforms used in the effect
  8392. */
  8393. static PrepareUniforms(uniformsList: string[]): void;
  8394. /**
  8395. * Returns color grading data based on a hue, density, saturation and exposure value.
  8396. * @param filterHue The hue of the color filter.
  8397. * @param filterDensity The density of the color filter.
  8398. * @param saturation The saturation.
  8399. * @param exposure The exposure.
  8400. * @param result The result data container.
  8401. */
  8402. private getColorGradingDataToRef;
  8403. /**
  8404. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8405. * @param value The input slider value in range [-100,100].
  8406. * @returns Adjusted value.
  8407. */
  8408. private static applyColorGradingSliderNonlinear;
  8409. /**
  8410. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8411. * @param hue The hue (H) input.
  8412. * @param saturation The saturation (S) input.
  8413. * @param brightness The brightness (B) input.
  8414. * @result An RGBA color represented as Vector4.
  8415. */
  8416. private static fromHSBToRef;
  8417. /**
  8418. * Returns a value clamped between min and max
  8419. * @param value The value to clamp
  8420. * @param min The minimum of value
  8421. * @param max The maximum of value
  8422. * @returns The clamped value.
  8423. */
  8424. private static clamp;
  8425. /**
  8426. * Clones the current color curve instance.
  8427. * @return The cloned curves
  8428. */
  8429. clone(): ColorCurves;
  8430. /**
  8431. * Serializes the current color curve instance to a json representation.
  8432. * @return a JSON representation
  8433. */
  8434. serialize(): any;
  8435. /**
  8436. * Parses the color curve from a json representation.
  8437. * @param source the JSON source to parse
  8438. * @return The parsed curves
  8439. */
  8440. static Parse(source: any): ColorCurves;
  8441. }
  8442. }
  8443. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8444. import { Observable } from "babylonjs/Misc/observable";
  8445. import { Nullable } from "babylonjs/types";
  8446. import { Color4 } from "babylonjs/Maths/math.color";
  8447. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8448. import { Effect } from "babylonjs/Materials/effect";
  8449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8450. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8451. /**
  8452. * Interface to follow in your material defines to integrate easily the
  8453. * Image proccessing functions.
  8454. * @hidden
  8455. */
  8456. export interface IImageProcessingConfigurationDefines {
  8457. IMAGEPROCESSING: boolean;
  8458. VIGNETTE: boolean;
  8459. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8460. VIGNETTEBLENDMODEOPAQUE: boolean;
  8461. TONEMAPPING: boolean;
  8462. TONEMAPPING_ACES: boolean;
  8463. CONTRAST: boolean;
  8464. EXPOSURE: boolean;
  8465. COLORCURVES: boolean;
  8466. COLORGRADING: boolean;
  8467. COLORGRADING3D: boolean;
  8468. SAMPLER3DGREENDEPTH: boolean;
  8469. SAMPLER3DBGRMAP: boolean;
  8470. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8471. }
  8472. /**
  8473. * @hidden
  8474. */
  8475. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8476. IMAGEPROCESSING: boolean;
  8477. VIGNETTE: boolean;
  8478. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8479. VIGNETTEBLENDMODEOPAQUE: boolean;
  8480. TONEMAPPING: boolean;
  8481. TONEMAPPING_ACES: boolean;
  8482. CONTRAST: boolean;
  8483. COLORCURVES: boolean;
  8484. COLORGRADING: boolean;
  8485. COLORGRADING3D: boolean;
  8486. SAMPLER3DGREENDEPTH: boolean;
  8487. SAMPLER3DBGRMAP: boolean;
  8488. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8489. EXPOSURE: boolean;
  8490. constructor();
  8491. }
  8492. /**
  8493. * This groups together the common properties used for image processing either in direct forward pass
  8494. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8495. * or not.
  8496. */
  8497. export class ImageProcessingConfiguration {
  8498. /**
  8499. * Default tone mapping applied in BabylonJS.
  8500. */
  8501. static readonly TONEMAPPING_STANDARD: number;
  8502. /**
  8503. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8504. * to other engines rendering to increase portability.
  8505. */
  8506. static readonly TONEMAPPING_ACES: number;
  8507. /**
  8508. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8509. */
  8510. colorCurves: Nullable<ColorCurves>;
  8511. private _colorCurvesEnabled;
  8512. /**
  8513. * Gets wether the color curves effect is enabled.
  8514. */
  8515. get colorCurvesEnabled(): boolean;
  8516. /**
  8517. * Sets wether the color curves effect is enabled.
  8518. */
  8519. set colorCurvesEnabled(value: boolean);
  8520. private _colorGradingTexture;
  8521. /**
  8522. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8523. */
  8524. get colorGradingTexture(): Nullable<BaseTexture>;
  8525. /**
  8526. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8527. */
  8528. set colorGradingTexture(value: Nullable<BaseTexture>);
  8529. private _colorGradingEnabled;
  8530. /**
  8531. * Gets wether the color grading effect is enabled.
  8532. */
  8533. get colorGradingEnabled(): boolean;
  8534. /**
  8535. * Sets wether the color grading effect is enabled.
  8536. */
  8537. set colorGradingEnabled(value: boolean);
  8538. private _colorGradingWithGreenDepth;
  8539. /**
  8540. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8541. */
  8542. get colorGradingWithGreenDepth(): boolean;
  8543. /**
  8544. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8545. */
  8546. set colorGradingWithGreenDepth(value: boolean);
  8547. private _colorGradingBGR;
  8548. /**
  8549. * Gets wether the color grading texture contains BGR values.
  8550. */
  8551. get colorGradingBGR(): boolean;
  8552. /**
  8553. * Sets wether the color grading texture contains BGR values.
  8554. */
  8555. set colorGradingBGR(value: boolean);
  8556. /** @hidden */
  8557. _exposure: number;
  8558. /**
  8559. * Gets the Exposure used in the effect.
  8560. */
  8561. get exposure(): number;
  8562. /**
  8563. * Sets the Exposure used in the effect.
  8564. */
  8565. set exposure(value: number);
  8566. private _toneMappingEnabled;
  8567. /**
  8568. * Gets wether the tone mapping effect is enabled.
  8569. */
  8570. get toneMappingEnabled(): boolean;
  8571. /**
  8572. * Sets wether the tone mapping effect is enabled.
  8573. */
  8574. set toneMappingEnabled(value: boolean);
  8575. private _toneMappingType;
  8576. /**
  8577. * Gets the type of tone mapping effect.
  8578. */
  8579. get toneMappingType(): number;
  8580. /**
  8581. * Sets the type of tone mapping effect used in BabylonJS.
  8582. */
  8583. set toneMappingType(value: number);
  8584. protected _contrast: number;
  8585. /**
  8586. * Gets the contrast used in the effect.
  8587. */
  8588. get contrast(): number;
  8589. /**
  8590. * Sets the contrast used in the effect.
  8591. */
  8592. set contrast(value: number);
  8593. /**
  8594. * Vignette stretch size.
  8595. */
  8596. vignetteStretch: number;
  8597. /**
  8598. * Vignette centre X Offset.
  8599. */
  8600. vignetteCentreX: number;
  8601. /**
  8602. * Vignette centre Y Offset.
  8603. */
  8604. vignetteCentreY: number;
  8605. /**
  8606. * Vignette weight or intensity of the vignette effect.
  8607. */
  8608. vignetteWeight: number;
  8609. /**
  8610. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8611. * if vignetteEnabled is set to true.
  8612. */
  8613. vignetteColor: Color4;
  8614. /**
  8615. * Camera field of view used by the Vignette effect.
  8616. */
  8617. vignetteCameraFov: number;
  8618. private _vignetteBlendMode;
  8619. /**
  8620. * Gets the vignette blend mode allowing different kind of effect.
  8621. */
  8622. get vignetteBlendMode(): number;
  8623. /**
  8624. * Sets the vignette blend mode allowing different kind of effect.
  8625. */
  8626. set vignetteBlendMode(value: number);
  8627. private _vignetteEnabled;
  8628. /**
  8629. * Gets wether the vignette effect is enabled.
  8630. */
  8631. get vignetteEnabled(): boolean;
  8632. /**
  8633. * Sets wether the vignette effect is enabled.
  8634. */
  8635. set vignetteEnabled(value: boolean);
  8636. private _applyByPostProcess;
  8637. /**
  8638. * Gets wether the image processing is applied through a post process or not.
  8639. */
  8640. get applyByPostProcess(): boolean;
  8641. /**
  8642. * Sets wether the image processing is applied through a post process or not.
  8643. */
  8644. set applyByPostProcess(value: boolean);
  8645. private _isEnabled;
  8646. /**
  8647. * Gets wether the image processing is enabled or not.
  8648. */
  8649. get isEnabled(): boolean;
  8650. /**
  8651. * Sets wether the image processing is enabled or not.
  8652. */
  8653. set isEnabled(value: boolean);
  8654. /**
  8655. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8656. */
  8657. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8658. /**
  8659. * Method called each time the image processing information changes requires to recompile the effect.
  8660. */
  8661. protected _updateParameters(): void;
  8662. /**
  8663. * Gets the current class name.
  8664. * @return "ImageProcessingConfiguration"
  8665. */
  8666. getClassName(): string;
  8667. /**
  8668. * Prepare the list of uniforms associated with the Image Processing effects.
  8669. * @param uniforms The list of uniforms used in the effect
  8670. * @param defines the list of defines currently in use
  8671. */
  8672. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8673. /**
  8674. * Prepare the list of samplers associated with the Image Processing effects.
  8675. * @param samplersList The list of uniforms used in the effect
  8676. * @param defines the list of defines currently in use
  8677. */
  8678. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8679. /**
  8680. * Prepare the list of defines associated to the shader.
  8681. * @param defines the list of defines to complete
  8682. * @param forPostProcess Define if we are currently in post process mode or not
  8683. */
  8684. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8685. /**
  8686. * Returns true if all the image processing information are ready.
  8687. * @returns True if ready, otherwise, false
  8688. */
  8689. isReady(): boolean;
  8690. /**
  8691. * Binds the image processing to the shader.
  8692. * @param effect The effect to bind to
  8693. * @param overrideAspectRatio Override the aspect ratio of the effect
  8694. */
  8695. bind(effect: Effect, overrideAspectRatio?: number): void;
  8696. /**
  8697. * Clones the current image processing instance.
  8698. * @return The cloned image processing
  8699. */
  8700. clone(): ImageProcessingConfiguration;
  8701. /**
  8702. * Serializes the current image processing instance to a json representation.
  8703. * @return a JSON representation
  8704. */
  8705. serialize(): any;
  8706. /**
  8707. * Parses the image processing from a json representation.
  8708. * @param source the JSON source to parse
  8709. * @return The parsed image processing
  8710. */
  8711. static Parse(source: any): ImageProcessingConfiguration;
  8712. private static _VIGNETTEMODE_MULTIPLY;
  8713. private static _VIGNETTEMODE_OPAQUE;
  8714. /**
  8715. * Used to apply the vignette as a mix with the pixel color.
  8716. */
  8717. static get VIGNETTEMODE_MULTIPLY(): number;
  8718. /**
  8719. * Used to apply the vignette as a replacement of the pixel color.
  8720. */
  8721. static get VIGNETTEMODE_OPAQUE(): number;
  8722. }
  8723. }
  8724. declare module "babylonjs/Shaders/postprocess.vertex" {
  8725. /** @hidden */
  8726. export var postprocessVertexShader: {
  8727. name: string;
  8728. shader: string;
  8729. };
  8730. }
  8731. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8732. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8733. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8734. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8735. /**
  8736. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8737. */
  8738. export type RenderTargetTextureSize = number | {
  8739. width: number;
  8740. height: number;
  8741. layers?: number;
  8742. };
  8743. module "babylonjs/Engines/thinEngine" {
  8744. interface ThinEngine {
  8745. /**
  8746. * Creates a new render target texture
  8747. * @param size defines the size of the texture
  8748. * @param options defines the options used to create the texture
  8749. * @returns a new render target texture stored in an InternalTexture
  8750. */
  8751. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8752. /**
  8753. * Creates a depth stencil texture.
  8754. * This is only available in WebGL 2 or with the depth texture extension available.
  8755. * @param size The size of face edge in the texture.
  8756. * @param options The options defining the texture.
  8757. * @returns The texture
  8758. */
  8759. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8760. /** @hidden */
  8761. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8762. }
  8763. }
  8764. }
  8765. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8766. /**
  8767. * Defines the kind of connection point for node based material
  8768. */
  8769. export enum NodeMaterialBlockConnectionPointTypes {
  8770. /** Float */
  8771. Float = 1,
  8772. /** Int */
  8773. Int = 2,
  8774. /** Vector2 */
  8775. Vector2 = 4,
  8776. /** Vector3 */
  8777. Vector3 = 8,
  8778. /** Vector4 */
  8779. Vector4 = 16,
  8780. /** Color3 */
  8781. Color3 = 32,
  8782. /** Color4 */
  8783. Color4 = 64,
  8784. /** Matrix */
  8785. Matrix = 128,
  8786. /** Custom object */
  8787. Object = 256,
  8788. /** Detect type based on connection */
  8789. AutoDetect = 1024,
  8790. /** Output type that will be defined by input type */
  8791. BasedOnInput = 2048
  8792. }
  8793. }
  8794. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8795. /**
  8796. * Enum used to define the target of a block
  8797. */
  8798. export enum NodeMaterialBlockTargets {
  8799. /** Vertex shader */
  8800. Vertex = 1,
  8801. /** Fragment shader */
  8802. Fragment = 2,
  8803. /** Neutral */
  8804. Neutral = 4,
  8805. /** Vertex and Fragment */
  8806. VertexAndFragment = 3
  8807. }
  8808. }
  8809. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8810. /**
  8811. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8812. */
  8813. export enum NodeMaterialBlockConnectionPointMode {
  8814. /** Value is an uniform */
  8815. Uniform = 0,
  8816. /** Value is a mesh attribute */
  8817. Attribute = 1,
  8818. /** Value is a varying between vertex and fragment shaders */
  8819. Varying = 2,
  8820. /** Mode is undefined */
  8821. Undefined = 3
  8822. }
  8823. }
  8824. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8825. /**
  8826. * Enum used to define system values e.g. values automatically provided by the system
  8827. */
  8828. export enum NodeMaterialSystemValues {
  8829. /** World */
  8830. World = 1,
  8831. /** View */
  8832. View = 2,
  8833. /** Projection */
  8834. Projection = 3,
  8835. /** ViewProjection */
  8836. ViewProjection = 4,
  8837. /** WorldView */
  8838. WorldView = 5,
  8839. /** WorldViewProjection */
  8840. WorldViewProjection = 6,
  8841. /** CameraPosition */
  8842. CameraPosition = 7,
  8843. /** Fog Color */
  8844. FogColor = 8,
  8845. /** Delta time */
  8846. DeltaTime = 9
  8847. }
  8848. }
  8849. declare module "babylonjs/Maths/math.axis" {
  8850. import { Vector3 } from "babylonjs/Maths/math.vector";
  8851. /** Defines supported spaces */
  8852. export enum Space {
  8853. /** Local (object) space */
  8854. LOCAL = 0,
  8855. /** World space */
  8856. WORLD = 1,
  8857. /** Bone space */
  8858. BONE = 2
  8859. }
  8860. /** Defines the 3 main axes */
  8861. export class Axis {
  8862. /** X axis */
  8863. static X: Vector3;
  8864. /** Y axis */
  8865. static Y: Vector3;
  8866. /** Z axis */
  8867. static Z: Vector3;
  8868. }
  8869. }
  8870. declare module "babylonjs/Maths/math.frustum" {
  8871. import { Matrix } from "babylonjs/Maths/math.vector";
  8872. import { DeepImmutable } from "babylonjs/types";
  8873. import { Plane } from "babylonjs/Maths/math.plane";
  8874. /**
  8875. * Represents a camera frustum
  8876. */
  8877. export class Frustum {
  8878. /**
  8879. * Gets the planes representing the frustum
  8880. * @param transform matrix to be applied to the returned planes
  8881. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8882. */
  8883. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8884. /**
  8885. * Gets the near frustum plane transformed by the transform matrix
  8886. * @param transform transformation matrix to be applied to the resulting frustum plane
  8887. * @param frustumPlane the resuling frustum plane
  8888. */
  8889. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8890. /**
  8891. * Gets the far frustum plane transformed by the transform matrix
  8892. * @param transform transformation matrix to be applied to the resulting frustum plane
  8893. * @param frustumPlane the resuling frustum plane
  8894. */
  8895. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8896. /**
  8897. * Gets the left frustum plane transformed by the transform matrix
  8898. * @param transform transformation matrix to be applied to the resulting frustum plane
  8899. * @param frustumPlane the resuling frustum plane
  8900. */
  8901. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8902. /**
  8903. * Gets the right frustum plane transformed by the transform matrix
  8904. * @param transform transformation matrix to be applied to the resulting frustum plane
  8905. * @param frustumPlane the resuling frustum plane
  8906. */
  8907. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8908. /**
  8909. * Gets the top frustum plane transformed by the transform matrix
  8910. * @param transform transformation matrix to be applied to the resulting frustum plane
  8911. * @param frustumPlane the resuling frustum plane
  8912. */
  8913. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8914. /**
  8915. * Gets the bottom frustum plane transformed by the transform matrix
  8916. * @param transform transformation matrix to be applied to the resulting frustum plane
  8917. * @param frustumPlane the resuling frustum plane
  8918. */
  8919. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8920. /**
  8921. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8922. * @param transform transformation matrix to be applied to the resulting frustum planes
  8923. * @param frustumPlanes the resuling frustum planes
  8924. */
  8925. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8926. }
  8927. }
  8928. declare module "babylonjs/Maths/math.size" {
  8929. /**
  8930. * Interface for the size containing width and height
  8931. */
  8932. export interface ISize {
  8933. /**
  8934. * Width
  8935. */
  8936. width: number;
  8937. /**
  8938. * Heighht
  8939. */
  8940. height: number;
  8941. }
  8942. /**
  8943. * Size containing widht and height
  8944. */
  8945. export class Size implements ISize {
  8946. /**
  8947. * Width
  8948. */
  8949. width: number;
  8950. /**
  8951. * Height
  8952. */
  8953. height: number;
  8954. /**
  8955. * Creates a Size object from the given width and height (floats).
  8956. * @param width width of the new size
  8957. * @param height height of the new size
  8958. */
  8959. constructor(width: number, height: number);
  8960. /**
  8961. * Returns a string with the Size width and height
  8962. * @returns a string with the Size width and height
  8963. */
  8964. toString(): string;
  8965. /**
  8966. * "Size"
  8967. * @returns the string "Size"
  8968. */
  8969. getClassName(): string;
  8970. /**
  8971. * Returns the Size hash code.
  8972. * @returns a hash code for a unique width and height
  8973. */
  8974. getHashCode(): number;
  8975. /**
  8976. * Updates the current size from the given one.
  8977. * @param src the given size
  8978. */
  8979. copyFrom(src: Size): void;
  8980. /**
  8981. * Updates in place the current Size from the given floats.
  8982. * @param width width of the new size
  8983. * @param height height of the new size
  8984. * @returns the updated Size.
  8985. */
  8986. copyFromFloats(width: number, height: number): Size;
  8987. /**
  8988. * Updates in place the current Size from the given floats.
  8989. * @param width width to set
  8990. * @param height height to set
  8991. * @returns the updated Size.
  8992. */
  8993. set(width: number, height: number): Size;
  8994. /**
  8995. * Multiplies the width and height by numbers
  8996. * @param w factor to multiple the width by
  8997. * @param h factor to multiple the height by
  8998. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8999. */
  9000. multiplyByFloats(w: number, h: number): Size;
  9001. /**
  9002. * Clones the size
  9003. * @returns a new Size copied from the given one.
  9004. */
  9005. clone(): Size;
  9006. /**
  9007. * True if the current Size and the given one width and height are strictly equal.
  9008. * @param other the other size to compare against
  9009. * @returns True if the current Size and the given one width and height are strictly equal.
  9010. */
  9011. equals(other: Size): boolean;
  9012. /**
  9013. * The surface of the Size : width * height (float).
  9014. */
  9015. get surface(): number;
  9016. /**
  9017. * Create a new size of zero
  9018. * @returns a new Size set to (0.0, 0.0)
  9019. */
  9020. static Zero(): Size;
  9021. /**
  9022. * Sums the width and height of two sizes
  9023. * @param otherSize size to add to this size
  9024. * @returns a new Size set as the addition result of the current Size and the given one.
  9025. */
  9026. add(otherSize: Size): Size;
  9027. /**
  9028. * Subtracts the width and height of two
  9029. * @param otherSize size to subtract to this size
  9030. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9031. */
  9032. subtract(otherSize: Size): Size;
  9033. /**
  9034. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9035. * @param start starting size to lerp between
  9036. * @param end end size to lerp between
  9037. * @param amount amount to lerp between the start and end values
  9038. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9039. */
  9040. static Lerp(start: Size, end: Size, amount: number): Size;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math.vertexFormat" {
  9044. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9045. /**
  9046. * Contains position and normal vectors for a vertex
  9047. */
  9048. export class PositionNormalVertex {
  9049. /** the position of the vertex (defaut: 0,0,0) */
  9050. position: Vector3;
  9051. /** the normal of the vertex (defaut: 0,1,0) */
  9052. normal: Vector3;
  9053. /**
  9054. * Creates a PositionNormalVertex
  9055. * @param position the position of the vertex (defaut: 0,0,0)
  9056. * @param normal the normal of the vertex (defaut: 0,1,0)
  9057. */
  9058. constructor(
  9059. /** the position of the vertex (defaut: 0,0,0) */
  9060. position?: Vector3,
  9061. /** the normal of the vertex (defaut: 0,1,0) */
  9062. normal?: Vector3);
  9063. /**
  9064. * Clones the PositionNormalVertex
  9065. * @returns the cloned PositionNormalVertex
  9066. */
  9067. clone(): PositionNormalVertex;
  9068. }
  9069. /**
  9070. * Contains position, normal and uv vectors for a vertex
  9071. */
  9072. export class PositionNormalTextureVertex {
  9073. /** the position of the vertex (defaut: 0,0,0) */
  9074. position: Vector3;
  9075. /** the normal of the vertex (defaut: 0,1,0) */
  9076. normal: Vector3;
  9077. /** the uv of the vertex (default: 0,0) */
  9078. uv: Vector2;
  9079. /**
  9080. * Creates a PositionNormalTextureVertex
  9081. * @param position the position of the vertex (defaut: 0,0,0)
  9082. * @param normal the normal of the vertex (defaut: 0,1,0)
  9083. * @param uv the uv of the vertex (default: 0,0)
  9084. */
  9085. constructor(
  9086. /** the position of the vertex (defaut: 0,0,0) */
  9087. position?: Vector3,
  9088. /** the normal of the vertex (defaut: 0,1,0) */
  9089. normal?: Vector3,
  9090. /** the uv of the vertex (default: 0,0) */
  9091. uv?: Vector2);
  9092. /**
  9093. * Clones the PositionNormalTextureVertex
  9094. * @returns the cloned PositionNormalTextureVertex
  9095. */
  9096. clone(): PositionNormalTextureVertex;
  9097. }
  9098. }
  9099. declare module "babylonjs/Maths/math" {
  9100. export * from "babylonjs/Maths/math.axis";
  9101. export * from "babylonjs/Maths/math.color";
  9102. export * from "babylonjs/Maths/math.constants";
  9103. export * from "babylonjs/Maths/math.frustum";
  9104. export * from "babylonjs/Maths/math.path";
  9105. export * from "babylonjs/Maths/math.plane";
  9106. export * from "babylonjs/Maths/math.size";
  9107. export * from "babylonjs/Maths/math.vector";
  9108. export * from "babylonjs/Maths/math.vertexFormat";
  9109. export * from "babylonjs/Maths/math.viewport";
  9110. }
  9111. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9112. /**
  9113. * Enum defining the type of animations supported by InputBlock
  9114. */
  9115. export enum AnimatedInputBlockTypes {
  9116. /** No animation */
  9117. None = 0,
  9118. /** Time based animation. Will only work for floats */
  9119. Time = 1
  9120. }
  9121. }
  9122. declare module "babylonjs/Lights/shadowLight" {
  9123. import { Camera } from "babylonjs/Cameras/camera";
  9124. import { Scene } from "babylonjs/scene";
  9125. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9127. import { Light } from "babylonjs/Lights/light";
  9128. /**
  9129. * Interface describing all the common properties and methods a shadow light needs to implement.
  9130. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9131. * as well as binding the different shadow properties to the effects.
  9132. */
  9133. export interface IShadowLight extends Light {
  9134. /**
  9135. * The light id in the scene (used in scene.findLighById for instance)
  9136. */
  9137. id: string;
  9138. /**
  9139. * The position the shdow will be casted from.
  9140. */
  9141. position: Vector3;
  9142. /**
  9143. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9144. */
  9145. direction: Vector3;
  9146. /**
  9147. * The transformed position. Position of the light in world space taking parenting in account.
  9148. */
  9149. transformedPosition: Vector3;
  9150. /**
  9151. * The transformed direction. Direction of the light in world space taking parenting in account.
  9152. */
  9153. transformedDirection: Vector3;
  9154. /**
  9155. * The friendly name of the light in the scene.
  9156. */
  9157. name: string;
  9158. /**
  9159. * Defines the shadow projection clipping minimum z value.
  9160. */
  9161. shadowMinZ: number;
  9162. /**
  9163. * Defines the shadow projection clipping maximum z value.
  9164. */
  9165. shadowMaxZ: number;
  9166. /**
  9167. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9168. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9169. */
  9170. computeTransformedInformation(): boolean;
  9171. /**
  9172. * Gets the scene the light belongs to.
  9173. * @returns The scene
  9174. */
  9175. getScene(): Scene;
  9176. /**
  9177. * Callback defining a custom Projection Matrix Builder.
  9178. * This can be used to override the default projection matrix computation.
  9179. */
  9180. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9181. /**
  9182. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9183. * @param matrix The materix to updated with the projection information
  9184. * @param viewMatrix The transform matrix of the light
  9185. * @param renderList The list of mesh to render in the map
  9186. * @returns The current light
  9187. */
  9188. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9189. /**
  9190. * Gets the current depth scale used in ESM.
  9191. * @returns The scale
  9192. */
  9193. getDepthScale(): number;
  9194. /**
  9195. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9196. * @returns true if a cube texture needs to be use
  9197. */
  9198. needCube(): boolean;
  9199. /**
  9200. * Detects if the projection matrix requires to be recomputed this frame.
  9201. * @returns true if it requires to be recomputed otherwise, false.
  9202. */
  9203. needProjectionMatrixCompute(): boolean;
  9204. /**
  9205. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9206. */
  9207. forceProjectionMatrixCompute(): void;
  9208. /**
  9209. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9210. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9211. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9212. */
  9213. getShadowDirection(faceIndex?: number): Vector3;
  9214. /**
  9215. * Gets the minZ used for shadow according to both the scene and the light.
  9216. * @param activeCamera The camera we are returning the min for
  9217. * @returns the depth min z
  9218. */
  9219. getDepthMinZ(activeCamera: Camera): number;
  9220. /**
  9221. * Gets the maxZ used for shadow according to both the scene and the light.
  9222. * @param activeCamera The camera we are returning the max for
  9223. * @returns the depth max z
  9224. */
  9225. getDepthMaxZ(activeCamera: Camera): number;
  9226. }
  9227. /**
  9228. * Base implementation IShadowLight
  9229. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9230. */
  9231. export abstract class ShadowLight extends Light implements IShadowLight {
  9232. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9233. protected _position: Vector3;
  9234. protected _setPosition(value: Vector3): void;
  9235. /**
  9236. * Sets the position the shadow will be casted from. Also use as the light position for both
  9237. * point and spot lights.
  9238. */
  9239. get position(): Vector3;
  9240. /**
  9241. * Sets the position the shadow will be casted from. Also use as the light position for both
  9242. * point and spot lights.
  9243. */
  9244. set position(value: Vector3);
  9245. protected _direction: Vector3;
  9246. protected _setDirection(value: Vector3): void;
  9247. /**
  9248. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9249. * Also use as the light direction on spot and directional lights.
  9250. */
  9251. get direction(): Vector3;
  9252. /**
  9253. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9254. * Also use as the light direction on spot and directional lights.
  9255. */
  9256. set direction(value: Vector3);
  9257. protected _shadowMinZ: number;
  9258. /**
  9259. * Gets the shadow projection clipping minimum z value.
  9260. */
  9261. get shadowMinZ(): number;
  9262. /**
  9263. * Sets the shadow projection clipping minimum z value.
  9264. */
  9265. set shadowMinZ(value: number);
  9266. protected _shadowMaxZ: number;
  9267. /**
  9268. * Sets the shadow projection clipping maximum z value.
  9269. */
  9270. get shadowMaxZ(): number;
  9271. /**
  9272. * Gets the shadow projection clipping maximum z value.
  9273. */
  9274. set shadowMaxZ(value: number);
  9275. /**
  9276. * Callback defining a custom Projection Matrix Builder.
  9277. * This can be used to override the default projection matrix computation.
  9278. */
  9279. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9280. /**
  9281. * The transformed position. Position of the light in world space taking parenting in account.
  9282. */
  9283. transformedPosition: Vector3;
  9284. /**
  9285. * The transformed direction. Direction of the light in world space taking parenting in account.
  9286. */
  9287. transformedDirection: Vector3;
  9288. private _needProjectionMatrixCompute;
  9289. /**
  9290. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9291. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9292. */
  9293. computeTransformedInformation(): boolean;
  9294. /**
  9295. * Return the depth scale used for the shadow map.
  9296. * @returns the depth scale.
  9297. */
  9298. getDepthScale(): number;
  9299. /**
  9300. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9301. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9302. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9303. */
  9304. getShadowDirection(faceIndex?: number): Vector3;
  9305. /**
  9306. * Returns the ShadowLight absolute position in the World.
  9307. * @returns the position vector in world space
  9308. */
  9309. getAbsolutePosition(): Vector3;
  9310. /**
  9311. * Sets the ShadowLight direction toward the passed target.
  9312. * @param target The point to target in local space
  9313. * @returns the updated ShadowLight direction
  9314. */
  9315. setDirectionToTarget(target: Vector3): Vector3;
  9316. /**
  9317. * Returns the light rotation in euler definition.
  9318. * @returns the x y z rotation in local space.
  9319. */
  9320. getRotation(): Vector3;
  9321. /**
  9322. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9323. * @returns true if a cube texture needs to be use
  9324. */
  9325. needCube(): boolean;
  9326. /**
  9327. * Detects if the projection matrix requires to be recomputed this frame.
  9328. * @returns true if it requires to be recomputed otherwise, false.
  9329. */
  9330. needProjectionMatrixCompute(): boolean;
  9331. /**
  9332. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9333. */
  9334. forceProjectionMatrixCompute(): void;
  9335. /** @hidden */
  9336. _initCache(): void;
  9337. /** @hidden */
  9338. _isSynchronized(): boolean;
  9339. /**
  9340. * Computes the world matrix of the node
  9341. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9342. * @returns the world matrix
  9343. */
  9344. computeWorldMatrix(force?: boolean): Matrix;
  9345. /**
  9346. * Gets the minZ used for shadow according to both the scene and the light.
  9347. * @param activeCamera The camera we are returning the min for
  9348. * @returns the depth min z
  9349. */
  9350. getDepthMinZ(activeCamera: Camera): number;
  9351. /**
  9352. * Gets the maxZ used for shadow according to both the scene and the light.
  9353. * @param activeCamera The camera we are returning the max for
  9354. * @returns the depth max z
  9355. */
  9356. getDepthMaxZ(activeCamera: Camera): number;
  9357. /**
  9358. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9359. * @param matrix The materix to updated with the projection information
  9360. * @param viewMatrix The transform matrix of the light
  9361. * @param renderList The list of mesh to render in the map
  9362. * @returns The current light
  9363. */
  9364. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9365. }
  9366. }
  9367. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9368. /** @hidden */
  9369. export var packingFunctions: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9375. /** @hidden */
  9376. export var bayerDitherFunctions: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9382. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9383. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9384. /** @hidden */
  9385. export var shadowMapFragmentDeclaration: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9391. /** @hidden */
  9392. export var clipPlaneFragmentDeclaration: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9398. /** @hidden */
  9399. export var clipPlaneFragment: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9405. /** @hidden */
  9406. export var shadowMapFragment: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9412. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9413. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9414. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9415. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9416. /** @hidden */
  9417. export var shadowMapPixelShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9423. /** @hidden */
  9424. export var bonesDeclaration: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9430. /** @hidden */
  9431. export var morphTargetsVertexGlobalDeclaration: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9437. /** @hidden */
  9438. export var morphTargetsVertexDeclaration: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9444. /** @hidden */
  9445. export var instancesDeclaration: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9451. /** @hidden */
  9452. export var helperFunctions: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9458. /** @hidden */
  9459. export var shadowMapVertexDeclaration: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9465. /** @hidden */
  9466. export var clipPlaneVertexDeclaration: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9472. /** @hidden */
  9473. export var morphTargetsVertex: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9479. /** @hidden */
  9480. export var instancesVertex: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9486. /** @hidden */
  9487. export var bonesVertex: {
  9488. name: string;
  9489. shader: string;
  9490. };
  9491. }
  9492. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9493. /** @hidden */
  9494. export var shadowMapVertexNormalBias: {
  9495. name: string;
  9496. shader: string;
  9497. };
  9498. }
  9499. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9500. /** @hidden */
  9501. export var shadowMapVertexMetric: {
  9502. name: string;
  9503. shader: string;
  9504. };
  9505. }
  9506. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9507. /** @hidden */
  9508. export var clipPlaneVertex: {
  9509. name: string;
  9510. shader: string;
  9511. };
  9512. }
  9513. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9514. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9515. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9516. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9517. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9518. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9519. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9520. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9521. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9522. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9523. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9524. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9525. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9526. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9527. /** @hidden */
  9528. export var shadowMapVertexShader: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9534. /** @hidden */
  9535. export var depthBoxBlurPixelShader: {
  9536. name: string;
  9537. shader: string;
  9538. };
  9539. }
  9540. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9541. /** @hidden */
  9542. export var shadowMapFragmentSoftTransparentShadow: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module "babylonjs/Materials/effectFallbacks" {
  9548. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9549. import { Effect } from "babylonjs/Materials/effect";
  9550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9551. /**
  9552. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9553. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9554. */
  9555. export class EffectFallbacks implements IEffectFallbacks {
  9556. private _defines;
  9557. private _currentRank;
  9558. private _maxRank;
  9559. private _mesh;
  9560. /**
  9561. * Removes the fallback from the bound mesh.
  9562. */
  9563. unBindMesh(): void;
  9564. /**
  9565. * Adds a fallback on the specified property.
  9566. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9567. * @param define The name of the define in the shader
  9568. */
  9569. addFallback(rank: number, define: string): void;
  9570. /**
  9571. * Sets the mesh to use CPU skinning when needing to fallback.
  9572. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9573. * @param mesh The mesh to use the fallbacks.
  9574. */
  9575. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9576. /**
  9577. * Checks to see if more fallbacks are still availible.
  9578. */
  9579. get hasMoreFallbacks(): boolean;
  9580. /**
  9581. * Removes the defines that should be removed when falling back.
  9582. * @param currentDefines defines the current define statements for the shader.
  9583. * @param effect defines the current effect we try to compile
  9584. * @returns The resulting defines with defines of the current rank removed.
  9585. */
  9586. reduce(currentDefines: string, effect: Effect): string;
  9587. }
  9588. }
  9589. declare module "babylonjs/Actions/action" {
  9590. import { Observable } from "babylonjs/Misc/observable";
  9591. import { Condition } from "babylonjs/Actions/condition";
  9592. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9593. import { Nullable } from "babylonjs/types";
  9594. import { Scene } from "babylonjs/scene";
  9595. import { ActionManager } from "babylonjs/Actions/actionManager";
  9596. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9597. import { Node } from "babylonjs/node";
  9598. /**
  9599. * Interface used to define Action
  9600. */
  9601. export interface IAction {
  9602. /**
  9603. * Trigger for the action
  9604. */
  9605. trigger: number;
  9606. /** Options of the trigger */
  9607. triggerOptions: any;
  9608. /**
  9609. * Gets the trigger parameters
  9610. * @returns the trigger parameters
  9611. */
  9612. getTriggerParameter(): any;
  9613. /**
  9614. * Internal only - executes current action event
  9615. * @hidden
  9616. */
  9617. _executeCurrent(evt?: ActionEvent): void;
  9618. /**
  9619. * Serialize placeholder for child classes
  9620. * @param parent of child
  9621. * @returns the serialized object
  9622. */
  9623. serialize(parent: any): any;
  9624. /**
  9625. * Internal only
  9626. * @hidden
  9627. */
  9628. _prepare(): void;
  9629. /**
  9630. * Internal only - manager for action
  9631. * @hidden
  9632. */
  9633. _actionManager: Nullable<AbstractActionManager>;
  9634. /**
  9635. * Adds action to chain of actions, may be a DoNothingAction
  9636. * @param action defines the next action to execute
  9637. * @returns The action passed in
  9638. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9639. */
  9640. then(action: IAction): IAction;
  9641. }
  9642. /**
  9643. * The action to be carried out following a trigger
  9644. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9645. */
  9646. export class Action implements IAction {
  9647. /** the trigger, with or without parameters, for the action */
  9648. triggerOptions: any;
  9649. /**
  9650. * Trigger for the action
  9651. */
  9652. trigger: number;
  9653. /**
  9654. * Internal only - manager for action
  9655. * @hidden
  9656. */
  9657. _actionManager: ActionManager;
  9658. private _nextActiveAction;
  9659. private _child;
  9660. private _condition?;
  9661. private _triggerParameter;
  9662. /**
  9663. * An event triggered prior to action being executed.
  9664. */
  9665. onBeforeExecuteObservable: Observable<Action>;
  9666. /**
  9667. * Creates a new Action
  9668. * @param triggerOptions the trigger, with or without parameters, for the action
  9669. * @param condition an optional determinant of action
  9670. */
  9671. constructor(
  9672. /** the trigger, with or without parameters, for the action */
  9673. triggerOptions: any, condition?: Condition);
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. _prepare(): void;
  9679. /**
  9680. * Gets the trigger parameters
  9681. * @returns the trigger parameters
  9682. */
  9683. getTriggerParameter(): any;
  9684. /**
  9685. * Internal only - executes current action event
  9686. * @hidden
  9687. */
  9688. _executeCurrent(evt?: ActionEvent): void;
  9689. /**
  9690. * Execute placeholder for child classes
  9691. * @param evt optional action event
  9692. */
  9693. execute(evt?: ActionEvent): void;
  9694. /**
  9695. * Skips to next active action
  9696. */
  9697. skipToNextActiveAction(): void;
  9698. /**
  9699. * Adds action to chain of actions, may be a DoNothingAction
  9700. * @param action defines the next action to execute
  9701. * @returns The action passed in
  9702. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9703. */
  9704. then(action: Action): Action;
  9705. /**
  9706. * Internal only
  9707. * @hidden
  9708. */
  9709. _getProperty(propertyPath: string): string;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. _getEffectiveTarget(target: any, propertyPath: string): any;
  9715. /**
  9716. * Serialize placeholder for child classes
  9717. * @param parent of child
  9718. * @returns the serialized object
  9719. */
  9720. serialize(parent: any): any;
  9721. /**
  9722. * Internal only called by serialize
  9723. * @hidden
  9724. */
  9725. protected _serialize(serializedAction: any, parent?: any): any;
  9726. /**
  9727. * Internal only
  9728. * @hidden
  9729. */
  9730. static _SerializeValueAsString: (value: any) => string;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. static _GetTargetProperty: (target: Scene | Node) => {
  9736. name: string;
  9737. targetType: string;
  9738. value: string;
  9739. };
  9740. }
  9741. }
  9742. declare module "babylonjs/Actions/condition" {
  9743. import { ActionManager } from "babylonjs/Actions/actionManager";
  9744. /**
  9745. * A Condition applied to an Action
  9746. */
  9747. export class Condition {
  9748. /**
  9749. * Internal only - manager for action
  9750. * @hidden
  9751. */
  9752. _actionManager: ActionManager;
  9753. /**
  9754. * Internal only
  9755. * @hidden
  9756. */
  9757. _evaluationId: number;
  9758. /**
  9759. * Internal only
  9760. * @hidden
  9761. */
  9762. _currentResult: boolean;
  9763. /**
  9764. * Creates a new Condition
  9765. * @param actionManager the manager of the action the condition is applied to
  9766. */
  9767. constructor(actionManager: ActionManager);
  9768. /**
  9769. * Check if the current condition is valid
  9770. * @returns a boolean
  9771. */
  9772. isValid(): boolean;
  9773. /**
  9774. * Internal only
  9775. * @hidden
  9776. */
  9777. _getProperty(propertyPath: string): string;
  9778. /**
  9779. * Internal only
  9780. * @hidden
  9781. */
  9782. _getEffectiveTarget(target: any, propertyPath: string): any;
  9783. /**
  9784. * Serialize placeholder for child classes
  9785. * @returns the serialized object
  9786. */
  9787. serialize(): any;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. protected _serialize(serializedCondition: any): any;
  9793. }
  9794. /**
  9795. * Defines specific conditional operators as extensions of Condition
  9796. */
  9797. export class ValueCondition extends Condition {
  9798. /** path to specify the property of the target the conditional operator uses */
  9799. propertyPath: string;
  9800. /** the value compared by the conditional operator against the current value of the property */
  9801. value: any;
  9802. /** the conditional operator, default ValueCondition.IsEqual */
  9803. operator: number;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. private static _IsEqual;
  9809. /**
  9810. * Internal only
  9811. * @hidden
  9812. */
  9813. private static _IsDifferent;
  9814. /**
  9815. * Internal only
  9816. * @hidden
  9817. */
  9818. private static _IsGreater;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private static _IsLesser;
  9824. /**
  9825. * returns the number for IsEqual
  9826. */
  9827. static get IsEqual(): number;
  9828. /**
  9829. * Returns the number for IsDifferent
  9830. */
  9831. static get IsDifferent(): number;
  9832. /**
  9833. * Returns the number for IsGreater
  9834. */
  9835. static get IsGreater(): number;
  9836. /**
  9837. * Returns the number for IsLesser
  9838. */
  9839. static get IsLesser(): number;
  9840. /**
  9841. * Internal only The action manager for the condition
  9842. * @hidden
  9843. */
  9844. _actionManager: ActionManager;
  9845. /**
  9846. * Internal only
  9847. * @hidden
  9848. */
  9849. private _target;
  9850. /**
  9851. * Internal only
  9852. * @hidden
  9853. */
  9854. private _effectiveTarget;
  9855. /**
  9856. * Internal only
  9857. * @hidden
  9858. */
  9859. private _property;
  9860. /**
  9861. * Creates a new ValueCondition
  9862. * @param actionManager manager for the action the condition applies to
  9863. * @param target for the action
  9864. * @param propertyPath path to specify the property of the target the conditional operator uses
  9865. * @param value the value compared by the conditional operator against the current value of the property
  9866. * @param operator the conditional operator, default ValueCondition.IsEqual
  9867. */
  9868. constructor(actionManager: ActionManager, target: any,
  9869. /** path to specify the property of the target the conditional operator uses */
  9870. propertyPath: string,
  9871. /** the value compared by the conditional operator against the current value of the property */
  9872. value: any,
  9873. /** the conditional operator, default ValueCondition.IsEqual */
  9874. operator?: number);
  9875. /**
  9876. * Compares the given value with the property value for the specified conditional operator
  9877. * @returns the result of the comparison
  9878. */
  9879. isValid(): boolean;
  9880. /**
  9881. * Serialize the ValueCondition into a JSON compatible object
  9882. * @returns serialization object
  9883. */
  9884. serialize(): any;
  9885. /**
  9886. * Gets the name of the conditional operator for the ValueCondition
  9887. * @param operator the conditional operator
  9888. * @returns the name
  9889. */
  9890. static GetOperatorName(operator: number): string;
  9891. }
  9892. /**
  9893. * Defines a predicate condition as an extension of Condition
  9894. */
  9895. export class PredicateCondition extends Condition {
  9896. /** defines the predicate function used to validate the condition */
  9897. predicate: () => boolean;
  9898. /**
  9899. * Internal only - manager for action
  9900. * @hidden
  9901. */
  9902. _actionManager: ActionManager;
  9903. /**
  9904. * Creates a new PredicateCondition
  9905. * @param actionManager manager for the action the condition applies to
  9906. * @param predicate defines the predicate function used to validate the condition
  9907. */
  9908. constructor(actionManager: ActionManager,
  9909. /** defines the predicate function used to validate the condition */
  9910. predicate: () => boolean);
  9911. /**
  9912. * @returns the validity of the predicate condition
  9913. */
  9914. isValid(): boolean;
  9915. }
  9916. /**
  9917. * Defines a state condition as an extension of Condition
  9918. */
  9919. export class StateCondition extends Condition {
  9920. /** Value to compare with target state */
  9921. value: string;
  9922. /**
  9923. * Internal only - manager for action
  9924. * @hidden
  9925. */
  9926. _actionManager: ActionManager;
  9927. /**
  9928. * Internal only
  9929. * @hidden
  9930. */
  9931. private _target;
  9932. /**
  9933. * Creates a new StateCondition
  9934. * @param actionManager manager for the action the condition applies to
  9935. * @param target of the condition
  9936. * @param value to compare with target state
  9937. */
  9938. constructor(actionManager: ActionManager, target: any,
  9939. /** Value to compare with target state */
  9940. value: string);
  9941. /**
  9942. * Gets a boolean indicating if the current condition is met
  9943. * @returns the validity of the state
  9944. */
  9945. isValid(): boolean;
  9946. /**
  9947. * Serialize the StateCondition into a JSON compatible object
  9948. * @returns serialization object
  9949. */
  9950. serialize(): any;
  9951. }
  9952. }
  9953. declare module "babylonjs/Actions/directActions" {
  9954. import { Action } from "babylonjs/Actions/action";
  9955. import { Condition } from "babylonjs/Actions/condition";
  9956. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9957. /**
  9958. * This defines an action responsible to toggle a boolean once triggered.
  9959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9960. */
  9961. export class SwitchBooleanAction extends Action {
  9962. /**
  9963. * The path to the boolean property in the target object
  9964. */
  9965. propertyPath: string;
  9966. private _target;
  9967. private _effectiveTarget;
  9968. private _property;
  9969. /**
  9970. * Instantiate the action
  9971. * @param triggerOptions defines the trigger options
  9972. * @param target defines the object containing the boolean
  9973. * @param propertyPath defines the path to the boolean property in the target object
  9974. * @param condition defines the trigger related conditions
  9975. */
  9976. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9977. /** @hidden */
  9978. _prepare(): void;
  9979. /**
  9980. * Execute the action toggle the boolean value.
  9981. */
  9982. execute(): void;
  9983. /**
  9984. * Serializes the actions and its related information.
  9985. * @param parent defines the object to serialize in
  9986. * @returns the serialized object
  9987. */
  9988. serialize(parent: any): any;
  9989. }
  9990. /**
  9991. * This defines an action responsible to set a the state field of the target
  9992. * to a desired value once triggered.
  9993. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9994. */
  9995. export class SetStateAction extends Action {
  9996. /**
  9997. * The value to store in the state field.
  9998. */
  9999. value: string;
  10000. private _target;
  10001. /**
  10002. * Instantiate the action
  10003. * @param triggerOptions defines the trigger options
  10004. * @param target defines the object containing the state property
  10005. * @param value defines the value to store in the state field
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10009. /**
  10010. * Execute the action and store the value on the target state property.
  10011. */
  10012. execute(): void;
  10013. /**
  10014. * Serializes the actions and its related information.
  10015. * @param parent defines the object to serialize in
  10016. * @returns the serialized object
  10017. */
  10018. serialize(parent: any): any;
  10019. }
  10020. /**
  10021. * This defines an action responsible to set a property of the target
  10022. * to a desired value once triggered.
  10023. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10024. */
  10025. export class SetValueAction extends Action {
  10026. /**
  10027. * The path of the property to set in the target.
  10028. */
  10029. propertyPath: string;
  10030. /**
  10031. * The value to set in the property
  10032. */
  10033. value: any;
  10034. private _target;
  10035. private _effectiveTarget;
  10036. private _property;
  10037. /**
  10038. * Instantiate the action
  10039. * @param triggerOptions defines the trigger options
  10040. * @param target defines the object containing the property
  10041. * @param propertyPath defines the path of the property to set in the target
  10042. * @param value defines the value to set in the property
  10043. * @param condition defines the trigger related conditions
  10044. */
  10045. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10046. /** @hidden */
  10047. _prepare(): void;
  10048. /**
  10049. * Execute the action and set the targetted property to the desired value.
  10050. */
  10051. execute(): void;
  10052. /**
  10053. * Serializes the actions and its related information.
  10054. * @param parent defines the object to serialize in
  10055. * @returns the serialized object
  10056. */
  10057. serialize(parent: any): any;
  10058. }
  10059. /**
  10060. * This defines an action responsible to increment the target value
  10061. * to a desired value once triggered.
  10062. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10063. */
  10064. export class IncrementValueAction extends Action {
  10065. /**
  10066. * The path of the property to increment in the target.
  10067. */
  10068. propertyPath: string;
  10069. /**
  10070. * The value we should increment the property by.
  10071. */
  10072. value: any;
  10073. private _target;
  10074. private _effectiveTarget;
  10075. private _property;
  10076. /**
  10077. * Instantiate the action
  10078. * @param triggerOptions defines the trigger options
  10079. * @param target defines the object containing the property
  10080. * @param propertyPath defines the path of the property to increment in the target
  10081. * @param value defines the value value we should increment the property by
  10082. * @param condition defines the trigger related conditions
  10083. */
  10084. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10085. /** @hidden */
  10086. _prepare(): void;
  10087. /**
  10088. * Execute the action and increment the target of the value amount.
  10089. */
  10090. execute(): void;
  10091. /**
  10092. * Serializes the actions and its related information.
  10093. * @param parent defines the object to serialize in
  10094. * @returns the serialized object
  10095. */
  10096. serialize(parent: any): any;
  10097. }
  10098. /**
  10099. * This defines an action responsible to start an animation once triggered.
  10100. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10101. */
  10102. export class PlayAnimationAction extends Action {
  10103. /**
  10104. * Where the animation should start (animation frame)
  10105. */
  10106. from: number;
  10107. /**
  10108. * Where the animation should stop (animation frame)
  10109. */
  10110. to: number;
  10111. /**
  10112. * Define if the animation should loop or stop after the first play.
  10113. */
  10114. loop?: boolean;
  10115. private _target;
  10116. /**
  10117. * Instantiate the action
  10118. * @param triggerOptions defines the trigger options
  10119. * @param target defines the target animation or animation name
  10120. * @param from defines from where the animation should start (animation frame)
  10121. * @param end defines where the animation should stop (animation frame)
  10122. * @param loop defines if the animation should loop or stop after the first play
  10123. * @param condition defines the trigger related conditions
  10124. */
  10125. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10126. /** @hidden */
  10127. _prepare(): void;
  10128. /**
  10129. * Execute the action and play the animation.
  10130. */
  10131. execute(): void;
  10132. /**
  10133. * Serializes the actions and its related information.
  10134. * @param parent defines the object to serialize in
  10135. * @returns the serialized object
  10136. */
  10137. serialize(parent: any): any;
  10138. }
  10139. /**
  10140. * This defines an action responsible to stop an animation once triggered.
  10141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10142. */
  10143. export class StopAnimationAction extends Action {
  10144. private _target;
  10145. /**
  10146. * Instantiate the action
  10147. * @param triggerOptions defines the trigger options
  10148. * @param target defines the target animation or animation name
  10149. * @param condition defines the trigger related conditions
  10150. */
  10151. constructor(triggerOptions: any, target: any, condition?: Condition);
  10152. /** @hidden */
  10153. _prepare(): void;
  10154. /**
  10155. * Execute the action and stop the animation.
  10156. */
  10157. execute(): void;
  10158. /**
  10159. * Serializes the actions and its related information.
  10160. * @param parent defines the object to serialize in
  10161. * @returns the serialized object
  10162. */
  10163. serialize(parent: any): any;
  10164. }
  10165. /**
  10166. * This defines an action responsible that does nothing once triggered.
  10167. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10168. */
  10169. export class DoNothingAction extends Action {
  10170. /**
  10171. * Instantiate the action
  10172. * @param triggerOptions defines the trigger options
  10173. * @param condition defines the trigger related conditions
  10174. */
  10175. constructor(triggerOptions?: any, condition?: Condition);
  10176. /**
  10177. * Execute the action and do nothing.
  10178. */
  10179. execute(): void;
  10180. /**
  10181. * Serializes the actions and its related information.
  10182. * @param parent defines the object to serialize in
  10183. * @returns the serialized object
  10184. */
  10185. serialize(parent: any): any;
  10186. }
  10187. /**
  10188. * This defines an action responsible to trigger several actions once triggered.
  10189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10190. */
  10191. export class CombineAction extends Action {
  10192. /**
  10193. * The list of aggregated animations to run.
  10194. */
  10195. children: Action[];
  10196. /**
  10197. * Instantiate the action
  10198. * @param triggerOptions defines the trigger options
  10199. * @param children defines the list of aggregated animations to run
  10200. * @param condition defines the trigger related conditions
  10201. */
  10202. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10203. /** @hidden */
  10204. _prepare(): void;
  10205. /**
  10206. * Execute the action and executes all the aggregated actions.
  10207. */
  10208. execute(evt: ActionEvent): void;
  10209. /**
  10210. * Serializes the actions and its related information.
  10211. * @param parent defines the object to serialize in
  10212. * @returns the serialized object
  10213. */
  10214. serialize(parent: any): any;
  10215. }
  10216. /**
  10217. * This defines an action responsible to run code (external event) once triggered.
  10218. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10219. */
  10220. export class ExecuteCodeAction extends Action {
  10221. /**
  10222. * The callback function to run.
  10223. */
  10224. func: (evt: ActionEvent) => void;
  10225. /**
  10226. * Instantiate the action
  10227. * @param triggerOptions defines the trigger options
  10228. * @param func defines the callback function to run
  10229. * @param condition defines the trigger related conditions
  10230. */
  10231. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10232. /**
  10233. * Execute the action and run the attached code.
  10234. */
  10235. execute(evt: ActionEvent): void;
  10236. }
  10237. /**
  10238. * This defines an action responsible to set the parent property of the target once triggered.
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10240. */
  10241. export class SetParentAction extends Action {
  10242. private _parent;
  10243. private _target;
  10244. /**
  10245. * Instantiate the action
  10246. * @param triggerOptions defines the trigger options
  10247. * @param target defines the target containing the parent property
  10248. * @param parent defines from where the animation should start (animation frame)
  10249. * @param condition defines the trigger related conditions
  10250. */
  10251. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10252. /** @hidden */
  10253. _prepare(): void;
  10254. /**
  10255. * Execute the action and set the parent property.
  10256. */
  10257. execute(): void;
  10258. /**
  10259. * Serializes the actions and its related information.
  10260. * @param parent defines the object to serialize in
  10261. * @returns the serialized object
  10262. */
  10263. serialize(parent: any): any;
  10264. }
  10265. }
  10266. declare module "babylonjs/Actions/actionManager" {
  10267. import { Nullable } from "babylonjs/types";
  10268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10269. import { Scene } from "babylonjs/scene";
  10270. import { IAction } from "babylonjs/Actions/action";
  10271. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10272. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10273. /**
  10274. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10275. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10276. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10277. */
  10278. export class ActionManager extends AbstractActionManager {
  10279. /**
  10280. * Nothing
  10281. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10282. */
  10283. static readonly NothingTrigger: number;
  10284. /**
  10285. * On pick
  10286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10287. */
  10288. static readonly OnPickTrigger: number;
  10289. /**
  10290. * On left pick
  10291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10292. */
  10293. static readonly OnLeftPickTrigger: number;
  10294. /**
  10295. * On right pick
  10296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10297. */
  10298. static readonly OnRightPickTrigger: number;
  10299. /**
  10300. * On center pick
  10301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10302. */
  10303. static readonly OnCenterPickTrigger: number;
  10304. /**
  10305. * On pick down
  10306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10307. */
  10308. static readonly OnPickDownTrigger: number;
  10309. /**
  10310. * On double pick
  10311. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10312. */
  10313. static readonly OnDoublePickTrigger: number;
  10314. /**
  10315. * On pick up
  10316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10317. */
  10318. static readonly OnPickUpTrigger: number;
  10319. /**
  10320. * On pick out.
  10321. * This trigger will only be raised if you also declared a OnPickDown
  10322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10323. */
  10324. static readonly OnPickOutTrigger: number;
  10325. /**
  10326. * On long press
  10327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10328. */
  10329. static readonly OnLongPressTrigger: number;
  10330. /**
  10331. * On pointer over
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPointerOverTrigger: number;
  10335. /**
  10336. * On pointer out
  10337. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10338. */
  10339. static readonly OnPointerOutTrigger: number;
  10340. /**
  10341. * On every frame
  10342. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10343. */
  10344. static readonly OnEveryFrameTrigger: number;
  10345. /**
  10346. * On intersection enter
  10347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10348. */
  10349. static readonly OnIntersectionEnterTrigger: number;
  10350. /**
  10351. * On intersection exit
  10352. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10353. */
  10354. static readonly OnIntersectionExitTrigger: number;
  10355. /**
  10356. * On key down
  10357. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10358. */
  10359. static readonly OnKeyDownTrigger: number;
  10360. /**
  10361. * On key up
  10362. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10363. */
  10364. static readonly OnKeyUpTrigger: number;
  10365. private _scene;
  10366. /**
  10367. * Creates a new action manager
  10368. * @param scene defines the hosting scene
  10369. */
  10370. constructor(scene: Scene);
  10371. /**
  10372. * Releases all associated resources
  10373. */
  10374. dispose(): void;
  10375. /**
  10376. * Gets hosting scene
  10377. * @returns the hosting scene
  10378. */
  10379. getScene(): Scene;
  10380. /**
  10381. * Does this action manager handles actions of any of the given triggers
  10382. * @param triggers defines the triggers to be tested
  10383. * @return a boolean indicating whether one (or more) of the triggers is handled
  10384. */
  10385. hasSpecificTriggers(triggers: number[]): boolean;
  10386. /**
  10387. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10388. * speed.
  10389. * @param triggerA defines the trigger to be tested
  10390. * @param triggerB defines the trigger to be tested
  10391. * @return a boolean indicating whether one (or more) of the triggers is handled
  10392. */
  10393. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10394. /**
  10395. * Does this action manager handles actions of a given trigger
  10396. * @param trigger defines the trigger to be tested
  10397. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10398. * @return whether the trigger is handled
  10399. */
  10400. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10401. /**
  10402. * Does this action manager has pointer triggers
  10403. */
  10404. get hasPointerTriggers(): boolean;
  10405. /**
  10406. * Does this action manager has pick triggers
  10407. */
  10408. get hasPickTriggers(): boolean;
  10409. /**
  10410. * Registers an action to this action manager
  10411. * @param action defines the action to be registered
  10412. * @return the action amended (prepared) after registration
  10413. */
  10414. registerAction(action: IAction): Nullable<IAction>;
  10415. /**
  10416. * Unregisters an action to this action manager
  10417. * @param action defines the action to be unregistered
  10418. * @return a boolean indicating whether the action has been unregistered
  10419. */
  10420. unregisterAction(action: IAction): Boolean;
  10421. /**
  10422. * Process a specific trigger
  10423. * @param trigger defines the trigger to process
  10424. * @param evt defines the event details to be processed
  10425. */
  10426. processTrigger(trigger: number, evt?: IActionEvent): void;
  10427. /** @hidden */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /** @hidden */
  10430. _getProperty(propertyPath: string): string;
  10431. /**
  10432. * Serialize this manager to a JSON object
  10433. * @param name defines the property name to store this manager
  10434. * @returns a JSON representation of this manager
  10435. */
  10436. serialize(name: string): any;
  10437. /**
  10438. * Creates a new ActionManager from a JSON data
  10439. * @param parsedActions defines the JSON data to read from
  10440. * @param object defines the hosting mesh
  10441. * @param scene defines the hosting scene
  10442. */
  10443. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10444. /**
  10445. * Get a trigger name by index
  10446. * @param trigger defines the trigger index
  10447. * @returns a trigger name
  10448. */
  10449. static GetTriggerName(trigger: number): string;
  10450. }
  10451. }
  10452. declare module "babylonjs/Sprites/sprite" {
  10453. import { Vector3 } from "babylonjs/Maths/math.vector";
  10454. import { Nullable } from "babylonjs/types";
  10455. import { ActionManager } from "babylonjs/Actions/actionManager";
  10456. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10457. import { Color4 } from "babylonjs/Maths/math.color";
  10458. import { Observable } from "babylonjs/Misc/observable";
  10459. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10460. import { Animation } from "babylonjs/Animations/animation";
  10461. /**
  10462. * Class used to represent a sprite
  10463. * @see https://doc.babylonjs.com/babylon101/sprites
  10464. */
  10465. export class Sprite implements IAnimatable {
  10466. /** defines the name */
  10467. name: string;
  10468. /** Gets or sets the current world position */
  10469. position: Vector3;
  10470. /** Gets or sets the main color */
  10471. color: Color4;
  10472. /** Gets or sets the width */
  10473. width: number;
  10474. /** Gets or sets the height */
  10475. height: number;
  10476. /** Gets or sets rotation angle */
  10477. angle: number;
  10478. /** Gets or sets the cell index in the sprite sheet */
  10479. cellIndex: number;
  10480. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10481. cellRef: string;
  10482. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10483. invertU: boolean;
  10484. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10485. invertV: boolean;
  10486. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10487. disposeWhenFinishedAnimating: boolean;
  10488. /** Gets the list of attached animations */
  10489. animations: Nullable<Array<Animation>>;
  10490. /** Gets or sets a boolean indicating if the sprite can be picked */
  10491. isPickable: boolean;
  10492. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10493. useAlphaForPicking: boolean;
  10494. /** @hidden */
  10495. _xOffset: number;
  10496. /** @hidden */
  10497. _yOffset: number;
  10498. /** @hidden */
  10499. _xSize: number;
  10500. /** @hidden */
  10501. _ySize: number;
  10502. /**
  10503. * Gets or sets the associated action manager
  10504. */
  10505. actionManager: Nullable<ActionManager>;
  10506. /**
  10507. * An event triggered when the control has been disposed
  10508. */
  10509. onDisposeObservable: Observable<Sprite>;
  10510. private _animationStarted;
  10511. private _loopAnimation;
  10512. private _fromIndex;
  10513. private _toIndex;
  10514. private _delay;
  10515. private _direction;
  10516. private _manager;
  10517. private _time;
  10518. private _onAnimationEnd;
  10519. /**
  10520. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10521. */
  10522. isVisible: boolean;
  10523. /**
  10524. * Gets or sets the sprite size
  10525. */
  10526. get size(): number;
  10527. set size(value: number);
  10528. /**
  10529. * Returns a boolean indicating if the animation is started
  10530. */
  10531. get animationStarted(): boolean;
  10532. /**
  10533. * Gets or sets the unique id of the sprite
  10534. */
  10535. uniqueId: number;
  10536. /**
  10537. * Gets the manager of this sprite
  10538. */
  10539. get manager(): ISpriteManager;
  10540. /**
  10541. * Creates a new Sprite
  10542. * @param name defines the name
  10543. * @param manager defines the manager
  10544. */
  10545. constructor(
  10546. /** defines the name */
  10547. name: string, manager: ISpriteManager);
  10548. /**
  10549. * Returns the string "Sprite"
  10550. * @returns "Sprite"
  10551. */
  10552. getClassName(): string;
  10553. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10554. get fromIndex(): number;
  10555. set fromIndex(value: number);
  10556. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10557. get toIndex(): number;
  10558. set toIndex(value: number);
  10559. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10560. get loopAnimation(): boolean;
  10561. set loopAnimation(value: boolean);
  10562. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10563. get delay(): number;
  10564. set delay(value: number);
  10565. /**
  10566. * Starts an animation
  10567. * @param from defines the initial key
  10568. * @param to defines the end key
  10569. * @param loop defines if the animation must loop
  10570. * @param delay defines the start delay (in ms)
  10571. * @param onAnimationEnd defines a callback to call when animation ends
  10572. */
  10573. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10574. /** Stops current animation (if any) */
  10575. stopAnimation(): void;
  10576. /** @hidden */
  10577. _animate(deltaTime: number): void;
  10578. /** Release associated resources */
  10579. dispose(): void;
  10580. /**
  10581. * Serializes the sprite to a JSON object
  10582. * @returns the JSON object
  10583. */
  10584. serialize(): any;
  10585. /**
  10586. * Parses a JSON object to create a new sprite
  10587. * @param parsedSprite The JSON object to parse
  10588. * @param manager defines the hosting manager
  10589. * @returns the new sprite
  10590. */
  10591. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10592. }
  10593. }
  10594. declare module "babylonjs/Collisions/pickingInfo" {
  10595. import { Nullable } from "babylonjs/types";
  10596. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10598. import { Sprite } from "babylonjs/Sprites/sprite";
  10599. import { Ray } from "babylonjs/Culling/ray";
  10600. /**
  10601. * Information about the result of picking within a scene
  10602. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10603. */
  10604. export class PickingInfo {
  10605. /** @hidden */
  10606. _pickingUnavailable: boolean;
  10607. /**
  10608. * If the pick collided with an object
  10609. */
  10610. hit: boolean;
  10611. /**
  10612. * Distance away where the pick collided
  10613. */
  10614. distance: number;
  10615. /**
  10616. * The location of pick collision
  10617. */
  10618. pickedPoint: Nullable<Vector3>;
  10619. /**
  10620. * The mesh corresponding the the pick collision
  10621. */
  10622. pickedMesh: Nullable<AbstractMesh>;
  10623. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10624. bu: number;
  10625. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10626. bv: number;
  10627. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10628. faceId: number;
  10629. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10630. subMeshFaceId: number;
  10631. /** Id of the the submesh that was picked */
  10632. subMeshId: number;
  10633. /** If a sprite was picked, this will be the sprite the pick collided with */
  10634. pickedSprite: Nullable<Sprite>;
  10635. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10636. thinInstanceIndex: number;
  10637. /**
  10638. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10639. */
  10640. originMesh: Nullable<AbstractMesh>;
  10641. /**
  10642. * The ray that was used to perform the picking.
  10643. */
  10644. ray: Nullable<Ray>;
  10645. /**
  10646. * Gets the normal correspodning to the face the pick collided with
  10647. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10648. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10649. * @returns The normal correspodning to the face the pick collided with
  10650. */
  10651. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10652. /**
  10653. * Gets the texture coordinates of where the pick occured
  10654. * @returns the vector containing the coordnates of the texture
  10655. */
  10656. getTextureCoordinates(): Nullable<Vector2>;
  10657. }
  10658. }
  10659. declare module "babylonjs/Culling/ray" {
  10660. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10661. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10663. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10664. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10665. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10666. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10667. import { Plane } from "babylonjs/Maths/math.plane";
  10668. /**
  10669. * Class representing a ray with position and direction
  10670. */
  10671. export class Ray {
  10672. /** origin point */
  10673. origin: Vector3;
  10674. /** direction */
  10675. direction: Vector3;
  10676. /** length of the ray */
  10677. length: number;
  10678. private static readonly _TmpVector3;
  10679. private _tmpRay;
  10680. /**
  10681. * Creates a new ray
  10682. * @param origin origin point
  10683. * @param direction direction
  10684. * @param length length of the ray
  10685. */
  10686. constructor(
  10687. /** origin point */
  10688. origin: Vector3,
  10689. /** direction */
  10690. direction: Vector3,
  10691. /** length of the ray */
  10692. length?: number);
  10693. /**
  10694. * Checks if the ray intersects a box
  10695. * This does not account for the ray lenght by design to improve perfs.
  10696. * @param minimum bound of the box
  10697. * @param maximum bound of the box
  10698. * @param intersectionTreshold extra extend to be added to the box in all direction
  10699. * @returns if the box was hit
  10700. */
  10701. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10702. /**
  10703. * Checks if the ray intersects a box
  10704. * This does not account for the ray lenght by design to improve perfs.
  10705. * @param box the bounding box to check
  10706. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10707. * @returns if the box was hit
  10708. */
  10709. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10710. /**
  10711. * If the ray hits a sphere
  10712. * @param sphere the bounding sphere to check
  10713. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10714. * @returns true if it hits the sphere
  10715. */
  10716. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10717. /**
  10718. * If the ray hits a triange
  10719. * @param vertex0 triangle vertex
  10720. * @param vertex1 triangle vertex
  10721. * @param vertex2 triangle vertex
  10722. * @returns intersection information if hit
  10723. */
  10724. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10725. /**
  10726. * Checks if ray intersects a plane
  10727. * @param plane the plane to check
  10728. * @returns the distance away it was hit
  10729. */
  10730. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10731. /**
  10732. * Calculate the intercept of a ray on a given axis
  10733. * @param axis to check 'x' | 'y' | 'z'
  10734. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10735. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10736. */
  10737. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10738. /**
  10739. * Checks if ray intersects a mesh
  10740. * @param mesh the mesh to check
  10741. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10742. * @returns picking info of the intersecton
  10743. */
  10744. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10745. /**
  10746. * Checks if ray intersects a mesh
  10747. * @param meshes the meshes to check
  10748. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10749. * @param results array to store result in
  10750. * @returns Array of picking infos
  10751. */
  10752. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10753. private _comparePickingInfo;
  10754. private static smallnum;
  10755. private static rayl;
  10756. /**
  10757. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10758. * @param sega the first point of the segment to test the intersection against
  10759. * @param segb the second point of the segment to test the intersection against
  10760. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10761. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10762. */
  10763. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10764. /**
  10765. * Update the ray from viewport position
  10766. * @param x position
  10767. * @param y y position
  10768. * @param viewportWidth viewport width
  10769. * @param viewportHeight viewport height
  10770. * @param world world matrix
  10771. * @param view view matrix
  10772. * @param projection projection matrix
  10773. * @returns this ray updated
  10774. */
  10775. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10776. /**
  10777. * Creates a ray with origin and direction of 0,0,0
  10778. * @returns the new ray
  10779. */
  10780. static Zero(): Ray;
  10781. /**
  10782. * Creates a new ray from screen space and viewport
  10783. * @param x position
  10784. * @param y y position
  10785. * @param viewportWidth viewport width
  10786. * @param viewportHeight viewport height
  10787. * @param world world matrix
  10788. * @param view view matrix
  10789. * @param projection projection matrix
  10790. * @returns new ray
  10791. */
  10792. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10793. /**
  10794. * 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
  10795. * transformed to the given world matrix.
  10796. * @param origin The origin point
  10797. * @param end The end point
  10798. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10799. * @returns the new ray
  10800. */
  10801. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10802. /**
  10803. * Transforms a ray by a matrix
  10804. * @param ray ray to transform
  10805. * @param matrix matrix to apply
  10806. * @returns the resulting new ray
  10807. */
  10808. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10809. /**
  10810. * Transforms a ray by a matrix
  10811. * @param ray ray to transform
  10812. * @param matrix matrix to apply
  10813. * @param result ray to store result in
  10814. */
  10815. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10816. /**
  10817. * Unproject a ray from screen space to object space
  10818. * @param sourceX defines the screen space x coordinate to use
  10819. * @param sourceY defines the screen space y coordinate to use
  10820. * @param viewportWidth defines the current width of the viewport
  10821. * @param viewportHeight defines the current height of the viewport
  10822. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10823. * @param view defines the view matrix to use
  10824. * @param projection defines the projection matrix to use
  10825. */
  10826. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10827. }
  10828. /**
  10829. * Type used to define predicate used to select faces when a mesh intersection is detected
  10830. */
  10831. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10832. module "babylonjs/scene" {
  10833. interface Scene {
  10834. /** @hidden */
  10835. _tempPickingRay: Nullable<Ray>;
  10836. /** @hidden */
  10837. _cachedRayForTransform: Ray;
  10838. /** @hidden */
  10839. _pickWithRayInverseMatrix: Matrix;
  10840. /** @hidden */
  10841. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10842. /** @hidden */
  10843. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10844. /** @hidden */
  10845. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10846. }
  10847. }
  10848. }
  10849. declare module "babylonjs/sceneComponent" {
  10850. import { Scene } from "babylonjs/scene";
  10851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10852. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10853. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10854. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10855. import { Nullable } from "babylonjs/types";
  10856. import { Camera } from "babylonjs/Cameras/camera";
  10857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10858. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10859. import { AbstractScene } from "babylonjs/abstractScene";
  10860. import { Mesh } from "babylonjs/Meshes/mesh";
  10861. /**
  10862. * Groups all the scene component constants in one place to ease maintenance.
  10863. * @hidden
  10864. */
  10865. export class SceneComponentConstants {
  10866. static readonly NAME_EFFECTLAYER: string;
  10867. static readonly NAME_LAYER: string;
  10868. static readonly NAME_LENSFLARESYSTEM: string;
  10869. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10870. static readonly NAME_PARTICLESYSTEM: string;
  10871. static readonly NAME_GAMEPAD: string;
  10872. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10873. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10874. static readonly NAME_PREPASSRENDERER: string;
  10875. static readonly NAME_DEPTHRENDERER: string;
  10876. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10877. static readonly NAME_SPRITE: string;
  10878. static readonly NAME_SUBSURFACE: string;
  10879. static readonly NAME_OUTLINERENDERER: string;
  10880. static readonly NAME_PROCEDURALTEXTURE: string;
  10881. static readonly NAME_SHADOWGENERATOR: string;
  10882. static readonly NAME_OCTREE: string;
  10883. static readonly NAME_PHYSICSENGINE: string;
  10884. static readonly NAME_AUDIO: string;
  10885. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10886. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10887. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10888. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10889. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10890. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10891. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10892. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10893. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10894. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10895. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10896. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10897. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10898. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10899. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10900. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10901. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10902. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10903. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10904. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10905. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10906. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10907. static readonly STEP_AFTERRENDER_AUDIO: number;
  10908. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10909. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10910. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10911. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10912. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10913. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10914. static readonly STEP_POINTERMOVE_SPRITE: number;
  10915. static readonly STEP_POINTERDOWN_SPRITE: number;
  10916. static readonly STEP_POINTERUP_SPRITE: number;
  10917. }
  10918. /**
  10919. * This represents a scene component.
  10920. *
  10921. * This is used to decouple the dependency the scene is having on the different workloads like
  10922. * layers, post processes...
  10923. */
  10924. export interface ISceneComponent {
  10925. /**
  10926. * The name of the component. Each component must have a unique name.
  10927. */
  10928. name: string;
  10929. /**
  10930. * The scene the component belongs to.
  10931. */
  10932. scene: Scene;
  10933. /**
  10934. * Register the component to one instance of a scene.
  10935. */
  10936. register(): void;
  10937. /**
  10938. * Rebuilds the elements related to this component in case of
  10939. * context lost for instance.
  10940. */
  10941. rebuild(): void;
  10942. /**
  10943. * Disposes the component and the associated ressources.
  10944. */
  10945. dispose(): void;
  10946. }
  10947. /**
  10948. * This represents a SERIALIZABLE scene component.
  10949. *
  10950. * This extends Scene Component to add Serialization methods on top.
  10951. */
  10952. export interface ISceneSerializableComponent extends ISceneComponent {
  10953. /**
  10954. * Adds all the elements from the container to the scene
  10955. * @param container the container holding the elements
  10956. */
  10957. addFromContainer(container: AbstractScene): void;
  10958. /**
  10959. * Removes all the elements in the container from the scene
  10960. * @param container contains the elements to remove
  10961. * @param dispose if the removed element should be disposed (default: false)
  10962. */
  10963. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10964. /**
  10965. * Serializes the component data to the specified json object
  10966. * @param serializationObject The object to serialize to
  10967. */
  10968. serialize(serializationObject: any): void;
  10969. }
  10970. /**
  10971. * Strong typing of a Mesh related stage step action
  10972. */
  10973. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10974. /**
  10975. * Strong typing of a Evaluate Sub Mesh related stage step action
  10976. */
  10977. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10978. /**
  10979. * Strong typing of a Active Mesh related stage step action
  10980. */
  10981. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10982. /**
  10983. * Strong typing of a Camera related stage step action
  10984. */
  10985. export type CameraStageAction = (camera: Camera) => void;
  10986. /**
  10987. * Strong typing of a Camera Frame buffer related stage step action
  10988. */
  10989. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10990. /**
  10991. * Strong typing of a Render Target related stage step action
  10992. */
  10993. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10994. /**
  10995. * Strong typing of a RenderingGroup related stage step action
  10996. */
  10997. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10998. /**
  10999. * Strong typing of a Mesh Render related stage step action
  11000. */
  11001. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11002. /**
  11003. * Strong typing of a simple stage step action
  11004. */
  11005. export type SimpleStageAction = () => void;
  11006. /**
  11007. * Strong typing of a render target action.
  11008. */
  11009. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11010. /**
  11011. * Strong typing of a pointer move action.
  11012. */
  11013. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11014. /**
  11015. * Strong typing of a pointer up/down action.
  11016. */
  11017. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11018. /**
  11019. * Representation of a stage in the scene (Basically a list of ordered steps)
  11020. * @hidden
  11021. */
  11022. export class Stage<T extends Function> extends Array<{
  11023. index: number;
  11024. component: ISceneComponent;
  11025. action: T;
  11026. }> {
  11027. /**
  11028. * Hide ctor from the rest of the world.
  11029. * @param items The items to add.
  11030. */
  11031. private constructor();
  11032. /**
  11033. * Creates a new Stage.
  11034. * @returns A new instance of a Stage
  11035. */
  11036. static Create<T extends Function>(): Stage<T>;
  11037. /**
  11038. * Registers a step in an ordered way in the targeted stage.
  11039. * @param index Defines the position to register the step in
  11040. * @param component Defines the component attached to the step
  11041. * @param action Defines the action to launch during the step
  11042. */
  11043. registerStep(index: number, component: ISceneComponent, action: T): void;
  11044. /**
  11045. * Clears all the steps from the stage.
  11046. */
  11047. clear(): void;
  11048. }
  11049. }
  11050. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11051. import { Nullable } from "babylonjs/types";
  11052. import { Observable } from "babylonjs/Misc/observable";
  11053. import { Scene } from "babylonjs/scene";
  11054. import { Sprite } from "babylonjs/Sprites/sprite";
  11055. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11056. import { Ray } from "babylonjs/Culling/ray";
  11057. import { Camera } from "babylonjs/Cameras/camera";
  11058. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11059. import { ISceneComponent } from "babylonjs/sceneComponent";
  11060. module "babylonjs/scene" {
  11061. interface Scene {
  11062. /** @hidden */
  11063. _pointerOverSprite: Nullable<Sprite>;
  11064. /** @hidden */
  11065. _pickedDownSprite: Nullable<Sprite>;
  11066. /** @hidden */
  11067. _tempSpritePickingRay: Nullable<Ray>;
  11068. /**
  11069. * All of the sprite managers added to this scene
  11070. * @see https://doc.babylonjs.com/babylon101/sprites
  11071. */
  11072. spriteManagers: Array<ISpriteManager>;
  11073. /**
  11074. * An event triggered when sprites rendering is about to start
  11075. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11076. */
  11077. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11078. /**
  11079. * An event triggered when sprites rendering is done
  11080. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11081. */
  11082. onAfterSpritesRenderingObservable: Observable<Scene>;
  11083. /** @hidden */
  11084. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11085. /** Launch a ray to try to pick a sprite in the scene
  11086. * @param x position on screen
  11087. * @param y position on screen
  11088. * @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
  11089. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11090. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11091. * @returns a PickingInfo
  11092. */
  11093. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11094. /** Use the given ray to pick a sprite in the scene
  11095. * @param ray The ray (in world space) to use to pick meshes
  11096. * @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
  11097. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11098. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11099. * @returns a PickingInfo
  11100. */
  11101. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11102. /** @hidden */
  11103. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11104. /** Launch a ray to try to pick sprites in the scene
  11105. * @param x position on screen
  11106. * @param y position on screen
  11107. * @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
  11108. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11109. * @returns a PickingInfo array
  11110. */
  11111. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11112. /** Use the given ray to pick sprites in the scene
  11113. * @param ray The ray (in world space) to use to pick meshes
  11114. * @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
  11115. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11116. * @returns a PickingInfo array
  11117. */
  11118. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11119. /**
  11120. * Force the sprite under the pointer
  11121. * @param sprite defines the sprite to use
  11122. */
  11123. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11124. /**
  11125. * Gets the sprite under the pointer
  11126. * @returns a Sprite or null if no sprite is under the pointer
  11127. */
  11128. getPointerOverSprite(): Nullable<Sprite>;
  11129. }
  11130. }
  11131. /**
  11132. * Defines the sprite scene component responsible to manage sprites
  11133. * in a given scene.
  11134. */
  11135. export class SpriteSceneComponent implements ISceneComponent {
  11136. /**
  11137. * The component name helpfull to identify the component in the list of scene components.
  11138. */
  11139. readonly name: string;
  11140. /**
  11141. * The scene the component belongs to.
  11142. */
  11143. scene: Scene;
  11144. /** @hidden */
  11145. private _spritePredicate;
  11146. /**
  11147. * Creates a new instance of the component for the given scene
  11148. * @param scene Defines the scene to register the component in
  11149. */
  11150. constructor(scene: Scene);
  11151. /**
  11152. * Registers the component in a given scene
  11153. */
  11154. register(): void;
  11155. /**
  11156. * Rebuilds the elements related to this component in case of
  11157. * context lost for instance.
  11158. */
  11159. rebuild(): void;
  11160. /**
  11161. * Disposes the component and the associated ressources.
  11162. */
  11163. dispose(): void;
  11164. private _pickSpriteButKeepRay;
  11165. private _pointerMove;
  11166. private _pointerDown;
  11167. private _pointerUp;
  11168. }
  11169. }
  11170. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11171. /** @hidden */
  11172. export var fogFragmentDeclaration: {
  11173. name: string;
  11174. shader: string;
  11175. };
  11176. }
  11177. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11178. /** @hidden */
  11179. export var fogFragment: {
  11180. name: string;
  11181. shader: string;
  11182. };
  11183. }
  11184. declare module "babylonjs/Shaders/sprites.fragment" {
  11185. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11186. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11187. /** @hidden */
  11188. export var spritesPixelShader: {
  11189. name: string;
  11190. shader: string;
  11191. };
  11192. }
  11193. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11194. /** @hidden */
  11195. export var fogVertexDeclaration: {
  11196. name: string;
  11197. shader: string;
  11198. };
  11199. }
  11200. declare module "babylonjs/Shaders/sprites.vertex" {
  11201. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11202. /** @hidden */
  11203. export var spritesVertexShader: {
  11204. name: string;
  11205. shader: string;
  11206. };
  11207. }
  11208. declare module "babylonjs/Sprites/spriteManager" {
  11209. import { IDisposable, Scene } from "babylonjs/scene";
  11210. import { Nullable } from "babylonjs/types";
  11211. import { Observable } from "babylonjs/Misc/observable";
  11212. import { Sprite } from "babylonjs/Sprites/sprite";
  11213. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11214. import { Camera } from "babylonjs/Cameras/camera";
  11215. import { Texture } from "babylonjs/Materials/Textures/texture";
  11216. import "babylonjs/Shaders/sprites.fragment";
  11217. import "babylonjs/Shaders/sprites.vertex";
  11218. import { Ray } from "babylonjs/Culling/ray";
  11219. /**
  11220. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11221. */
  11222. export interface ISpriteManager extends IDisposable {
  11223. /**
  11224. * Gets manager's name
  11225. */
  11226. name: string;
  11227. /**
  11228. * Restricts the camera to viewing objects with the same layerMask.
  11229. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11230. */
  11231. layerMask: number;
  11232. /**
  11233. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11234. */
  11235. isPickable: boolean;
  11236. /**
  11237. * Gets the hosting scene
  11238. */
  11239. scene: Scene;
  11240. /**
  11241. * Specifies the rendering group id for this mesh (0 by default)
  11242. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11243. */
  11244. renderingGroupId: number;
  11245. /**
  11246. * Defines the list of sprites managed by the manager.
  11247. */
  11248. sprites: Array<Sprite>;
  11249. /**
  11250. * Gets or sets the spritesheet texture
  11251. */
  11252. texture: Texture;
  11253. /** Defines the default width of a cell in the spritesheet */
  11254. cellWidth: number;
  11255. /** Defines the default height of a cell in the spritesheet */
  11256. cellHeight: number;
  11257. /**
  11258. * Tests the intersection of a sprite with a specific ray.
  11259. * @param ray The ray we are sending to test the collision
  11260. * @param camera The camera space we are sending rays in
  11261. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11262. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11263. * @returns picking info or null.
  11264. */
  11265. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11266. /**
  11267. * Intersects the sprites with a ray
  11268. * @param ray defines the ray to intersect with
  11269. * @param camera defines the current active camera
  11270. * @param predicate defines a predicate used to select candidate sprites
  11271. * @returns null if no hit or a PickingInfo array
  11272. */
  11273. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11274. /**
  11275. * Renders the list of sprites on screen.
  11276. */
  11277. render(): void;
  11278. }
  11279. /**
  11280. * Class used to manage multiple sprites on the same spritesheet
  11281. * @see https://doc.babylonjs.com/babylon101/sprites
  11282. */
  11283. export class SpriteManager implements ISpriteManager {
  11284. /** defines the manager's name */
  11285. name: string;
  11286. /** Define the Url to load snippets */
  11287. static SnippetUrl: string;
  11288. /** Snippet ID if the manager was created from the snippet server */
  11289. snippetId: string;
  11290. /** Gets the list of sprites */
  11291. sprites: Sprite[];
  11292. /** Gets or sets the rendering group id (0 by default) */
  11293. renderingGroupId: number;
  11294. /** Gets or sets camera layer mask */
  11295. layerMask: number;
  11296. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11297. fogEnabled: boolean;
  11298. /** Gets or sets a boolean indicating if the sprites are pickable */
  11299. isPickable: boolean;
  11300. /** Defines the default width of a cell in the spritesheet */
  11301. cellWidth: number;
  11302. /** Defines the default height of a cell in the spritesheet */
  11303. cellHeight: number;
  11304. /** Associative array from JSON sprite data file */
  11305. private _cellData;
  11306. /** Array of sprite names from JSON sprite data file */
  11307. private _spriteMap;
  11308. /** True when packed cell data from JSON file is ready*/
  11309. private _packedAndReady;
  11310. private _textureContent;
  11311. private _useInstancing;
  11312. /**
  11313. * An event triggered when the manager is disposed.
  11314. */
  11315. onDisposeObservable: Observable<SpriteManager>;
  11316. private _onDisposeObserver;
  11317. /**
  11318. * Callback called when the manager is disposed
  11319. */
  11320. set onDispose(callback: () => void);
  11321. private _capacity;
  11322. private _fromPacked;
  11323. private _spriteTexture;
  11324. private _epsilon;
  11325. private _scene;
  11326. private _vertexData;
  11327. private _buffer;
  11328. private _vertexBuffers;
  11329. private _spriteBuffer;
  11330. private _indexBuffer;
  11331. private _effectBase;
  11332. private _effectFog;
  11333. private _vertexBufferSize;
  11334. /**
  11335. * Gets or sets the unique id of the sprite
  11336. */
  11337. uniqueId: number;
  11338. /**
  11339. * Gets the array of sprites
  11340. */
  11341. get children(): Sprite[];
  11342. /**
  11343. * Gets the hosting scene
  11344. */
  11345. get scene(): Scene;
  11346. /**
  11347. * Gets the capacity of the manager
  11348. */
  11349. get capacity(): number;
  11350. /**
  11351. * Gets or sets the spritesheet texture
  11352. */
  11353. get texture(): Texture;
  11354. set texture(value: Texture);
  11355. private _blendMode;
  11356. /**
  11357. * Blend mode use to render the particle, it can be any of
  11358. * the static Constants.ALPHA_x properties provided in this class.
  11359. * Default value is Constants.ALPHA_COMBINE
  11360. */
  11361. get blendMode(): number;
  11362. set blendMode(blendMode: number);
  11363. /** Disables writing to the depth buffer when rendering the sprites.
  11364. * It can be handy to disable depth writing when using textures without alpha channel
  11365. * and setting some specific blend modes.
  11366. */
  11367. disableDepthWrite: boolean;
  11368. /**
  11369. * Creates a new sprite manager
  11370. * @param name defines the manager's name
  11371. * @param imgUrl defines the sprite sheet url
  11372. * @param capacity defines the maximum allowed number of sprites
  11373. * @param cellSize defines the size of a sprite cell
  11374. * @param scene defines the hosting scene
  11375. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11376. * @param samplingMode defines the smapling mode to use with spritesheet
  11377. * @param fromPacked set to false; do not alter
  11378. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11379. */
  11380. constructor(
  11381. /** defines the manager's name */
  11382. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11383. /**
  11384. * Returns the string "SpriteManager"
  11385. * @returns "SpriteManager"
  11386. */
  11387. getClassName(): string;
  11388. private _makePacked;
  11389. private _appendSpriteVertex;
  11390. private _checkTextureAlpha;
  11391. /**
  11392. * Intersects the sprites with a ray
  11393. * @param ray defines the ray to intersect with
  11394. * @param camera defines the current active camera
  11395. * @param predicate defines a predicate used to select candidate sprites
  11396. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11397. * @returns null if no hit or a PickingInfo
  11398. */
  11399. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11400. /**
  11401. * Intersects the sprites with a ray
  11402. * @param ray defines the ray to intersect with
  11403. * @param camera defines the current active camera
  11404. * @param predicate defines a predicate used to select candidate sprites
  11405. * @returns null if no hit or a PickingInfo array
  11406. */
  11407. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11408. /**
  11409. * Render all child sprites
  11410. */
  11411. render(): void;
  11412. /**
  11413. * Release associated resources
  11414. */
  11415. dispose(): void;
  11416. /**
  11417. * Serializes the sprite manager to a JSON object
  11418. * @param serializeTexture defines if the texture must be serialized as well
  11419. * @returns the JSON object
  11420. */
  11421. serialize(serializeTexture?: boolean): any;
  11422. /**
  11423. * Parses a JSON object to create a new sprite manager.
  11424. * @param parsedManager The JSON object to parse
  11425. * @param scene The scene to create the sprite managerin
  11426. * @param rootUrl The root url to use to load external dependencies like texture
  11427. * @returns the new sprite manager
  11428. */
  11429. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11430. /**
  11431. * Creates a sprite manager from a snippet saved in a remote file
  11432. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11433. * @param url defines the url to load from
  11434. * @param scene defines the hosting scene
  11435. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11436. * @returns a promise that will resolve to the new sprite manager
  11437. */
  11438. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11439. /**
  11440. * Creates a sprite manager from a snippet saved by the sprite editor
  11441. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11442. * @param scene defines the hosting scene
  11443. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11444. * @returns a promise that will resolve to the new sprite manager
  11445. */
  11446. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11447. }
  11448. }
  11449. declare module "babylonjs/Misc/gradients" {
  11450. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11451. /** Interface used by value gradients (color, factor, ...) */
  11452. export interface IValueGradient {
  11453. /**
  11454. * Gets or sets the gradient value (between 0 and 1)
  11455. */
  11456. gradient: number;
  11457. }
  11458. /** Class used to store color4 gradient */
  11459. export class ColorGradient implements IValueGradient {
  11460. /**
  11461. * Gets or sets the gradient value (between 0 and 1)
  11462. */
  11463. gradient: number;
  11464. /**
  11465. * Gets or sets first associated color
  11466. */
  11467. color1: Color4;
  11468. /**
  11469. * Gets or sets second associated color
  11470. */
  11471. color2?: Color4 | undefined;
  11472. /**
  11473. * Creates a new color4 gradient
  11474. * @param gradient gets or sets the gradient value (between 0 and 1)
  11475. * @param color1 gets or sets first associated color
  11476. * @param color2 gets or sets first second color
  11477. */
  11478. constructor(
  11479. /**
  11480. * Gets or sets the gradient value (between 0 and 1)
  11481. */
  11482. gradient: number,
  11483. /**
  11484. * Gets or sets first associated color
  11485. */
  11486. color1: Color4,
  11487. /**
  11488. * Gets or sets second associated color
  11489. */
  11490. color2?: Color4 | undefined);
  11491. /**
  11492. * Will get a color picked randomly between color1 and color2.
  11493. * If color2 is undefined then color1 will be used
  11494. * @param result defines the target Color4 to store the result in
  11495. */
  11496. getColorToRef(result: Color4): void;
  11497. }
  11498. /** Class used to store color 3 gradient */
  11499. export class Color3Gradient implements IValueGradient {
  11500. /**
  11501. * Gets or sets the gradient value (between 0 and 1)
  11502. */
  11503. gradient: number;
  11504. /**
  11505. * Gets or sets the associated color
  11506. */
  11507. color: Color3;
  11508. /**
  11509. * Creates a new color3 gradient
  11510. * @param gradient gets or sets the gradient value (between 0 and 1)
  11511. * @param color gets or sets associated color
  11512. */
  11513. constructor(
  11514. /**
  11515. * Gets or sets the gradient value (between 0 and 1)
  11516. */
  11517. gradient: number,
  11518. /**
  11519. * Gets or sets the associated color
  11520. */
  11521. color: Color3);
  11522. }
  11523. /** Class used to store factor gradient */
  11524. export class FactorGradient implements IValueGradient {
  11525. /**
  11526. * Gets or sets the gradient value (between 0 and 1)
  11527. */
  11528. gradient: number;
  11529. /**
  11530. * Gets or sets first associated factor
  11531. */
  11532. factor1: number;
  11533. /**
  11534. * Gets or sets second associated factor
  11535. */
  11536. factor2?: number | undefined;
  11537. /**
  11538. * Creates a new factor gradient
  11539. * @param gradient gets or sets the gradient value (between 0 and 1)
  11540. * @param factor1 gets or sets first associated factor
  11541. * @param factor2 gets or sets second associated factor
  11542. */
  11543. constructor(
  11544. /**
  11545. * Gets or sets the gradient value (between 0 and 1)
  11546. */
  11547. gradient: number,
  11548. /**
  11549. * Gets or sets first associated factor
  11550. */
  11551. factor1: number,
  11552. /**
  11553. * Gets or sets second associated factor
  11554. */
  11555. factor2?: number | undefined);
  11556. /**
  11557. * Will get a number picked randomly between factor1 and factor2.
  11558. * If factor2 is undefined then factor1 will be used
  11559. * @returns the picked number
  11560. */
  11561. getFactor(): number;
  11562. }
  11563. /**
  11564. * Helper used to simplify some generic gradient tasks
  11565. */
  11566. export class GradientHelper {
  11567. /**
  11568. * Gets the current gradient from an array of IValueGradient
  11569. * @param ratio defines the current ratio to get
  11570. * @param gradients defines the array of IValueGradient
  11571. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11572. */
  11573. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11574. }
  11575. }
  11576. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11577. import { Nullable } from "babylonjs/types";
  11578. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11579. import { Scene } from "babylonjs/scene";
  11580. module "babylonjs/Engines/thinEngine" {
  11581. interface ThinEngine {
  11582. /**
  11583. * Creates a raw texture
  11584. * @param data defines the data to store in the texture
  11585. * @param width defines the width of the texture
  11586. * @param height defines the height of the texture
  11587. * @param format defines the format of the data
  11588. * @param generateMipMaps defines if the engine should generate the mip levels
  11589. * @param invertY defines if data must be stored with Y axis inverted
  11590. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11591. * @param compression defines the compression used (null by default)
  11592. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11593. * @returns the raw texture inside an InternalTexture
  11594. */
  11595. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11596. /**
  11597. * Update a raw texture
  11598. * @param texture defines the texture to update
  11599. * @param data defines the data to store in the texture
  11600. * @param format defines the format of the data
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. */
  11603. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11604. /**
  11605. * Update a raw texture
  11606. * @param texture defines the texture to update
  11607. * @param data defines the data to store in the texture
  11608. * @param format defines the format of the data
  11609. * @param invertY defines if data must be stored with Y axis inverted
  11610. * @param compression defines the compression used (null by default)
  11611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11612. */
  11613. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11614. /**
  11615. * Creates a new raw cube texture
  11616. * @param data defines the array of data to use to create each face
  11617. * @param size defines the size of the textures
  11618. * @param format defines the format of the data
  11619. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11620. * @param generateMipMaps defines if the engine should generate the mip levels
  11621. * @param invertY defines if data must be stored with Y axis inverted
  11622. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11623. * @param compression defines the compression used (null by default)
  11624. * @returns the cube texture as an InternalTexture
  11625. */
  11626. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11627. /**
  11628. * Update a raw cube texture
  11629. * @param texture defines the texture to udpdate
  11630. * @param data defines the data to store
  11631. * @param format defines the data format
  11632. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11633. * @param invertY defines if data must be stored with Y axis inverted
  11634. */
  11635. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11636. /**
  11637. * Update a raw cube texture
  11638. * @param texture defines the texture to udpdate
  11639. * @param data defines the data to store
  11640. * @param format defines the data format
  11641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11642. * @param invertY defines if data must be stored with Y axis inverted
  11643. * @param compression defines the compression used (null by default)
  11644. */
  11645. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11646. /**
  11647. * Update a raw cube texture
  11648. * @param texture defines the texture to udpdate
  11649. * @param data defines the data to store
  11650. * @param format defines the data format
  11651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11652. * @param invertY defines if data must be stored with Y axis inverted
  11653. * @param compression defines the compression used (null by default)
  11654. * @param level defines which level of the texture to update
  11655. */
  11656. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11657. /**
  11658. * Creates a new raw cube texture from a specified url
  11659. * @param url defines the url where the data is located
  11660. * @param scene defines the current scene
  11661. * @param size defines the size of the textures
  11662. * @param format defines the format of the data
  11663. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11664. * @param noMipmap defines if the engine should avoid generating the mip levels
  11665. * @param callback defines a callback used to extract texture data from loaded data
  11666. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11667. * @param onLoad defines a callback called when texture is loaded
  11668. * @param onError defines a callback called if there is an error
  11669. * @returns the cube texture as an InternalTexture
  11670. */
  11671. 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;
  11672. /**
  11673. * Creates a new raw cube texture from a specified url
  11674. * @param url defines the url where the data is located
  11675. * @param scene defines the current scene
  11676. * @param size defines the size of the textures
  11677. * @param format defines the format of the data
  11678. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11679. * @param noMipmap defines if the engine should avoid generating the mip levels
  11680. * @param callback defines a callback used to extract texture data from loaded data
  11681. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11682. * @param onLoad defines a callback called when texture is loaded
  11683. * @param onError defines a callback called if there is an error
  11684. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. * @returns the cube texture as an InternalTexture
  11687. */
  11688. 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;
  11689. /**
  11690. * Creates a new raw 3D texture
  11691. * @param data defines the data used to create the texture
  11692. * @param width defines the width of the texture
  11693. * @param height defines the height of the texture
  11694. * @param depth defines the depth of the texture
  11695. * @param format defines the format of the texture
  11696. * @param generateMipMaps defines if the engine must generate mip levels
  11697. * @param invertY defines if data must be stored with Y axis inverted
  11698. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11699. * @param compression defines the compressed used (can be null)
  11700. * @param textureType defines the compressed used (can be null)
  11701. * @returns a new raw 3D texture (stored in an InternalTexture)
  11702. */
  11703. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11704. /**
  11705. * Update a raw 3D texture
  11706. * @param texture defines the texture to update
  11707. * @param data defines the data to store
  11708. * @param format defines the data format
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. */
  11711. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11712. /**
  11713. * Update a raw 3D texture
  11714. * @param texture defines the texture to update
  11715. * @param data defines the data to store
  11716. * @param format defines the data format
  11717. * @param invertY defines if data must be stored with Y axis inverted
  11718. * @param compression defines the used compression (can be null)
  11719. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11720. */
  11721. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11722. /**
  11723. * Creates a new raw 2D array texture
  11724. * @param data defines the data used to create the texture
  11725. * @param width defines the width of the texture
  11726. * @param height defines the height of the texture
  11727. * @param depth defines the number of layers of the texture
  11728. * @param format defines the format of the texture
  11729. * @param generateMipMaps defines if the engine must generate mip levels
  11730. * @param invertY defines if data must be stored with Y axis inverted
  11731. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11732. * @param compression defines the compressed used (can be null)
  11733. * @param textureType defines the compressed used (can be null)
  11734. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11735. */
  11736. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11737. /**
  11738. * Update a raw 2D array texture
  11739. * @param texture defines the texture to update
  11740. * @param data defines the data to store
  11741. * @param format defines the data format
  11742. * @param invertY defines if data must be stored with Y axis inverted
  11743. */
  11744. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11745. /**
  11746. * Update a raw 2D array texture
  11747. * @param texture defines the texture to update
  11748. * @param data defines the data to store
  11749. * @param format defines the data format
  11750. * @param invertY defines if data must be stored with Y axis inverted
  11751. * @param compression defines the used compression (can be null)
  11752. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11753. */
  11754. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11755. }
  11756. }
  11757. }
  11758. declare module "babylonjs/Materials/Textures/rawTexture" {
  11759. import { Texture } from "babylonjs/Materials/Textures/texture";
  11760. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11761. import { Nullable } from "babylonjs/types";
  11762. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11763. import { Scene } from "babylonjs/scene";
  11764. /**
  11765. * Raw texture can help creating a texture directly from an array of data.
  11766. * This can be super useful if you either get the data from an uncompressed source or
  11767. * if you wish to create your texture pixel by pixel.
  11768. */
  11769. export class RawTexture extends Texture {
  11770. /**
  11771. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11772. */
  11773. format: number;
  11774. /**
  11775. * Instantiates a new RawTexture.
  11776. * Raw texture can help creating a texture directly from an array of data.
  11777. * This can be super useful if you either get the data from an uncompressed source or
  11778. * if you wish to create your texture pixel by pixel.
  11779. * @param data define the array of data to use to create the texture
  11780. * @param width define the width of the texture
  11781. * @param height define the height of the texture
  11782. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11783. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11784. * @param generateMipMaps define whether mip maps should be generated or not
  11785. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11786. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11787. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11788. */
  11789. constructor(data: ArrayBufferView, width: number, height: number,
  11790. /**
  11791. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11792. */
  11793. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11794. /**
  11795. * Updates the texture underlying data.
  11796. * @param data Define the new data of the texture
  11797. */
  11798. update(data: ArrayBufferView): void;
  11799. /**
  11800. * Creates a luminance texture from some data.
  11801. * @param data Define the texture data
  11802. * @param width Define the width of the texture
  11803. * @param height Define the height of the texture
  11804. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11805. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11806. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11807. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11808. * @returns the luminance texture
  11809. */
  11810. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11811. /**
  11812. * Creates a luminance alpha texture from some data.
  11813. * @param data Define the texture data
  11814. * @param width Define the width of the texture
  11815. * @param height Define the height of the texture
  11816. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11817. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11818. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11819. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11820. * @returns the luminance alpha texture
  11821. */
  11822. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11823. /**
  11824. * Creates an alpha texture from some data.
  11825. * @param data Define the texture data
  11826. * @param width Define the width of the texture
  11827. * @param height Define the height of the texture
  11828. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11832. * @returns the alpha texture
  11833. */
  11834. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11835. /**
  11836. * Creates a RGB texture from some data.
  11837. * @param data Define the texture data
  11838. * @param width Define the width of the texture
  11839. * @param height Define the height of the texture
  11840. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11841. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11842. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11843. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11844. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11845. * @returns the RGB alpha texture
  11846. */
  11847. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11848. /**
  11849. * Creates a RGBA texture from some data.
  11850. * @param data Define the texture data
  11851. * @param width Define the width of the texture
  11852. * @param height Define the height of the texture
  11853. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11854. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11855. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11856. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11857. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11858. * @returns the RGBA texture
  11859. */
  11860. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11861. /**
  11862. * Creates a R texture from some data.
  11863. * @param data Define the texture data
  11864. * @param width Define the width of the texture
  11865. * @param height Define the height of the texture
  11866. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11867. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11868. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11869. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11870. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11871. * @returns the R texture
  11872. */
  11873. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11874. }
  11875. }
  11876. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11877. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11878. import { IndicesArray, DataArray } from "babylonjs/types";
  11879. module "babylonjs/Engines/thinEngine" {
  11880. interface ThinEngine {
  11881. /**
  11882. * Update a dynamic index buffer
  11883. * @param indexBuffer defines the target index buffer
  11884. * @param indices defines the data to update
  11885. * @param offset defines the offset in the target index buffer where update should start
  11886. */
  11887. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11888. /**
  11889. * Updates a dynamic vertex buffer.
  11890. * @param vertexBuffer the vertex buffer to update
  11891. * @param data the data used to update the vertex buffer
  11892. * @param byteOffset the byte offset of the data
  11893. * @param byteLength the byte length of the data
  11894. */
  11895. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11896. }
  11897. }
  11898. }
  11899. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11900. import { Scene } from "babylonjs/scene";
  11901. import { ISceneComponent } from "babylonjs/sceneComponent";
  11902. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11903. module "babylonjs/abstractScene" {
  11904. interface AbstractScene {
  11905. /**
  11906. * The list of procedural textures added to the scene
  11907. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11908. */
  11909. proceduralTextures: Array<ProceduralTexture>;
  11910. }
  11911. }
  11912. /**
  11913. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11914. * in a given scene.
  11915. */
  11916. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11917. /**
  11918. * The component name helpfull to identify the component in the list of scene components.
  11919. */
  11920. readonly name: string;
  11921. /**
  11922. * The scene the component belongs to.
  11923. */
  11924. scene: Scene;
  11925. /**
  11926. * Creates a new instance of the component for the given scene
  11927. * @param scene Defines the scene to register the component in
  11928. */
  11929. constructor(scene: Scene);
  11930. /**
  11931. * Registers the component in a given scene
  11932. */
  11933. register(): void;
  11934. /**
  11935. * Rebuilds the elements related to this component in case of
  11936. * context lost for instance.
  11937. */
  11938. rebuild(): void;
  11939. /**
  11940. * Disposes the component and the associated ressources.
  11941. */
  11942. dispose(): void;
  11943. private _beforeClear;
  11944. }
  11945. }
  11946. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11948. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11949. module "babylonjs/Engines/thinEngine" {
  11950. interface ThinEngine {
  11951. /**
  11952. * Creates a new render target cube texture
  11953. * @param size defines the size of the texture
  11954. * @param options defines the options used to create the texture
  11955. * @returns a new render target cube texture stored in an InternalTexture
  11956. */
  11957. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11958. }
  11959. }
  11960. }
  11961. declare module "babylonjs/Shaders/procedural.vertex" {
  11962. /** @hidden */
  11963. export var proceduralVertexShader: {
  11964. name: string;
  11965. shader: string;
  11966. };
  11967. }
  11968. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11969. import { Observable } from "babylonjs/Misc/observable";
  11970. import { Nullable } from "babylonjs/types";
  11971. import { Scene } from "babylonjs/scene";
  11972. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11973. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11974. import { Effect } from "babylonjs/Materials/effect";
  11975. import { Texture } from "babylonjs/Materials/Textures/texture";
  11976. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11977. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11978. import "babylonjs/Shaders/procedural.vertex";
  11979. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11980. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11981. /**
  11982. * 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.
  11983. * This is the base class of any Procedural texture and contains most of the shareable code.
  11984. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11985. */
  11986. export class ProceduralTexture extends Texture {
  11987. /**
  11988. * Define if the texture is enabled or not (disabled texture will not render)
  11989. */
  11990. isEnabled: boolean;
  11991. /**
  11992. * Define if the texture must be cleared before rendering (default is true)
  11993. */
  11994. autoClear: boolean;
  11995. /**
  11996. * Callback called when the texture is generated
  11997. */
  11998. onGenerated: () => void;
  11999. /**
  12000. * Event raised when the texture is generated
  12001. */
  12002. onGeneratedObservable: Observable<ProceduralTexture>;
  12003. /**
  12004. * Event raised before the texture is generated
  12005. */
  12006. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12007. /**
  12008. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12009. */
  12010. nodeMaterialSource: Nullable<NodeMaterial>;
  12011. /** @hidden */
  12012. _generateMipMaps: boolean;
  12013. /** @hidden **/
  12014. _effect: Effect;
  12015. /** @hidden */
  12016. _textures: {
  12017. [key: string]: Texture;
  12018. };
  12019. /** @hidden */
  12020. protected _fallbackTexture: Nullable<Texture>;
  12021. private _size;
  12022. private _currentRefreshId;
  12023. private _frameId;
  12024. private _refreshRate;
  12025. private _vertexBuffers;
  12026. private _indexBuffer;
  12027. private _uniforms;
  12028. private _samplers;
  12029. private _fragment;
  12030. private _floats;
  12031. private _ints;
  12032. private _floatsArrays;
  12033. private _colors3;
  12034. private _colors4;
  12035. private _vectors2;
  12036. private _vectors3;
  12037. private _matrices;
  12038. private _fallbackTextureUsed;
  12039. private _fullEngine;
  12040. private _cachedDefines;
  12041. private _contentUpdateId;
  12042. private _contentData;
  12043. /**
  12044. * Instantiates a new procedural texture.
  12045. * 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.
  12046. * This is the base class of any Procedural texture and contains most of the shareable code.
  12047. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12048. * @param name Define the name of the texture
  12049. * @param size Define the size of the texture to create
  12050. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12051. * @param scene Define the scene the texture belongs to
  12052. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12053. * @param generateMipMaps Define if the texture should creates mip maps or not
  12054. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12055. */
  12056. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12057. /**
  12058. * The effect that is created when initializing the post process.
  12059. * @returns The created effect corresponding the the postprocess.
  12060. */
  12061. getEffect(): Effect;
  12062. /**
  12063. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12064. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12065. */
  12066. getContent(): Nullable<ArrayBufferView>;
  12067. private _createIndexBuffer;
  12068. /** @hidden */
  12069. _rebuild(): void;
  12070. /**
  12071. * Resets the texture in order to recreate its associated resources.
  12072. * This can be called in case of context loss
  12073. */
  12074. reset(): void;
  12075. protected _getDefines(): string;
  12076. /**
  12077. * Is the texture ready to be used ? (rendered at least once)
  12078. * @returns true if ready, otherwise, false.
  12079. */
  12080. isReady(): boolean;
  12081. /**
  12082. * Resets the refresh counter of the texture and start bak from scratch.
  12083. * Could be useful to regenerate the texture if it is setup to render only once.
  12084. */
  12085. resetRefreshCounter(): void;
  12086. /**
  12087. * Set the fragment shader to use in order to render the texture.
  12088. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12089. */
  12090. setFragment(fragment: any): void;
  12091. /**
  12092. * Define the refresh rate of the texture or the rendering frequency.
  12093. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12094. */
  12095. get refreshRate(): number;
  12096. set refreshRate(value: number);
  12097. /** @hidden */
  12098. _shouldRender(): boolean;
  12099. /**
  12100. * Get the size the texture is rendering at.
  12101. * @returns the size (on cube texture it is always squared)
  12102. */
  12103. getRenderSize(): RenderTargetTextureSize;
  12104. /**
  12105. * Resize the texture to new value.
  12106. * @param size Define the new size the texture should have
  12107. * @param generateMipMaps Define whether the new texture should create mip maps
  12108. */
  12109. resize(size: number, generateMipMaps: boolean): void;
  12110. private _checkUniform;
  12111. /**
  12112. * Set a texture in the shader program used to render.
  12113. * @param name Define the name of the uniform samplers as defined in the shader
  12114. * @param texture Define the texture to bind to this sampler
  12115. * @return the texture itself allowing "fluent" like uniform updates
  12116. */
  12117. setTexture(name: string, texture: Texture): ProceduralTexture;
  12118. /**
  12119. * Set a float in the shader.
  12120. * @param name Define the name of the uniform as defined in the shader
  12121. * @param value Define the value to give to the uniform
  12122. * @return the texture itself allowing "fluent" like uniform updates
  12123. */
  12124. setFloat(name: string, value: number): ProceduralTexture;
  12125. /**
  12126. * Set a int in the shader.
  12127. * @param name Define the name of the uniform as defined in the shader
  12128. * @param value Define the value to give to the uniform
  12129. * @return the texture itself allowing "fluent" like uniform updates
  12130. */
  12131. setInt(name: string, value: number): ProceduralTexture;
  12132. /**
  12133. * Set an array of floats in the shader.
  12134. * @param name Define the name of the uniform as defined in the shader
  12135. * @param value Define the value to give to the uniform
  12136. * @return the texture itself allowing "fluent" like uniform updates
  12137. */
  12138. setFloats(name: string, value: number[]): ProceduralTexture;
  12139. /**
  12140. * Set a vec3 in the shader from a Color3.
  12141. * @param name Define the name of the uniform as defined in the shader
  12142. * @param value Define the value to give to the uniform
  12143. * @return the texture itself allowing "fluent" like uniform updates
  12144. */
  12145. setColor3(name: string, value: Color3): ProceduralTexture;
  12146. /**
  12147. * Set a vec4 in the shader from a Color4.
  12148. * @param name Define the name of the uniform as defined in the shader
  12149. * @param value Define the value to give to the uniform
  12150. * @return the texture itself allowing "fluent" like uniform updates
  12151. */
  12152. setColor4(name: string, value: Color4): ProceduralTexture;
  12153. /**
  12154. * Set a vec2 in the shader from a Vector2.
  12155. * @param name Define the name of the uniform as defined in the shader
  12156. * @param value Define the value to give to the uniform
  12157. * @return the texture itself allowing "fluent" like uniform updates
  12158. */
  12159. setVector2(name: string, value: Vector2): ProceduralTexture;
  12160. /**
  12161. * Set a vec3 in the shader from a Vector3.
  12162. * @param name Define the name of the uniform as defined in the shader
  12163. * @param value Define the value to give to the uniform
  12164. * @return the texture itself allowing "fluent" like uniform updates
  12165. */
  12166. setVector3(name: string, value: Vector3): ProceduralTexture;
  12167. /**
  12168. * Set a mat4 in the shader from a MAtrix.
  12169. * @param name Define the name of the uniform as defined in the shader
  12170. * @param value Define the value to give to the uniform
  12171. * @return the texture itself allowing "fluent" like uniform updates
  12172. */
  12173. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12174. /**
  12175. * Render the texture to its associated render target.
  12176. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12177. */
  12178. render(useCameraPostProcess?: boolean): void;
  12179. /**
  12180. * Clone the texture.
  12181. * @returns the cloned texture
  12182. */
  12183. clone(): ProceduralTexture;
  12184. /**
  12185. * Dispose the texture and release its asoociated resources.
  12186. */
  12187. dispose(): void;
  12188. }
  12189. }
  12190. declare module "babylonjs/Particles/baseParticleSystem" {
  12191. import { Nullable } from "babylonjs/types";
  12192. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12194. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12195. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12196. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12197. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12198. import { Color4 } from "babylonjs/Maths/math.color";
  12199. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12200. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12201. import { Animation } from "babylonjs/Animations/animation";
  12202. import { Scene } from "babylonjs/scene";
  12203. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12204. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12205. /**
  12206. * This represents the base class for particle system in Babylon.
  12207. * 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.
  12208. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12209. * @example https://doc.babylonjs.com/babylon101/particles
  12210. */
  12211. export class BaseParticleSystem {
  12212. /**
  12213. * Source color is added to the destination color without alpha affecting the result
  12214. */
  12215. static BLENDMODE_ONEONE: number;
  12216. /**
  12217. * Blend current color and particle color using particle’s alpha
  12218. */
  12219. static BLENDMODE_STANDARD: number;
  12220. /**
  12221. * Add current color and particle color multiplied by particle’s alpha
  12222. */
  12223. static BLENDMODE_ADD: number;
  12224. /**
  12225. * Multiply current color with particle color
  12226. */
  12227. static BLENDMODE_MULTIPLY: number;
  12228. /**
  12229. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12230. */
  12231. static BLENDMODE_MULTIPLYADD: number;
  12232. /**
  12233. * List of animations used by the particle system.
  12234. */
  12235. animations: Animation[];
  12236. /**
  12237. * Gets or sets the unique id of the particle system
  12238. */
  12239. uniqueId: number;
  12240. /**
  12241. * The id of the Particle system.
  12242. */
  12243. id: string;
  12244. /**
  12245. * The friendly name of the Particle system.
  12246. */
  12247. name: string;
  12248. /**
  12249. * Snippet ID if the particle system was created from the snippet server
  12250. */
  12251. snippetId: string;
  12252. /**
  12253. * The rendering group used by the Particle system to chose when to render.
  12254. */
  12255. renderingGroupId: number;
  12256. /**
  12257. * The emitter represents the Mesh or position we are attaching the particle system to.
  12258. */
  12259. emitter: Nullable<AbstractMesh | Vector3>;
  12260. /**
  12261. * The maximum number of particles to emit per frame
  12262. */
  12263. emitRate: number;
  12264. /**
  12265. * If you want to launch only a few particles at once, that can be done, as well.
  12266. */
  12267. manualEmitCount: number;
  12268. /**
  12269. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12270. */
  12271. updateSpeed: number;
  12272. /**
  12273. * The amount of time the particle system is running (depends of the overall update speed).
  12274. */
  12275. targetStopDuration: number;
  12276. /**
  12277. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12278. */
  12279. disposeOnStop: boolean;
  12280. /**
  12281. * Minimum power of emitting particles.
  12282. */
  12283. minEmitPower: number;
  12284. /**
  12285. * Maximum power of emitting particles.
  12286. */
  12287. maxEmitPower: number;
  12288. /**
  12289. * Minimum life time of emitting particles.
  12290. */
  12291. minLifeTime: number;
  12292. /**
  12293. * Maximum life time of emitting particles.
  12294. */
  12295. maxLifeTime: number;
  12296. /**
  12297. * Minimum Size of emitting particles.
  12298. */
  12299. minSize: number;
  12300. /**
  12301. * Maximum Size of emitting particles.
  12302. */
  12303. maxSize: number;
  12304. /**
  12305. * Minimum scale of emitting particles on X axis.
  12306. */
  12307. minScaleX: number;
  12308. /**
  12309. * Maximum scale of emitting particles on X axis.
  12310. */
  12311. maxScaleX: number;
  12312. /**
  12313. * Minimum scale of emitting particles on Y axis.
  12314. */
  12315. minScaleY: number;
  12316. /**
  12317. * Maximum scale of emitting particles on Y axis.
  12318. */
  12319. maxScaleY: number;
  12320. /**
  12321. * Gets or sets the minimal initial rotation in radians.
  12322. */
  12323. minInitialRotation: number;
  12324. /**
  12325. * Gets or sets the maximal initial rotation in radians.
  12326. */
  12327. maxInitialRotation: number;
  12328. /**
  12329. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12330. */
  12331. minAngularSpeed: number;
  12332. /**
  12333. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12334. */
  12335. maxAngularSpeed: number;
  12336. /**
  12337. * The texture used to render each particle. (this can be a spritesheet)
  12338. */
  12339. particleTexture: Nullable<BaseTexture>;
  12340. /**
  12341. * The layer mask we are rendering the particles through.
  12342. */
  12343. layerMask: number;
  12344. /**
  12345. * This can help using your own shader to render the particle system.
  12346. * The according effect will be created
  12347. */
  12348. customShader: any;
  12349. /**
  12350. * By default particle system starts as soon as they are created. This prevents the
  12351. * automatic start to happen and let you decide when to start emitting particles.
  12352. */
  12353. preventAutoStart: boolean;
  12354. private _noiseTexture;
  12355. /**
  12356. * Gets or sets a texture used to add random noise to particle positions
  12357. */
  12358. get noiseTexture(): Nullable<ProceduralTexture>;
  12359. set noiseTexture(value: Nullable<ProceduralTexture>);
  12360. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12361. noiseStrength: Vector3;
  12362. /**
  12363. * Callback triggered when the particle animation is ending.
  12364. */
  12365. onAnimationEnd: Nullable<() => void>;
  12366. /**
  12367. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12368. */
  12369. blendMode: number;
  12370. /**
  12371. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12372. * to override the particles.
  12373. */
  12374. forceDepthWrite: boolean;
  12375. /** 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 */
  12376. preWarmCycles: number;
  12377. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12378. preWarmStepOffset: number;
  12379. /**
  12380. * 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)
  12381. */
  12382. spriteCellChangeSpeed: number;
  12383. /**
  12384. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12385. */
  12386. startSpriteCellID: number;
  12387. /**
  12388. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12389. */
  12390. endSpriteCellID: number;
  12391. /**
  12392. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12393. */
  12394. spriteCellWidth: number;
  12395. /**
  12396. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12397. */
  12398. spriteCellHeight: number;
  12399. /**
  12400. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12401. */
  12402. spriteRandomStartCell: boolean;
  12403. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12404. translationPivot: Vector2;
  12405. /** @hidden */
  12406. protected _isAnimationSheetEnabled: boolean;
  12407. /**
  12408. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12409. */
  12410. beginAnimationOnStart: boolean;
  12411. /**
  12412. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12413. */
  12414. beginAnimationFrom: number;
  12415. /**
  12416. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12417. */
  12418. beginAnimationTo: number;
  12419. /**
  12420. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12421. */
  12422. beginAnimationLoop: boolean;
  12423. /**
  12424. * Gets or sets a world offset applied to all particles
  12425. */
  12426. worldOffset: Vector3;
  12427. /**
  12428. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12429. */
  12430. get isAnimationSheetEnabled(): boolean;
  12431. set isAnimationSheetEnabled(value: boolean);
  12432. /**
  12433. * Get hosting scene
  12434. * @returns the scene
  12435. */
  12436. getScene(): Nullable<Scene>;
  12437. /**
  12438. * You can use gravity if you want to give an orientation to your particles.
  12439. */
  12440. gravity: Vector3;
  12441. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12442. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12443. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12444. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12445. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12446. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12447. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12448. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12449. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12450. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12451. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12452. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12453. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12454. /**
  12455. * Defines the delay in milliseconds before starting the system (0 by default)
  12456. */
  12457. startDelay: number;
  12458. /**
  12459. * Gets the current list of drag gradients.
  12460. * You must use addDragGradient and removeDragGradient to udpate this list
  12461. * @returns the list of drag gradients
  12462. */
  12463. getDragGradients(): Nullable<Array<FactorGradient>>;
  12464. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12465. limitVelocityDamping: number;
  12466. /**
  12467. * Gets the current list of limit velocity gradients.
  12468. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12469. * @returns the list of limit velocity gradients
  12470. */
  12471. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12472. /**
  12473. * Gets the current list of color gradients.
  12474. * You must use addColorGradient and removeColorGradient to udpate this list
  12475. * @returns the list of color gradients
  12476. */
  12477. getColorGradients(): Nullable<Array<ColorGradient>>;
  12478. /**
  12479. * Gets the current list of size gradients.
  12480. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12481. * @returns the list of size gradients
  12482. */
  12483. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12484. /**
  12485. * Gets the current list of color remap gradients.
  12486. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12487. * @returns the list of color remap gradients
  12488. */
  12489. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12490. /**
  12491. * Gets the current list of alpha remap gradients.
  12492. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12493. * @returns the list of alpha remap gradients
  12494. */
  12495. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12496. /**
  12497. * Gets the current list of life time gradients.
  12498. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12499. * @returns the list of life time gradients
  12500. */
  12501. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12502. /**
  12503. * Gets the current list of angular speed gradients.
  12504. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12505. * @returns the list of angular speed gradients
  12506. */
  12507. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12508. /**
  12509. * Gets the current list of velocity gradients.
  12510. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12511. * @returns the list of velocity gradients
  12512. */
  12513. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12514. /**
  12515. * Gets the current list of start size gradients.
  12516. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12517. * @returns the list of start size gradients
  12518. */
  12519. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12520. /**
  12521. * Gets the current list of emit rate gradients.
  12522. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12523. * @returns the list of emit rate gradients
  12524. */
  12525. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12526. /**
  12527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12528. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12529. */
  12530. get direction1(): Vector3;
  12531. set direction1(value: Vector3);
  12532. /**
  12533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12535. */
  12536. get direction2(): Vector3;
  12537. set direction2(value: Vector3);
  12538. /**
  12539. * 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.
  12540. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12541. */
  12542. get minEmitBox(): Vector3;
  12543. set minEmitBox(value: Vector3);
  12544. /**
  12545. * 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.
  12546. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12547. */
  12548. get maxEmitBox(): Vector3;
  12549. set maxEmitBox(value: Vector3);
  12550. /**
  12551. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12552. */
  12553. color1: Color4;
  12554. /**
  12555. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12556. */
  12557. color2: Color4;
  12558. /**
  12559. * Color the particle will have at the end of its lifetime
  12560. */
  12561. colorDead: Color4;
  12562. /**
  12563. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12564. */
  12565. textureMask: Color4;
  12566. /**
  12567. * The particle emitter type defines the emitter used by the particle system.
  12568. * It can be for example box, sphere, or cone...
  12569. */
  12570. particleEmitterType: IParticleEmitterType;
  12571. /** @hidden */
  12572. _isSubEmitter: boolean;
  12573. /**
  12574. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12575. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12576. */
  12577. billboardMode: number;
  12578. protected _isBillboardBased: boolean;
  12579. /**
  12580. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12581. */
  12582. get isBillboardBased(): boolean;
  12583. set isBillboardBased(value: boolean);
  12584. /**
  12585. * The scene the particle system belongs to.
  12586. */
  12587. protected _scene: Nullable<Scene>;
  12588. /**
  12589. * The engine the particle system belongs to.
  12590. */
  12591. protected _engine: ThinEngine;
  12592. /**
  12593. * Local cache of defines for image processing.
  12594. */
  12595. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12596. /**
  12597. * Default configuration related to image processing available in the standard Material.
  12598. */
  12599. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12600. /**
  12601. * Gets the image processing configuration used either in this material.
  12602. */
  12603. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12604. /**
  12605. * Sets the Default image processing configuration used either in the this material.
  12606. *
  12607. * If sets to null, the scene one is in use.
  12608. */
  12609. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12610. /**
  12611. * Attaches a new image processing configuration to the Standard Material.
  12612. * @param configuration
  12613. */
  12614. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12615. /** @hidden */
  12616. protected _reset(): void;
  12617. /** @hidden */
  12618. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12619. /**
  12620. * Instantiates a particle system.
  12621. * 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.
  12622. * @param name The name of the particle system
  12623. */
  12624. constructor(name: string);
  12625. /**
  12626. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12629. * @returns the emitter
  12630. */
  12631. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12632. /**
  12633. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12634. * @param radius The radius of the hemisphere to emit from
  12635. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12636. * @returns the emitter
  12637. */
  12638. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12639. /**
  12640. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12641. * @param radius The radius of the sphere to emit from
  12642. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12643. * @returns the emitter
  12644. */
  12645. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12646. /**
  12647. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12648. * @param radius The radius of the sphere to emit from
  12649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12651. * @returns the emitter
  12652. */
  12653. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12654. /**
  12655. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12656. * @param radius The radius of the emission cylinder
  12657. * @param height The height of the emission cylinder
  12658. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12659. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12660. * @returns the emitter
  12661. */
  12662. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12663. /**
  12664. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12665. * @param radius The radius of the cylinder to emit from
  12666. * @param height The height of the emission cylinder
  12667. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12670. * @returns the emitter
  12671. */
  12672. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12673. /**
  12674. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12675. * @param radius The radius of the cone to emit from
  12676. * @param angle The base angle of the cone
  12677. * @returns the emitter
  12678. */
  12679. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12680. /**
  12681. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12682. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12683. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12684. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12685. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12686. * @returns the emitter
  12687. */
  12688. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12689. }
  12690. }
  12691. declare module "babylonjs/Particles/subEmitter" {
  12692. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12693. import { Scene } from "babylonjs/scene";
  12694. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12695. /**
  12696. * Type of sub emitter
  12697. */
  12698. export enum SubEmitterType {
  12699. /**
  12700. * Attached to the particle over it's lifetime
  12701. */
  12702. ATTACHED = 0,
  12703. /**
  12704. * Created when the particle dies
  12705. */
  12706. END = 1
  12707. }
  12708. /**
  12709. * Sub emitter class used to emit particles from an existing particle
  12710. */
  12711. export class SubEmitter {
  12712. /**
  12713. * the particle system to be used by the sub emitter
  12714. */
  12715. particleSystem: ParticleSystem;
  12716. /**
  12717. * Type of the submitter (Default: END)
  12718. */
  12719. type: SubEmitterType;
  12720. /**
  12721. * 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)
  12722. * Note: This only is supported when using an emitter of type Mesh
  12723. */
  12724. inheritDirection: boolean;
  12725. /**
  12726. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12727. */
  12728. inheritedVelocityAmount: number;
  12729. /**
  12730. * Creates a sub emitter
  12731. * @param particleSystem the particle system to be used by the sub emitter
  12732. */
  12733. constructor(
  12734. /**
  12735. * the particle system to be used by the sub emitter
  12736. */
  12737. particleSystem: ParticleSystem);
  12738. /**
  12739. * Clones the sub emitter
  12740. * @returns the cloned sub emitter
  12741. */
  12742. clone(): SubEmitter;
  12743. /**
  12744. * Serialize current object to a JSON object
  12745. * @returns the serialized object
  12746. */
  12747. serialize(): any;
  12748. /** @hidden */
  12749. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12750. /**
  12751. * Creates a new SubEmitter from a serialized JSON version
  12752. * @param serializationObject defines the JSON object to read from
  12753. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12754. * @param rootUrl defines the rootUrl for data loading
  12755. * @returns a new SubEmitter
  12756. */
  12757. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12758. /** Release associated resources */
  12759. dispose(): void;
  12760. }
  12761. }
  12762. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12763. /** @hidden */
  12764. export var imageProcessingDeclaration: {
  12765. name: string;
  12766. shader: string;
  12767. };
  12768. }
  12769. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12770. /** @hidden */
  12771. export var imageProcessingFunctions: {
  12772. name: string;
  12773. shader: string;
  12774. };
  12775. }
  12776. declare module "babylonjs/Shaders/particles.fragment" {
  12777. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12778. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12779. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12780. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12781. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12782. /** @hidden */
  12783. export var particlesPixelShader: {
  12784. name: string;
  12785. shader: string;
  12786. };
  12787. }
  12788. declare module "babylonjs/Shaders/particles.vertex" {
  12789. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12790. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12791. /** @hidden */
  12792. export var particlesVertexShader: {
  12793. name: string;
  12794. shader: string;
  12795. };
  12796. }
  12797. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12798. import { Nullable } from "babylonjs/types";
  12799. import { Plane } from "babylonjs/Maths/math";
  12800. /**
  12801. * Interface used to define entities containing multiple clip planes
  12802. */
  12803. export interface IClipPlanesHolder {
  12804. /**
  12805. * Gets or sets the active clipplane 1
  12806. */
  12807. clipPlane: Nullable<Plane>;
  12808. /**
  12809. * Gets or sets the active clipplane 2
  12810. */
  12811. clipPlane2: Nullable<Plane>;
  12812. /**
  12813. * Gets or sets the active clipplane 3
  12814. */
  12815. clipPlane3: Nullable<Plane>;
  12816. /**
  12817. * Gets or sets the active clipplane 4
  12818. */
  12819. clipPlane4: Nullable<Plane>;
  12820. /**
  12821. * Gets or sets the active clipplane 5
  12822. */
  12823. clipPlane5: Nullable<Plane>;
  12824. /**
  12825. * Gets or sets the active clipplane 6
  12826. */
  12827. clipPlane6: Nullable<Plane>;
  12828. }
  12829. }
  12830. declare module "babylonjs/Materials/thinMaterialHelper" {
  12831. import { Effect } from "babylonjs/Materials/effect";
  12832. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12833. /**
  12834. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12835. *
  12836. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12837. *
  12838. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12839. */
  12840. export class ThinMaterialHelper {
  12841. /**
  12842. * Binds the clip plane information from the holder to the effect.
  12843. * @param effect The effect we are binding the data to
  12844. * @param holder The entity containing the clip plane information
  12845. */
  12846. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12847. }
  12848. }
  12849. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12850. module "babylonjs/Engines/thinEngine" {
  12851. interface ThinEngine {
  12852. /**
  12853. * Sets alpha constants used by some alpha blending modes
  12854. * @param r defines the red component
  12855. * @param g defines the green component
  12856. * @param b defines the blue component
  12857. * @param a defines the alpha component
  12858. */
  12859. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12860. /**
  12861. * Sets the current alpha mode
  12862. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12863. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12864. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12865. */
  12866. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12867. /**
  12868. * Gets the current alpha mode
  12869. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12870. * @returns the current alpha mode
  12871. */
  12872. getAlphaMode(): number;
  12873. /**
  12874. * Sets the current alpha equation
  12875. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12876. */
  12877. setAlphaEquation(equation: number): void;
  12878. /**
  12879. * Gets the current alpha equation.
  12880. * @returns the current alpha equation
  12881. */
  12882. getAlphaEquation(): number;
  12883. }
  12884. }
  12885. }
  12886. declare module "babylonjs/Particles/particleSystem" {
  12887. import { Nullable } from "babylonjs/types";
  12888. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12889. import { Observable } from "babylonjs/Misc/observable";
  12890. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12891. import { Effect } from "babylonjs/Materials/effect";
  12892. import { IDisposable } from "babylonjs/scene";
  12893. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12894. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12895. import { Particle } from "babylonjs/Particles/particle";
  12896. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12897. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12898. import "babylonjs/Shaders/particles.fragment";
  12899. import "babylonjs/Shaders/particles.vertex";
  12900. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12901. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12902. import "babylonjs/Engines/Extensions/engine.alpha";
  12903. import { Scene } from "babylonjs/scene";
  12904. /**
  12905. * This represents a particle system in Babylon.
  12906. * 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.
  12907. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12908. * @example https://doc.babylonjs.com/babylon101/particles
  12909. */
  12910. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12911. /**
  12912. * Billboard mode will only apply to Y axis
  12913. */
  12914. static readonly BILLBOARDMODE_Y: number;
  12915. /**
  12916. * Billboard mode will apply to all axes
  12917. */
  12918. static readonly BILLBOARDMODE_ALL: number;
  12919. /**
  12920. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12921. */
  12922. static readonly BILLBOARDMODE_STRETCHED: number;
  12923. /**
  12924. * This function can be defined to provide custom update for active particles.
  12925. * This function will be called instead of regular update (age, position, color, etc.).
  12926. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12927. */
  12928. updateFunction: (particles: Particle[]) => void;
  12929. private _emitterWorldMatrix;
  12930. /**
  12931. * This function can be defined to specify initial direction for every new particle.
  12932. * It by default use the emitterType defined function
  12933. */
  12934. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12935. /**
  12936. * This function can be defined to specify initial position for every new particle.
  12937. * It by default use the emitterType defined function
  12938. */
  12939. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12940. /**
  12941. * @hidden
  12942. */
  12943. _inheritedVelocityOffset: Vector3;
  12944. /**
  12945. * An event triggered when the system is disposed
  12946. */
  12947. onDisposeObservable: Observable<IParticleSystem>;
  12948. private _onDisposeObserver;
  12949. /**
  12950. * Sets a callback that will be triggered when the system is disposed
  12951. */
  12952. set onDispose(callback: () => void);
  12953. private _particles;
  12954. private _epsilon;
  12955. private _capacity;
  12956. private _stockParticles;
  12957. private _newPartsExcess;
  12958. private _vertexData;
  12959. private _vertexBuffer;
  12960. private _vertexBuffers;
  12961. private _spriteBuffer;
  12962. private _indexBuffer;
  12963. private _effect;
  12964. private _customEffect;
  12965. private _cachedDefines;
  12966. private _scaledColorStep;
  12967. private _colorDiff;
  12968. private _scaledDirection;
  12969. private _scaledGravity;
  12970. private _currentRenderId;
  12971. private _alive;
  12972. private _useInstancing;
  12973. private _started;
  12974. private _stopped;
  12975. private _actualFrame;
  12976. private _scaledUpdateSpeed;
  12977. private _vertexBufferSize;
  12978. /** @hidden */
  12979. _currentEmitRateGradient: Nullable<FactorGradient>;
  12980. /** @hidden */
  12981. _currentEmitRate1: number;
  12982. /** @hidden */
  12983. _currentEmitRate2: number;
  12984. /** @hidden */
  12985. _currentStartSizeGradient: Nullable<FactorGradient>;
  12986. /** @hidden */
  12987. _currentStartSize1: number;
  12988. /** @hidden */
  12989. _currentStartSize2: number;
  12990. private readonly _rawTextureWidth;
  12991. private _rampGradientsTexture;
  12992. private _useRampGradients;
  12993. /** Gets or sets a matrix to use to compute projection */
  12994. defaultProjectionMatrix: Matrix;
  12995. /** Gets or sets a matrix to use to compute view */
  12996. defaultViewMatrix: Matrix;
  12997. /** Gets or sets a boolean indicating that ramp gradients must be used
  12998. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12999. */
  13000. get useRampGradients(): boolean;
  13001. set useRampGradients(value: boolean);
  13002. /**
  13003. * 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.
  13004. * 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: [])
  13005. */
  13006. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13007. private _subEmitters;
  13008. /**
  13009. * @hidden
  13010. * If the particle systems emitter should be disposed when the particle system is disposed
  13011. */
  13012. _disposeEmitterOnDispose: boolean;
  13013. /**
  13014. * The current active Sub-systems, this property is used by the root particle system only.
  13015. */
  13016. activeSubSystems: Array<ParticleSystem>;
  13017. /**
  13018. * Specifies if the particles are updated in emitter local space or world space
  13019. */
  13020. isLocal: boolean;
  13021. private _rootParticleSystem;
  13022. /**
  13023. * Gets the current list of active particles
  13024. */
  13025. get particles(): Particle[];
  13026. /**
  13027. * Gets the number of particles active at the same time.
  13028. * @returns The number of active particles.
  13029. */
  13030. getActiveCount(): number;
  13031. /**
  13032. * Returns the string "ParticleSystem"
  13033. * @returns a string containing the class name
  13034. */
  13035. getClassName(): string;
  13036. /**
  13037. * Gets a boolean indicating that the system is stopping
  13038. * @returns true if the system is currently stopping
  13039. */
  13040. isStopping(): boolean;
  13041. /**
  13042. * Gets the custom effect used to render the particles
  13043. * @param blendMode Blend mode for which the effect should be retrieved
  13044. * @returns The effect
  13045. */
  13046. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13047. /**
  13048. * Sets the custom effect used to render the particles
  13049. * @param effect The effect to set
  13050. * @param blendMode Blend mode for which the effect should be set
  13051. */
  13052. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13053. /** @hidden */
  13054. private _onBeforeDrawParticlesObservable;
  13055. /**
  13056. * Observable that will be called just before the particles are drawn
  13057. */
  13058. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13059. /**
  13060. * Gets the name of the particle vertex shader
  13061. */
  13062. get vertexShaderName(): string;
  13063. /**
  13064. * Instantiates a particle system.
  13065. * 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.
  13066. * @param name The name of the particle system
  13067. * @param capacity The max number of particles alive at the same time
  13068. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13069. * @param customEffect a custom effect used to change the way particles are rendered by default
  13070. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13071. * @param epsilon Offset used to render the particles
  13072. */
  13073. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13074. private _addFactorGradient;
  13075. private _removeFactorGradient;
  13076. /**
  13077. * Adds a new life time gradient
  13078. * @param gradient defines the gradient to use (between 0 and 1)
  13079. * @param factor defines the life time factor to affect to the specified gradient
  13080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13081. * @returns the current particle system
  13082. */
  13083. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13084. /**
  13085. * Remove a specific life time gradient
  13086. * @param gradient defines the gradient to remove
  13087. * @returns the current particle system
  13088. */
  13089. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13090. /**
  13091. * Adds a new size gradient
  13092. * @param gradient defines the gradient to use (between 0 and 1)
  13093. * @param factor defines the size factor to affect to the specified gradient
  13094. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13095. * @returns the current particle system
  13096. */
  13097. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13098. /**
  13099. * Remove a specific size gradient
  13100. * @param gradient defines the gradient to remove
  13101. * @returns the current particle system
  13102. */
  13103. removeSizeGradient(gradient: number): IParticleSystem;
  13104. /**
  13105. * Adds a new color remap gradient
  13106. * @param gradient defines the gradient to use (between 0 and 1)
  13107. * @param min defines the color remap minimal range
  13108. * @param max defines the color remap maximal range
  13109. * @returns the current particle system
  13110. */
  13111. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13112. /**
  13113. * Remove a specific color remap gradient
  13114. * @param gradient defines the gradient to remove
  13115. * @returns the current particle system
  13116. */
  13117. removeColorRemapGradient(gradient: number): IParticleSystem;
  13118. /**
  13119. * Adds a new alpha remap gradient
  13120. * @param gradient defines the gradient to use (between 0 and 1)
  13121. * @param min defines the alpha remap minimal range
  13122. * @param max defines the alpha remap maximal range
  13123. * @returns the current particle system
  13124. */
  13125. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13126. /**
  13127. * Remove a specific alpha remap gradient
  13128. * @param gradient defines the gradient to remove
  13129. * @returns the current particle system
  13130. */
  13131. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13132. /**
  13133. * Adds a new angular speed gradient
  13134. * @param gradient defines the gradient to use (between 0 and 1)
  13135. * @param factor defines the angular speed to affect to the specified gradient
  13136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13137. * @returns the current particle system
  13138. */
  13139. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13140. /**
  13141. * Remove a specific angular speed gradient
  13142. * @param gradient defines the gradient to remove
  13143. * @returns the current particle system
  13144. */
  13145. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13146. /**
  13147. * Adds a new velocity gradient
  13148. * @param gradient defines the gradient to use (between 0 and 1)
  13149. * @param factor defines the velocity to affect to the specified gradient
  13150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13151. * @returns the current particle system
  13152. */
  13153. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13154. /**
  13155. * Remove a specific velocity gradient
  13156. * @param gradient defines the gradient to remove
  13157. * @returns the current particle system
  13158. */
  13159. removeVelocityGradient(gradient: number): IParticleSystem;
  13160. /**
  13161. * Adds a new limit velocity gradient
  13162. * @param gradient defines the gradient to use (between 0 and 1)
  13163. * @param factor defines the limit velocity value to affect to the specified gradient
  13164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13165. * @returns the current particle system
  13166. */
  13167. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13168. /**
  13169. * Remove a specific limit velocity gradient
  13170. * @param gradient defines the gradient to remove
  13171. * @returns the current particle system
  13172. */
  13173. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13174. /**
  13175. * Adds a new drag gradient
  13176. * @param gradient defines the gradient to use (between 0 and 1)
  13177. * @param factor defines the drag value to affect to the specified gradient
  13178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13179. * @returns the current particle system
  13180. */
  13181. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13182. /**
  13183. * Remove a specific drag gradient
  13184. * @param gradient defines the gradient to remove
  13185. * @returns the current particle system
  13186. */
  13187. removeDragGradient(gradient: number): IParticleSystem;
  13188. /**
  13189. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13190. * @param gradient defines the gradient to use (between 0 and 1)
  13191. * @param factor defines the emit rate value to affect to the specified gradient
  13192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13193. * @returns the current particle system
  13194. */
  13195. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13196. /**
  13197. * Remove a specific emit rate gradient
  13198. * @param gradient defines the gradient to remove
  13199. * @returns the current particle system
  13200. */
  13201. removeEmitRateGradient(gradient: number): IParticleSystem;
  13202. /**
  13203. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13204. * @param gradient defines the gradient to use (between 0 and 1)
  13205. * @param factor defines the start size value to affect to the specified gradient
  13206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13207. * @returns the current particle system
  13208. */
  13209. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13210. /**
  13211. * Remove a specific start size gradient
  13212. * @param gradient defines the gradient to remove
  13213. * @returns the current particle system
  13214. */
  13215. removeStartSizeGradient(gradient: number): IParticleSystem;
  13216. private _createRampGradientTexture;
  13217. /**
  13218. * Gets the current list of ramp gradients.
  13219. * You must use addRampGradient and removeRampGradient to udpate this list
  13220. * @returns the list of ramp gradients
  13221. */
  13222. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13223. /** Force the system to rebuild all gradients that need to be resync */
  13224. forceRefreshGradients(): void;
  13225. private _syncRampGradientTexture;
  13226. /**
  13227. * Adds a new ramp gradient used to remap particle colors
  13228. * @param gradient defines the gradient to use (between 0 and 1)
  13229. * @param color defines the color to affect to the specified gradient
  13230. * @returns the current particle system
  13231. */
  13232. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13233. /**
  13234. * Remove a specific ramp gradient
  13235. * @param gradient defines the gradient to remove
  13236. * @returns the current particle system
  13237. */
  13238. removeRampGradient(gradient: number): ParticleSystem;
  13239. /**
  13240. * Adds a new color gradient
  13241. * @param gradient defines the gradient to use (between 0 and 1)
  13242. * @param color1 defines the color to affect to the specified gradient
  13243. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13244. * @returns this particle system
  13245. */
  13246. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13247. /**
  13248. * Remove a specific color gradient
  13249. * @param gradient defines the gradient to remove
  13250. * @returns this particle system
  13251. */
  13252. removeColorGradient(gradient: number): IParticleSystem;
  13253. private _fetchR;
  13254. protected _reset(): void;
  13255. private _resetEffect;
  13256. private _createVertexBuffers;
  13257. private _createIndexBuffer;
  13258. /**
  13259. * Gets the maximum number of particles active at the same time.
  13260. * @returns The max number of active particles.
  13261. */
  13262. getCapacity(): number;
  13263. /**
  13264. * Gets whether there are still active particles in the system.
  13265. * @returns True if it is alive, otherwise false.
  13266. */
  13267. isAlive(): boolean;
  13268. /**
  13269. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13270. * @returns True if it has been started, otherwise false.
  13271. */
  13272. isStarted(): boolean;
  13273. private _prepareSubEmitterInternalArray;
  13274. /**
  13275. * Starts the particle system and begins to emit
  13276. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13277. */
  13278. start(delay?: number): void;
  13279. /**
  13280. * Stops the particle system.
  13281. * @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.
  13282. */
  13283. stop(stopSubEmitters?: boolean): void;
  13284. /**
  13285. * Remove all active particles
  13286. */
  13287. reset(): void;
  13288. /**
  13289. * @hidden (for internal use only)
  13290. */
  13291. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13292. /**
  13293. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13294. * Its lifetime will start back at 0.
  13295. */
  13296. recycleParticle: (particle: Particle) => void;
  13297. private _stopSubEmitters;
  13298. private _createParticle;
  13299. private _removeFromRoot;
  13300. private _emitFromParticle;
  13301. private _update;
  13302. /** @hidden */
  13303. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13304. /** @hidden */
  13305. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13306. /**
  13307. * Fill the defines array according to the current settings of the particle system
  13308. * @param defines Array to be updated
  13309. * @param blendMode blend mode to take into account when updating the array
  13310. */
  13311. fillDefines(defines: Array<string>, blendMode: number): void;
  13312. /**
  13313. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13314. * @param uniforms Uniforms array to fill
  13315. * @param attributes Attributes array to fill
  13316. * @param samplers Samplers array to fill
  13317. */
  13318. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13319. /** @hidden */
  13320. private _getEffect;
  13321. /**
  13322. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13323. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13324. */
  13325. animate(preWarmOnly?: boolean): void;
  13326. private _appendParticleVertices;
  13327. /**
  13328. * Rebuilds the particle system.
  13329. */
  13330. rebuild(): void;
  13331. /**
  13332. * Is this system ready to be used/rendered
  13333. * @return true if the system is ready
  13334. */
  13335. isReady(): boolean;
  13336. private _render;
  13337. /**
  13338. * Renders the particle system in its current state.
  13339. * @returns the current number of particles
  13340. */
  13341. render(): number;
  13342. /**
  13343. * Disposes the particle system and free the associated resources
  13344. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13345. */
  13346. dispose(disposeTexture?: boolean): void;
  13347. /**
  13348. * Clones the particle system.
  13349. * @param name The name of the cloned object
  13350. * @param newEmitter The new emitter to use
  13351. * @returns the cloned particle system
  13352. */
  13353. clone(name: string, newEmitter: any): ParticleSystem;
  13354. /**
  13355. * Serializes the particle system to a JSON object
  13356. * @param serializeTexture defines if the texture must be serialized as well
  13357. * @returns the JSON object
  13358. */
  13359. serialize(serializeTexture?: boolean): any;
  13360. /** @hidden */
  13361. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13362. /** @hidden */
  13363. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13364. /**
  13365. * Parses a JSON object to create a particle system.
  13366. * @param parsedParticleSystem The JSON object to parse
  13367. * @param sceneOrEngine The scene or the engine to create the particle system in
  13368. * @param rootUrl The root url to use to load external dependencies like texture
  13369. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13370. * @returns the Parsed particle system
  13371. */
  13372. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13373. }
  13374. }
  13375. declare module "babylonjs/Particles/particle" {
  13376. import { Nullable } from "babylonjs/types";
  13377. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13378. import { Color4 } from "babylonjs/Maths/math.color";
  13379. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13380. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13381. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13382. /**
  13383. * A particle represents one of the element emitted by a particle system.
  13384. * This is mainly define by its coordinates, direction, velocity and age.
  13385. */
  13386. export class Particle {
  13387. /**
  13388. * The particle system the particle belongs to.
  13389. */
  13390. particleSystem: ParticleSystem;
  13391. private static _Count;
  13392. /**
  13393. * Unique ID of the particle
  13394. */
  13395. id: number;
  13396. /**
  13397. * The world position of the particle in the scene.
  13398. */
  13399. position: Vector3;
  13400. /**
  13401. * The world direction of the particle in the scene.
  13402. */
  13403. direction: Vector3;
  13404. /**
  13405. * The color of the particle.
  13406. */
  13407. color: Color4;
  13408. /**
  13409. * The color change of the particle per step.
  13410. */
  13411. colorStep: Color4;
  13412. /**
  13413. * Defines how long will the life of the particle be.
  13414. */
  13415. lifeTime: number;
  13416. /**
  13417. * The current age of the particle.
  13418. */
  13419. age: number;
  13420. /**
  13421. * The current size of the particle.
  13422. */
  13423. size: number;
  13424. /**
  13425. * The current scale of the particle.
  13426. */
  13427. scale: Vector2;
  13428. /**
  13429. * The current angle of the particle.
  13430. */
  13431. angle: number;
  13432. /**
  13433. * Defines how fast is the angle changing.
  13434. */
  13435. angularSpeed: number;
  13436. /**
  13437. * Defines the cell index used by the particle to be rendered from a sprite.
  13438. */
  13439. cellIndex: number;
  13440. /**
  13441. * The information required to support color remapping
  13442. */
  13443. remapData: Vector4;
  13444. /** @hidden */
  13445. _randomCellOffset?: number;
  13446. /** @hidden */
  13447. _initialDirection: Nullable<Vector3>;
  13448. /** @hidden */
  13449. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13450. /** @hidden */
  13451. _initialStartSpriteCellID: number;
  13452. /** @hidden */
  13453. _initialEndSpriteCellID: number;
  13454. /** @hidden */
  13455. _currentColorGradient: Nullable<ColorGradient>;
  13456. /** @hidden */
  13457. _currentColor1: Color4;
  13458. /** @hidden */
  13459. _currentColor2: Color4;
  13460. /** @hidden */
  13461. _currentSizeGradient: Nullable<FactorGradient>;
  13462. /** @hidden */
  13463. _currentSize1: number;
  13464. /** @hidden */
  13465. _currentSize2: number;
  13466. /** @hidden */
  13467. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13468. /** @hidden */
  13469. _currentAngularSpeed1: number;
  13470. /** @hidden */
  13471. _currentAngularSpeed2: number;
  13472. /** @hidden */
  13473. _currentVelocityGradient: Nullable<FactorGradient>;
  13474. /** @hidden */
  13475. _currentVelocity1: number;
  13476. /** @hidden */
  13477. _currentVelocity2: number;
  13478. /** @hidden */
  13479. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13480. /** @hidden */
  13481. _currentLimitVelocity1: number;
  13482. /** @hidden */
  13483. _currentLimitVelocity2: number;
  13484. /** @hidden */
  13485. _currentDragGradient: Nullable<FactorGradient>;
  13486. /** @hidden */
  13487. _currentDrag1: number;
  13488. /** @hidden */
  13489. _currentDrag2: number;
  13490. /** @hidden */
  13491. _randomNoiseCoordinates1: Vector3;
  13492. /** @hidden */
  13493. _randomNoiseCoordinates2: Vector3;
  13494. /** @hidden */
  13495. _localPosition?: Vector3;
  13496. /**
  13497. * Creates a new instance Particle
  13498. * @param particleSystem the particle system the particle belongs to
  13499. */
  13500. constructor(
  13501. /**
  13502. * The particle system the particle belongs to.
  13503. */
  13504. particleSystem: ParticleSystem);
  13505. private updateCellInfoFromSystem;
  13506. /**
  13507. * Defines how the sprite cell index is updated for the particle
  13508. */
  13509. updateCellIndex(): void;
  13510. /** @hidden */
  13511. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13512. /** @hidden */
  13513. _inheritParticleInfoToSubEmitters(): void;
  13514. /** @hidden */
  13515. _reset(): void;
  13516. /**
  13517. * Copy the properties of particle to another one.
  13518. * @param other the particle to copy the information to.
  13519. */
  13520. copyTo(other: Particle): void;
  13521. }
  13522. }
  13523. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13524. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13525. import { Effect } from "babylonjs/Materials/effect";
  13526. import { Particle } from "babylonjs/Particles/particle";
  13527. import { Nullable } from "babylonjs/types";
  13528. import { Scene } from "babylonjs/scene";
  13529. /**
  13530. * Particle emitter represents a volume emitting particles.
  13531. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13532. */
  13533. export interface IParticleEmitterType {
  13534. /**
  13535. * Called by the particle System when the direction is computed for the created particle.
  13536. * @param worldMatrix is the world matrix of the particle system
  13537. * @param directionToUpdate is the direction vector to update with the result
  13538. * @param particle is the particle we are computed the direction for
  13539. * @param isLocal defines if the direction should be set in local space
  13540. */
  13541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13542. /**
  13543. * Called by the particle System when the position is computed for the created particle.
  13544. * @param worldMatrix is the world matrix of the particle system
  13545. * @param positionToUpdate is the position vector to update with the result
  13546. * @param particle is the particle we are computed the position for
  13547. * @param isLocal defines if the position should be set in local space
  13548. */
  13549. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13550. /**
  13551. * Clones the current emitter and returns a copy of it
  13552. * @returns the new emitter
  13553. */
  13554. clone(): IParticleEmitterType;
  13555. /**
  13556. * Called by the GPUParticleSystem to setup the update shader
  13557. * @param effect defines the update shader
  13558. */
  13559. applyToShader(effect: Effect): void;
  13560. /**
  13561. * Returns a string to use to update the GPU particles update shader
  13562. * @returns the effect defines string
  13563. */
  13564. getEffectDefines(): string;
  13565. /**
  13566. * Returns a string representing the class name
  13567. * @returns a string containing the class name
  13568. */
  13569. getClassName(): string;
  13570. /**
  13571. * Serializes the particle system to a JSON object.
  13572. * @returns the JSON object
  13573. */
  13574. serialize(): any;
  13575. /**
  13576. * Parse properties from a JSON object
  13577. * @param serializationObject defines the JSON object
  13578. * @param scene defines the hosting scene
  13579. */
  13580. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13581. }
  13582. }
  13583. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13584. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13585. import { Effect } from "babylonjs/Materials/effect";
  13586. import { Particle } from "babylonjs/Particles/particle";
  13587. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13588. /**
  13589. * Particle emitter emitting particles from the inside of a box.
  13590. * It emits the particles randomly between 2 given directions.
  13591. */
  13592. export class BoxParticleEmitter implements IParticleEmitterType {
  13593. /**
  13594. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13595. */
  13596. direction1: Vector3;
  13597. /**
  13598. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13599. */
  13600. direction2: Vector3;
  13601. /**
  13602. * 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.
  13603. */
  13604. minEmitBox: Vector3;
  13605. /**
  13606. * 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.
  13607. */
  13608. maxEmitBox: Vector3;
  13609. /**
  13610. * Creates a new instance BoxParticleEmitter
  13611. */
  13612. constructor();
  13613. /**
  13614. * Called by the particle System when the direction is computed for the created particle.
  13615. * @param worldMatrix is the world matrix of the particle system
  13616. * @param directionToUpdate is the direction vector to update with the result
  13617. * @param particle is the particle we are computed the direction for
  13618. * @param isLocal defines if the direction should be set in local space
  13619. */
  13620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13621. /**
  13622. * Called by the particle System when the position is computed for the created particle.
  13623. * @param worldMatrix is the world matrix of the particle system
  13624. * @param positionToUpdate is the position vector to update with the result
  13625. * @param particle is the particle we are computed the position for
  13626. * @param isLocal defines if the position should be set in local space
  13627. */
  13628. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13629. /**
  13630. * Clones the current emitter and returns a copy of it
  13631. * @returns the new emitter
  13632. */
  13633. clone(): BoxParticleEmitter;
  13634. /**
  13635. * Called by the GPUParticleSystem to setup the update shader
  13636. * @param effect defines the update shader
  13637. */
  13638. applyToShader(effect: Effect): void;
  13639. /**
  13640. * Returns a string to use to update the GPU particles update shader
  13641. * @returns a string containng the defines string
  13642. */
  13643. getEffectDefines(): string;
  13644. /**
  13645. * Returns the string "BoxParticleEmitter"
  13646. * @returns a string containing the class name
  13647. */
  13648. getClassName(): string;
  13649. /**
  13650. * Serializes the particle system to a JSON object.
  13651. * @returns the JSON object
  13652. */
  13653. serialize(): any;
  13654. /**
  13655. * Parse properties from a JSON object
  13656. * @param serializationObject defines the JSON object
  13657. */
  13658. parse(serializationObject: any): void;
  13659. }
  13660. }
  13661. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13662. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13663. import { Effect } from "babylonjs/Materials/effect";
  13664. import { Particle } from "babylonjs/Particles/particle";
  13665. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13666. /**
  13667. * Particle emitter emitting particles from the inside of a cone.
  13668. * It emits the particles alongside the cone volume from the base to the particle.
  13669. * The emission direction might be randomized.
  13670. */
  13671. export class ConeParticleEmitter implements IParticleEmitterType {
  13672. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13673. directionRandomizer: number;
  13674. private _radius;
  13675. private _angle;
  13676. private _height;
  13677. /**
  13678. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13679. */
  13680. radiusRange: number;
  13681. /**
  13682. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13683. */
  13684. heightRange: number;
  13685. /**
  13686. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13687. */
  13688. emitFromSpawnPointOnly: boolean;
  13689. /**
  13690. * Gets or sets the radius of the emission cone
  13691. */
  13692. get radius(): number;
  13693. set radius(value: number);
  13694. /**
  13695. * Gets or sets the angle of the emission cone
  13696. */
  13697. get angle(): number;
  13698. set angle(value: number);
  13699. private _buildHeight;
  13700. /**
  13701. * Creates a new instance ConeParticleEmitter
  13702. * @param radius the radius of the emission cone (1 by default)
  13703. * @param angle the cone base angle (PI by default)
  13704. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13705. */
  13706. constructor(radius?: number, angle?: number,
  13707. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13708. directionRandomizer?: number);
  13709. /**
  13710. * Called by the particle System when the direction is computed for the created particle.
  13711. * @param worldMatrix is the world matrix of the particle system
  13712. * @param directionToUpdate is the direction vector to update with the result
  13713. * @param particle is the particle we are computed the direction for
  13714. * @param isLocal defines if the direction should be set in local space
  13715. */
  13716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13717. /**
  13718. * Called by the particle System when the position is computed for the created particle.
  13719. * @param worldMatrix is the world matrix of the particle system
  13720. * @param positionToUpdate is the position vector to update with the result
  13721. * @param particle is the particle we are computed the position for
  13722. * @param isLocal defines if the position should be set in local space
  13723. */
  13724. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13725. /**
  13726. * Clones the current emitter and returns a copy of it
  13727. * @returns the new emitter
  13728. */
  13729. clone(): ConeParticleEmitter;
  13730. /**
  13731. * Called by the GPUParticleSystem to setup the update shader
  13732. * @param effect defines the update shader
  13733. */
  13734. applyToShader(effect: Effect): void;
  13735. /**
  13736. * Returns a string to use to update the GPU particles update shader
  13737. * @returns a string containng the defines string
  13738. */
  13739. getEffectDefines(): string;
  13740. /**
  13741. * Returns the string "ConeParticleEmitter"
  13742. * @returns a string containing the class name
  13743. */
  13744. getClassName(): string;
  13745. /**
  13746. * Serializes the particle system to a JSON object.
  13747. * @returns the JSON object
  13748. */
  13749. serialize(): any;
  13750. /**
  13751. * Parse properties from a JSON object
  13752. * @param serializationObject defines the JSON object
  13753. */
  13754. parse(serializationObject: any): void;
  13755. }
  13756. }
  13757. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13758. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13759. import { Effect } from "babylonjs/Materials/effect";
  13760. import { Particle } from "babylonjs/Particles/particle";
  13761. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13762. /**
  13763. * Particle emitter emitting particles from the inside of a cylinder.
  13764. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13765. */
  13766. export class CylinderParticleEmitter implements IParticleEmitterType {
  13767. /**
  13768. * The radius of the emission cylinder.
  13769. */
  13770. radius: number;
  13771. /**
  13772. * The height of the emission cylinder.
  13773. */
  13774. height: number;
  13775. /**
  13776. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13777. */
  13778. radiusRange: number;
  13779. /**
  13780. * How much to randomize the particle direction [0-1].
  13781. */
  13782. directionRandomizer: number;
  13783. /**
  13784. * Creates a new instance CylinderParticleEmitter
  13785. * @param radius the radius of the emission cylinder (1 by default)
  13786. * @param height the height of the emission cylinder (1 by default)
  13787. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13788. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13789. */
  13790. constructor(
  13791. /**
  13792. * The radius of the emission cylinder.
  13793. */
  13794. radius?: number,
  13795. /**
  13796. * The height of the emission cylinder.
  13797. */
  13798. height?: number,
  13799. /**
  13800. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13801. */
  13802. radiusRange?: number,
  13803. /**
  13804. * How much to randomize the particle direction [0-1].
  13805. */
  13806. directionRandomizer?: number);
  13807. /**
  13808. * Called by the particle System when the direction is computed for the created particle.
  13809. * @param worldMatrix is the world matrix of the particle system
  13810. * @param directionToUpdate is the direction vector to update with the result
  13811. * @param particle is the particle we are computed the direction for
  13812. * @param isLocal defines if the direction should be set in local space
  13813. */
  13814. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13815. /**
  13816. * Called by the particle System when the position is computed for the created particle.
  13817. * @param worldMatrix is the world matrix of the particle system
  13818. * @param positionToUpdate is the position vector to update with the result
  13819. * @param particle is the particle we are computed the position for
  13820. * @param isLocal defines if the position should be set in local space
  13821. */
  13822. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13823. /**
  13824. * Clones the current emitter and returns a copy of it
  13825. * @returns the new emitter
  13826. */
  13827. clone(): CylinderParticleEmitter;
  13828. /**
  13829. * Called by the GPUParticleSystem to setup the update shader
  13830. * @param effect defines the update shader
  13831. */
  13832. applyToShader(effect: Effect): void;
  13833. /**
  13834. * Returns a string to use to update the GPU particles update shader
  13835. * @returns a string containng the defines string
  13836. */
  13837. getEffectDefines(): string;
  13838. /**
  13839. * Returns the string "CylinderParticleEmitter"
  13840. * @returns a string containing the class name
  13841. */
  13842. getClassName(): string;
  13843. /**
  13844. * Serializes the particle system to a JSON object.
  13845. * @returns the JSON object
  13846. */
  13847. serialize(): any;
  13848. /**
  13849. * Parse properties from a JSON object
  13850. * @param serializationObject defines the JSON object
  13851. */
  13852. parse(serializationObject: any): void;
  13853. }
  13854. /**
  13855. * Particle emitter emitting particles from the inside of a cylinder.
  13856. * It emits the particles randomly between two vectors.
  13857. */
  13858. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13859. /**
  13860. * The min limit of the emission direction.
  13861. */
  13862. direction1: Vector3;
  13863. /**
  13864. * The max limit of the emission direction.
  13865. */
  13866. direction2: Vector3;
  13867. /**
  13868. * Creates a new instance CylinderDirectedParticleEmitter
  13869. * @param radius the radius of the emission cylinder (1 by default)
  13870. * @param height the height of the emission cylinder (1 by default)
  13871. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13872. * @param direction1 the min limit of the emission direction (up vector by default)
  13873. * @param direction2 the max limit of the emission direction (up vector by default)
  13874. */
  13875. constructor(radius?: number, height?: number, radiusRange?: number,
  13876. /**
  13877. * The min limit of the emission direction.
  13878. */
  13879. direction1?: Vector3,
  13880. /**
  13881. * The max limit of the emission direction.
  13882. */
  13883. direction2?: Vector3);
  13884. /**
  13885. * Called by the particle System when the direction is computed for the created particle.
  13886. * @param worldMatrix is the world matrix of the particle system
  13887. * @param directionToUpdate is the direction vector to update with the result
  13888. * @param particle is the particle we are computed the direction for
  13889. */
  13890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13891. /**
  13892. * Clones the current emitter and returns a copy of it
  13893. * @returns the new emitter
  13894. */
  13895. clone(): CylinderDirectedParticleEmitter;
  13896. /**
  13897. * Called by the GPUParticleSystem to setup the update shader
  13898. * @param effect defines the update shader
  13899. */
  13900. applyToShader(effect: Effect): void;
  13901. /**
  13902. * Returns a string to use to update the GPU particles update shader
  13903. * @returns a string containng the defines string
  13904. */
  13905. getEffectDefines(): string;
  13906. /**
  13907. * Returns the string "CylinderDirectedParticleEmitter"
  13908. * @returns a string containing the class name
  13909. */
  13910. getClassName(): string;
  13911. /**
  13912. * Serializes the particle system to a JSON object.
  13913. * @returns the JSON object
  13914. */
  13915. serialize(): any;
  13916. /**
  13917. * Parse properties from a JSON object
  13918. * @param serializationObject defines the JSON object
  13919. */
  13920. parse(serializationObject: any): void;
  13921. }
  13922. }
  13923. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13924. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13925. import { Effect } from "babylonjs/Materials/effect";
  13926. import { Particle } from "babylonjs/Particles/particle";
  13927. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13928. /**
  13929. * Particle emitter emitting particles from the inside of a hemisphere.
  13930. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13931. */
  13932. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13933. /**
  13934. * The radius of the emission hemisphere.
  13935. */
  13936. radius: number;
  13937. /**
  13938. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13939. */
  13940. radiusRange: number;
  13941. /**
  13942. * How much to randomize the particle direction [0-1].
  13943. */
  13944. directionRandomizer: number;
  13945. /**
  13946. * Creates a new instance HemisphericParticleEmitter
  13947. * @param radius the radius of the emission hemisphere (1 by default)
  13948. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13949. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13950. */
  13951. constructor(
  13952. /**
  13953. * The radius of the emission hemisphere.
  13954. */
  13955. radius?: number,
  13956. /**
  13957. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13958. */
  13959. radiusRange?: number,
  13960. /**
  13961. * How much to randomize the particle direction [0-1].
  13962. */
  13963. directionRandomizer?: number);
  13964. /**
  13965. * Called by the particle System when the direction is computed for the created particle.
  13966. * @param worldMatrix is the world matrix of the particle system
  13967. * @param directionToUpdate is the direction vector to update with the result
  13968. * @param particle is the particle we are computed the direction for
  13969. * @param isLocal defines if the direction should be set in local space
  13970. */
  13971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13972. /**
  13973. * Called by the particle System when the position is computed for the created particle.
  13974. * @param worldMatrix is the world matrix of the particle system
  13975. * @param positionToUpdate is the position vector to update with the result
  13976. * @param particle is the particle we are computed the position for
  13977. * @param isLocal defines if the position should be set in local space
  13978. */
  13979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13980. /**
  13981. * Clones the current emitter and returns a copy of it
  13982. * @returns the new emitter
  13983. */
  13984. clone(): HemisphericParticleEmitter;
  13985. /**
  13986. * Called by the GPUParticleSystem to setup the update shader
  13987. * @param effect defines the update shader
  13988. */
  13989. applyToShader(effect: Effect): void;
  13990. /**
  13991. * Returns a string to use to update the GPU particles update shader
  13992. * @returns a string containng the defines string
  13993. */
  13994. getEffectDefines(): string;
  13995. /**
  13996. * Returns the string "HemisphericParticleEmitter"
  13997. * @returns a string containing the class name
  13998. */
  13999. getClassName(): string;
  14000. /**
  14001. * Serializes the particle system to a JSON object.
  14002. * @returns the JSON object
  14003. */
  14004. serialize(): any;
  14005. /**
  14006. * Parse properties from a JSON object
  14007. * @param serializationObject defines the JSON object
  14008. */
  14009. parse(serializationObject: any): void;
  14010. }
  14011. }
  14012. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14013. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14014. import { Effect } from "babylonjs/Materials/effect";
  14015. import { Particle } from "babylonjs/Particles/particle";
  14016. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14017. /**
  14018. * Particle emitter emitting particles from a point.
  14019. * It emits the particles randomly between 2 given directions.
  14020. */
  14021. export class PointParticleEmitter implements IParticleEmitterType {
  14022. /**
  14023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14024. */
  14025. direction1: Vector3;
  14026. /**
  14027. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14028. */
  14029. direction2: Vector3;
  14030. /**
  14031. * Creates a new instance PointParticleEmitter
  14032. */
  14033. constructor();
  14034. /**
  14035. * Called by the particle System when the direction is computed for the created particle.
  14036. * @param worldMatrix is the world matrix of the particle system
  14037. * @param directionToUpdate is the direction vector to update with the result
  14038. * @param particle is the particle we are computed the direction for
  14039. * @param isLocal defines if the direction should be set in local space
  14040. */
  14041. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14042. /**
  14043. * Called by the particle System when the position is computed for the created particle.
  14044. * @param worldMatrix is the world matrix of the particle system
  14045. * @param positionToUpdate is the position vector to update with the result
  14046. * @param particle is the particle we are computed the position for
  14047. * @param isLocal defines if the position should be set in local space
  14048. */
  14049. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14050. /**
  14051. * Clones the current emitter and returns a copy of it
  14052. * @returns the new emitter
  14053. */
  14054. clone(): PointParticleEmitter;
  14055. /**
  14056. * Called by the GPUParticleSystem to setup the update shader
  14057. * @param effect defines the update shader
  14058. */
  14059. applyToShader(effect: Effect): void;
  14060. /**
  14061. * Returns a string to use to update the GPU particles update shader
  14062. * @returns a string containng the defines string
  14063. */
  14064. getEffectDefines(): string;
  14065. /**
  14066. * Returns the string "PointParticleEmitter"
  14067. * @returns a string containing the class name
  14068. */
  14069. getClassName(): string;
  14070. /**
  14071. * Serializes the particle system to a JSON object.
  14072. * @returns the JSON object
  14073. */
  14074. serialize(): any;
  14075. /**
  14076. * Parse properties from a JSON object
  14077. * @param serializationObject defines the JSON object
  14078. */
  14079. parse(serializationObject: any): void;
  14080. }
  14081. }
  14082. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14083. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14084. import { Effect } from "babylonjs/Materials/effect";
  14085. import { Particle } from "babylonjs/Particles/particle";
  14086. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14087. /**
  14088. * Particle emitter emitting particles from the inside of a sphere.
  14089. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14090. */
  14091. export class SphereParticleEmitter implements IParticleEmitterType {
  14092. /**
  14093. * The radius of the emission sphere.
  14094. */
  14095. radius: number;
  14096. /**
  14097. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14098. */
  14099. radiusRange: number;
  14100. /**
  14101. * How much to randomize the particle direction [0-1].
  14102. */
  14103. directionRandomizer: number;
  14104. /**
  14105. * Creates a new instance SphereParticleEmitter
  14106. * @param radius the radius of the emission sphere (1 by default)
  14107. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14108. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14109. */
  14110. constructor(
  14111. /**
  14112. * The radius of the emission sphere.
  14113. */
  14114. radius?: number,
  14115. /**
  14116. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14117. */
  14118. radiusRange?: number,
  14119. /**
  14120. * How much to randomize the particle direction [0-1].
  14121. */
  14122. directionRandomizer?: number);
  14123. /**
  14124. * Called by the particle System when the direction is computed for the created particle.
  14125. * @param worldMatrix is the world matrix of the particle system
  14126. * @param directionToUpdate is the direction vector to update with the result
  14127. * @param particle is the particle we are computed the direction for
  14128. * @param isLocal defines if the direction should be set in local space
  14129. */
  14130. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14131. /**
  14132. * Called by the particle System when the position is computed for the created particle.
  14133. * @param worldMatrix is the world matrix of the particle system
  14134. * @param positionToUpdate is the position vector to update with the result
  14135. * @param particle is the particle we are computed the position for
  14136. * @param isLocal defines if the position should be set in local space
  14137. */
  14138. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14139. /**
  14140. * Clones the current emitter and returns a copy of it
  14141. * @returns the new emitter
  14142. */
  14143. clone(): SphereParticleEmitter;
  14144. /**
  14145. * Called by the GPUParticleSystem to setup the update shader
  14146. * @param effect defines the update shader
  14147. */
  14148. applyToShader(effect: Effect): void;
  14149. /**
  14150. * Returns a string to use to update the GPU particles update shader
  14151. * @returns a string containng the defines string
  14152. */
  14153. getEffectDefines(): string;
  14154. /**
  14155. * Returns the string "SphereParticleEmitter"
  14156. * @returns a string containing the class name
  14157. */
  14158. getClassName(): string;
  14159. /**
  14160. * Serializes the particle system to a JSON object.
  14161. * @returns the JSON object
  14162. */
  14163. serialize(): any;
  14164. /**
  14165. * Parse properties from a JSON object
  14166. * @param serializationObject defines the JSON object
  14167. */
  14168. parse(serializationObject: any): void;
  14169. }
  14170. /**
  14171. * Particle emitter emitting particles from the inside of a sphere.
  14172. * It emits the particles randomly between two vectors.
  14173. */
  14174. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14175. /**
  14176. * The min limit of the emission direction.
  14177. */
  14178. direction1: Vector3;
  14179. /**
  14180. * The max limit of the emission direction.
  14181. */
  14182. direction2: Vector3;
  14183. /**
  14184. * Creates a new instance SphereDirectedParticleEmitter
  14185. * @param radius the radius of the emission sphere (1 by default)
  14186. * @param direction1 the min limit of the emission direction (up vector by default)
  14187. * @param direction2 the max limit of the emission direction (up vector by default)
  14188. */
  14189. constructor(radius?: number,
  14190. /**
  14191. * The min limit of the emission direction.
  14192. */
  14193. direction1?: Vector3,
  14194. /**
  14195. * The max limit of the emission direction.
  14196. */
  14197. direction2?: Vector3);
  14198. /**
  14199. * Called by the particle System when the direction is computed for the created particle.
  14200. * @param worldMatrix is the world matrix of the particle system
  14201. * @param directionToUpdate is the direction vector to update with the result
  14202. * @param particle is the particle we are computed the direction for
  14203. */
  14204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14205. /**
  14206. * Clones the current emitter and returns a copy of it
  14207. * @returns the new emitter
  14208. */
  14209. clone(): SphereDirectedParticleEmitter;
  14210. /**
  14211. * Called by the GPUParticleSystem to setup the update shader
  14212. * @param effect defines the update shader
  14213. */
  14214. applyToShader(effect: Effect): void;
  14215. /**
  14216. * Returns a string to use to update the GPU particles update shader
  14217. * @returns a string containng the defines string
  14218. */
  14219. getEffectDefines(): string;
  14220. /**
  14221. * Returns the string "SphereDirectedParticleEmitter"
  14222. * @returns a string containing the class name
  14223. */
  14224. getClassName(): string;
  14225. /**
  14226. * Serializes the particle system to a JSON object.
  14227. * @returns the JSON object
  14228. */
  14229. serialize(): any;
  14230. /**
  14231. * Parse properties from a JSON object
  14232. * @param serializationObject defines the JSON object
  14233. */
  14234. parse(serializationObject: any): void;
  14235. }
  14236. }
  14237. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14238. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14239. import { Effect } from "babylonjs/Materials/effect";
  14240. import { Particle } from "babylonjs/Particles/particle";
  14241. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14242. import { Nullable } from "babylonjs/types";
  14243. /**
  14244. * Particle emitter emitting particles from a custom list of positions.
  14245. */
  14246. export class CustomParticleEmitter implements IParticleEmitterType {
  14247. /**
  14248. * Gets or sets the position generator that will create the inital position of each particle.
  14249. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14250. */
  14251. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14252. /**
  14253. * Gets or sets the destination generator that will create the final destination of each particle.
  14254. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14255. */
  14256. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14257. /**
  14258. * Creates a new instance CustomParticleEmitter
  14259. */
  14260. constructor();
  14261. /**
  14262. * Called by the particle System when the direction is computed for the created particle.
  14263. * @param worldMatrix is the world matrix of the particle system
  14264. * @param directionToUpdate is the direction vector to update with the result
  14265. * @param particle is the particle we are computed the direction for
  14266. * @param isLocal defines if the direction should be set in local space
  14267. */
  14268. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14269. /**
  14270. * Called by the particle System when the position is computed for the created particle.
  14271. * @param worldMatrix is the world matrix of the particle system
  14272. * @param positionToUpdate is the position vector to update with the result
  14273. * @param particle is the particle we are computed the position for
  14274. * @param isLocal defines if the position should be set in local space
  14275. */
  14276. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14277. /**
  14278. * Clones the current emitter and returns a copy of it
  14279. * @returns the new emitter
  14280. */
  14281. clone(): CustomParticleEmitter;
  14282. /**
  14283. * Called by the GPUParticleSystem to setup the update shader
  14284. * @param effect defines the update shader
  14285. */
  14286. applyToShader(effect: Effect): void;
  14287. /**
  14288. * Returns a string to use to update the GPU particles update shader
  14289. * @returns a string containng the defines string
  14290. */
  14291. getEffectDefines(): string;
  14292. /**
  14293. * Returns the string "PointParticleEmitter"
  14294. * @returns a string containing the class name
  14295. */
  14296. getClassName(): string;
  14297. /**
  14298. * Serializes the particle system to a JSON object.
  14299. * @returns the JSON object
  14300. */
  14301. serialize(): any;
  14302. /**
  14303. * Parse properties from a JSON object
  14304. * @param serializationObject defines the JSON object
  14305. */
  14306. parse(serializationObject: any): void;
  14307. }
  14308. }
  14309. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14310. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14311. import { Effect } from "babylonjs/Materials/effect";
  14312. import { Particle } from "babylonjs/Particles/particle";
  14313. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14314. import { Nullable } from "babylonjs/types";
  14315. import { Scene } from "babylonjs/scene";
  14316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14317. /**
  14318. * Particle emitter emitting particles from the inside of a box.
  14319. * It emits the particles randomly between 2 given directions.
  14320. */
  14321. export class MeshParticleEmitter implements IParticleEmitterType {
  14322. private _indices;
  14323. private _positions;
  14324. private _normals;
  14325. private _storedNormal;
  14326. private _mesh;
  14327. /**
  14328. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14329. */
  14330. direction1: Vector3;
  14331. /**
  14332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14333. */
  14334. direction2: Vector3;
  14335. /**
  14336. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14337. */
  14338. useMeshNormalsForDirection: boolean;
  14339. /** Defines the mesh to use as source */
  14340. get mesh(): Nullable<AbstractMesh>;
  14341. set mesh(value: Nullable<AbstractMesh>);
  14342. /**
  14343. * Creates a new instance MeshParticleEmitter
  14344. * @param mesh defines the mesh to use as source
  14345. */
  14346. constructor(mesh?: Nullable<AbstractMesh>);
  14347. /**
  14348. * Called by the particle System when the direction is computed for the created particle.
  14349. * @param worldMatrix is the world matrix of the particle system
  14350. * @param directionToUpdate is the direction vector to update with the result
  14351. * @param particle is the particle we are computed the direction for
  14352. * @param isLocal defines if the direction should be set in local space
  14353. */
  14354. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14355. /**
  14356. * Called by the particle System when the position is computed for the created particle.
  14357. * @param worldMatrix is the world matrix of the particle system
  14358. * @param positionToUpdate is the position vector to update with the result
  14359. * @param particle is the particle we are computed the position for
  14360. * @param isLocal defines if the position should be set in local space
  14361. */
  14362. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14363. /**
  14364. * Clones the current emitter and returns a copy of it
  14365. * @returns the new emitter
  14366. */
  14367. clone(): MeshParticleEmitter;
  14368. /**
  14369. * Called by the GPUParticleSystem to setup the update shader
  14370. * @param effect defines the update shader
  14371. */
  14372. applyToShader(effect: Effect): void;
  14373. /**
  14374. * Returns a string to use to update the GPU particles update shader
  14375. * @returns a string containng the defines string
  14376. */
  14377. getEffectDefines(): string;
  14378. /**
  14379. * Returns the string "BoxParticleEmitter"
  14380. * @returns a string containing the class name
  14381. */
  14382. getClassName(): string;
  14383. /**
  14384. * Serializes the particle system to a JSON object.
  14385. * @returns the JSON object
  14386. */
  14387. serialize(): any;
  14388. /**
  14389. * Parse properties from a JSON object
  14390. * @param serializationObject defines the JSON object
  14391. * @param scene defines the hosting scene
  14392. */
  14393. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14394. }
  14395. }
  14396. declare module "babylonjs/Particles/EmitterTypes/index" {
  14397. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14398. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14399. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14400. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14401. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14402. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14403. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14404. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14405. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14406. }
  14407. declare module "babylonjs/Particles/IParticleSystem" {
  14408. import { Nullable } from "babylonjs/types";
  14409. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14410. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14411. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14412. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14413. import { Scene } from "babylonjs/scene";
  14414. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14415. import { Effect } from "babylonjs/Materials/effect";
  14416. import { Observable } from "babylonjs/Misc/observable";
  14417. import { Animation } from "babylonjs/Animations/animation";
  14418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14419. /**
  14420. * Interface representing a particle system in Babylon.js.
  14421. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14422. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14423. */
  14424. export interface IParticleSystem {
  14425. /**
  14426. * List of animations used by the particle system.
  14427. */
  14428. animations: Animation[];
  14429. /**
  14430. * The id of the Particle system.
  14431. */
  14432. id: string;
  14433. /**
  14434. * The name of the Particle system.
  14435. */
  14436. name: string;
  14437. /**
  14438. * The emitter represents the Mesh or position we are attaching the particle system to.
  14439. */
  14440. emitter: Nullable<AbstractMesh | Vector3>;
  14441. /**
  14442. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14443. */
  14444. isBillboardBased: boolean;
  14445. /**
  14446. * The rendering group used by the Particle system to chose when to render.
  14447. */
  14448. renderingGroupId: number;
  14449. /**
  14450. * The layer mask we are rendering the particles through.
  14451. */
  14452. layerMask: number;
  14453. /**
  14454. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14455. */
  14456. updateSpeed: number;
  14457. /**
  14458. * The amount of time the particle system is running (depends of the overall update speed).
  14459. */
  14460. targetStopDuration: number;
  14461. /**
  14462. * The texture used to render each particle. (this can be a spritesheet)
  14463. */
  14464. particleTexture: Nullable<BaseTexture>;
  14465. /**
  14466. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14467. */
  14468. blendMode: number;
  14469. /**
  14470. * Minimum life time of emitting particles.
  14471. */
  14472. minLifeTime: number;
  14473. /**
  14474. * Maximum life time of emitting particles.
  14475. */
  14476. maxLifeTime: number;
  14477. /**
  14478. * Minimum Size of emitting particles.
  14479. */
  14480. minSize: number;
  14481. /**
  14482. * Maximum Size of emitting particles.
  14483. */
  14484. maxSize: number;
  14485. /**
  14486. * Minimum scale of emitting particles on X axis.
  14487. */
  14488. minScaleX: number;
  14489. /**
  14490. * Maximum scale of emitting particles on X axis.
  14491. */
  14492. maxScaleX: number;
  14493. /**
  14494. * Minimum scale of emitting particles on Y axis.
  14495. */
  14496. minScaleY: number;
  14497. /**
  14498. * Maximum scale of emitting particles on Y axis.
  14499. */
  14500. maxScaleY: number;
  14501. /**
  14502. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14503. */
  14504. color1: Color4;
  14505. /**
  14506. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14507. */
  14508. color2: Color4;
  14509. /**
  14510. * Color the particle will have at the end of its lifetime.
  14511. */
  14512. colorDead: Color4;
  14513. /**
  14514. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14515. */
  14516. emitRate: number;
  14517. /**
  14518. * You can use gravity if you want to give an orientation to your particles.
  14519. */
  14520. gravity: Vector3;
  14521. /**
  14522. * Minimum power of emitting particles.
  14523. */
  14524. minEmitPower: number;
  14525. /**
  14526. * Maximum power of emitting particles.
  14527. */
  14528. maxEmitPower: number;
  14529. /**
  14530. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14531. */
  14532. minAngularSpeed: number;
  14533. /**
  14534. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14535. */
  14536. maxAngularSpeed: number;
  14537. /**
  14538. * Gets or sets the minimal initial rotation in radians.
  14539. */
  14540. minInitialRotation: number;
  14541. /**
  14542. * Gets or sets the maximal initial rotation in radians.
  14543. */
  14544. maxInitialRotation: number;
  14545. /**
  14546. * The particle emitter type defines the emitter used by the particle system.
  14547. * It can be for example box, sphere, or cone...
  14548. */
  14549. particleEmitterType: Nullable<IParticleEmitterType>;
  14550. /**
  14551. * Defines the delay in milliseconds before starting the system (0 by default)
  14552. */
  14553. startDelay: number;
  14554. /**
  14555. * 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
  14556. */
  14557. preWarmCycles: number;
  14558. /**
  14559. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14560. */
  14561. preWarmStepOffset: number;
  14562. /**
  14563. * 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)
  14564. */
  14565. spriteCellChangeSpeed: number;
  14566. /**
  14567. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14568. */
  14569. startSpriteCellID: number;
  14570. /**
  14571. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14572. */
  14573. endSpriteCellID: number;
  14574. /**
  14575. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14576. */
  14577. spriteCellWidth: number;
  14578. /**
  14579. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14580. */
  14581. spriteCellHeight: number;
  14582. /**
  14583. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14584. */
  14585. spriteRandomStartCell: boolean;
  14586. /**
  14587. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14588. */
  14589. isAnimationSheetEnabled: boolean;
  14590. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14591. translationPivot: Vector2;
  14592. /**
  14593. * Gets or sets a texture used to add random noise to particle positions
  14594. */
  14595. noiseTexture: Nullable<BaseTexture>;
  14596. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14597. noiseStrength: Vector3;
  14598. /**
  14599. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14600. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14601. */
  14602. billboardMode: number;
  14603. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14604. limitVelocityDamping: number;
  14605. /**
  14606. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14607. */
  14608. beginAnimationOnStart: boolean;
  14609. /**
  14610. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14611. */
  14612. beginAnimationFrom: number;
  14613. /**
  14614. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14615. */
  14616. beginAnimationTo: number;
  14617. /**
  14618. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14619. */
  14620. beginAnimationLoop: boolean;
  14621. /**
  14622. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14623. */
  14624. disposeOnStop: boolean;
  14625. /**
  14626. * Specifies if the particles are updated in emitter local space or world space
  14627. */
  14628. isLocal: boolean;
  14629. /** Snippet ID if the particle system was created from the snippet server */
  14630. snippetId: string;
  14631. /** Gets or sets a matrix to use to compute projection */
  14632. defaultProjectionMatrix: Matrix;
  14633. /**
  14634. * Gets the maximum number of particles active at the same time.
  14635. * @returns The max number of active particles.
  14636. */
  14637. getCapacity(): number;
  14638. /**
  14639. * Gets the number of particles active at the same time.
  14640. * @returns The number of active particles.
  14641. */
  14642. getActiveCount(): number;
  14643. /**
  14644. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14645. * @returns True if it has been started, otherwise false.
  14646. */
  14647. isStarted(): boolean;
  14648. /**
  14649. * Animates the particle system for this frame.
  14650. */
  14651. animate(): void;
  14652. /**
  14653. * Renders the particle system in its current state.
  14654. * @returns the current number of particles
  14655. */
  14656. render(): number;
  14657. /**
  14658. * Dispose the particle system and frees its associated resources.
  14659. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14660. */
  14661. dispose(disposeTexture?: boolean): void;
  14662. /**
  14663. * An event triggered when the system is disposed
  14664. */
  14665. onDisposeObservable: Observable<IParticleSystem>;
  14666. /**
  14667. * Clones the particle system.
  14668. * @param name The name of the cloned object
  14669. * @param newEmitter The new emitter to use
  14670. * @returns the cloned particle system
  14671. */
  14672. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14673. /**
  14674. * Serializes the particle system to a JSON object
  14675. * @param serializeTexture defines if the texture must be serialized as well
  14676. * @returns the JSON object
  14677. */
  14678. serialize(serializeTexture: boolean): any;
  14679. /**
  14680. * Rebuild the particle system
  14681. */
  14682. rebuild(): void;
  14683. /** Force the system to rebuild all gradients that need to be resync */
  14684. forceRefreshGradients(): void;
  14685. /**
  14686. * Starts the particle system and begins to emit
  14687. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14688. */
  14689. start(delay?: number): void;
  14690. /**
  14691. * Stops the particle system.
  14692. */
  14693. stop(): void;
  14694. /**
  14695. * Remove all active particles
  14696. */
  14697. reset(): void;
  14698. /**
  14699. * Gets a boolean indicating that the system is stopping
  14700. * @returns true if the system is currently stopping
  14701. */
  14702. isStopping(): boolean;
  14703. /**
  14704. * Is this system ready to be used/rendered
  14705. * @return true if the system is ready
  14706. */
  14707. isReady(): boolean;
  14708. /**
  14709. * Returns the string "ParticleSystem"
  14710. * @returns a string containing the class name
  14711. */
  14712. getClassName(): string;
  14713. /**
  14714. * Gets the custom effect used to render the particles
  14715. * @param blendMode Blend mode for which the effect should be retrieved
  14716. * @returns The effect
  14717. */
  14718. getCustomEffect(blendMode: number): Nullable<Effect>;
  14719. /**
  14720. * Sets the custom effect used to render the particles
  14721. * @param effect The effect to set
  14722. * @param blendMode Blend mode for which the effect should be set
  14723. */
  14724. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14725. /**
  14726. * Fill the defines array according to the current settings of the particle system
  14727. * @param defines Array to be updated
  14728. * @param blendMode blend mode to take into account when updating the array
  14729. */
  14730. fillDefines(defines: Array<string>, blendMode: number): void;
  14731. /**
  14732. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14733. * @param uniforms Uniforms array to fill
  14734. * @param attributes Attributes array to fill
  14735. * @param samplers Samplers array to fill
  14736. */
  14737. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14738. /**
  14739. * Observable that will be called just before the particles are drawn
  14740. */
  14741. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14742. /**
  14743. * Gets the name of the particle vertex shader
  14744. */
  14745. vertexShaderName: string;
  14746. /**
  14747. * Adds a new color gradient
  14748. * @param gradient defines the gradient to use (between 0 and 1)
  14749. * @param color1 defines the color to affect to the specified gradient
  14750. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14751. * @returns the current particle system
  14752. */
  14753. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14754. /**
  14755. * Remove a specific color gradient
  14756. * @param gradient defines the gradient to remove
  14757. * @returns the current particle system
  14758. */
  14759. removeColorGradient(gradient: number): IParticleSystem;
  14760. /**
  14761. * Adds a new size gradient
  14762. * @param gradient defines the gradient to use (between 0 and 1)
  14763. * @param factor defines the size factor to affect to the specified gradient
  14764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14765. * @returns the current particle system
  14766. */
  14767. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14768. /**
  14769. * Remove a specific size gradient
  14770. * @param gradient defines the gradient to remove
  14771. * @returns the current particle system
  14772. */
  14773. removeSizeGradient(gradient: number): IParticleSystem;
  14774. /**
  14775. * Gets the current list of color gradients.
  14776. * You must use addColorGradient and removeColorGradient to udpate this list
  14777. * @returns the list of color gradients
  14778. */
  14779. getColorGradients(): Nullable<Array<ColorGradient>>;
  14780. /**
  14781. * Gets the current list of size gradients.
  14782. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14783. * @returns the list of size gradients
  14784. */
  14785. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14786. /**
  14787. * Gets the current list of angular speed gradients.
  14788. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14789. * @returns the list of angular speed gradients
  14790. */
  14791. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14792. /**
  14793. * Adds a new angular speed gradient
  14794. * @param gradient defines the gradient to use (between 0 and 1)
  14795. * @param factor defines the angular speed to affect to the specified gradient
  14796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14797. * @returns the current particle system
  14798. */
  14799. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14800. /**
  14801. * Remove a specific angular speed gradient
  14802. * @param gradient defines the gradient to remove
  14803. * @returns the current particle system
  14804. */
  14805. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14806. /**
  14807. * Gets the current list of velocity gradients.
  14808. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14809. * @returns the list of velocity gradients
  14810. */
  14811. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14812. /**
  14813. * Adds a new velocity gradient
  14814. * @param gradient defines the gradient to use (between 0 and 1)
  14815. * @param factor defines the velocity to affect to the specified gradient
  14816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14817. * @returns the current particle system
  14818. */
  14819. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14820. /**
  14821. * Remove a specific velocity gradient
  14822. * @param gradient defines the gradient to remove
  14823. * @returns the current particle system
  14824. */
  14825. removeVelocityGradient(gradient: number): IParticleSystem;
  14826. /**
  14827. * Gets the current list of limit velocity gradients.
  14828. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14829. * @returns the list of limit velocity gradients
  14830. */
  14831. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14832. /**
  14833. * Adds a new limit velocity gradient
  14834. * @param gradient defines the gradient to use (between 0 and 1)
  14835. * @param factor defines the limit velocity to affect to the specified gradient
  14836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14837. * @returns the current particle system
  14838. */
  14839. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14840. /**
  14841. * Remove a specific limit velocity gradient
  14842. * @param gradient defines the gradient to remove
  14843. * @returns the current particle system
  14844. */
  14845. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14846. /**
  14847. * Adds a new drag gradient
  14848. * @param gradient defines the gradient to use (between 0 and 1)
  14849. * @param factor defines the drag to affect to the specified gradient
  14850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14851. * @returns the current particle system
  14852. */
  14853. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14854. /**
  14855. * Remove a specific drag gradient
  14856. * @param gradient defines the gradient to remove
  14857. * @returns the current particle system
  14858. */
  14859. removeDragGradient(gradient: number): IParticleSystem;
  14860. /**
  14861. * Gets the current list of drag gradients.
  14862. * You must use addDragGradient and removeDragGradient to udpate this list
  14863. * @returns the list of drag gradients
  14864. */
  14865. getDragGradients(): Nullable<Array<FactorGradient>>;
  14866. /**
  14867. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14868. * @param gradient defines the gradient to use (between 0 and 1)
  14869. * @param factor defines the emit rate to affect to the specified gradient
  14870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14871. * @returns the current particle system
  14872. */
  14873. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14874. /**
  14875. * Remove a specific emit rate gradient
  14876. * @param gradient defines the gradient to remove
  14877. * @returns the current particle system
  14878. */
  14879. removeEmitRateGradient(gradient: number): IParticleSystem;
  14880. /**
  14881. * Gets the current list of emit rate gradients.
  14882. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14883. * @returns the list of emit rate gradients
  14884. */
  14885. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14886. /**
  14887. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14888. * @param gradient defines the gradient to use (between 0 and 1)
  14889. * @param factor defines the start size to affect to the specified gradient
  14890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14891. * @returns the current particle system
  14892. */
  14893. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14894. /**
  14895. * Remove a specific start size gradient
  14896. * @param gradient defines the gradient to remove
  14897. * @returns the current particle system
  14898. */
  14899. removeStartSizeGradient(gradient: number): IParticleSystem;
  14900. /**
  14901. * Gets the current list of start size gradients.
  14902. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14903. * @returns the list of start size gradients
  14904. */
  14905. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14906. /**
  14907. * Adds a new life time gradient
  14908. * @param gradient defines the gradient to use (between 0 and 1)
  14909. * @param factor defines the life time factor to affect to the specified gradient
  14910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14911. * @returns the current particle system
  14912. */
  14913. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14914. /**
  14915. * Remove a specific life time gradient
  14916. * @param gradient defines the gradient to remove
  14917. * @returns the current particle system
  14918. */
  14919. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14920. /**
  14921. * Gets the current list of life time gradients.
  14922. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14923. * @returns the list of life time gradients
  14924. */
  14925. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14926. /**
  14927. * Gets the current list of color gradients.
  14928. * You must use addColorGradient and removeColorGradient to udpate this list
  14929. * @returns the list of color gradients
  14930. */
  14931. getColorGradients(): Nullable<Array<ColorGradient>>;
  14932. /**
  14933. * Adds a new ramp gradient used to remap particle colors
  14934. * @param gradient defines the gradient to use (between 0 and 1)
  14935. * @param color defines the color to affect to the specified gradient
  14936. * @returns the current particle system
  14937. */
  14938. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14939. /**
  14940. * Gets the current list of ramp gradients.
  14941. * You must use addRampGradient and removeRampGradient to udpate this list
  14942. * @returns the list of ramp gradients
  14943. */
  14944. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14945. /** Gets or sets a boolean indicating that ramp gradients must be used
  14946. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14947. */
  14948. useRampGradients: boolean;
  14949. /**
  14950. * Adds a new color remap gradient
  14951. * @param gradient defines the gradient to use (between 0 and 1)
  14952. * @param min defines the color remap minimal range
  14953. * @param max defines the color remap maximal range
  14954. * @returns the current particle system
  14955. */
  14956. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14957. /**
  14958. * Gets the current list of color remap gradients.
  14959. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14960. * @returns the list of color remap gradients
  14961. */
  14962. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14963. /**
  14964. * Adds a new alpha remap gradient
  14965. * @param gradient defines the gradient to use (between 0 and 1)
  14966. * @param min defines the alpha remap minimal range
  14967. * @param max defines the alpha remap maximal range
  14968. * @returns the current particle system
  14969. */
  14970. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14971. /**
  14972. * Gets the current list of alpha remap gradients.
  14973. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14974. * @returns the list of alpha remap gradients
  14975. */
  14976. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14977. /**
  14978. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14979. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14980. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14981. * @returns the emitter
  14982. */
  14983. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14984. /**
  14985. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14986. * @param radius The radius of the hemisphere to emit from
  14987. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14988. * @returns the emitter
  14989. */
  14990. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14991. /**
  14992. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14993. * @param radius The radius of the sphere to emit from
  14994. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14995. * @returns the emitter
  14996. */
  14997. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14998. /**
  14999. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15000. * @param radius The radius of the sphere to emit from
  15001. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15002. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15003. * @returns the emitter
  15004. */
  15005. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15006. /**
  15007. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15008. * @param radius The radius of the emission cylinder
  15009. * @param height The height of the emission cylinder
  15010. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15011. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15012. * @returns the emitter
  15013. */
  15014. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15015. /**
  15016. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15017. * @param radius The radius of the cylinder to emit from
  15018. * @param height The height of the emission cylinder
  15019. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15020. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15021. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15022. * @returns the emitter
  15023. */
  15024. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15025. /**
  15026. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15027. * @param radius The radius of the cone to emit from
  15028. * @param angle The base angle of the cone
  15029. * @returns the emitter
  15030. */
  15031. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15032. /**
  15033. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15034. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15035. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15036. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15037. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15038. * @returns the emitter
  15039. */
  15040. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15041. /**
  15042. * Get hosting scene
  15043. * @returns the scene
  15044. */
  15045. getScene(): Nullable<Scene>;
  15046. }
  15047. }
  15048. declare module "babylonjs/Meshes/transformNode" {
  15049. import { DeepImmutable } from "babylonjs/types";
  15050. import { Observable } from "babylonjs/Misc/observable";
  15051. import { Nullable } from "babylonjs/types";
  15052. import { Camera } from "babylonjs/Cameras/camera";
  15053. import { Scene } from "babylonjs/scene";
  15054. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15055. import { Node } from "babylonjs/node";
  15056. import { Bone } from "babylonjs/Bones/bone";
  15057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15058. import { Space } from "babylonjs/Maths/math.axis";
  15059. /**
  15060. * 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.
  15061. * @see https://doc.babylonjs.com/how_to/transformnode
  15062. */
  15063. export class TransformNode extends Node {
  15064. /**
  15065. * Object will not rotate to face the camera
  15066. */
  15067. static BILLBOARDMODE_NONE: number;
  15068. /**
  15069. * Object will rotate to face the camera but only on the x axis
  15070. */
  15071. static BILLBOARDMODE_X: number;
  15072. /**
  15073. * Object will rotate to face the camera but only on the y axis
  15074. */
  15075. static BILLBOARDMODE_Y: number;
  15076. /**
  15077. * Object will rotate to face the camera but only on the z axis
  15078. */
  15079. static BILLBOARDMODE_Z: number;
  15080. /**
  15081. * Object will rotate to face the camera
  15082. */
  15083. static BILLBOARDMODE_ALL: number;
  15084. /**
  15085. * Object will rotate to face the camera's position instead of orientation
  15086. */
  15087. static BILLBOARDMODE_USE_POSITION: number;
  15088. private static _TmpRotation;
  15089. private static _TmpScaling;
  15090. private static _TmpTranslation;
  15091. private _forward;
  15092. private _forwardInverted;
  15093. private _up;
  15094. private _right;
  15095. private _rightInverted;
  15096. private _position;
  15097. private _rotation;
  15098. private _rotationQuaternion;
  15099. protected _scaling: Vector3;
  15100. protected _isDirty: boolean;
  15101. private _transformToBoneReferal;
  15102. private _isAbsoluteSynced;
  15103. private _billboardMode;
  15104. /**
  15105. * Gets or sets the billboard mode. Default is 0.
  15106. *
  15107. * | Value | Type | Description |
  15108. * | --- | --- | --- |
  15109. * | 0 | BILLBOARDMODE_NONE | |
  15110. * | 1 | BILLBOARDMODE_X | |
  15111. * | 2 | BILLBOARDMODE_Y | |
  15112. * | 4 | BILLBOARDMODE_Z | |
  15113. * | 7 | BILLBOARDMODE_ALL | |
  15114. *
  15115. */
  15116. get billboardMode(): number;
  15117. set billboardMode(value: number);
  15118. private _preserveParentRotationForBillboard;
  15119. /**
  15120. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15121. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15122. */
  15123. get preserveParentRotationForBillboard(): boolean;
  15124. set preserveParentRotationForBillboard(value: boolean);
  15125. /**
  15126. * 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
  15127. */
  15128. scalingDeterminant: number;
  15129. private _infiniteDistance;
  15130. /**
  15131. * Gets or sets the distance of the object to max, often used by skybox
  15132. */
  15133. get infiniteDistance(): boolean;
  15134. set infiniteDistance(value: boolean);
  15135. /**
  15136. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15137. * By default the system will update normals to compensate
  15138. */
  15139. ignoreNonUniformScaling: boolean;
  15140. /**
  15141. * 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
  15142. */
  15143. reIntegrateRotationIntoRotationQuaternion: boolean;
  15144. /** @hidden */
  15145. _poseMatrix: Nullable<Matrix>;
  15146. /** @hidden */
  15147. _localMatrix: Matrix;
  15148. private _usePivotMatrix;
  15149. private _absolutePosition;
  15150. private _absoluteScaling;
  15151. private _absoluteRotationQuaternion;
  15152. private _pivotMatrix;
  15153. private _pivotMatrixInverse;
  15154. /** @hidden */
  15155. _postMultiplyPivotMatrix: boolean;
  15156. protected _isWorldMatrixFrozen: boolean;
  15157. /** @hidden */
  15158. _indexInSceneTransformNodesArray: number;
  15159. /**
  15160. * An event triggered after the world matrix is updated
  15161. */
  15162. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15163. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15164. /**
  15165. * Gets a string identifying the name of the class
  15166. * @returns "TransformNode" string
  15167. */
  15168. getClassName(): string;
  15169. /**
  15170. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15171. */
  15172. get position(): Vector3;
  15173. set position(newPosition: Vector3);
  15174. /**
  15175. * 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)).
  15176. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15177. */
  15178. get rotation(): Vector3;
  15179. set rotation(newRotation: Vector3);
  15180. /**
  15181. * 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)).
  15182. */
  15183. get scaling(): Vector3;
  15184. set scaling(newScaling: Vector3);
  15185. /**
  15186. * 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).
  15187. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15188. */
  15189. get rotationQuaternion(): Nullable<Quaternion>;
  15190. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15191. /**
  15192. * The forward direction of that transform in world space.
  15193. */
  15194. get forward(): Vector3;
  15195. /**
  15196. * The up direction of that transform in world space.
  15197. */
  15198. get up(): Vector3;
  15199. /**
  15200. * The right direction of that transform in world space.
  15201. */
  15202. get right(): Vector3;
  15203. /**
  15204. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15205. * @param matrix the matrix to copy the pose from
  15206. * @returns this TransformNode.
  15207. */
  15208. updatePoseMatrix(matrix: Matrix): TransformNode;
  15209. /**
  15210. * Returns the mesh Pose matrix.
  15211. * @returns the pose matrix
  15212. */
  15213. getPoseMatrix(): Matrix;
  15214. /** @hidden */
  15215. _isSynchronized(): boolean;
  15216. /** @hidden */
  15217. _initCache(): void;
  15218. /**
  15219. * Flag the transform node as dirty (Forcing it to update everything)
  15220. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15221. * @returns this transform node
  15222. */
  15223. markAsDirty(property: string): TransformNode;
  15224. /**
  15225. * Returns the current mesh absolute position.
  15226. * Returns a Vector3.
  15227. */
  15228. get absolutePosition(): Vector3;
  15229. /**
  15230. * Returns the current mesh absolute scaling.
  15231. * Returns a Vector3.
  15232. */
  15233. get absoluteScaling(): Vector3;
  15234. /**
  15235. * Returns the current mesh absolute rotation.
  15236. * Returns a Quaternion.
  15237. */
  15238. get absoluteRotationQuaternion(): Quaternion;
  15239. /**
  15240. * Sets a new matrix to apply before all other transformation
  15241. * @param matrix defines the transform matrix
  15242. * @returns the current TransformNode
  15243. */
  15244. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15245. /**
  15246. * Sets a new pivot matrix to the current node
  15247. * @param matrix defines the new pivot matrix to use
  15248. * @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
  15249. * @returns the current TransformNode
  15250. */
  15251. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15252. /**
  15253. * Returns the mesh pivot matrix.
  15254. * Default : Identity.
  15255. * @returns the matrix
  15256. */
  15257. getPivotMatrix(): Matrix;
  15258. /**
  15259. * Instantiate (when possible) or clone that node with its hierarchy
  15260. * @param newParent defines the new parent to use for the instance (or clone)
  15261. * @param options defines options to configure how copy is done
  15262. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15263. * @returns an instance (or a clone) of the current node with its hiearchy
  15264. */
  15265. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15266. doNotInstantiate: boolean;
  15267. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15268. /**
  15269. * Prevents the World matrix to be computed any longer
  15270. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15271. * @returns the TransformNode.
  15272. */
  15273. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15274. /**
  15275. * Allows back the World matrix computation.
  15276. * @returns the TransformNode.
  15277. */
  15278. unfreezeWorldMatrix(): this;
  15279. /**
  15280. * True if the World matrix has been frozen.
  15281. */
  15282. get isWorldMatrixFrozen(): boolean;
  15283. /**
  15284. * Retuns the mesh absolute position in the World.
  15285. * @returns a Vector3.
  15286. */
  15287. getAbsolutePosition(): Vector3;
  15288. /**
  15289. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15290. * @param absolutePosition the absolute position to set
  15291. * @returns the TransformNode.
  15292. */
  15293. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15294. /**
  15295. * Sets the mesh position in its local space.
  15296. * @param vector3 the position to set in localspace
  15297. * @returns the TransformNode.
  15298. */
  15299. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15300. /**
  15301. * Returns the mesh position in the local space from the current World matrix values.
  15302. * @returns a new Vector3.
  15303. */
  15304. getPositionExpressedInLocalSpace(): Vector3;
  15305. /**
  15306. * Translates the mesh along the passed Vector3 in its local space.
  15307. * @param vector3 the distance to translate in localspace
  15308. * @returns the TransformNode.
  15309. */
  15310. locallyTranslate(vector3: Vector3): TransformNode;
  15311. private static _lookAtVectorCache;
  15312. /**
  15313. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15314. * @param targetPoint the position (must be in same space as current mesh) to look at
  15315. * @param yawCor optional yaw (y-axis) correction in radians
  15316. * @param pitchCor optional pitch (x-axis) correction in radians
  15317. * @param rollCor optional roll (z-axis) correction in radians
  15318. * @param space the choosen space of the target
  15319. * @returns the TransformNode.
  15320. */
  15321. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15322. /**
  15323. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15324. * This Vector3 is expressed in the World space.
  15325. * @param localAxis axis to rotate
  15326. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15327. */
  15328. getDirection(localAxis: Vector3): Vector3;
  15329. /**
  15330. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15331. * localAxis is expressed in the mesh local space.
  15332. * result is computed in the Wordl space from the mesh World matrix.
  15333. * @param localAxis axis to rotate
  15334. * @param result the resulting transformnode
  15335. * @returns this TransformNode.
  15336. */
  15337. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15338. /**
  15339. * Sets this transform node rotation to the given local axis.
  15340. * @param localAxis the axis in local space
  15341. * @param yawCor optional yaw (y-axis) correction in radians
  15342. * @param pitchCor optional pitch (x-axis) correction in radians
  15343. * @param rollCor optional roll (z-axis) correction in radians
  15344. * @returns this TransformNode
  15345. */
  15346. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15347. /**
  15348. * Sets a new pivot point to the current node
  15349. * @param point defines the new pivot point to use
  15350. * @param space defines if the point is in world or local space (local by default)
  15351. * @returns the current TransformNode
  15352. */
  15353. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15354. /**
  15355. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15356. * @returns the pivot point
  15357. */
  15358. getPivotPoint(): Vector3;
  15359. /**
  15360. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15361. * @param result the vector3 to store the result
  15362. * @returns this TransformNode.
  15363. */
  15364. getPivotPointToRef(result: Vector3): TransformNode;
  15365. /**
  15366. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15367. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15368. */
  15369. getAbsolutePivotPoint(): Vector3;
  15370. /**
  15371. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15372. * @param result vector3 to store the result
  15373. * @returns this TransformNode.
  15374. */
  15375. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15376. /**
  15377. * Defines the passed node as the parent of the current node.
  15378. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15379. * @see https://doc.babylonjs.com/how_to/parenting
  15380. * @param node the node ot set as the parent
  15381. * @returns this TransformNode.
  15382. */
  15383. setParent(node: Nullable<Node>): TransformNode;
  15384. private _nonUniformScaling;
  15385. /**
  15386. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15387. */
  15388. get nonUniformScaling(): boolean;
  15389. /** @hidden */
  15390. _updateNonUniformScalingState(value: boolean): boolean;
  15391. /**
  15392. * Attach the current TransformNode to another TransformNode associated with a bone
  15393. * @param bone Bone affecting the TransformNode
  15394. * @param affectedTransformNode TransformNode associated with the bone
  15395. * @returns this object
  15396. */
  15397. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15398. /**
  15399. * Detach the transform node if its associated with a bone
  15400. * @returns this object
  15401. */
  15402. detachFromBone(): TransformNode;
  15403. private static _rotationAxisCache;
  15404. /**
  15405. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15406. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15407. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15408. * The passed axis is also normalized.
  15409. * @param axis the axis to rotate around
  15410. * @param amount the amount to rotate in radians
  15411. * @param space Space to rotate in (Default: local)
  15412. * @returns the TransformNode.
  15413. */
  15414. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15415. /**
  15416. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15417. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15418. * The passed axis is also normalized. .
  15419. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15420. * @param point the point to rotate around
  15421. * @param axis the axis to rotate around
  15422. * @param amount the amount to rotate in radians
  15423. * @returns the TransformNode
  15424. */
  15425. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15426. /**
  15427. * Translates the mesh along the axis vector for the passed distance in the given space.
  15428. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15429. * @param axis the axis to translate in
  15430. * @param distance the distance to translate
  15431. * @param space Space to rotate in (Default: local)
  15432. * @returns the TransformNode.
  15433. */
  15434. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15435. /**
  15436. * Adds a rotation step to the mesh current rotation.
  15437. * x, y, z are Euler angles expressed in radians.
  15438. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15439. * This means this rotation is made in the mesh local space only.
  15440. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15441. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15442. * ```javascript
  15443. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15444. * ```
  15445. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15446. * 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.
  15447. * @param x Rotation to add
  15448. * @param y Rotation to add
  15449. * @param z Rotation to add
  15450. * @returns the TransformNode.
  15451. */
  15452. addRotation(x: number, y: number, z: number): TransformNode;
  15453. /**
  15454. * @hidden
  15455. */
  15456. protected _getEffectiveParent(): Nullable<Node>;
  15457. /**
  15458. * Computes the world matrix of the node
  15459. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15460. * @returns the world matrix
  15461. */
  15462. computeWorldMatrix(force?: boolean): Matrix;
  15463. /**
  15464. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15465. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15466. */
  15467. resetLocalMatrix(independentOfChildren?: boolean): void;
  15468. protected _afterComputeWorldMatrix(): void;
  15469. /**
  15470. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15471. * @param func callback function to add
  15472. *
  15473. * @returns the TransformNode.
  15474. */
  15475. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15476. /**
  15477. * Removes a registered callback function.
  15478. * @param func callback function to remove
  15479. * @returns the TransformNode.
  15480. */
  15481. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15482. /**
  15483. * Gets the position of the current mesh in camera space
  15484. * @param camera defines the camera to use
  15485. * @returns a position
  15486. */
  15487. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15488. /**
  15489. * Returns the distance from the mesh to the active camera
  15490. * @param camera defines the camera to use
  15491. * @returns the distance
  15492. */
  15493. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15494. /**
  15495. * Clone the current transform node
  15496. * @param name Name of the new clone
  15497. * @param newParent New parent for the clone
  15498. * @param doNotCloneChildren Do not clone children hierarchy
  15499. * @returns the new transform node
  15500. */
  15501. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15502. /**
  15503. * Serializes the objects information.
  15504. * @param currentSerializationObject defines the object to serialize in
  15505. * @returns the serialized object
  15506. */
  15507. serialize(currentSerializationObject?: any): any;
  15508. /**
  15509. * Returns a new TransformNode object parsed from the source provided.
  15510. * @param parsedTransformNode is the source.
  15511. * @param scene the scne the object belongs to
  15512. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15513. * @returns a new TransformNode object parsed from the source provided.
  15514. */
  15515. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15516. /**
  15517. * Get all child-transformNodes of this node
  15518. * @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
  15519. * @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
  15520. * @returns an array of TransformNode
  15521. */
  15522. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15523. /**
  15524. * Releases resources associated with this transform node.
  15525. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15526. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15527. */
  15528. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15529. /**
  15530. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15531. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15532. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15533. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15534. * @returns the current mesh
  15535. */
  15536. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15537. private _syncAbsoluteScalingAndRotation;
  15538. }
  15539. }
  15540. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15541. /**
  15542. * Class used to override all child animations of a given target
  15543. */
  15544. export class AnimationPropertiesOverride {
  15545. /**
  15546. * Gets or sets a value indicating if animation blending must be used
  15547. */
  15548. enableBlending: boolean;
  15549. /**
  15550. * Gets or sets the blending speed to use when enableBlending is true
  15551. */
  15552. blendingSpeed: number;
  15553. /**
  15554. * Gets or sets the default loop mode to use
  15555. */
  15556. loopMode: number;
  15557. }
  15558. }
  15559. declare module "babylonjs/Bones/bone" {
  15560. import { Skeleton } from "babylonjs/Bones/skeleton";
  15561. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15562. import { Nullable } from "babylonjs/types";
  15563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15564. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15565. import { Node } from "babylonjs/node";
  15566. import { Space } from "babylonjs/Maths/math.axis";
  15567. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15568. /**
  15569. * Class used to store bone information
  15570. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15571. */
  15572. export class Bone extends Node {
  15573. /**
  15574. * defines the bone name
  15575. */
  15576. name: string;
  15577. private static _tmpVecs;
  15578. private static _tmpQuat;
  15579. private static _tmpMats;
  15580. /**
  15581. * Gets the list of child bones
  15582. */
  15583. children: Bone[];
  15584. /** Gets the animations associated with this bone */
  15585. animations: import("babylonjs/Animations/animation").Animation[];
  15586. /**
  15587. * Gets or sets bone length
  15588. */
  15589. length: number;
  15590. /**
  15591. * @hidden Internal only
  15592. * Set this value to map this bone to a different index in the transform matrices
  15593. * Set this value to -1 to exclude the bone from the transform matrices
  15594. */
  15595. _index: Nullable<number>;
  15596. private _skeleton;
  15597. private _localMatrix;
  15598. private _restPose;
  15599. private _bindPose;
  15600. private _baseMatrix;
  15601. private _absoluteTransform;
  15602. private _invertedAbsoluteTransform;
  15603. private _parent;
  15604. private _scalingDeterminant;
  15605. private _worldTransform;
  15606. private _localScaling;
  15607. private _localRotation;
  15608. private _localPosition;
  15609. private _needToDecompose;
  15610. private _needToCompose;
  15611. /** @hidden */
  15612. _linkedTransformNode: Nullable<TransformNode>;
  15613. /** @hidden */
  15614. _waitingTransformNodeId: Nullable<string>;
  15615. /** @hidden */
  15616. get _matrix(): Matrix;
  15617. /** @hidden */
  15618. set _matrix(value: Matrix);
  15619. /**
  15620. * Create a new bone
  15621. * @param name defines the bone name
  15622. * @param skeleton defines the parent skeleton
  15623. * @param parentBone defines the parent (can be null if the bone is the root)
  15624. * @param localMatrix defines the local matrix
  15625. * @param restPose defines the rest pose matrix
  15626. * @param baseMatrix defines the base matrix
  15627. * @param index defines index of the bone in the hiearchy
  15628. */
  15629. constructor(
  15630. /**
  15631. * defines the bone name
  15632. */
  15633. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15634. /**
  15635. * Gets the current object class name.
  15636. * @return the class name
  15637. */
  15638. getClassName(): string;
  15639. /**
  15640. * Gets the parent skeleton
  15641. * @returns a skeleton
  15642. */
  15643. getSkeleton(): Skeleton;
  15644. /**
  15645. * Gets parent bone
  15646. * @returns a bone or null if the bone is the root of the bone hierarchy
  15647. */
  15648. getParent(): Nullable<Bone>;
  15649. /**
  15650. * Returns an array containing the root bones
  15651. * @returns an array containing the root bones
  15652. */
  15653. getChildren(): Array<Bone>;
  15654. /**
  15655. * Gets the node index in matrix array generated for rendering
  15656. * @returns the node index
  15657. */
  15658. getIndex(): number;
  15659. /**
  15660. * Sets the parent bone
  15661. * @param parent defines the parent (can be null if the bone is the root)
  15662. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15663. */
  15664. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15665. /**
  15666. * Gets the local matrix
  15667. * @returns a matrix
  15668. */
  15669. getLocalMatrix(): Matrix;
  15670. /**
  15671. * Gets the base matrix (initial matrix which remains unchanged)
  15672. * @returns a matrix
  15673. */
  15674. getBaseMatrix(): Matrix;
  15675. /**
  15676. * Gets the rest pose matrix
  15677. * @returns a matrix
  15678. */
  15679. getRestPose(): Matrix;
  15680. /**
  15681. * Sets the rest pose matrix
  15682. * @param matrix the local-space rest pose to set for this bone
  15683. */
  15684. setRestPose(matrix: Matrix): void;
  15685. /**
  15686. * Gets the bind pose matrix
  15687. * @returns the bind pose matrix
  15688. */
  15689. getBindPose(): Matrix;
  15690. /**
  15691. * Sets the bind pose matrix
  15692. * @param matrix the local-space bind pose to set for this bone
  15693. */
  15694. setBindPose(matrix: Matrix): void;
  15695. /**
  15696. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15697. */
  15698. getWorldMatrix(): Matrix;
  15699. /**
  15700. * Sets the local matrix to rest pose matrix
  15701. */
  15702. returnToRest(): void;
  15703. /**
  15704. * Gets the inverse of the absolute transform matrix.
  15705. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15706. * @returns a matrix
  15707. */
  15708. getInvertedAbsoluteTransform(): Matrix;
  15709. /**
  15710. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15711. * @returns a matrix
  15712. */
  15713. getAbsoluteTransform(): Matrix;
  15714. /**
  15715. * Links with the given transform node.
  15716. * The local matrix of this bone is copied from the transform node every frame.
  15717. * @param transformNode defines the transform node to link to
  15718. */
  15719. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15720. /**
  15721. * Gets the node used to drive the bone's transformation
  15722. * @returns a transform node or null
  15723. */
  15724. getTransformNode(): Nullable<TransformNode>;
  15725. /** Gets or sets current position (in local space) */
  15726. get position(): Vector3;
  15727. set position(newPosition: Vector3);
  15728. /** Gets or sets current rotation (in local space) */
  15729. get rotation(): Vector3;
  15730. set rotation(newRotation: Vector3);
  15731. /** Gets or sets current rotation quaternion (in local space) */
  15732. get rotationQuaternion(): Quaternion;
  15733. set rotationQuaternion(newRotation: Quaternion);
  15734. /** Gets or sets current scaling (in local space) */
  15735. get scaling(): Vector3;
  15736. set scaling(newScaling: Vector3);
  15737. /**
  15738. * Gets the animation properties override
  15739. */
  15740. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15741. private _decompose;
  15742. private _compose;
  15743. /**
  15744. * Update the base and local matrices
  15745. * @param matrix defines the new base or local matrix
  15746. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15747. * @param updateLocalMatrix defines if the local matrix should be updated
  15748. */
  15749. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15750. /** @hidden */
  15751. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15752. /**
  15753. * Flag the bone as dirty (Forcing it to update everything)
  15754. */
  15755. markAsDirty(): void;
  15756. /** @hidden */
  15757. _markAsDirtyAndCompose(): void;
  15758. private _markAsDirtyAndDecompose;
  15759. /**
  15760. * Translate the bone in local or world space
  15761. * @param vec The amount to translate the bone
  15762. * @param space The space that the translation is in
  15763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15764. */
  15765. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15766. /**
  15767. * Set the postion of the bone in local or world space
  15768. * @param position The position to set the bone
  15769. * @param space The space that the position is in
  15770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15771. */
  15772. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15773. /**
  15774. * Set the absolute position of the bone (world space)
  15775. * @param position The position to set the bone
  15776. * @param mesh The mesh that this bone is attached to
  15777. */
  15778. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15779. /**
  15780. * Scale the bone on the x, y and z axes (in local space)
  15781. * @param x The amount to scale the bone on the x axis
  15782. * @param y The amount to scale the bone on the y axis
  15783. * @param z The amount to scale the bone on the z axis
  15784. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15785. */
  15786. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15787. /**
  15788. * Set the bone scaling in local space
  15789. * @param scale defines the scaling vector
  15790. */
  15791. setScale(scale: Vector3): void;
  15792. /**
  15793. * Gets the current scaling in local space
  15794. * @returns the current scaling vector
  15795. */
  15796. getScale(): Vector3;
  15797. /**
  15798. * Gets the current scaling in local space and stores it in a target vector
  15799. * @param result defines the target vector
  15800. */
  15801. getScaleToRef(result: Vector3): void;
  15802. /**
  15803. * Set the yaw, pitch, and roll of the bone in local or world space
  15804. * @param yaw The rotation of the bone on the y axis
  15805. * @param pitch The rotation of the bone on the x axis
  15806. * @param roll The rotation of the bone on the z axis
  15807. * @param space The space that the axes of rotation are in
  15808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15809. */
  15810. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15811. /**
  15812. * Add a rotation to the bone on an axis in local or world space
  15813. * @param axis The axis to rotate the bone on
  15814. * @param amount The amount to rotate the bone
  15815. * @param space The space that the axis is in
  15816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15817. */
  15818. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15819. /**
  15820. * Set the rotation of the bone to a particular axis angle in local or world space
  15821. * @param axis The axis to rotate the bone on
  15822. * @param angle The angle that the bone should be rotated to
  15823. * @param space The space that the axis is in
  15824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15825. */
  15826. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15827. /**
  15828. * Set the euler rotation of the bone in local or world space
  15829. * @param rotation The euler rotation that the bone should be set to
  15830. * @param space The space that the rotation is in
  15831. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15832. */
  15833. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15834. /**
  15835. * Set the quaternion rotation of the bone in local or world space
  15836. * @param quat The quaternion rotation that the bone should be set to
  15837. * @param space The space that the rotation is in
  15838. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15839. */
  15840. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15841. /**
  15842. * Set the rotation matrix of the bone in local or world space
  15843. * @param rotMat The rotation matrix that the bone should be set to
  15844. * @param space The space that the rotation is in
  15845. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15846. */
  15847. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15848. private _rotateWithMatrix;
  15849. private _getNegativeRotationToRef;
  15850. /**
  15851. * Get the position of the bone in local or world space
  15852. * @param space The space that the returned position is in
  15853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15854. * @returns The position of the bone
  15855. */
  15856. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15857. /**
  15858. * Copy the position of the bone to a vector3 in local or world space
  15859. * @param space The space that the returned position is in
  15860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15861. * @param result The vector3 to copy the position to
  15862. */
  15863. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15864. /**
  15865. * Get the absolute position of the bone (world space)
  15866. * @param mesh The mesh that this bone is attached to
  15867. * @returns The absolute position of the bone
  15868. */
  15869. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15870. /**
  15871. * Copy the absolute position of the bone (world space) to the result param
  15872. * @param mesh The mesh that this bone is attached to
  15873. * @param result The vector3 to copy the absolute position to
  15874. */
  15875. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15876. /**
  15877. * Compute the absolute transforms of this bone and its children
  15878. */
  15879. computeAbsoluteTransforms(): void;
  15880. /**
  15881. * Get the world direction from an axis that is in the local space of the bone
  15882. * @param localAxis The local direction that is used to compute the world direction
  15883. * @param mesh The mesh that this bone is attached to
  15884. * @returns The world direction
  15885. */
  15886. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15887. /**
  15888. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15889. * @param localAxis The local direction that is used to compute the world direction
  15890. * @param mesh The mesh that this bone is attached to
  15891. * @param result The vector3 that the world direction will be copied to
  15892. */
  15893. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15894. /**
  15895. * Get the euler rotation of the bone in local or world space
  15896. * @param space The space that the rotation should be in
  15897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15898. * @returns The euler rotation
  15899. */
  15900. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15901. /**
  15902. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15903. * @param space The space that the rotation should be in
  15904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15905. * @param result The vector3 that the rotation should be copied to
  15906. */
  15907. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15908. /**
  15909. * Get the quaternion rotation of the bone in either local or world space
  15910. * @param space The space that the rotation should be in
  15911. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15912. * @returns The quaternion rotation
  15913. */
  15914. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15915. /**
  15916. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15917. * @param space The space that the rotation should be in
  15918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15919. * @param result The quaternion that the rotation should be copied to
  15920. */
  15921. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15922. /**
  15923. * Get the rotation matrix of the bone in local or world space
  15924. * @param space The space that the rotation should be in
  15925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15926. * @returns The rotation matrix
  15927. */
  15928. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15929. /**
  15930. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15931. * @param space The space that the rotation should be in
  15932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15933. * @param result The quaternion that the rotation should be copied to
  15934. */
  15935. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15936. /**
  15937. * Get the world position of a point that is in the local space of the bone
  15938. * @param position The local position
  15939. * @param mesh The mesh that this bone is attached to
  15940. * @returns The world position
  15941. */
  15942. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15943. /**
  15944. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15945. * @param position The local position
  15946. * @param mesh The mesh that this bone is attached to
  15947. * @param result The vector3 that the world position should be copied to
  15948. */
  15949. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15950. /**
  15951. * Get the local position of a point that is in world space
  15952. * @param position The world position
  15953. * @param mesh The mesh that this bone is attached to
  15954. * @returns The local position
  15955. */
  15956. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15957. /**
  15958. * Get the local position of a point that is in world space and copy it to the result param
  15959. * @param position The world position
  15960. * @param mesh The mesh that this bone is attached to
  15961. * @param result The vector3 that the local position should be copied to
  15962. */
  15963. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15964. /**
  15965. * Set the current local matrix as the restPose for this bone.
  15966. */
  15967. setCurrentPoseAsRest(): void;
  15968. }
  15969. }
  15970. declare module "babylonjs/Animations/runtimeAnimation" {
  15971. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15972. import { Animatable } from "babylonjs/Animations/animatable";
  15973. import { Scene } from "babylonjs/scene";
  15974. /**
  15975. * Defines a runtime animation
  15976. */
  15977. export class RuntimeAnimation {
  15978. private _events;
  15979. /**
  15980. * The current frame of the runtime animation
  15981. */
  15982. private _currentFrame;
  15983. /**
  15984. * The animation used by the runtime animation
  15985. */
  15986. private _animation;
  15987. /**
  15988. * The target of the runtime animation
  15989. */
  15990. private _target;
  15991. /**
  15992. * The initiating animatable
  15993. */
  15994. private _host;
  15995. /**
  15996. * The original value of the runtime animation
  15997. */
  15998. private _originalValue;
  15999. /**
  16000. * The original blend value of the runtime animation
  16001. */
  16002. private _originalBlendValue;
  16003. /**
  16004. * The offsets cache of the runtime animation
  16005. */
  16006. private _offsetsCache;
  16007. /**
  16008. * The high limits cache of the runtime animation
  16009. */
  16010. private _highLimitsCache;
  16011. /**
  16012. * Specifies if the runtime animation has been stopped
  16013. */
  16014. private _stopped;
  16015. /**
  16016. * The blending factor of the runtime animation
  16017. */
  16018. private _blendingFactor;
  16019. /**
  16020. * The BabylonJS scene
  16021. */
  16022. private _scene;
  16023. /**
  16024. * The current value of the runtime animation
  16025. */
  16026. private _currentValue;
  16027. /** @hidden */
  16028. _animationState: _IAnimationState;
  16029. /**
  16030. * The active target of the runtime animation
  16031. */
  16032. private _activeTargets;
  16033. private _currentActiveTarget;
  16034. private _directTarget;
  16035. /**
  16036. * The target path of the runtime animation
  16037. */
  16038. private _targetPath;
  16039. /**
  16040. * The weight of the runtime animation
  16041. */
  16042. private _weight;
  16043. /**
  16044. * The ratio offset of the runtime animation
  16045. */
  16046. private _ratioOffset;
  16047. /**
  16048. * The previous delay of the runtime animation
  16049. */
  16050. private _previousDelay;
  16051. /**
  16052. * The previous ratio of the runtime animation
  16053. */
  16054. private _previousRatio;
  16055. private _enableBlending;
  16056. private _keys;
  16057. private _minFrame;
  16058. private _maxFrame;
  16059. private _minValue;
  16060. private _maxValue;
  16061. private _targetIsArray;
  16062. /**
  16063. * Gets the current frame of the runtime animation
  16064. */
  16065. get currentFrame(): number;
  16066. /**
  16067. * Gets the weight of the runtime animation
  16068. */
  16069. get weight(): number;
  16070. /**
  16071. * Gets the current value of the runtime animation
  16072. */
  16073. get currentValue(): any;
  16074. /**
  16075. * Gets the target path of the runtime animation
  16076. */
  16077. get targetPath(): string;
  16078. /**
  16079. * Gets the actual target of the runtime animation
  16080. */
  16081. get target(): any;
  16082. /**
  16083. * Gets the additive state of the runtime animation
  16084. */
  16085. get isAdditive(): boolean;
  16086. /** @hidden */
  16087. _onLoop: () => void;
  16088. /**
  16089. * Create a new RuntimeAnimation object
  16090. * @param target defines the target of the animation
  16091. * @param animation defines the source animation object
  16092. * @param scene defines the hosting scene
  16093. * @param host defines the initiating Animatable
  16094. */
  16095. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16096. private _preparePath;
  16097. /**
  16098. * Gets the animation from the runtime animation
  16099. */
  16100. get animation(): Animation;
  16101. /**
  16102. * Resets the runtime animation to the beginning
  16103. * @param restoreOriginal defines whether to restore the target property to the original value
  16104. */
  16105. reset(restoreOriginal?: boolean): void;
  16106. /**
  16107. * Specifies if the runtime animation is stopped
  16108. * @returns Boolean specifying if the runtime animation is stopped
  16109. */
  16110. isStopped(): boolean;
  16111. /**
  16112. * Disposes of the runtime animation
  16113. */
  16114. dispose(): void;
  16115. /**
  16116. * Apply the interpolated value to the target
  16117. * @param currentValue defines the value computed by the animation
  16118. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16119. */
  16120. setValue(currentValue: any, weight: number): void;
  16121. private _getOriginalValues;
  16122. private _setValue;
  16123. /**
  16124. * Gets the loop pmode of the runtime animation
  16125. * @returns Loop Mode
  16126. */
  16127. private _getCorrectLoopMode;
  16128. /**
  16129. * Move the current animation to a given frame
  16130. * @param frame defines the frame to move to
  16131. */
  16132. goToFrame(frame: number): void;
  16133. /**
  16134. * @hidden Internal use only
  16135. */
  16136. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16137. /**
  16138. * Execute the current animation
  16139. * @param delay defines the delay to add to the current frame
  16140. * @param from defines the lower bound of the animation range
  16141. * @param to defines the upper bound of the animation range
  16142. * @param loop defines if the current animation must loop
  16143. * @param speedRatio defines the current speed ratio
  16144. * @param weight defines the weight of the animation (default is -1 so no weight)
  16145. * @param onLoop optional callback called when animation loops
  16146. * @returns a boolean indicating if the animation is running
  16147. */
  16148. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16149. }
  16150. }
  16151. declare module "babylonjs/Animations/animatable" {
  16152. import { Animation } from "babylonjs/Animations/animation";
  16153. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16154. import { Nullable } from "babylonjs/types";
  16155. import { Observable } from "babylonjs/Misc/observable";
  16156. import { Scene } from "babylonjs/scene";
  16157. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16158. import { Node } from "babylonjs/node";
  16159. /**
  16160. * Class used to store an actual running animation
  16161. */
  16162. export class Animatable {
  16163. /** defines the target object */
  16164. target: any;
  16165. /** defines the starting frame number (default is 0) */
  16166. fromFrame: number;
  16167. /** defines the ending frame number (default is 100) */
  16168. toFrame: number;
  16169. /** defines if the animation must loop (default is false) */
  16170. loopAnimation: boolean;
  16171. /** defines a callback to call when animation ends if it is not looping */
  16172. onAnimationEnd?: (() => void) | null | undefined;
  16173. /** defines a callback to call when animation loops */
  16174. onAnimationLoop?: (() => void) | null | undefined;
  16175. /** defines whether the animation should be evaluated additively */
  16176. isAdditive: boolean;
  16177. private _localDelayOffset;
  16178. private _pausedDelay;
  16179. private _runtimeAnimations;
  16180. private _paused;
  16181. private _scene;
  16182. private _speedRatio;
  16183. private _weight;
  16184. private _syncRoot;
  16185. /**
  16186. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16187. * This will only apply for non looping animation (default is true)
  16188. */
  16189. disposeOnEnd: boolean;
  16190. /**
  16191. * Gets a boolean indicating if the animation has started
  16192. */
  16193. animationStarted: boolean;
  16194. /**
  16195. * Observer raised when the animation ends
  16196. */
  16197. onAnimationEndObservable: Observable<Animatable>;
  16198. /**
  16199. * Observer raised when the animation loops
  16200. */
  16201. onAnimationLoopObservable: Observable<Animatable>;
  16202. /**
  16203. * Gets the root Animatable used to synchronize and normalize animations
  16204. */
  16205. get syncRoot(): Nullable<Animatable>;
  16206. /**
  16207. * Gets the current frame of the first RuntimeAnimation
  16208. * Used to synchronize Animatables
  16209. */
  16210. get masterFrame(): number;
  16211. /**
  16212. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16213. */
  16214. get weight(): number;
  16215. set weight(value: number);
  16216. /**
  16217. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16218. */
  16219. get speedRatio(): number;
  16220. set speedRatio(value: number);
  16221. /**
  16222. * Creates a new Animatable
  16223. * @param scene defines the hosting scene
  16224. * @param target defines the target object
  16225. * @param fromFrame defines the starting frame number (default is 0)
  16226. * @param toFrame defines the ending frame number (default is 100)
  16227. * @param loopAnimation defines if the animation must loop (default is false)
  16228. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16229. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16230. * @param animations defines a group of animation to add to the new Animatable
  16231. * @param onAnimationLoop defines a callback to call when animation loops
  16232. * @param isAdditive defines whether the animation should be evaluated additively
  16233. */
  16234. constructor(scene: Scene,
  16235. /** defines the target object */
  16236. target: any,
  16237. /** defines the starting frame number (default is 0) */
  16238. fromFrame?: number,
  16239. /** defines the ending frame number (default is 100) */
  16240. toFrame?: number,
  16241. /** defines if the animation must loop (default is false) */
  16242. loopAnimation?: boolean, speedRatio?: number,
  16243. /** defines a callback to call when animation ends if it is not looping */
  16244. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16245. /** defines a callback to call when animation loops */
  16246. onAnimationLoop?: (() => void) | null | undefined,
  16247. /** defines whether the animation should be evaluated additively */
  16248. isAdditive?: boolean);
  16249. /**
  16250. * Synchronize and normalize current Animatable with a source Animatable
  16251. * This is useful when using animation weights and when animations are not of the same length
  16252. * @param root defines the root Animatable to synchronize with
  16253. * @returns the current Animatable
  16254. */
  16255. syncWith(root: Animatable): Animatable;
  16256. /**
  16257. * Gets the list of runtime animations
  16258. * @returns an array of RuntimeAnimation
  16259. */
  16260. getAnimations(): RuntimeAnimation[];
  16261. /**
  16262. * Adds more animations to the current animatable
  16263. * @param target defines the target of the animations
  16264. * @param animations defines the new animations to add
  16265. */
  16266. appendAnimations(target: any, animations: Animation[]): void;
  16267. /**
  16268. * Gets the source animation for a specific property
  16269. * @param property defines the propertyu to look for
  16270. * @returns null or the source animation for the given property
  16271. */
  16272. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16273. /**
  16274. * Gets the runtime animation for a specific property
  16275. * @param property defines the propertyu to look for
  16276. * @returns null or the runtime animation for the given property
  16277. */
  16278. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16279. /**
  16280. * Resets the animatable to its original state
  16281. */
  16282. reset(): void;
  16283. /**
  16284. * Allows the animatable to blend with current running animations
  16285. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16286. * @param blendingSpeed defines the blending speed to use
  16287. */
  16288. enableBlending(blendingSpeed: number): void;
  16289. /**
  16290. * Disable animation blending
  16291. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16292. */
  16293. disableBlending(): void;
  16294. /**
  16295. * Jump directly to a given frame
  16296. * @param frame defines the frame to jump to
  16297. */
  16298. goToFrame(frame: number): void;
  16299. /**
  16300. * Pause the animation
  16301. */
  16302. pause(): void;
  16303. /**
  16304. * Restart the animation
  16305. */
  16306. restart(): void;
  16307. private _raiseOnAnimationEnd;
  16308. /**
  16309. * Stop and delete the current animation
  16310. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16311. * @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)
  16312. */
  16313. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16314. /**
  16315. * Wait asynchronously for the animation to end
  16316. * @returns a promise which will be fullfilled when the animation ends
  16317. */
  16318. waitAsync(): Promise<Animatable>;
  16319. /** @hidden */
  16320. _animate(delay: number): boolean;
  16321. }
  16322. module "babylonjs/scene" {
  16323. interface Scene {
  16324. /** @hidden */
  16325. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16326. /** @hidden */
  16327. _processLateAnimationBindingsForMatrices(holder: {
  16328. totalWeight: number;
  16329. totalAdditiveWeight: number;
  16330. animations: RuntimeAnimation[];
  16331. additiveAnimations: RuntimeAnimation[];
  16332. originalValue: Matrix;
  16333. }): any;
  16334. /** @hidden */
  16335. _processLateAnimationBindingsForQuaternions(holder: {
  16336. totalWeight: number;
  16337. totalAdditiveWeight: number;
  16338. animations: RuntimeAnimation[];
  16339. additiveAnimations: RuntimeAnimation[];
  16340. originalValue: Quaternion;
  16341. }, refQuaternion: Quaternion): Quaternion;
  16342. /** @hidden */
  16343. _processLateAnimationBindings(): void;
  16344. /**
  16345. * Will start the animation sequence of a given target
  16346. * @param target defines the target
  16347. * @param from defines from which frame should animation start
  16348. * @param to defines until which frame should animation run.
  16349. * @param weight defines the weight to apply to the animation (1.0 by default)
  16350. * @param loop defines if the animation loops
  16351. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16352. * @param onAnimationEnd defines the function to be executed when the animation ends
  16353. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16354. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16355. * @param onAnimationLoop defines the callback to call when an animation loops
  16356. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16357. * @returns the animatable object created for this animation
  16358. */
  16359. 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;
  16360. /**
  16361. * Will start the animation sequence of a given target
  16362. * @param target defines the target
  16363. * @param from defines from which frame should animation start
  16364. * @param to defines until which frame should animation run.
  16365. * @param loop defines if the animation loops
  16366. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16367. * @param onAnimationEnd defines the function to be executed when the animation ends
  16368. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16369. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16370. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16371. * @param onAnimationLoop defines the callback to call when an animation loops
  16372. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16373. * @returns the animatable object created for this animation
  16374. */
  16375. 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;
  16376. /**
  16377. * Will start the animation sequence of a given target and its hierarchy
  16378. * @param target defines the target
  16379. * @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.
  16380. * @param from defines from which frame should animation start
  16381. * @param to defines until which frame should animation run.
  16382. * @param loop defines if the animation loops
  16383. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16384. * @param onAnimationEnd defines the function to be executed when the animation ends
  16385. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16386. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16387. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16388. * @param onAnimationLoop defines the callback to call when an animation loops
  16389. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16390. * @returns the list of created animatables
  16391. */
  16392. 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[];
  16393. /**
  16394. * Begin a new animation on a given node
  16395. * @param target defines the target where the animation will take place
  16396. * @param animations defines the list of animations to start
  16397. * @param from defines the initial value
  16398. * @param to defines the final value
  16399. * @param loop defines if you want animation to loop (off by default)
  16400. * @param speedRatio defines the speed ratio to apply to all animations
  16401. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16402. * @param onAnimationLoop defines the callback to call when an animation loops
  16403. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16404. * @returns the list of created animatables
  16405. */
  16406. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16407. /**
  16408. * Begin a new animation on a given node and its hierarchy
  16409. * @param target defines the root node where the animation will take place
  16410. * @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.
  16411. * @param animations defines the list of animations to start
  16412. * @param from defines the initial value
  16413. * @param to defines the final value
  16414. * @param loop defines if you want animation to loop (off by default)
  16415. * @param speedRatio defines the speed ratio to apply to all animations
  16416. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16417. * @param onAnimationLoop defines the callback to call when an animation loops
  16418. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16419. * @returns the list of animatables created for all nodes
  16420. */
  16421. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16422. /**
  16423. * Gets the animatable associated with a specific target
  16424. * @param target defines the target of the animatable
  16425. * @returns the required animatable if found
  16426. */
  16427. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16428. /**
  16429. * Gets all animatables associated with a given target
  16430. * @param target defines the target to look animatables for
  16431. * @returns an array of Animatables
  16432. */
  16433. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16434. /**
  16435. * Stops and removes all animations that have been applied to the scene
  16436. */
  16437. stopAllAnimations(): void;
  16438. /**
  16439. * Gets the current delta time used by animation engine
  16440. */
  16441. deltaTime: number;
  16442. }
  16443. }
  16444. module "babylonjs/Bones/bone" {
  16445. interface Bone {
  16446. /**
  16447. * Copy an animation range from another bone
  16448. * @param source defines the source bone
  16449. * @param rangeName defines the range name to copy
  16450. * @param frameOffset defines the frame offset
  16451. * @param rescaleAsRequired defines if rescaling must be applied if required
  16452. * @param skelDimensionsRatio defines the scaling ratio
  16453. * @returns true if operation was successful
  16454. */
  16455. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16456. }
  16457. }
  16458. }
  16459. declare module "babylonjs/Bones/skeleton" {
  16460. import { Bone } from "babylonjs/Bones/bone";
  16461. import { Observable } from "babylonjs/Misc/observable";
  16462. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16463. import { Scene } from "babylonjs/scene";
  16464. import { Nullable } from "babylonjs/types";
  16465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16466. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16467. import { Animatable } from "babylonjs/Animations/animatable";
  16468. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16469. import { Animation } from "babylonjs/Animations/animation";
  16470. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16471. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16472. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16473. /**
  16474. * Class used to handle skinning animations
  16475. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16476. */
  16477. export class Skeleton implements IAnimatable {
  16478. /** defines the skeleton name */
  16479. name: string;
  16480. /** defines the skeleton Id */
  16481. id: string;
  16482. /**
  16483. * Defines the list of child bones
  16484. */
  16485. bones: Bone[];
  16486. /**
  16487. * Defines an estimate of the dimension of the skeleton at rest
  16488. */
  16489. dimensionsAtRest: Vector3;
  16490. /**
  16491. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16492. */
  16493. needInitialSkinMatrix: boolean;
  16494. /**
  16495. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16496. */
  16497. overrideMesh: Nullable<AbstractMesh>;
  16498. /**
  16499. * Gets the list of animations attached to this skeleton
  16500. */
  16501. animations: Array<Animation>;
  16502. private _scene;
  16503. private _isDirty;
  16504. private _transformMatrices;
  16505. private _transformMatrixTexture;
  16506. private _meshesWithPoseMatrix;
  16507. private _animatables;
  16508. private _identity;
  16509. private _synchronizedWithMesh;
  16510. private _ranges;
  16511. private _lastAbsoluteTransformsUpdateId;
  16512. private _canUseTextureForBones;
  16513. private _uniqueId;
  16514. /** @hidden */
  16515. _numBonesWithLinkedTransformNode: number;
  16516. /** @hidden */
  16517. _hasWaitingData: Nullable<boolean>;
  16518. /** @hidden */
  16519. _waitingOverrideMeshId: Nullable<string>;
  16520. /**
  16521. * Specifies if the skeleton should be serialized
  16522. */
  16523. doNotSerialize: boolean;
  16524. private _useTextureToStoreBoneMatrices;
  16525. /**
  16526. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16527. * Please note that this option is not available if the hardware does not support it
  16528. */
  16529. get useTextureToStoreBoneMatrices(): boolean;
  16530. set useTextureToStoreBoneMatrices(value: boolean);
  16531. private _animationPropertiesOverride;
  16532. /**
  16533. * Gets or sets the animation properties override
  16534. */
  16535. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16536. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16537. /**
  16538. * List of inspectable custom properties (used by the Inspector)
  16539. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16540. */
  16541. inspectableCustomProperties: IInspectable[];
  16542. /**
  16543. * An observable triggered before computing the skeleton's matrices
  16544. */
  16545. onBeforeComputeObservable: Observable<Skeleton>;
  16546. /**
  16547. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16548. */
  16549. get isUsingTextureForMatrices(): boolean;
  16550. /**
  16551. * Gets the unique ID of this skeleton
  16552. */
  16553. get uniqueId(): number;
  16554. /**
  16555. * Creates a new skeleton
  16556. * @param name defines the skeleton name
  16557. * @param id defines the skeleton Id
  16558. * @param scene defines the hosting scene
  16559. */
  16560. constructor(
  16561. /** defines the skeleton name */
  16562. name: string,
  16563. /** defines the skeleton Id */
  16564. id: string, scene: Scene);
  16565. /**
  16566. * Gets the current object class name.
  16567. * @return the class name
  16568. */
  16569. getClassName(): string;
  16570. /**
  16571. * Returns an array containing the root bones
  16572. * @returns an array containing the root bones
  16573. */
  16574. getChildren(): Array<Bone>;
  16575. /**
  16576. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16577. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16578. * @returns a Float32Array containing matrices data
  16579. */
  16580. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16581. /**
  16582. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16583. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16584. * @returns a raw texture containing the data
  16585. */
  16586. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16587. /**
  16588. * Gets the current hosting scene
  16589. * @returns a scene object
  16590. */
  16591. getScene(): Scene;
  16592. /**
  16593. * Gets a string representing the current skeleton data
  16594. * @param fullDetails defines a boolean indicating if we want a verbose version
  16595. * @returns a string representing the current skeleton data
  16596. */
  16597. toString(fullDetails?: boolean): string;
  16598. /**
  16599. * Get bone's index searching by name
  16600. * @param name defines bone's name to search for
  16601. * @return the indice of the bone. Returns -1 if not found
  16602. */
  16603. getBoneIndexByName(name: string): number;
  16604. /**
  16605. * Creater a new animation range
  16606. * @param name defines the name of the range
  16607. * @param from defines the start key
  16608. * @param to defines the end key
  16609. */
  16610. createAnimationRange(name: string, from: number, to: number): void;
  16611. /**
  16612. * Delete a specific animation range
  16613. * @param name defines the name of the range
  16614. * @param deleteFrames defines if frames must be removed as well
  16615. */
  16616. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16617. /**
  16618. * Gets a specific animation range
  16619. * @param name defines the name of the range to look for
  16620. * @returns the requested animation range or null if not found
  16621. */
  16622. getAnimationRange(name: string): Nullable<AnimationRange>;
  16623. /**
  16624. * Gets the list of all animation ranges defined on this skeleton
  16625. * @returns an array
  16626. */
  16627. getAnimationRanges(): Nullable<AnimationRange>[];
  16628. /**
  16629. * Copy animation range from a source skeleton.
  16630. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16631. * @param source defines the source skeleton
  16632. * @param name defines the name of the range to copy
  16633. * @param rescaleAsRequired defines if rescaling must be applied if required
  16634. * @returns true if operation was successful
  16635. */
  16636. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16637. /**
  16638. * Forces the skeleton to go to rest pose
  16639. */
  16640. returnToRest(): void;
  16641. private _getHighestAnimationFrame;
  16642. /**
  16643. * Begin a specific animation range
  16644. * @param name defines the name of the range to start
  16645. * @param loop defines if looping must be turned on (false by default)
  16646. * @param speedRatio defines the speed ratio to apply (1 by default)
  16647. * @param onAnimationEnd defines a callback which will be called when animation will end
  16648. * @returns a new animatable
  16649. */
  16650. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16651. /**
  16652. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16653. * @param skeleton defines the Skeleton containing the animation range to convert
  16654. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16655. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16656. * @returns the original skeleton
  16657. */
  16658. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16659. /** @hidden */
  16660. _markAsDirty(): void;
  16661. /** @hidden */
  16662. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16663. /** @hidden */
  16664. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16665. private _computeTransformMatrices;
  16666. /**
  16667. * Build all resources required to render a skeleton
  16668. */
  16669. prepare(): void;
  16670. /**
  16671. * Gets the list of animatables currently running for this skeleton
  16672. * @returns an array of animatables
  16673. */
  16674. getAnimatables(): IAnimatable[];
  16675. /**
  16676. * Clone the current skeleton
  16677. * @param name defines the name of the new skeleton
  16678. * @param id defines the id of the new skeleton
  16679. * @returns the new skeleton
  16680. */
  16681. clone(name: string, id?: string): Skeleton;
  16682. /**
  16683. * Enable animation blending for this skeleton
  16684. * @param blendingSpeed defines the blending speed to apply
  16685. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16686. */
  16687. enableBlending(blendingSpeed?: number): void;
  16688. /**
  16689. * Releases all resources associated with the current skeleton
  16690. */
  16691. dispose(): void;
  16692. /**
  16693. * Serialize the skeleton in a JSON object
  16694. * @returns a JSON object
  16695. */
  16696. serialize(): any;
  16697. /**
  16698. * Creates a new skeleton from serialized data
  16699. * @param parsedSkeleton defines the serialized data
  16700. * @param scene defines the hosting scene
  16701. * @returns a new skeleton
  16702. */
  16703. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16704. /**
  16705. * Compute all node absolute transforms
  16706. * @param forceUpdate defines if computation must be done even if cache is up to date
  16707. */
  16708. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16709. /**
  16710. * Gets the root pose matrix
  16711. * @returns a matrix
  16712. */
  16713. getPoseMatrix(): Nullable<Matrix>;
  16714. /**
  16715. * Sorts bones per internal index
  16716. */
  16717. sortBones(): void;
  16718. private _sortBones;
  16719. /**
  16720. * Set the current local matrix as the restPose for all bones in the skeleton.
  16721. */
  16722. setCurrentPoseAsRest(): void;
  16723. }
  16724. }
  16725. declare module "babylonjs/Meshes/instancedMesh" {
  16726. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16727. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16728. import { Camera } from "babylonjs/Cameras/camera";
  16729. import { Node } from "babylonjs/node";
  16730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16731. import { Mesh } from "babylonjs/Meshes/mesh";
  16732. import { Material } from "babylonjs/Materials/material";
  16733. import { Skeleton } from "babylonjs/Bones/skeleton";
  16734. import { Light } from "babylonjs/Lights/light";
  16735. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16736. /**
  16737. * Creates an instance based on a source mesh.
  16738. */
  16739. export class InstancedMesh extends AbstractMesh {
  16740. private _sourceMesh;
  16741. private _currentLOD;
  16742. /** @hidden */
  16743. _indexInSourceMeshInstanceArray: number;
  16744. constructor(name: string, source: Mesh);
  16745. /**
  16746. * Returns the string "InstancedMesh".
  16747. */
  16748. getClassName(): string;
  16749. /** Gets the list of lights affecting that mesh */
  16750. get lightSources(): Light[];
  16751. _resyncLightSources(): void;
  16752. _resyncLightSource(light: Light): void;
  16753. _removeLightSource(light: Light, dispose: boolean): void;
  16754. /**
  16755. * If the source mesh receives shadows
  16756. */
  16757. get receiveShadows(): boolean;
  16758. /**
  16759. * The material of the source mesh
  16760. */
  16761. get material(): Nullable<Material>;
  16762. /**
  16763. * Visibility of the source mesh
  16764. */
  16765. get visibility(): number;
  16766. /**
  16767. * Skeleton of the source mesh
  16768. */
  16769. get skeleton(): Nullable<Skeleton>;
  16770. /**
  16771. * Rendering ground id of the source mesh
  16772. */
  16773. get renderingGroupId(): number;
  16774. set renderingGroupId(value: number);
  16775. /**
  16776. * Returns the total number of vertices (integer).
  16777. */
  16778. getTotalVertices(): number;
  16779. /**
  16780. * Returns a positive integer : the total number of indices in this mesh geometry.
  16781. * @returns the numner of indices or zero if the mesh has no geometry.
  16782. */
  16783. getTotalIndices(): number;
  16784. /**
  16785. * The source mesh of the instance
  16786. */
  16787. get sourceMesh(): Mesh;
  16788. /**
  16789. * Creates a new InstancedMesh object from the mesh model.
  16790. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16791. * @param name defines the name of the new instance
  16792. * @returns a new InstancedMesh
  16793. */
  16794. createInstance(name: string): InstancedMesh;
  16795. /**
  16796. * Is this node ready to be used/rendered
  16797. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16798. * @return {boolean} is it ready
  16799. */
  16800. isReady(completeCheck?: boolean): boolean;
  16801. /**
  16802. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16803. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16804. * @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.
  16805. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16806. */
  16807. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16808. /**
  16809. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16810. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16811. * The `data` are either a numeric array either a Float32Array.
  16812. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16813. * 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).
  16814. * Note that a new underlying VertexBuffer object is created each call.
  16815. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16816. *
  16817. * Possible `kind` values :
  16818. * - VertexBuffer.PositionKind
  16819. * - VertexBuffer.UVKind
  16820. * - VertexBuffer.UV2Kind
  16821. * - VertexBuffer.UV3Kind
  16822. * - VertexBuffer.UV4Kind
  16823. * - VertexBuffer.UV5Kind
  16824. * - VertexBuffer.UV6Kind
  16825. * - VertexBuffer.ColorKind
  16826. * - VertexBuffer.MatricesIndicesKind
  16827. * - VertexBuffer.MatricesIndicesExtraKind
  16828. * - VertexBuffer.MatricesWeightsKind
  16829. * - VertexBuffer.MatricesWeightsExtraKind
  16830. *
  16831. * Returns the Mesh.
  16832. */
  16833. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16834. /**
  16835. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16836. * If the mesh has no geometry, it is simply returned as it is.
  16837. * The `data` are either a numeric array either a Float32Array.
  16838. * No new underlying VertexBuffer object is created.
  16839. * 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.
  16840. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16841. *
  16842. * Possible `kind` values :
  16843. * - VertexBuffer.PositionKind
  16844. * - VertexBuffer.UVKind
  16845. * - VertexBuffer.UV2Kind
  16846. * - VertexBuffer.UV3Kind
  16847. * - VertexBuffer.UV4Kind
  16848. * - VertexBuffer.UV5Kind
  16849. * - VertexBuffer.UV6Kind
  16850. * - VertexBuffer.ColorKind
  16851. * - VertexBuffer.MatricesIndicesKind
  16852. * - VertexBuffer.MatricesIndicesExtraKind
  16853. * - VertexBuffer.MatricesWeightsKind
  16854. * - VertexBuffer.MatricesWeightsExtraKind
  16855. *
  16856. * Returns the Mesh.
  16857. */
  16858. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16859. /**
  16860. * Sets the mesh indices.
  16861. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16862. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16863. * This method creates a new index buffer each call.
  16864. * Returns the Mesh.
  16865. */
  16866. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16867. /**
  16868. * Boolean : True if the mesh owns the requested kind of data.
  16869. */
  16870. isVerticesDataPresent(kind: string): boolean;
  16871. /**
  16872. * Returns an array of indices (IndicesArray).
  16873. */
  16874. getIndices(): Nullable<IndicesArray>;
  16875. get _positions(): Nullable<Vector3[]>;
  16876. /**
  16877. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16878. * This means the mesh underlying bounding box and sphere are recomputed.
  16879. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16880. * @returns the current mesh
  16881. */
  16882. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16883. /** @hidden */
  16884. _preActivate(): InstancedMesh;
  16885. /** @hidden */
  16886. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16887. /** @hidden */
  16888. _postActivate(): void;
  16889. getWorldMatrix(): Matrix;
  16890. get isAnInstance(): boolean;
  16891. /**
  16892. * Returns the current associated LOD AbstractMesh.
  16893. */
  16894. getLOD(camera: Camera): AbstractMesh;
  16895. /** @hidden */
  16896. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16897. /** @hidden */
  16898. _syncSubMeshes(): InstancedMesh;
  16899. /** @hidden */
  16900. _generatePointsArray(): boolean;
  16901. /** @hidden */
  16902. _updateBoundingInfo(): AbstractMesh;
  16903. /**
  16904. * Creates a new InstancedMesh from the current mesh.
  16905. * - name (string) : the cloned mesh name
  16906. * - newParent (optional Node) : the optional Node to parent the clone to.
  16907. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16908. *
  16909. * Returns the clone.
  16910. */
  16911. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16912. /**
  16913. * Disposes the InstancedMesh.
  16914. * Returns nothing.
  16915. */
  16916. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16917. }
  16918. module "babylonjs/Meshes/mesh" {
  16919. interface Mesh {
  16920. /**
  16921. * Register a custom buffer that will be instanced
  16922. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16923. * @param kind defines the buffer kind
  16924. * @param stride defines the stride in floats
  16925. */
  16926. registerInstancedBuffer(kind: string, stride: number): void;
  16927. /**
  16928. * true to use the edge renderer for all instances of this mesh
  16929. */
  16930. edgesShareWithInstances: boolean;
  16931. /** @hidden */
  16932. _userInstancedBuffersStorage: {
  16933. data: {
  16934. [key: string]: Float32Array;
  16935. };
  16936. sizes: {
  16937. [key: string]: number;
  16938. };
  16939. vertexBuffers: {
  16940. [key: string]: Nullable<VertexBuffer>;
  16941. };
  16942. strides: {
  16943. [key: string]: number;
  16944. };
  16945. };
  16946. }
  16947. }
  16948. module "babylonjs/Meshes/abstractMesh" {
  16949. interface AbstractMesh {
  16950. /**
  16951. * Object used to store instanced buffers defined by user
  16952. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16953. */
  16954. instancedBuffers: {
  16955. [key: string]: any;
  16956. };
  16957. }
  16958. }
  16959. }
  16960. declare module "babylonjs/Materials/shaderMaterial" {
  16961. import { Nullable } from "babylonjs/types";
  16962. import { Scene } from "babylonjs/scene";
  16963. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16965. import { Mesh } from "babylonjs/Meshes/mesh";
  16966. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16968. import { Effect } from "babylonjs/Materials/effect";
  16969. import { Material } from "babylonjs/Materials/material";
  16970. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16971. /**
  16972. * Defines the options associated with the creation of a shader material.
  16973. */
  16974. export interface IShaderMaterialOptions {
  16975. /**
  16976. * Does the material work in alpha blend mode
  16977. */
  16978. needAlphaBlending: boolean;
  16979. /**
  16980. * Does the material work in alpha test mode
  16981. */
  16982. needAlphaTesting: boolean;
  16983. /**
  16984. * The list of attribute names used in the shader
  16985. */
  16986. attributes: string[];
  16987. /**
  16988. * The list of unifrom names used in the shader
  16989. */
  16990. uniforms: string[];
  16991. /**
  16992. * The list of UBO names used in the shader
  16993. */
  16994. uniformBuffers: string[];
  16995. /**
  16996. * The list of sampler names used in the shader
  16997. */
  16998. samplers: string[];
  16999. /**
  17000. * The list of defines used in the shader
  17001. */
  17002. defines: string[];
  17003. }
  17004. /**
  17005. * 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.
  17006. *
  17007. * This returned material effects how the mesh will look based on the code in the shaders.
  17008. *
  17009. * @see https://doc.babylonjs.com/how_to/shader_material
  17010. */
  17011. export class ShaderMaterial extends Material {
  17012. private _shaderPath;
  17013. private _options;
  17014. private _textures;
  17015. private _textureArrays;
  17016. private _floats;
  17017. private _ints;
  17018. private _floatsArrays;
  17019. private _colors3;
  17020. private _colors3Arrays;
  17021. private _colors4;
  17022. private _colors4Arrays;
  17023. private _vectors2;
  17024. private _vectors3;
  17025. private _vectors4;
  17026. private _matrices;
  17027. private _matrixArrays;
  17028. private _matrices3x3;
  17029. private _matrices2x2;
  17030. private _vectors2Arrays;
  17031. private _vectors3Arrays;
  17032. private _vectors4Arrays;
  17033. private _cachedWorldViewMatrix;
  17034. private _cachedWorldViewProjectionMatrix;
  17035. private _renderId;
  17036. private _multiview;
  17037. private _cachedDefines;
  17038. /** Define the Url to load snippets */
  17039. static SnippetUrl: string;
  17040. /** Snippet ID if the material was created from the snippet server */
  17041. snippetId: string;
  17042. /**
  17043. * Instantiate a new shader material.
  17044. * 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.
  17045. * This returned material effects how the mesh will look based on the code in the shaders.
  17046. * @see https://doc.babylonjs.com/how_to/shader_material
  17047. * @param name Define the name of the material in the scene
  17048. * @param scene Define the scene the material belongs to
  17049. * @param shaderPath Defines the route to the shader code in one of three ways:
  17050. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17051. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17052. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17053. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17054. * @param options Define the options used to create the shader
  17055. */
  17056. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17057. /**
  17058. * Gets the shader path used to define the shader code
  17059. * It can be modified to trigger a new compilation
  17060. */
  17061. get shaderPath(): any;
  17062. /**
  17063. * Sets the shader path used to define the shader code
  17064. * It can be modified to trigger a new compilation
  17065. */
  17066. set shaderPath(shaderPath: any);
  17067. /**
  17068. * Gets the options used to compile the shader.
  17069. * They can be modified to trigger a new compilation
  17070. */
  17071. get options(): IShaderMaterialOptions;
  17072. /**
  17073. * Gets the current class name of the material e.g. "ShaderMaterial"
  17074. * Mainly use in serialization.
  17075. * @returns the class name
  17076. */
  17077. getClassName(): string;
  17078. /**
  17079. * Specifies if the material will require alpha blending
  17080. * @returns a boolean specifying if alpha blending is needed
  17081. */
  17082. needAlphaBlending(): boolean;
  17083. /**
  17084. * Specifies if this material should be rendered in alpha test mode
  17085. * @returns a boolean specifying if an alpha test is needed.
  17086. */
  17087. needAlphaTesting(): boolean;
  17088. private _checkUniform;
  17089. /**
  17090. * Set a texture in the shader.
  17091. * @param name Define the name of the uniform samplers as defined in the shader
  17092. * @param texture Define the texture to bind to this sampler
  17093. * @return the material itself allowing "fluent" like uniform updates
  17094. */
  17095. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17096. /**
  17097. * Set a texture array in the shader.
  17098. * @param name Define the name of the uniform sampler array as defined in the shader
  17099. * @param textures Define the list of textures to bind to this sampler
  17100. * @return the material itself allowing "fluent" like uniform updates
  17101. */
  17102. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17103. /**
  17104. * Set a float in the shader.
  17105. * @param name Define the name of the uniform as defined in the shader
  17106. * @param value Define the value to give to the uniform
  17107. * @return the material itself allowing "fluent" like uniform updates
  17108. */
  17109. setFloat(name: string, value: number): ShaderMaterial;
  17110. /**
  17111. * Set a int in the shader.
  17112. * @param name Define the name of the uniform as defined in the shader
  17113. * @param value Define the value to give to the uniform
  17114. * @return the material itself allowing "fluent" like uniform updates
  17115. */
  17116. setInt(name: string, value: number): ShaderMaterial;
  17117. /**
  17118. * Set an array of floats in the shader.
  17119. * @param name Define the name of the uniform as defined in the shader
  17120. * @param value Define the value to give to the uniform
  17121. * @return the material itself allowing "fluent" like uniform updates
  17122. */
  17123. setFloats(name: string, value: number[]): ShaderMaterial;
  17124. /**
  17125. * Set a vec3 in the shader from a Color3.
  17126. * @param name Define the name of the uniform as defined in the shader
  17127. * @param value Define the value to give to the uniform
  17128. * @return the material itself allowing "fluent" like uniform updates
  17129. */
  17130. setColor3(name: string, value: Color3): ShaderMaterial;
  17131. /**
  17132. * Set a vec3 array in the shader from a Color3 array.
  17133. * @param name Define the name of the uniform as defined in the shader
  17134. * @param value Define the value to give to the uniform
  17135. * @return the material itself allowing "fluent" like uniform updates
  17136. */
  17137. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17138. /**
  17139. * Set a vec4 in the shader from a Color4.
  17140. * @param name Define the name of the uniform as defined in the shader
  17141. * @param value Define the value to give to the uniform
  17142. * @return the material itself allowing "fluent" like uniform updates
  17143. */
  17144. setColor4(name: string, value: Color4): ShaderMaterial;
  17145. /**
  17146. * Set a vec4 array in the shader from a Color4 array.
  17147. * @param name Define the name of the uniform as defined in the shader
  17148. * @param value Define the value to give to the uniform
  17149. * @return the material itself allowing "fluent" like uniform updates
  17150. */
  17151. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17152. /**
  17153. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ShaderMaterial;
  17159. /**
  17160. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ShaderMaterial;
  17166. /**
  17167. * Set a vec4 in the shader from a Vector4.
  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. setVector4(name: string, value: Vector4): ShaderMaterial;
  17173. /**
  17174. * Set a mat4 in the shader from a Matrix.
  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. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17180. /**
  17181. * Set a float32Array in the shader from a matrix 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. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17187. /**
  17188. * Set a mat3 in the shader from a Float32Array.
  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. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17194. /**
  17195. * Set a mat2 in the shader from a Float32Array.
  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. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17201. /**
  17202. * Set a vec2 array in the shader from a number array.
  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. setArray2(name: string, value: number[]): ShaderMaterial;
  17208. /**
  17209. * Set a vec3 array in the shader from a number array.
  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. setArray3(name: string, value: number[]): ShaderMaterial;
  17215. /**
  17216. * Set a vec4 array in the shader from a number array.
  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. setArray4(name: string, value: number[]): ShaderMaterial;
  17222. private _checkCache;
  17223. /**
  17224. * Specifies that the submesh is ready to be used
  17225. * @param mesh defines the mesh to check
  17226. * @param subMesh defines which submesh to check
  17227. * @param useInstances specifies that instances should be used
  17228. * @returns a boolean indicating that the submesh is ready or not
  17229. */
  17230. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17231. /**
  17232. * Checks if the material is ready to render the requested mesh
  17233. * @param mesh Define the mesh to render
  17234. * @param useInstances Define whether or not the material is used with instances
  17235. * @returns true if ready, otherwise false
  17236. */
  17237. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17238. /**
  17239. * Binds the world matrix to the material
  17240. * @param world defines the world transformation matrix
  17241. * @param effectOverride - If provided, use this effect instead of internal effect
  17242. */
  17243. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17244. /**
  17245. * Binds the submesh to this material by preparing the effect and shader to draw
  17246. * @param world defines the world transformation matrix
  17247. * @param mesh defines the mesh containing the submesh
  17248. * @param subMesh defines the submesh to bind the material to
  17249. */
  17250. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17251. /**
  17252. * Binds the material to the mesh
  17253. * @param world defines the world transformation matrix
  17254. * @param mesh defines the mesh to bind the material to
  17255. * @param effectOverride - If provided, use this effect instead of internal effect
  17256. */
  17257. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17258. protected _afterBind(mesh?: Mesh): void;
  17259. /**
  17260. * Gets the active textures from the material
  17261. * @returns an array of textures
  17262. */
  17263. getActiveTextures(): BaseTexture[];
  17264. /**
  17265. * Specifies if the material uses a texture
  17266. * @param texture defines the texture to check against the material
  17267. * @returns a boolean specifying if the material uses the texture
  17268. */
  17269. hasTexture(texture: BaseTexture): boolean;
  17270. /**
  17271. * Makes a duplicate of the material, and gives it a new name
  17272. * @param name defines the new name for the duplicated material
  17273. * @returns the cloned material
  17274. */
  17275. clone(name: string): ShaderMaterial;
  17276. /**
  17277. * Disposes the material
  17278. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17279. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17280. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17281. */
  17282. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17283. /**
  17284. * Serializes this material in a JSON representation
  17285. * @returns the serialized material object
  17286. */
  17287. serialize(): any;
  17288. /**
  17289. * Creates a shader material from parsed shader material data
  17290. * @param source defines the JSON represnetation of the material
  17291. * @param scene defines the hosting scene
  17292. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17293. * @returns a new material
  17294. */
  17295. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17296. /**
  17297. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17298. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17299. * @param url defines the url to load from
  17300. * @param scene defines the hosting scene
  17301. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17302. * @returns a promise that will resolve to the new ShaderMaterial
  17303. */
  17304. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17305. /**
  17306. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17307. * @param snippetId defines the snippet to load
  17308. * @param scene defines the hosting scene
  17309. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17310. * @returns a promise that will resolve to the new ShaderMaterial
  17311. */
  17312. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17313. }
  17314. }
  17315. declare module "babylonjs/Shaders/color.fragment" {
  17316. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17317. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17318. /** @hidden */
  17319. export var colorPixelShader: {
  17320. name: string;
  17321. shader: string;
  17322. };
  17323. }
  17324. declare module "babylonjs/Shaders/color.vertex" {
  17325. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17326. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17327. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17328. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17329. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17330. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17331. /** @hidden */
  17332. export var colorVertexShader: {
  17333. name: string;
  17334. shader: string;
  17335. };
  17336. }
  17337. declare module "babylonjs/Meshes/linesMesh" {
  17338. import { Nullable } from "babylonjs/types";
  17339. import { Scene } from "babylonjs/scene";
  17340. import { Color3 } from "babylonjs/Maths/math.color";
  17341. import { Node } from "babylonjs/node";
  17342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17343. import { Mesh } from "babylonjs/Meshes/mesh";
  17344. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17345. import { Effect } from "babylonjs/Materials/effect";
  17346. import { Material } from "babylonjs/Materials/material";
  17347. import "babylonjs/Shaders/color.fragment";
  17348. import "babylonjs/Shaders/color.vertex";
  17349. /**
  17350. * Line mesh
  17351. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17352. */
  17353. export class LinesMesh extends Mesh {
  17354. /**
  17355. * If vertex color should be applied to the mesh
  17356. */
  17357. readonly useVertexColor?: boolean | undefined;
  17358. /**
  17359. * If vertex alpha should be applied to the mesh
  17360. */
  17361. readonly useVertexAlpha?: boolean | undefined;
  17362. /**
  17363. * Color of the line (Default: White)
  17364. */
  17365. color: Color3;
  17366. /**
  17367. * Alpha of the line (Default: 1)
  17368. */
  17369. alpha: number;
  17370. /**
  17371. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17372. * This margin is expressed in world space coordinates, so its value may vary.
  17373. * Default value is 0.1
  17374. */
  17375. intersectionThreshold: number;
  17376. private _colorShader;
  17377. private color4;
  17378. /**
  17379. * Creates a new LinesMesh
  17380. * @param name defines the name
  17381. * @param scene defines the hosting scene
  17382. * @param parent defines the parent mesh if any
  17383. * @param source defines the optional source LinesMesh used to clone data from
  17384. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17385. * When false, achieved by calling a clone(), also passing False.
  17386. * This will make creation of children, recursive.
  17387. * @param useVertexColor defines if this LinesMesh supports vertex color
  17388. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17389. */
  17390. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17391. /**
  17392. * If vertex color should be applied to the mesh
  17393. */
  17394. useVertexColor?: boolean | undefined,
  17395. /**
  17396. * If vertex alpha should be applied to the mesh
  17397. */
  17398. useVertexAlpha?: boolean | undefined);
  17399. private _addClipPlaneDefine;
  17400. private _removeClipPlaneDefine;
  17401. isReady(): boolean;
  17402. /**
  17403. * Returns the string "LineMesh"
  17404. */
  17405. getClassName(): string;
  17406. /**
  17407. * @hidden
  17408. */
  17409. get material(): Material;
  17410. /**
  17411. * @hidden
  17412. */
  17413. set material(value: Material);
  17414. /**
  17415. * @hidden
  17416. */
  17417. get checkCollisions(): boolean;
  17418. /** @hidden */
  17419. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17420. /** @hidden */
  17421. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17422. /**
  17423. * Disposes of the line mesh
  17424. * @param doNotRecurse If children should be disposed
  17425. */
  17426. dispose(doNotRecurse?: boolean): void;
  17427. /**
  17428. * Returns a new LineMesh object cloned from the current one.
  17429. */
  17430. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17431. /**
  17432. * Creates a new InstancedLinesMesh object from the mesh model.
  17433. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17434. * @param name defines the name of the new instance
  17435. * @returns a new InstancedLinesMesh
  17436. */
  17437. createInstance(name: string): InstancedLinesMesh;
  17438. }
  17439. /**
  17440. * Creates an instance based on a source LinesMesh
  17441. */
  17442. export class InstancedLinesMesh extends InstancedMesh {
  17443. /**
  17444. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17445. * This margin is expressed in world space coordinates, so its value may vary.
  17446. * Initilized with the intersectionThreshold value of the source LinesMesh
  17447. */
  17448. intersectionThreshold: number;
  17449. constructor(name: string, source: LinesMesh);
  17450. /**
  17451. * Returns the string "InstancedLinesMesh".
  17452. */
  17453. getClassName(): string;
  17454. }
  17455. }
  17456. declare module "babylonjs/Shaders/line.fragment" {
  17457. /** @hidden */
  17458. export var linePixelShader: {
  17459. name: string;
  17460. shader: string;
  17461. };
  17462. }
  17463. declare module "babylonjs/Shaders/line.vertex" {
  17464. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17465. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17466. /** @hidden */
  17467. export var lineVertexShader: {
  17468. name: string;
  17469. shader: string;
  17470. };
  17471. }
  17472. declare module "babylonjs/Rendering/edgesRenderer" {
  17473. import { Nullable } from "babylonjs/types";
  17474. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17476. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17477. import { IDisposable } from "babylonjs/scene";
  17478. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17479. import "babylonjs/Shaders/line.fragment";
  17480. import "babylonjs/Shaders/line.vertex";
  17481. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17482. import { SmartArray } from "babylonjs/Misc/smartArray";
  17483. module "babylonjs/scene" {
  17484. interface Scene {
  17485. /** @hidden */
  17486. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17487. }
  17488. }
  17489. module "babylonjs/Meshes/abstractMesh" {
  17490. interface AbstractMesh {
  17491. /**
  17492. * Gets the edgesRenderer associated with the mesh
  17493. */
  17494. edgesRenderer: Nullable<EdgesRenderer>;
  17495. }
  17496. }
  17497. module "babylonjs/Meshes/linesMesh" {
  17498. interface LinesMesh {
  17499. /**
  17500. * Enables the edge rendering mode on the mesh.
  17501. * This mode makes the mesh edges visible
  17502. * @param epsilon defines the maximal distance between two angles to detect a face
  17503. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17504. * @returns the currentAbstractMesh
  17505. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17506. */
  17507. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17508. }
  17509. }
  17510. module "babylonjs/Meshes/linesMesh" {
  17511. interface InstancedLinesMesh {
  17512. /**
  17513. * Enables the edge rendering mode on the mesh.
  17514. * This mode makes the mesh edges visible
  17515. * @param epsilon defines the maximal distance between two angles to detect a face
  17516. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17517. * @returns the current InstancedLinesMesh
  17518. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17519. */
  17520. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17521. }
  17522. }
  17523. /**
  17524. * Defines the minimum contract an Edges renderer should follow.
  17525. */
  17526. export interface IEdgesRenderer extends IDisposable {
  17527. /**
  17528. * Gets or sets a boolean indicating if the edgesRenderer is active
  17529. */
  17530. isEnabled: boolean;
  17531. /**
  17532. * Renders the edges of the attached mesh,
  17533. */
  17534. render(): void;
  17535. /**
  17536. * Checks wether or not the edges renderer is ready to render.
  17537. * @return true if ready, otherwise false.
  17538. */
  17539. isReady(): boolean;
  17540. /**
  17541. * List of instances to render in case the source mesh has instances
  17542. */
  17543. customInstances: SmartArray<Matrix>;
  17544. }
  17545. /**
  17546. * Defines the additional options of the edges renderer
  17547. */
  17548. export interface IEdgesRendererOptions {
  17549. /**
  17550. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17551. * If not defined, the default value is true
  17552. */
  17553. useAlternateEdgeFinder?: boolean;
  17554. /**
  17555. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17556. * If not defined, the default value is true.
  17557. * 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)
  17558. * This option is used only if useAlternateEdgeFinder = true
  17559. */
  17560. useFastVertexMerger?: boolean;
  17561. /**
  17562. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17563. * The default value is 1e-6
  17564. * This option is used only if useAlternateEdgeFinder = true
  17565. */
  17566. epsilonVertexMerge?: number;
  17567. /**
  17568. * 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
  17569. * 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.
  17570. * This option is used only if useAlternateEdgeFinder = true
  17571. */
  17572. applyTessellation?: boolean;
  17573. /**
  17574. * 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
  17575. * The default value is 1e-6
  17576. * This option is used only if useAlternateEdgeFinder = true
  17577. */
  17578. epsilonVertexAligned?: number;
  17579. }
  17580. /**
  17581. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17582. */
  17583. export class EdgesRenderer implements IEdgesRenderer {
  17584. /**
  17585. * Define the size of the edges with an orthographic camera
  17586. */
  17587. edgesWidthScalerForOrthographic: number;
  17588. /**
  17589. * Define the size of the edges with a perspective camera
  17590. */
  17591. edgesWidthScalerForPerspective: number;
  17592. protected _source: AbstractMesh;
  17593. protected _linesPositions: number[];
  17594. protected _linesNormals: number[];
  17595. protected _linesIndices: number[];
  17596. protected _epsilon: number;
  17597. protected _indicesCount: number;
  17598. protected _lineShader: ShaderMaterial;
  17599. protected _ib: DataBuffer;
  17600. protected _buffers: {
  17601. [key: string]: Nullable<VertexBuffer>;
  17602. };
  17603. protected _buffersForInstances: {
  17604. [key: string]: Nullable<VertexBuffer>;
  17605. };
  17606. protected _checkVerticesInsteadOfIndices: boolean;
  17607. protected _options: Nullable<IEdgesRendererOptions>;
  17608. private _meshRebuildObserver;
  17609. private _meshDisposeObserver;
  17610. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17611. isEnabled: boolean;
  17612. /**
  17613. * List of instances to render in case the source mesh has instances
  17614. */
  17615. customInstances: SmartArray<Matrix>;
  17616. private static GetShader;
  17617. /**
  17618. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17619. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17620. * @param source Mesh used to create edges
  17621. * @param epsilon sum of angles in adjacency to check for edge
  17622. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17623. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17624. * @param options The options to apply when generating the edges
  17625. */
  17626. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17627. protected _prepareRessources(): void;
  17628. /** @hidden */
  17629. _rebuild(): void;
  17630. /**
  17631. * Releases the required resources for the edges renderer
  17632. */
  17633. dispose(): void;
  17634. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17635. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17636. /**
  17637. * Checks if the pair of p0 and p1 is en edge
  17638. * @param faceIndex
  17639. * @param edge
  17640. * @param faceNormals
  17641. * @param p0
  17642. * @param p1
  17643. * @private
  17644. */
  17645. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17646. /**
  17647. * push line into the position, normal and index buffer
  17648. * @protected
  17649. */
  17650. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17651. /**
  17652. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17653. */
  17654. private _tessellateTriangle;
  17655. private _generateEdgesLinesAlternate;
  17656. /**
  17657. * Generates lines edges from adjacencjes
  17658. * @private
  17659. */
  17660. _generateEdgesLines(): void;
  17661. /**
  17662. * Checks wether or not the edges renderer is ready to render.
  17663. * @return true if ready, otherwise false.
  17664. */
  17665. isReady(): boolean;
  17666. /**
  17667. * Renders the edges of the attached mesh,
  17668. */
  17669. render(): void;
  17670. }
  17671. /**
  17672. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17673. */
  17674. export class LineEdgesRenderer extends EdgesRenderer {
  17675. /**
  17676. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17677. * @param source LineMesh used to generate edges
  17678. * @param epsilon not important (specified angle for edge detection)
  17679. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17680. */
  17681. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17682. /**
  17683. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17684. */
  17685. _generateEdgesLines(): void;
  17686. }
  17687. }
  17688. declare module "babylonjs/Rendering/renderingGroup" {
  17689. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17690. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17692. import { Nullable } from "babylonjs/types";
  17693. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17694. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17695. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17696. import { Material } from "babylonjs/Materials/material";
  17697. import { Scene } from "babylonjs/scene";
  17698. /**
  17699. * This represents the object necessary to create a rendering group.
  17700. * This is exclusively used and created by the rendering manager.
  17701. * To modify the behavior, you use the available helpers in your scene or meshes.
  17702. * @hidden
  17703. */
  17704. export class RenderingGroup {
  17705. index: number;
  17706. private static _zeroVector;
  17707. private _scene;
  17708. private _opaqueSubMeshes;
  17709. private _transparentSubMeshes;
  17710. private _alphaTestSubMeshes;
  17711. private _depthOnlySubMeshes;
  17712. private _particleSystems;
  17713. private _spriteManagers;
  17714. private _opaqueSortCompareFn;
  17715. private _alphaTestSortCompareFn;
  17716. private _transparentSortCompareFn;
  17717. private _renderOpaque;
  17718. private _renderAlphaTest;
  17719. private _renderTransparent;
  17720. /** @hidden */
  17721. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17722. onBeforeTransparentRendering: () => void;
  17723. /**
  17724. * Set the opaque sort comparison function.
  17725. * If null the sub meshes will be render in the order they were created
  17726. */
  17727. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17728. /**
  17729. * Set the alpha test sort comparison function.
  17730. * If null the sub meshes will be render in the order they were created
  17731. */
  17732. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17733. /**
  17734. * Set the transparent sort comparison function.
  17735. * If null the sub meshes will be render in the order they were created
  17736. */
  17737. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17738. /**
  17739. * Creates a new rendering group.
  17740. * @param index The rendering group index
  17741. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17742. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17743. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17744. */
  17745. 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>);
  17746. /**
  17747. * Render all the sub meshes contained in the group.
  17748. * @param customRenderFunction Used to override the default render behaviour of the group.
  17749. * @returns true if rendered some submeshes.
  17750. */
  17751. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17752. /**
  17753. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17754. * @param subMeshes The submeshes to render
  17755. */
  17756. private renderOpaqueSorted;
  17757. /**
  17758. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17759. * @param subMeshes The submeshes to render
  17760. */
  17761. private renderAlphaTestSorted;
  17762. /**
  17763. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17764. * @param subMeshes The submeshes to render
  17765. */
  17766. private renderTransparentSorted;
  17767. /**
  17768. * Renders the submeshes in a specified order.
  17769. * @param subMeshes The submeshes to sort before render
  17770. * @param sortCompareFn The comparison function use to sort
  17771. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17772. * @param transparent Specifies to activate blending if true
  17773. */
  17774. private static renderSorted;
  17775. /**
  17776. * Renders the submeshes in the order they were dispatched (no sort applied).
  17777. * @param subMeshes The submeshes to render
  17778. */
  17779. private static renderUnsorted;
  17780. /**
  17781. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17782. * are rendered back to front if in the same alpha index.
  17783. *
  17784. * @param a The first submesh
  17785. * @param b The second submesh
  17786. * @returns The result of the comparison
  17787. */
  17788. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17789. /**
  17790. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17791. * are rendered back to front.
  17792. *
  17793. * @param a The first submesh
  17794. * @param b The second submesh
  17795. * @returns The result of the comparison
  17796. */
  17797. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17798. /**
  17799. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17800. * are rendered front to back (prevent overdraw).
  17801. *
  17802. * @param a The first submesh
  17803. * @param b The second submesh
  17804. * @returns The result of the comparison
  17805. */
  17806. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17807. /**
  17808. * Resets the different lists of submeshes to prepare a new frame.
  17809. */
  17810. prepare(): void;
  17811. dispose(): void;
  17812. /**
  17813. * Inserts the submesh in its correct queue depending on its material.
  17814. * @param subMesh The submesh to dispatch
  17815. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17816. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17817. */
  17818. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17819. dispatchSprites(spriteManager: ISpriteManager): void;
  17820. dispatchParticles(particleSystem: IParticleSystem): void;
  17821. private _renderParticles;
  17822. private _renderSprites;
  17823. }
  17824. }
  17825. declare module "babylonjs/Rendering/renderingManager" {
  17826. import { Nullable } from "babylonjs/types";
  17827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17828. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17829. import { SmartArray } from "babylonjs/Misc/smartArray";
  17830. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17831. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17832. import { Material } from "babylonjs/Materials/material";
  17833. import { Scene } from "babylonjs/scene";
  17834. import { Camera } from "babylonjs/Cameras/camera";
  17835. /**
  17836. * Interface describing the different options available in the rendering manager
  17837. * regarding Auto Clear between groups.
  17838. */
  17839. export interface IRenderingManagerAutoClearSetup {
  17840. /**
  17841. * Defines whether or not autoclear is enable.
  17842. */
  17843. autoClear: boolean;
  17844. /**
  17845. * Defines whether or not to autoclear the depth buffer.
  17846. */
  17847. depth: boolean;
  17848. /**
  17849. * Defines whether or not to autoclear the stencil buffer.
  17850. */
  17851. stencil: boolean;
  17852. }
  17853. /**
  17854. * This class is used by the onRenderingGroupObservable
  17855. */
  17856. export class RenderingGroupInfo {
  17857. /**
  17858. * The Scene that being rendered
  17859. */
  17860. scene: Scene;
  17861. /**
  17862. * The camera currently used for the rendering pass
  17863. */
  17864. camera: Nullable<Camera>;
  17865. /**
  17866. * The ID of the renderingGroup being processed
  17867. */
  17868. renderingGroupId: number;
  17869. }
  17870. /**
  17871. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17872. * It is enable to manage the different groups as well as the different necessary sort functions.
  17873. * This should not be used directly aside of the few static configurations
  17874. */
  17875. export class RenderingManager {
  17876. /**
  17877. * The max id used for rendering groups (not included)
  17878. */
  17879. static MAX_RENDERINGGROUPS: number;
  17880. /**
  17881. * The min id used for rendering groups (included)
  17882. */
  17883. static MIN_RENDERINGGROUPS: number;
  17884. /**
  17885. * Used to globally prevent autoclearing scenes.
  17886. */
  17887. static AUTOCLEAR: boolean;
  17888. /**
  17889. * @hidden
  17890. */
  17891. _useSceneAutoClearSetup: boolean;
  17892. private _scene;
  17893. private _renderingGroups;
  17894. private _depthStencilBufferAlreadyCleaned;
  17895. private _autoClearDepthStencil;
  17896. private _customOpaqueSortCompareFn;
  17897. private _customAlphaTestSortCompareFn;
  17898. private _customTransparentSortCompareFn;
  17899. private _renderingGroupInfo;
  17900. /**
  17901. * Instantiates a new rendering group for a particular scene
  17902. * @param scene Defines the scene the groups belongs to
  17903. */
  17904. constructor(scene: Scene);
  17905. private _clearDepthStencilBuffer;
  17906. /**
  17907. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17908. * @hidden
  17909. */
  17910. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17911. /**
  17912. * Resets the different information of the group to prepare a new frame
  17913. * @hidden
  17914. */
  17915. reset(): void;
  17916. /**
  17917. * Dispose and release the group and its associated resources.
  17918. * @hidden
  17919. */
  17920. dispose(): void;
  17921. /**
  17922. * Clear the info related to rendering groups preventing retention points during dispose.
  17923. */
  17924. freeRenderingGroups(): void;
  17925. private _prepareRenderingGroup;
  17926. /**
  17927. * Add a sprite manager to the rendering manager in order to render it this frame.
  17928. * @param spriteManager Define the sprite manager to render
  17929. */
  17930. dispatchSprites(spriteManager: ISpriteManager): void;
  17931. /**
  17932. * Add a particle system to the rendering manager in order to render it this frame.
  17933. * @param particleSystem Define the particle system to render
  17934. */
  17935. dispatchParticles(particleSystem: IParticleSystem): void;
  17936. /**
  17937. * Add a submesh to the manager in order to render it this frame
  17938. * @param subMesh The submesh to dispatch
  17939. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17940. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17941. */
  17942. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17943. /**
  17944. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17945. * This allowed control for front to back rendering or reversly depending of the special needs.
  17946. *
  17947. * @param renderingGroupId The rendering group id corresponding to its index
  17948. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17949. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17950. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17951. */
  17952. 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;
  17953. /**
  17954. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17955. *
  17956. * @param renderingGroupId The rendering group id corresponding to its index
  17957. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17958. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17959. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17960. */
  17961. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17962. /**
  17963. * Gets the current auto clear configuration for one rendering group of the rendering
  17964. * manager.
  17965. * @param index the rendering group index to get the information for
  17966. * @returns The auto clear setup for the requested rendering group
  17967. */
  17968. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17969. }
  17970. }
  17971. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17972. import { SmartArray } from "babylonjs/Misc/smartArray";
  17973. import { Nullable } from "babylonjs/types";
  17974. import { Scene } from "babylonjs/scene";
  17975. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17978. import { Mesh } from "babylonjs/Meshes/mesh";
  17979. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17980. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17981. import { Effect } from "babylonjs/Materials/effect";
  17982. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17983. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17984. import "babylonjs/Shaders/shadowMap.fragment";
  17985. import "babylonjs/Shaders/shadowMap.vertex";
  17986. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17987. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17988. import { Observable } from "babylonjs/Misc/observable";
  17989. /**
  17990. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17991. */
  17992. export interface ICustomShaderOptions {
  17993. /**
  17994. * Gets or sets the custom shader name to use
  17995. */
  17996. shaderName: string;
  17997. /**
  17998. * The list of attribute names used in the shader
  17999. */
  18000. attributes?: string[];
  18001. /**
  18002. * The list of unifrom names used in the shader
  18003. */
  18004. uniforms?: string[];
  18005. /**
  18006. * The list of sampler names used in the shader
  18007. */
  18008. samplers?: string[];
  18009. /**
  18010. * The list of defines used in the shader
  18011. */
  18012. defines?: string[];
  18013. }
  18014. /**
  18015. * Interface to implement to create a shadow generator compatible with BJS.
  18016. */
  18017. export interface IShadowGenerator {
  18018. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18019. id: string;
  18020. /**
  18021. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18022. * @returns The render target texture if present otherwise, null
  18023. */
  18024. getShadowMap(): Nullable<RenderTargetTexture>;
  18025. /**
  18026. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18027. * @param subMesh The submesh we want to render in the shadow map
  18028. * @param useInstances Defines wether will draw in the map using instances
  18029. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18030. * @returns true if ready otherwise, false
  18031. */
  18032. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18033. /**
  18034. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18035. * @param defines Defines of the material we want to update
  18036. * @param lightIndex Index of the light in the enabled light list of the material
  18037. */
  18038. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18039. /**
  18040. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18041. * defined in the generator but impacting the effect).
  18042. * It implies the unifroms available on the materials are the standard BJS ones.
  18043. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18044. * @param effect The effect we are binfing the information for
  18045. */
  18046. bindShadowLight(lightIndex: string, effect: Effect): void;
  18047. /**
  18048. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18049. * (eq to shadow prjection matrix * light transform matrix)
  18050. * @returns The transform matrix used to create the shadow map
  18051. */
  18052. getTransformMatrix(): Matrix;
  18053. /**
  18054. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18055. * Cube and 2D textures for instance.
  18056. */
  18057. recreateShadowMap(): void;
  18058. /**
  18059. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18060. * @param onCompiled Callback triggered at the and of the effects compilation
  18061. * @param options Sets of optional options forcing the compilation with different modes
  18062. */
  18063. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18064. useInstances: boolean;
  18065. }>): void;
  18066. /**
  18067. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18068. * @param options Sets of optional options forcing the compilation with different modes
  18069. * @returns A promise that resolves when the compilation completes
  18070. */
  18071. forceCompilationAsync(options?: Partial<{
  18072. useInstances: boolean;
  18073. }>): Promise<void>;
  18074. /**
  18075. * Serializes the shadow generator setup to a json object.
  18076. * @returns The serialized JSON object
  18077. */
  18078. serialize(): any;
  18079. /**
  18080. * Disposes the Shadow map and related Textures and effects.
  18081. */
  18082. dispose(): void;
  18083. }
  18084. /**
  18085. * Default implementation IShadowGenerator.
  18086. * This is the main object responsible of generating shadows in the framework.
  18087. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18088. */
  18089. export class ShadowGenerator implements IShadowGenerator {
  18090. /**
  18091. * Name of the shadow generator class
  18092. */
  18093. static CLASSNAME: string;
  18094. /**
  18095. * Shadow generator mode None: no filtering applied.
  18096. */
  18097. static readonly FILTER_NONE: number;
  18098. /**
  18099. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18100. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18101. */
  18102. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18103. /**
  18104. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18105. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18106. */
  18107. static readonly FILTER_POISSONSAMPLING: number;
  18108. /**
  18109. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18110. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18111. */
  18112. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18113. /**
  18114. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18115. * edge artifacts on steep falloff.
  18116. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18117. */
  18118. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18119. /**
  18120. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18121. * edge artifacts on steep falloff.
  18122. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18123. */
  18124. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18125. /**
  18126. * Shadow generator mode PCF: Percentage Closer Filtering
  18127. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18128. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18129. */
  18130. static readonly FILTER_PCF: number;
  18131. /**
  18132. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18133. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18134. * Contact Hardening
  18135. */
  18136. static readonly FILTER_PCSS: number;
  18137. /**
  18138. * Reserved for PCF and PCSS
  18139. * Highest Quality.
  18140. *
  18141. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18142. *
  18143. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18144. */
  18145. static readonly QUALITY_HIGH: number;
  18146. /**
  18147. * Reserved for PCF and PCSS
  18148. * Good tradeoff for quality/perf cross devices
  18149. *
  18150. * Execute PCF on a 3*3 kernel.
  18151. *
  18152. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18153. */
  18154. static readonly QUALITY_MEDIUM: number;
  18155. /**
  18156. * Reserved for PCF and PCSS
  18157. * The lowest quality but the fastest.
  18158. *
  18159. * Execute PCF on a 1*1 kernel.
  18160. *
  18161. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18162. */
  18163. static readonly QUALITY_LOW: number;
  18164. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18165. id: string;
  18166. /** Gets or sets the custom shader name to use */
  18167. customShaderOptions: ICustomShaderOptions;
  18168. /**
  18169. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18170. */
  18171. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18172. /**
  18173. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18174. */
  18175. onAfterShadowMapRenderObservable: Observable<Effect>;
  18176. /**
  18177. * Observable triggered before a mesh is rendered in the shadow map.
  18178. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18179. */
  18180. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18181. /**
  18182. * Observable triggered after a mesh is rendered in the shadow map.
  18183. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18184. */
  18185. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18186. protected _bias: number;
  18187. /**
  18188. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18189. */
  18190. get bias(): number;
  18191. /**
  18192. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18193. */
  18194. set bias(bias: number);
  18195. protected _normalBias: number;
  18196. /**
  18197. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18198. */
  18199. get normalBias(): number;
  18200. /**
  18201. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18202. */
  18203. set normalBias(normalBias: number);
  18204. protected _blurBoxOffset: number;
  18205. /**
  18206. * Gets the blur box offset: offset applied during the blur pass.
  18207. * Only useful if useKernelBlur = false
  18208. */
  18209. get blurBoxOffset(): number;
  18210. /**
  18211. * Sets the blur box offset: offset applied during the blur pass.
  18212. * Only useful if useKernelBlur = false
  18213. */
  18214. set blurBoxOffset(value: number);
  18215. protected _blurScale: number;
  18216. /**
  18217. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18218. * 2 means half of the size.
  18219. */
  18220. get blurScale(): number;
  18221. /**
  18222. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18223. * 2 means half of the size.
  18224. */
  18225. set blurScale(value: number);
  18226. protected _blurKernel: number;
  18227. /**
  18228. * Gets the blur kernel: kernel size of the blur pass.
  18229. * Only useful if useKernelBlur = true
  18230. */
  18231. get blurKernel(): number;
  18232. /**
  18233. * Sets the blur kernel: kernel size of the blur pass.
  18234. * Only useful if useKernelBlur = true
  18235. */
  18236. set blurKernel(value: number);
  18237. protected _useKernelBlur: boolean;
  18238. /**
  18239. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18240. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18241. */
  18242. get useKernelBlur(): boolean;
  18243. /**
  18244. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18245. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18246. */
  18247. set useKernelBlur(value: boolean);
  18248. protected _depthScale: number;
  18249. /**
  18250. * Gets the depth scale used in ESM mode.
  18251. */
  18252. get depthScale(): number;
  18253. /**
  18254. * Sets the depth scale used in ESM mode.
  18255. * This can override the scale stored on the light.
  18256. */
  18257. set depthScale(value: number);
  18258. protected _validateFilter(filter: number): number;
  18259. protected _filter: number;
  18260. /**
  18261. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18262. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18263. */
  18264. get filter(): number;
  18265. /**
  18266. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18267. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18268. */
  18269. set filter(value: number);
  18270. /**
  18271. * Gets if the current filter is set to Poisson Sampling.
  18272. */
  18273. get usePoissonSampling(): boolean;
  18274. /**
  18275. * Sets the current filter to Poisson Sampling.
  18276. */
  18277. set usePoissonSampling(value: boolean);
  18278. /**
  18279. * Gets if the current filter is set to ESM.
  18280. */
  18281. get useExponentialShadowMap(): boolean;
  18282. /**
  18283. * Sets the current filter is to ESM.
  18284. */
  18285. set useExponentialShadowMap(value: boolean);
  18286. /**
  18287. * Gets if the current filter is set to filtered ESM.
  18288. */
  18289. get useBlurExponentialShadowMap(): boolean;
  18290. /**
  18291. * Gets if the current filter is set to filtered ESM.
  18292. */
  18293. set useBlurExponentialShadowMap(value: boolean);
  18294. /**
  18295. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18296. * exponential to prevent steep falloff artifacts).
  18297. */
  18298. get useCloseExponentialShadowMap(): boolean;
  18299. /**
  18300. * Sets the current filter to "close ESM" (using the inverse of the
  18301. * exponential to prevent steep falloff artifacts).
  18302. */
  18303. set useCloseExponentialShadowMap(value: boolean);
  18304. /**
  18305. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18306. * exponential to prevent steep falloff artifacts).
  18307. */
  18308. get useBlurCloseExponentialShadowMap(): boolean;
  18309. /**
  18310. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18311. * exponential to prevent steep falloff artifacts).
  18312. */
  18313. set useBlurCloseExponentialShadowMap(value: boolean);
  18314. /**
  18315. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18316. */
  18317. get usePercentageCloserFiltering(): boolean;
  18318. /**
  18319. * Sets the current filter to "PCF" (percentage closer filtering).
  18320. */
  18321. set usePercentageCloserFiltering(value: boolean);
  18322. protected _filteringQuality: number;
  18323. /**
  18324. * Gets the PCF or PCSS Quality.
  18325. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18326. */
  18327. get filteringQuality(): number;
  18328. /**
  18329. * Sets the PCF or PCSS Quality.
  18330. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18331. */
  18332. set filteringQuality(filteringQuality: number);
  18333. /**
  18334. * Gets if the current filter is set to "PCSS" (contact hardening).
  18335. */
  18336. get useContactHardeningShadow(): boolean;
  18337. /**
  18338. * Sets the current filter to "PCSS" (contact hardening).
  18339. */
  18340. set useContactHardeningShadow(value: boolean);
  18341. protected _contactHardeningLightSizeUVRatio: number;
  18342. /**
  18343. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18344. * Using a ratio helps keeping shape stability independently of the map size.
  18345. *
  18346. * It does not account for the light projection as it was having too much
  18347. * instability during the light setup or during light position changes.
  18348. *
  18349. * Only valid if useContactHardeningShadow is true.
  18350. */
  18351. get contactHardeningLightSizeUVRatio(): number;
  18352. /**
  18353. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18354. * Using a ratio helps keeping shape stability independently of the map size.
  18355. *
  18356. * It does not account for the light projection as it was having too much
  18357. * instability during the light setup or during light position changes.
  18358. *
  18359. * Only valid if useContactHardeningShadow is true.
  18360. */
  18361. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18362. protected _darkness: number;
  18363. /** Gets or sets the actual darkness of a shadow */
  18364. get darkness(): number;
  18365. set darkness(value: number);
  18366. /**
  18367. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18368. * 0 means strongest and 1 would means no shadow.
  18369. * @returns the darkness.
  18370. */
  18371. getDarkness(): number;
  18372. /**
  18373. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18374. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18375. * @returns the shadow generator allowing fluent coding.
  18376. */
  18377. setDarkness(darkness: number): ShadowGenerator;
  18378. protected _transparencyShadow: boolean;
  18379. /** Gets or sets the ability to have transparent shadow */
  18380. get transparencyShadow(): boolean;
  18381. set transparencyShadow(value: boolean);
  18382. /**
  18383. * Sets the ability to have transparent shadow (boolean).
  18384. * @param transparent True if transparent else False
  18385. * @returns the shadow generator allowing fluent coding
  18386. */
  18387. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18388. /**
  18389. * Enables or disables shadows with varying strength based on the transparency
  18390. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18391. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18392. * mesh.visibility * alphaTexture.a
  18393. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18394. */
  18395. enableSoftTransparentShadow: boolean;
  18396. protected _shadowMap: Nullable<RenderTargetTexture>;
  18397. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18398. /**
  18399. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18400. * @returns The render target texture if present otherwise, null
  18401. */
  18402. getShadowMap(): Nullable<RenderTargetTexture>;
  18403. /**
  18404. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18405. * @returns The render target texture if the shadow map is present otherwise, null
  18406. */
  18407. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18408. /**
  18409. * Gets the class name of that object
  18410. * @returns "ShadowGenerator"
  18411. */
  18412. getClassName(): string;
  18413. /**
  18414. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18415. * @param mesh Mesh to add
  18416. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18417. * @returns the Shadow Generator itself
  18418. */
  18419. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18420. /**
  18421. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18422. * @param mesh Mesh to remove
  18423. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18424. * @returns the Shadow Generator itself
  18425. */
  18426. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18427. /**
  18428. * Controls the extent to which the shadows fade out at the edge of the frustum
  18429. */
  18430. frustumEdgeFalloff: number;
  18431. protected _light: IShadowLight;
  18432. /**
  18433. * Returns the associated light object.
  18434. * @returns the light generating the shadow
  18435. */
  18436. getLight(): IShadowLight;
  18437. /**
  18438. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18439. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18440. * It might on the other hand introduce peter panning.
  18441. */
  18442. forceBackFacesOnly: boolean;
  18443. protected _scene: Scene;
  18444. protected _lightDirection: Vector3;
  18445. protected _effect: Effect;
  18446. protected _viewMatrix: Matrix;
  18447. protected _projectionMatrix: Matrix;
  18448. protected _transformMatrix: Matrix;
  18449. protected _cachedPosition: Vector3;
  18450. protected _cachedDirection: Vector3;
  18451. protected _cachedDefines: string;
  18452. protected _currentRenderID: number;
  18453. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18454. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18455. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18456. protected _blurPostProcesses: PostProcess[];
  18457. protected _mapSize: number;
  18458. protected _currentFaceIndex: number;
  18459. protected _currentFaceIndexCache: number;
  18460. protected _textureType: number;
  18461. protected _defaultTextureMatrix: Matrix;
  18462. protected _storedUniqueId: Nullable<number>;
  18463. /** @hidden */
  18464. static _SceneComponentInitialization: (scene: Scene) => void;
  18465. /**
  18466. * Creates a ShadowGenerator object.
  18467. * A ShadowGenerator is the required tool to use the shadows.
  18468. * Each light casting shadows needs to use its own ShadowGenerator.
  18469. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18470. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18471. * @param light The light object generating the shadows.
  18472. * @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.
  18473. */
  18474. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18475. protected _initializeGenerator(): void;
  18476. protected _createTargetRenderTexture(): void;
  18477. protected _initializeShadowMap(): void;
  18478. protected _initializeBlurRTTAndPostProcesses(): void;
  18479. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18480. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18481. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18482. protected _applyFilterValues(): void;
  18483. /**
  18484. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18485. * @param onCompiled Callback triggered at the and of the effects compilation
  18486. * @param options Sets of optional options forcing the compilation with different modes
  18487. */
  18488. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18489. useInstances: boolean;
  18490. }>): void;
  18491. /**
  18492. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18493. * @param options Sets of optional options forcing the compilation with different modes
  18494. * @returns A promise that resolves when the compilation completes
  18495. */
  18496. forceCompilationAsync(options?: Partial<{
  18497. useInstances: boolean;
  18498. }>): Promise<void>;
  18499. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18500. private _prepareShadowDefines;
  18501. /**
  18502. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18503. * @param subMesh The submesh we want to render in the shadow map
  18504. * @param useInstances Defines wether will draw in the map using instances
  18505. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18506. * @returns true if ready otherwise, false
  18507. */
  18508. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18509. /**
  18510. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18511. * @param defines Defines of the material we want to update
  18512. * @param lightIndex Index of the light in the enabled light list of the material
  18513. */
  18514. prepareDefines(defines: any, lightIndex: number): void;
  18515. /**
  18516. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18517. * defined in the generator but impacting the effect).
  18518. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18519. * @param effect The effect we are binfing the information for
  18520. */
  18521. bindShadowLight(lightIndex: string, effect: Effect): void;
  18522. /**
  18523. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18524. * (eq to shadow prjection matrix * light transform matrix)
  18525. * @returns The transform matrix used to create the shadow map
  18526. */
  18527. getTransformMatrix(): Matrix;
  18528. /**
  18529. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18530. * Cube and 2D textures for instance.
  18531. */
  18532. recreateShadowMap(): void;
  18533. protected _disposeBlurPostProcesses(): void;
  18534. protected _disposeRTTandPostProcesses(): void;
  18535. /**
  18536. * Disposes the ShadowGenerator.
  18537. * Returns nothing.
  18538. */
  18539. dispose(): void;
  18540. /**
  18541. * Serializes the shadow generator setup to a json object.
  18542. * @returns The serialized JSON object
  18543. */
  18544. serialize(): any;
  18545. /**
  18546. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18547. * @param parsedShadowGenerator The JSON object to parse
  18548. * @param scene The scene to create the shadow map for
  18549. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18550. * @returns The parsed shadow generator
  18551. */
  18552. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18553. }
  18554. }
  18555. declare module "babylonjs/Lights/light" {
  18556. import { Nullable } from "babylonjs/types";
  18557. import { Scene } from "babylonjs/scene";
  18558. import { Vector3 } from "babylonjs/Maths/math.vector";
  18559. import { Color3 } from "babylonjs/Maths/math.color";
  18560. import { Node } from "babylonjs/node";
  18561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18562. import { Effect } from "babylonjs/Materials/effect";
  18563. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18564. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18565. /**
  18566. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18567. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18568. * 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.
  18569. */
  18570. export abstract class Light extends Node {
  18571. /**
  18572. * Falloff Default: light is falling off following the material specification:
  18573. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18574. */
  18575. static readonly FALLOFF_DEFAULT: number;
  18576. /**
  18577. * Falloff Physical: light is falling off following the inverse squared distance law.
  18578. */
  18579. static readonly FALLOFF_PHYSICAL: number;
  18580. /**
  18581. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18582. * to enhance interoperability with other engines.
  18583. */
  18584. static readonly FALLOFF_GLTF: number;
  18585. /**
  18586. * Falloff Standard: light is falling off like in the standard material
  18587. * to enhance interoperability with other materials.
  18588. */
  18589. static readonly FALLOFF_STANDARD: number;
  18590. /**
  18591. * If every light affecting the material is in this lightmapMode,
  18592. * material.lightmapTexture adds or multiplies
  18593. * (depends on material.useLightmapAsShadowmap)
  18594. * after every other light calculations.
  18595. */
  18596. static readonly LIGHTMAP_DEFAULT: number;
  18597. /**
  18598. * material.lightmapTexture as only diffuse lighting from this light
  18599. * adds only specular lighting from this light
  18600. * adds dynamic shadows
  18601. */
  18602. static readonly LIGHTMAP_SPECULAR: number;
  18603. /**
  18604. * material.lightmapTexture as only lighting
  18605. * no light calculation from this light
  18606. * only adds dynamic shadows from this light
  18607. */
  18608. static readonly LIGHTMAP_SHADOWSONLY: number;
  18609. /**
  18610. * Each light type uses the default quantity according to its type:
  18611. * point/spot lights use luminous intensity
  18612. * directional lights use illuminance
  18613. */
  18614. static readonly INTENSITYMODE_AUTOMATIC: number;
  18615. /**
  18616. * lumen (lm)
  18617. */
  18618. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18619. /**
  18620. * candela (lm/sr)
  18621. */
  18622. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18623. /**
  18624. * lux (lm/m^2)
  18625. */
  18626. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18627. /**
  18628. * nit (cd/m^2)
  18629. */
  18630. static readonly INTENSITYMODE_LUMINANCE: number;
  18631. /**
  18632. * Light type const id of the point light.
  18633. */
  18634. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18635. /**
  18636. * Light type const id of the directional light.
  18637. */
  18638. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18639. /**
  18640. * Light type const id of the spot light.
  18641. */
  18642. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18643. /**
  18644. * Light type const id of the hemispheric light.
  18645. */
  18646. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18647. /**
  18648. * Diffuse gives the basic color to an object.
  18649. */
  18650. diffuse: Color3;
  18651. /**
  18652. * Specular produces a highlight color on an object.
  18653. * Note: This is note affecting PBR materials.
  18654. */
  18655. specular: Color3;
  18656. /**
  18657. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18658. * falling off base on range or angle.
  18659. * This can be set to any values in Light.FALLOFF_x.
  18660. *
  18661. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18662. * other types of materials.
  18663. */
  18664. falloffType: number;
  18665. /**
  18666. * Strength of the light.
  18667. * Note: By default it is define in the framework own unit.
  18668. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18669. */
  18670. intensity: number;
  18671. private _range;
  18672. protected _inverseSquaredRange: number;
  18673. /**
  18674. * Defines how far from the source the light is impacting in scene units.
  18675. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18676. */
  18677. get range(): number;
  18678. /**
  18679. * Defines how far from the source the light is impacting in scene units.
  18680. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18681. */
  18682. set range(value: number);
  18683. /**
  18684. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18685. * of light.
  18686. */
  18687. private _photometricScale;
  18688. private _intensityMode;
  18689. /**
  18690. * Gets the photometric scale used to interpret the intensity.
  18691. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18692. */
  18693. get intensityMode(): number;
  18694. /**
  18695. * Sets the photometric scale used to interpret the intensity.
  18696. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18697. */
  18698. set intensityMode(value: number);
  18699. private _radius;
  18700. /**
  18701. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18702. */
  18703. get radius(): number;
  18704. /**
  18705. * sets the light radius used by PBR Materials to simulate soft area lights.
  18706. */
  18707. set radius(value: number);
  18708. private _renderPriority;
  18709. /**
  18710. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18711. * exceeding the number allowed of the materials.
  18712. */
  18713. renderPriority: number;
  18714. private _shadowEnabled;
  18715. /**
  18716. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18717. * the current shadow generator.
  18718. */
  18719. get shadowEnabled(): boolean;
  18720. /**
  18721. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18722. * the current shadow generator.
  18723. */
  18724. set shadowEnabled(value: boolean);
  18725. private _includedOnlyMeshes;
  18726. /**
  18727. * Gets the only meshes impacted by this light.
  18728. */
  18729. get includedOnlyMeshes(): AbstractMesh[];
  18730. /**
  18731. * Sets the only meshes impacted by this light.
  18732. */
  18733. set includedOnlyMeshes(value: AbstractMesh[]);
  18734. private _excludedMeshes;
  18735. /**
  18736. * Gets the meshes not impacted by this light.
  18737. */
  18738. get excludedMeshes(): AbstractMesh[];
  18739. /**
  18740. * Sets the meshes not impacted by this light.
  18741. */
  18742. set excludedMeshes(value: AbstractMesh[]);
  18743. private _excludeWithLayerMask;
  18744. /**
  18745. * Gets the layer id use to find what meshes are not impacted by the light.
  18746. * Inactive if 0
  18747. */
  18748. get excludeWithLayerMask(): number;
  18749. /**
  18750. * Sets the layer id use to find what meshes are not impacted by the light.
  18751. * Inactive if 0
  18752. */
  18753. set excludeWithLayerMask(value: number);
  18754. private _includeOnlyWithLayerMask;
  18755. /**
  18756. * Gets the layer id use to find what meshes are impacted by the light.
  18757. * Inactive if 0
  18758. */
  18759. get includeOnlyWithLayerMask(): number;
  18760. /**
  18761. * Sets the layer id use to find what meshes are impacted by the light.
  18762. * Inactive if 0
  18763. */
  18764. set includeOnlyWithLayerMask(value: number);
  18765. private _lightmapMode;
  18766. /**
  18767. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18768. */
  18769. get lightmapMode(): number;
  18770. /**
  18771. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18772. */
  18773. set lightmapMode(value: number);
  18774. /**
  18775. * Shadow generator associted to the light.
  18776. * @hidden Internal use only.
  18777. */
  18778. _shadowGenerator: Nullable<IShadowGenerator>;
  18779. /**
  18780. * @hidden Internal use only.
  18781. */
  18782. _excludedMeshesIds: string[];
  18783. /**
  18784. * @hidden Internal use only.
  18785. */
  18786. _includedOnlyMeshesIds: string[];
  18787. /**
  18788. * The current light unifom buffer.
  18789. * @hidden Internal use only.
  18790. */
  18791. _uniformBuffer: UniformBuffer;
  18792. /** @hidden */
  18793. _renderId: number;
  18794. /**
  18795. * Creates a Light object in the scene.
  18796. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18797. * @param name The firendly name of the light
  18798. * @param scene The scene the light belongs too
  18799. */
  18800. constructor(name: string, scene: Scene);
  18801. protected abstract _buildUniformLayout(): void;
  18802. /**
  18803. * Sets the passed Effect "effect" with the Light information.
  18804. * @param effect The effect to update
  18805. * @param lightIndex The index of the light in the effect to update
  18806. * @returns The light
  18807. */
  18808. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18809. /**
  18810. * Sets the passed Effect "effect" with the Light textures.
  18811. * @param effect The effect to update
  18812. * @param lightIndex The index of the light in the effect to update
  18813. * @returns The light
  18814. */
  18815. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18816. /**
  18817. * Binds the lights information from the scene to the effect for the given mesh.
  18818. * @param lightIndex Light index
  18819. * @param scene The scene where the light belongs to
  18820. * @param effect The effect we are binding the data to
  18821. * @param useSpecular Defines if specular is supported
  18822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18823. */
  18824. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18825. /**
  18826. * Sets the passed Effect "effect" with the Light information.
  18827. * @param effect The effect to update
  18828. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18829. * @returns The light
  18830. */
  18831. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18832. /**
  18833. * Returns the string "Light".
  18834. * @returns the class name
  18835. */
  18836. getClassName(): string;
  18837. /** @hidden */
  18838. readonly _isLight: boolean;
  18839. /**
  18840. * Converts the light information to a readable string for debug purpose.
  18841. * @param fullDetails Supports for multiple levels of logging within scene loading
  18842. * @returns the human readable light info
  18843. */
  18844. toString(fullDetails?: boolean): string;
  18845. /** @hidden */
  18846. protected _syncParentEnabledState(): void;
  18847. /**
  18848. * Set the enabled state of this node.
  18849. * @param value - the new enabled state
  18850. */
  18851. setEnabled(value: boolean): void;
  18852. /**
  18853. * Returns the Light associated shadow generator if any.
  18854. * @return the associated shadow generator.
  18855. */
  18856. getShadowGenerator(): Nullable<IShadowGenerator>;
  18857. /**
  18858. * Returns a Vector3, the absolute light position in the World.
  18859. * @returns the world space position of the light
  18860. */
  18861. getAbsolutePosition(): Vector3;
  18862. /**
  18863. * Specifies if the light will affect the passed mesh.
  18864. * @param mesh The mesh to test against the light
  18865. * @return true the mesh is affected otherwise, false.
  18866. */
  18867. canAffectMesh(mesh: AbstractMesh): boolean;
  18868. /**
  18869. * Sort function to order lights for rendering.
  18870. * @param a First Light object to compare to second.
  18871. * @param b Second Light object to compare first.
  18872. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18873. */
  18874. static CompareLightsPriority(a: Light, b: Light): number;
  18875. /**
  18876. * Releases resources associated with this node.
  18877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18879. */
  18880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18881. /**
  18882. * Returns the light type ID (integer).
  18883. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18884. */
  18885. getTypeID(): number;
  18886. /**
  18887. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18888. * @returns the scaled intensity in intensity mode unit
  18889. */
  18890. getScaledIntensity(): number;
  18891. /**
  18892. * Returns a new Light object, named "name", from the current one.
  18893. * @param name The name of the cloned light
  18894. * @param newParent The parent of this light, if it has one
  18895. * @returns the new created light
  18896. */
  18897. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18898. /**
  18899. * Serializes the current light into a Serialization object.
  18900. * @returns the serialized object.
  18901. */
  18902. serialize(): any;
  18903. /**
  18904. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18905. * This new light is named "name" and added to the passed scene.
  18906. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18907. * @param name The friendly name of the light
  18908. * @param scene The scene the new light will belong to
  18909. * @returns the constructor function
  18910. */
  18911. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18912. /**
  18913. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18914. * @param parsedLight The JSON representation of the light
  18915. * @param scene The scene to create the parsed light in
  18916. * @returns the created light after parsing
  18917. */
  18918. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18919. private _hookArrayForExcluded;
  18920. private _hookArrayForIncludedOnly;
  18921. private _resyncMeshes;
  18922. /**
  18923. * Forces the meshes to update their light related information in their rendering used effects
  18924. * @hidden Internal Use Only
  18925. */
  18926. _markMeshesAsLightDirty(): void;
  18927. /**
  18928. * Recomputes the cached photometric scale if needed.
  18929. */
  18930. private _computePhotometricScale;
  18931. /**
  18932. * Returns the Photometric Scale according to the light type and intensity mode.
  18933. */
  18934. private _getPhotometricScale;
  18935. /**
  18936. * Reorder the light in the scene according to their defined priority.
  18937. * @hidden Internal Use Only
  18938. */
  18939. _reorderLightsInScene(): void;
  18940. /**
  18941. * Prepares the list of defines specific to the light type.
  18942. * @param defines the list of defines
  18943. * @param lightIndex defines the index of the light for the effect
  18944. */
  18945. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18946. }
  18947. }
  18948. declare module "babylonjs/Cameras/targetCamera" {
  18949. import { Nullable } from "babylonjs/types";
  18950. import { Camera } from "babylonjs/Cameras/camera";
  18951. import { Scene } from "babylonjs/scene";
  18952. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18953. /**
  18954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18955. * This is the base of the follow, arc rotate cameras and Free camera
  18956. * @see https://doc.babylonjs.com/features/cameras
  18957. */
  18958. export class TargetCamera extends Camera {
  18959. private static _RigCamTransformMatrix;
  18960. private static _TargetTransformMatrix;
  18961. private static _TargetFocalPoint;
  18962. private _tmpUpVector;
  18963. private _tmpTargetVector;
  18964. /**
  18965. * Define the current direction the camera is moving to
  18966. */
  18967. cameraDirection: Vector3;
  18968. /**
  18969. * Define the current rotation the camera is rotating to
  18970. */
  18971. cameraRotation: Vector2;
  18972. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18973. ignoreParentScaling: boolean;
  18974. /**
  18975. * When set, the up vector of the camera will be updated by the rotation of the camera
  18976. */
  18977. updateUpVectorFromRotation: boolean;
  18978. private _tmpQuaternion;
  18979. /**
  18980. * Define the current rotation of the camera
  18981. */
  18982. rotation: Vector3;
  18983. /**
  18984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18985. */
  18986. rotationQuaternion: Quaternion;
  18987. /**
  18988. * Define the current speed of the camera
  18989. */
  18990. speed: number;
  18991. /**
  18992. * Add constraint to the camera to prevent it to move freely in all directions and
  18993. * around all axis.
  18994. */
  18995. noRotationConstraint: boolean;
  18996. /**
  18997. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18998. * panning
  18999. */
  19000. invertRotation: boolean;
  19001. /**
  19002. * Speed multiplier for inverse camera panning
  19003. */
  19004. inverseRotationSpeed: number;
  19005. /**
  19006. * Define the current target of the camera as an object or a position.
  19007. */
  19008. lockedTarget: any;
  19009. /** @hidden */
  19010. _currentTarget: Vector3;
  19011. /** @hidden */
  19012. _initialFocalDistance: number;
  19013. /** @hidden */
  19014. _viewMatrix: Matrix;
  19015. /** @hidden */
  19016. _camMatrix: Matrix;
  19017. /** @hidden */
  19018. _cameraTransformMatrix: Matrix;
  19019. /** @hidden */
  19020. _cameraRotationMatrix: Matrix;
  19021. /** @hidden */
  19022. _referencePoint: Vector3;
  19023. /** @hidden */
  19024. _transformedReferencePoint: Vector3;
  19025. /** @hidden */
  19026. _reset: () => void;
  19027. private _defaultUp;
  19028. /**
  19029. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19030. * This is the base of the follow, arc rotate cameras and Free camera
  19031. * @see https://doc.babylonjs.com/features/cameras
  19032. * @param name Defines the name of the camera in the scene
  19033. * @param position Defines the start position of the camera in the scene
  19034. * @param scene Defines the scene the camera belongs to
  19035. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19036. */
  19037. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19038. /**
  19039. * Gets the position in front of the camera at a given distance.
  19040. * @param distance The distance from the camera we want the position to be
  19041. * @returns the position
  19042. */
  19043. getFrontPosition(distance: number): Vector3;
  19044. /** @hidden */
  19045. _getLockedTargetPosition(): Nullable<Vector3>;
  19046. private _storedPosition;
  19047. private _storedRotation;
  19048. private _storedRotationQuaternion;
  19049. /**
  19050. * Store current camera state of the camera (fov, position, rotation, etc..)
  19051. * @returns the camera
  19052. */
  19053. storeState(): Camera;
  19054. /**
  19055. * Restored camera state. You must call storeState() first
  19056. * @returns whether it was successful or not
  19057. * @hidden
  19058. */
  19059. _restoreStateValues(): boolean;
  19060. /** @hidden */
  19061. _initCache(): void;
  19062. /** @hidden */
  19063. _updateCache(ignoreParentClass?: boolean): void;
  19064. /** @hidden */
  19065. _isSynchronizedViewMatrix(): boolean;
  19066. /** @hidden */
  19067. _computeLocalCameraSpeed(): number;
  19068. /**
  19069. * Defines the target the camera should look at.
  19070. * @param target Defines the new target as a Vector or a mesh
  19071. */
  19072. setTarget(target: Vector3): void;
  19073. /**
  19074. * Defines the target point of the camera.
  19075. * The camera looks towards it form the radius distance.
  19076. */
  19077. get target(): Vector3;
  19078. set target(value: Vector3);
  19079. /**
  19080. * Return the current target position of the camera. This value is expressed in local space.
  19081. * @returns the target position
  19082. */
  19083. getTarget(): Vector3;
  19084. /** @hidden */
  19085. _decideIfNeedsToMove(): boolean;
  19086. /** @hidden */
  19087. _updatePosition(): void;
  19088. /** @hidden */
  19089. _checkInputs(): void;
  19090. protected _updateCameraRotationMatrix(): void;
  19091. /**
  19092. * 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)
  19093. * @returns the current camera
  19094. */
  19095. private _rotateUpVectorWithCameraRotationMatrix;
  19096. private _cachedRotationZ;
  19097. private _cachedQuaternionRotationZ;
  19098. /** @hidden */
  19099. _getViewMatrix(): Matrix;
  19100. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19101. /**
  19102. * @hidden
  19103. */
  19104. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19105. /**
  19106. * @hidden
  19107. */
  19108. _updateRigCameras(): void;
  19109. private _getRigCamPositionAndTarget;
  19110. /**
  19111. * Gets the current object class name.
  19112. * @return the class name
  19113. */
  19114. getClassName(): string;
  19115. }
  19116. }
  19117. declare module "babylonjs/Events/keyboardEvents" {
  19118. /**
  19119. * Gather the list of keyboard event types as constants.
  19120. */
  19121. export class KeyboardEventTypes {
  19122. /**
  19123. * The keydown event is fired when a key becomes active (pressed).
  19124. */
  19125. static readonly KEYDOWN: number;
  19126. /**
  19127. * The keyup event is fired when a key has been released.
  19128. */
  19129. static readonly KEYUP: number;
  19130. }
  19131. /**
  19132. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19133. */
  19134. export class KeyboardInfo {
  19135. /**
  19136. * Defines the type of event (KeyboardEventTypes)
  19137. */
  19138. type: number;
  19139. /**
  19140. * Defines the related dom event
  19141. */
  19142. event: KeyboardEvent;
  19143. /**
  19144. * Instantiates a new keyboard info.
  19145. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19146. * @param type Defines the type of event (KeyboardEventTypes)
  19147. * @param event Defines the related dom event
  19148. */
  19149. constructor(
  19150. /**
  19151. * Defines the type of event (KeyboardEventTypes)
  19152. */
  19153. type: number,
  19154. /**
  19155. * Defines the related dom event
  19156. */
  19157. event: KeyboardEvent);
  19158. }
  19159. /**
  19160. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19161. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19162. */
  19163. export class KeyboardInfoPre extends KeyboardInfo {
  19164. /**
  19165. * Defines the type of event (KeyboardEventTypes)
  19166. */
  19167. type: number;
  19168. /**
  19169. * Defines the related dom event
  19170. */
  19171. event: KeyboardEvent;
  19172. /**
  19173. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19174. */
  19175. skipOnPointerObservable: boolean;
  19176. /**
  19177. * Instantiates a new keyboard pre info.
  19178. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19179. * @param type Defines the type of event (KeyboardEventTypes)
  19180. * @param event Defines the related dom event
  19181. */
  19182. constructor(
  19183. /**
  19184. * Defines the type of event (KeyboardEventTypes)
  19185. */
  19186. type: number,
  19187. /**
  19188. * Defines the related dom event
  19189. */
  19190. event: KeyboardEvent);
  19191. }
  19192. }
  19193. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19194. import { Nullable } from "babylonjs/types";
  19195. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19197. /**
  19198. * Manage the keyboard inputs to control the movement of a free camera.
  19199. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19200. */
  19201. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19202. /**
  19203. * Defines the camera the input is attached to.
  19204. */
  19205. camera: FreeCamera;
  19206. /**
  19207. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19208. */
  19209. keysUp: number[];
  19210. /**
  19211. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19212. */
  19213. keysUpward: number[];
  19214. /**
  19215. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19216. */
  19217. keysDown: number[];
  19218. /**
  19219. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19220. */
  19221. keysDownward: number[];
  19222. /**
  19223. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19224. */
  19225. keysLeft: number[];
  19226. /**
  19227. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19228. */
  19229. keysRight: number[];
  19230. private _keys;
  19231. private _onCanvasBlurObserver;
  19232. private _onKeyboardObserver;
  19233. private _engine;
  19234. private _scene;
  19235. /**
  19236. * Attach the input controls to a specific dom element to get the input from.
  19237. * @param element Defines the element the controls should be listened from
  19238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19239. */
  19240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19241. /**
  19242. * Detach the current controls from the specified dom element.
  19243. * @param element Defines the element to stop listening the inputs from
  19244. */
  19245. detachControl(element: Nullable<HTMLElement>): void;
  19246. /**
  19247. * Update the current camera state depending on the inputs that have been used this frame.
  19248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19249. */
  19250. checkInputs(): void;
  19251. /**
  19252. * Gets the class name of the current intput.
  19253. * @returns the class name
  19254. */
  19255. getClassName(): string;
  19256. /** @hidden */
  19257. _onLostFocus(): void;
  19258. /**
  19259. * Get the friendly name associated with the input class.
  19260. * @returns the input friendly name
  19261. */
  19262. getSimpleName(): string;
  19263. }
  19264. }
  19265. declare module "babylonjs/Events/pointerEvents" {
  19266. import { Nullable } from "babylonjs/types";
  19267. import { Vector2 } from "babylonjs/Maths/math.vector";
  19268. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19269. import { Ray } from "babylonjs/Culling/ray";
  19270. /**
  19271. * Gather the list of pointer event types as constants.
  19272. */
  19273. export class PointerEventTypes {
  19274. /**
  19275. * 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.
  19276. */
  19277. static readonly POINTERDOWN: number;
  19278. /**
  19279. * The pointerup event is fired when a pointer is no longer active.
  19280. */
  19281. static readonly POINTERUP: number;
  19282. /**
  19283. * The pointermove event is fired when a pointer changes coordinates.
  19284. */
  19285. static readonly POINTERMOVE: number;
  19286. /**
  19287. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19288. */
  19289. static readonly POINTERWHEEL: number;
  19290. /**
  19291. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19292. */
  19293. static readonly POINTERPICK: number;
  19294. /**
  19295. * The pointertap event is fired when a the object has been touched and released without drag.
  19296. */
  19297. static readonly POINTERTAP: number;
  19298. /**
  19299. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19300. */
  19301. static readonly POINTERDOUBLETAP: number;
  19302. }
  19303. /**
  19304. * Base class of pointer info types.
  19305. */
  19306. export class PointerInfoBase {
  19307. /**
  19308. * Defines the type of event (PointerEventTypes)
  19309. */
  19310. type: number;
  19311. /**
  19312. * Defines the related dom event
  19313. */
  19314. event: PointerEvent | MouseWheelEvent;
  19315. /**
  19316. * Instantiates the base class of pointers info.
  19317. * @param type Defines the type of event (PointerEventTypes)
  19318. * @param event Defines the related dom event
  19319. */
  19320. constructor(
  19321. /**
  19322. * Defines the type of event (PointerEventTypes)
  19323. */
  19324. type: number,
  19325. /**
  19326. * Defines the related dom event
  19327. */
  19328. event: PointerEvent | MouseWheelEvent);
  19329. }
  19330. /**
  19331. * This class is used to store pointer related info for the onPrePointerObservable event.
  19332. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19333. */
  19334. export class PointerInfoPre extends PointerInfoBase {
  19335. /**
  19336. * Ray from a pointer if availible (eg. 6dof controller)
  19337. */
  19338. ray: Nullable<Ray>;
  19339. /**
  19340. * Defines the local position of the pointer on the canvas.
  19341. */
  19342. localPosition: Vector2;
  19343. /**
  19344. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19345. */
  19346. skipOnPointerObservable: boolean;
  19347. /**
  19348. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19349. * @param type Defines the type of event (PointerEventTypes)
  19350. * @param event Defines the related dom event
  19351. * @param localX Defines the local x coordinates of the pointer when the event occured
  19352. * @param localY Defines the local y coordinates of the pointer when the event occured
  19353. */
  19354. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19355. }
  19356. /**
  19357. * This type contains all the data related to a pointer event in Babylon.js.
  19358. * 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.
  19359. */
  19360. export class PointerInfo extends PointerInfoBase {
  19361. /**
  19362. * Defines the picking info associated to the info (if any)\
  19363. */
  19364. pickInfo: Nullable<PickingInfo>;
  19365. /**
  19366. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19367. * @param type Defines the type of event (PointerEventTypes)
  19368. * @param event Defines the related dom event
  19369. * @param pickInfo Defines the picking info associated to the info (if any)\
  19370. */
  19371. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19372. /**
  19373. * Defines the picking info associated to the info (if any)\
  19374. */
  19375. pickInfo: Nullable<PickingInfo>);
  19376. }
  19377. /**
  19378. * Data relating to a touch event on the screen.
  19379. */
  19380. export interface PointerTouch {
  19381. /**
  19382. * X coordinate of touch.
  19383. */
  19384. x: number;
  19385. /**
  19386. * Y coordinate of touch.
  19387. */
  19388. y: number;
  19389. /**
  19390. * Id of touch. Unique for each finger.
  19391. */
  19392. pointerId: number;
  19393. /**
  19394. * Event type passed from DOM.
  19395. */
  19396. type: any;
  19397. }
  19398. }
  19399. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19400. import { Observable } from "babylonjs/Misc/observable";
  19401. import { Nullable } from "babylonjs/types";
  19402. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19403. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19404. /**
  19405. * Manage the mouse inputs to control the movement of a free camera.
  19406. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19407. */
  19408. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19409. /**
  19410. * Define if touch is enabled in the mouse input
  19411. */
  19412. touchEnabled: boolean;
  19413. /**
  19414. * Defines the camera the input is attached to.
  19415. */
  19416. camera: FreeCamera;
  19417. /**
  19418. * Defines the buttons associated with the input to handle camera move.
  19419. */
  19420. buttons: number[];
  19421. /**
  19422. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19423. */
  19424. angularSensibility: number;
  19425. private _pointerInput;
  19426. private _onMouseMove;
  19427. private _observer;
  19428. private previousPosition;
  19429. /**
  19430. * Observable for when a pointer move event occurs containing the move offset
  19431. */
  19432. onPointerMovedObservable: Observable<{
  19433. offsetX: number;
  19434. offsetY: number;
  19435. }>;
  19436. /**
  19437. * @hidden
  19438. * If the camera should be rotated automatically based on pointer movement
  19439. */
  19440. _allowCameraRotation: boolean;
  19441. /**
  19442. * Manage the mouse inputs to control the movement of a free camera.
  19443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19444. * @param touchEnabled Defines if touch is enabled or not
  19445. */
  19446. constructor(
  19447. /**
  19448. * Define if touch is enabled in the mouse input
  19449. */
  19450. touchEnabled?: boolean);
  19451. /**
  19452. * Attach the input controls to a specific dom element to get the input from.
  19453. * @param element Defines the element the controls should be listened from
  19454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19455. */
  19456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19457. /**
  19458. * Called on JS contextmenu event.
  19459. * Override this method to provide functionality.
  19460. */
  19461. protected onContextMenu(evt: PointerEvent): void;
  19462. /**
  19463. * Detach the current controls from the specified dom element.
  19464. * @param element Defines the element to stop listening the inputs from
  19465. */
  19466. detachControl(element: Nullable<HTMLElement>): void;
  19467. /**
  19468. * Gets the class name of the current intput.
  19469. * @returns the class name
  19470. */
  19471. getClassName(): string;
  19472. /**
  19473. * Get the friendly name associated with the input class.
  19474. * @returns the input friendly name
  19475. */
  19476. getSimpleName(): string;
  19477. }
  19478. }
  19479. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19480. import { Nullable } from "babylonjs/types";
  19481. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19482. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19483. /**
  19484. * Manage the touch inputs to control the movement of a free camera.
  19485. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19486. */
  19487. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19488. /**
  19489. * Define if mouse events can be treated as touch events
  19490. */
  19491. allowMouse: boolean;
  19492. /**
  19493. * Defines the camera the input is attached to.
  19494. */
  19495. camera: FreeCamera;
  19496. /**
  19497. * Defines the touch sensibility for rotation.
  19498. * The higher the faster.
  19499. */
  19500. touchAngularSensibility: number;
  19501. /**
  19502. * Defines the touch sensibility for move.
  19503. * The higher the faster.
  19504. */
  19505. touchMoveSensibility: number;
  19506. private _offsetX;
  19507. private _offsetY;
  19508. private _pointerPressed;
  19509. private _pointerInput;
  19510. private _observer;
  19511. private _onLostFocus;
  19512. /**
  19513. * Manage the touch inputs to control the movement of a free camera.
  19514. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19515. * @param allowMouse Defines if mouse events can be treated as touch events
  19516. */
  19517. constructor(
  19518. /**
  19519. * Define if mouse events can be treated as touch events
  19520. */
  19521. allowMouse?: boolean);
  19522. /**
  19523. * Attach the input controls to a specific dom element to get the input from.
  19524. * @param element Defines the element the controls should be listened from
  19525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19526. */
  19527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19528. /**
  19529. * Detach the current controls from the specified dom element.
  19530. * @param element Defines the element to stop listening the inputs from
  19531. */
  19532. detachControl(element: Nullable<HTMLElement>): void;
  19533. /**
  19534. * Update the current camera state depending on the inputs that have been used this frame.
  19535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19536. */
  19537. checkInputs(): void;
  19538. /**
  19539. * Gets the class name of the current intput.
  19540. * @returns the class name
  19541. */
  19542. getClassName(): string;
  19543. /**
  19544. * Get the friendly name associated with the input class.
  19545. * @returns the input friendly name
  19546. */
  19547. getSimpleName(): string;
  19548. }
  19549. }
  19550. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19551. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19552. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19553. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19554. import { Nullable } from "babylonjs/types";
  19555. /**
  19556. * Default Inputs manager for the FreeCamera.
  19557. * It groups all the default supported inputs for ease of use.
  19558. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19559. */
  19560. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19561. /**
  19562. * @hidden
  19563. */
  19564. _mouseInput: Nullable<FreeCameraMouseInput>;
  19565. /**
  19566. * Instantiates a new FreeCameraInputsManager.
  19567. * @param camera Defines the camera the inputs belong to
  19568. */
  19569. constructor(camera: FreeCamera);
  19570. /**
  19571. * Add keyboard input support to the input manager.
  19572. * @returns the current input manager
  19573. */
  19574. addKeyboard(): FreeCameraInputsManager;
  19575. /**
  19576. * Add mouse input support to the input manager.
  19577. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19578. * @returns the current input manager
  19579. */
  19580. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19581. /**
  19582. * Removes the mouse input support from the manager
  19583. * @returns the current input manager
  19584. */
  19585. removeMouse(): FreeCameraInputsManager;
  19586. /**
  19587. * Add touch input support to the input manager.
  19588. * @returns the current input manager
  19589. */
  19590. addTouch(): FreeCameraInputsManager;
  19591. /**
  19592. * Remove all attached input methods from a camera
  19593. */
  19594. clear(): void;
  19595. }
  19596. }
  19597. declare module "babylonjs/Cameras/freeCamera" {
  19598. import { Vector3 } from "babylonjs/Maths/math.vector";
  19599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19600. import { Scene } from "babylonjs/scene";
  19601. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19602. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19603. /**
  19604. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19605. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19606. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19607. */
  19608. export class FreeCamera extends TargetCamera {
  19609. /**
  19610. * Define the collision ellipsoid of the camera.
  19611. * This is helpful to simulate a camera body like the player body around the camera
  19612. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19613. */
  19614. ellipsoid: Vector3;
  19615. /**
  19616. * Define an offset for the position of the ellipsoid around the camera.
  19617. * This can be helpful to determine the center of the body near the gravity center of the body
  19618. * instead of its head.
  19619. */
  19620. ellipsoidOffset: Vector3;
  19621. /**
  19622. * Enable or disable collisions of the camera with the rest of the scene objects.
  19623. */
  19624. checkCollisions: boolean;
  19625. /**
  19626. * Enable or disable gravity on the camera.
  19627. */
  19628. applyGravity: boolean;
  19629. /**
  19630. * Define the input manager associated to the camera.
  19631. */
  19632. inputs: FreeCameraInputsManager;
  19633. /**
  19634. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19635. * Higher values reduce sensitivity.
  19636. */
  19637. get angularSensibility(): number;
  19638. /**
  19639. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19640. * Higher values reduce sensitivity.
  19641. */
  19642. set angularSensibility(value: number);
  19643. /**
  19644. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19645. */
  19646. get keysUp(): number[];
  19647. set keysUp(value: number[]);
  19648. /**
  19649. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19650. */
  19651. get keysUpward(): number[];
  19652. set keysUpward(value: number[]);
  19653. /**
  19654. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19655. */
  19656. get keysDown(): number[];
  19657. set keysDown(value: number[]);
  19658. /**
  19659. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19660. */
  19661. get keysDownward(): number[];
  19662. set keysDownward(value: number[]);
  19663. /**
  19664. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19665. */
  19666. get keysLeft(): number[];
  19667. set keysLeft(value: number[]);
  19668. /**
  19669. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19670. */
  19671. get keysRight(): number[];
  19672. set keysRight(value: number[]);
  19673. /**
  19674. * Event raised when the camera collide with a mesh in the scene.
  19675. */
  19676. onCollide: (collidedMesh: AbstractMesh) => void;
  19677. private _collider;
  19678. private _needMoveForGravity;
  19679. private _oldPosition;
  19680. private _diffPosition;
  19681. private _newPosition;
  19682. /** @hidden */
  19683. _localDirection: Vector3;
  19684. /** @hidden */
  19685. _transformedDirection: Vector3;
  19686. /**
  19687. * Instantiates a Free Camera.
  19688. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19689. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19690. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19691. * @param name Define the name of the camera in the scene
  19692. * @param position Define the start position of the camera in the scene
  19693. * @param scene Define the scene the camera belongs to
  19694. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19695. */
  19696. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19697. /**
  19698. * Attached controls to the current camera.
  19699. * @param element Defines the element the controls should be listened from
  19700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19701. */
  19702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19703. /**
  19704. * Detach the current controls from the camera.
  19705. * The camera will stop reacting to inputs.
  19706. * @param element Defines the element to stop listening the inputs from
  19707. */
  19708. detachControl(element: HTMLElement): void;
  19709. private _collisionMask;
  19710. /**
  19711. * Define a collision mask to limit the list of object the camera can collide with
  19712. */
  19713. get collisionMask(): number;
  19714. set collisionMask(mask: number);
  19715. /** @hidden */
  19716. _collideWithWorld(displacement: Vector3): void;
  19717. private _onCollisionPositionChange;
  19718. /** @hidden */
  19719. _checkInputs(): void;
  19720. /** @hidden */
  19721. _decideIfNeedsToMove(): boolean;
  19722. /** @hidden */
  19723. _updatePosition(): void;
  19724. /**
  19725. * Destroy the camera and release the current resources hold by it.
  19726. */
  19727. dispose(): void;
  19728. /**
  19729. * Gets the current object class name.
  19730. * @return the class name
  19731. */
  19732. getClassName(): string;
  19733. }
  19734. }
  19735. declare module "babylonjs/Gamepads/gamepad" {
  19736. import { Observable } from "babylonjs/Misc/observable";
  19737. /**
  19738. * Represents a gamepad control stick position
  19739. */
  19740. export class StickValues {
  19741. /**
  19742. * The x component of the control stick
  19743. */
  19744. x: number;
  19745. /**
  19746. * The y component of the control stick
  19747. */
  19748. y: number;
  19749. /**
  19750. * Initializes the gamepad x and y control stick values
  19751. * @param x The x component of the gamepad control stick value
  19752. * @param y The y component of the gamepad control stick value
  19753. */
  19754. constructor(
  19755. /**
  19756. * The x component of the control stick
  19757. */
  19758. x: number,
  19759. /**
  19760. * The y component of the control stick
  19761. */
  19762. y: number);
  19763. }
  19764. /**
  19765. * An interface which manages callbacks for gamepad button changes
  19766. */
  19767. export interface GamepadButtonChanges {
  19768. /**
  19769. * Called when a gamepad has been changed
  19770. */
  19771. changed: boolean;
  19772. /**
  19773. * Called when a gamepad press event has been triggered
  19774. */
  19775. pressChanged: boolean;
  19776. /**
  19777. * Called when a touch event has been triggered
  19778. */
  19779. touchChanged: boolean;
  19780. /**
  19781. * Called when a value has changed
  19782. */
  19783. valueChanged: boolean;
  19784. }
  19785. /**
  19786. * Represents a gamepad
  19787. */
  19788. export class Gamepad {
  19789. /**
  19790. * The id of the gamepad
  19791. */
  19792. id: string;
  19793. /**
  19794. * The index of the gamepad
  19795. */
  19796. index: number;
  19797. /**
  19798. * The browser gamepad
  19799. */
  19800. browserGamepad: any;
  19801. /**
  19802. * Specifies what type of gamepad this represents
  19803. */
  19804. type: number;
  19805. private _leftStick;
  19806. private _rightStick;
  19807. /** @hidden */
  19808. _isConnected: boolean;
  19809. private _leftStickAxisX;
  19810. private _leftStickAxisY;
  19811. private _rightStickAxisX;
  19812. private _rightStickAxisY;
  19813. /**
  19814. * Triggered when the left control stick has been changed
  19815. */
  19816. private _onleftstickchanged;
  19817. /**
  19818. * Triggered when the right control stick has been changed
  19819. */
  19820. private _onrightstickchanged;
  19821. /**
  19822. * Represents a gamepad controller
  19823. */
  19824. static GAMEPAD: number;
  19825. /**
  19826. * Represents a generic controller
  19827. */
  19828. static GENERIC: number;
  19829. /**
  19830. * Represents an XBox controller
  19831. */
  19832. static XBOX: number;
  19833. /**
  19834. * Represents a pose-enabled controller
  19835. */
  19836. static POSE_ENABLED: number;
  19837. /**
  19838. * Represents an Dual Shock controller
  19839. */
  19840. static DUALSHOCK: number;
  19841. /**
  19842. * Specifies whether the left control stick should be Y-inverted
  19843. */
  19844. protected _invertLeftStickY: boolean;
  19845. /**
  19846. * Specifies if the gamepad has been connected
  19847. */
  19848. get isConnected(): boolean;
  19849. /**
  19850. * Initializes the gamepad
  19851. * @param id The id of the gamepad
  19852. * @param index The index of the gamepad
  19853. * @param browserGamepad The browser gamepad
  19854. * @param leftStickX The x component of the left joystick
  19855. * @param leftStickY The y component of the left joystick
  19856. * @param rightStickX The x component of the right joystick
  19857. * @param rightStickY The y component of the right joystick
  19858. */
  19859. constructor(
  19860. /**
  19861. * The id of the gamepad
  19862. */
  19863. id: string,
  19864. /**
  19865. * The index of the gamepad
  19866. */
  19867. index: number,
  19868. /**
  19869. * The browser gamepad
  19870. */
  19871. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19872. /**
  19873. * Callback triggered when the left joystick has changed
  19874. * @param callback
  19875. */
  19876. onleftstickchanged(callback: (values: StickValues) => void): void;
  19877. /**
  19878. * Callback triggered when the right joystick has changed
  19879. * @param callback
  19880. */
  19881. onrightstickchanged(callback: (values: StickValues) => void): void;
  19882. /**
  19883. * Gets the left joystick
  19884. */
  19885. get leftStick(): StickValues;
  19886. /**
  19887. * Sets the left joystick values
  19888. */
  19889. set leftStick(newValues: StickValues);
  19890. /**
  19891. * Gets the right joystick
  19892. */
  19893. get rightStick(): StickValues;
  19894. /**
  19895. * Sets the right joystick value
  19896. */
  19897. set rightStick(newValues: StickValues);
  19898. /**
  19899. * Updates the gamepad joystick positions
  19900. */
  19901. update(): void;
  19902. /**
  19903. * Disposes the gamepad
  19904. */
  19905. dispose(): void;
  19906. }
  19907. /**
  19908. * Represents a generic gamepad
  19909. */
  19910. export class GenericPad extends Gamepad {
  19911. private _buttons;
  19912. private _onbuttondown;
  19913. private _onbuttonup;
  19914. /**
  19915. * Observable triggered when a button has been pressed
  19916. */
  19917. onButtonDownObservable: Observable<number>;
  19918. /**
  19919. * Observable triggered when a button has been released
  19920. */
  19921. onButtonUpObservable: Observable<number>;
  19922. /**
  19923. * Callback triggered when a button has been pressed
  19924. * @param callback Called when a button has been pressed
  19925. */
  19926. onbuttondown(callback: (buttonPressed: number) => void): void;
  19927. /**
  19928. * Callback triggered when a button has been released
  19929. * @param callback Called when a button has been released
  19930. */
  19931. onbuttonup(callback: (buttonReleased: number) => void): void;
  19932. /**
  19933. * Initializes the generic gamepad
  19934. * @param id The id of the generic gamepad
  19935. * @param index The index of the generic gamepad
  19936. * @param browserGamepad The browser gamepad
  19937. */
  19938. constructor(id: string, index: number, browserGamepad: any);
  19939. private _setButtonValue;
  19940. /**
  19941. * Updates the generic gamepad
  19942. */
  19943. update(): void;
  19944. /**
  19945. * Disposes the generic gamepad
  19946. */
  19947. dispose(): void;
  19948. }
  19949. }
  19950. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19951. import { Observable } from "babylonjs/Misc/observable";
  19952. import { Nullable } from "babylonjs/types";
  19953. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19954. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19956. import { Ray } from "babylonjs/Culling/ray";
  19957. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19958. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19959. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19960. /**
  19961. * Defines the types of pose enabled controllers that are supported
  19962. */
  19963. export enum PoseEnabledControllerType {
  19964. /**
  19965. * HTC Vive
  19966. */
  19967. VIVE = 0,
  19968. /**
  19969. * Oculus Rift
  19970. */
  19971. OCULUS = 1,
  19972. /**
  19973. * Windows mixed reality
  19974. */
  19975. WINDOWS = 2,
  19976. /**
  19977. * Samsung gear VR
  19978. */
  19979. GEAR_VR = 3,
  19980. /**
  19981. * Google Daydream
  19982. */
  19983. DAYDREAM = 4,
  19984. /**
  19985. * Generic
  19986. */
  19987. GENERIC = 5
  19988. }
  19989. /**
  19990. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19991. */
  19992. export interface MutableGamepadButton {
  19993. /**
  19994. * Value of the button/trigger
  19995. */
  19996. value: number;
  19997. /**
  19998. * If the button/trigger is currently touched
  19999. */
  20000. touched: boolean;
  20001. /**
  20002. * If the button/trigger is currently pressed
  20003. */
  20004. pressed: boolean;
  20005. }
  20006. /**
  20007. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20008. * @hidden
  20009. */
  20010. export interface ExtendedGamepadButton extends GamepadButton {
  20011. /**
  20012. * If the button/trigger is currently pressed
  20013. */
  20014. readonly pressed: boolean;
  20015. /**
  20016. * If the button/trigger is currently touched
  20017. */
  20018. readonly touched: boolean;
  20019. /**
  20020. * Value of the button/trigger
  20021. */
  20022. readonly value: number;
  20023. }
  20024. /** @hidden */
  20025. export interface _GamePadFactory {
  20026. /**
  20027. * Returns whether or not the current gamepad can be created for this type of controller.
  20028. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20029. * @returns true if it can be created, otherwise false
  20030. */
  20031. canCreate(gamepadInfo: any): boolean;
  20032. /**
  20033. * Creates a new instance of the Gamepad.
  20034. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20035. * @returns the new gamepad instance
  20036. */
  20037. create(gamepadInfo: any): Gamepad;
  20038. }
  20039. /**
  20040. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20041. */
  20042. export class PoseEnabledControllerHelper {
  20043. /** @hidden */
  20044. static _ControllerFactories: _GamePadFactory[];
  20045. /** @hidden */
  20046. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20047. /**
  20048. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20049. * @param vrGamepad the gamepad to initialized
  20050. * @returns a vr controller of the type the gamepad identified as
  20051. */
  20052. static InitiateController(vrGamepad: any): Gamepad;
  20053. }
  20054. /**
  20055. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20056. */
  20057. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20058. /**
  20059. * If the controller is used in a webXR session
  20060. */
  20061. isXR: boolean;
  20062. private _deviceRoomPosition;
  20063. private _deviceRoomRotationQuaternion;
  20064. /**
  20065. * The device position in babylon space
  20066. */
  20067. devicePosition: Vector3;
  20068. /**
  20069. * The device rotation in babylon space
  20070. */
  20071. deviceRotationQuaternion: Quaternion;
  20072. /**
  20073. * The scale factor of the device in babylon space
  20074. */
  20075. deviceScaleFactor: number;
  20076. /**
  20077. * (Likely devicePosition should be used instead) The device position in its room space
  20078. */
  20079. position: Vector3;
  20080. /**
  20081. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20082. */
  20083. rotationQuaternion: Quaternion;
  20084. /**
  20085. * The type of controller (Eg. Windows mixed reality)
  20086. */
  20087. controllerType: PoseEnabledControllerType;
  20088. protected _calculatedPosition: Vector3;
  20089. private _calculatedRotation;
  20090. /**
  20091. * The raw pose from the device
  20092. */
  20093. rawPose: DevicePose;
  20094. private _trackPosition;
  20095. private _maxRotationDistFromHeadset;
  20096. private _draggedRoomRotation;
  20097. /**
  20098. * @hidden
  20099. */
  20100. _disableTrackPosition(fixedPosition: Vector3): void;
  20101. /**
  20102. * Internal, the mesh attached to the controller
  20103. * @hidden
  20104. */
  20105. _mesh: Nullable<AbstractMesh>;
  20106. private _poseControlledCamera;
  20107. private _leftHandSystemQuaternion;
  20108. /**
  20109. * Internal, matrix used to convert room space to babylon space
  20110. * @hidden
  20111. */
  20112. _deviceToWorld: Matrix;
  20113. /**
  20114. * Node to be used when casting a ray from the controller
  20115. * @hidden
  20116. */
  20117. _pointingPoseNode: Nullable<TransformNode>;
  20118. /**
  20119. * Name of the child mesh that can be used to cast a ray from the controller
  20120. */
  20121. static readonly POINTING_POSE: string;
  20122. /**
  20123. * Creates a new PoseEnabledController from a gamepad
  20124. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20125. */
  20126. constructor(browserGamepad: any);
  20127. private _workingMatrix;
  20128. /**
  20129. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20130. */
  20131. update(): void;
  20132. /**
  20133. * Updates only the pose device and mesh without doing any button event checking
  20134. */
  20135. protected _updatePoseAndMesh(): void;
  20136. /**
  20137. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20138. * @param poseData raw pose fromthe device
  20139. */
  20140. updateFromDevice(poseData: DevicePose): void;
  20141. /**
  20142. * @hidden
  20143. */
  20144. _meshAttachedObservable: Observable<AbstractMesh>;
  20145. /**
  20146. * Attaches a mesh to the controller
  20147. * @param mesh the mesh to be attached
  20148. */
  20149. attachToMesh(mesh: AbstractMesh): void;
  20150. /**
  20151. * Attaches the controllers mesh to a camera
  20152. * @param camera the camera the mesh should be attached to
  20153. */
  20154. attachToPoseControlledCamera(camera: TargetCamera): void;
  20155. /**
  20156. * Disposes of the controller
  20157. */
  20158. dispose(): void;
  20159. /**
  20160. * The mesh that is attached to the controller
  20161. */
  20162. get mesh(): Nullable<AbstractMesh>;
  20163. /**
  20164. * Gets the ray of the controller in the direction the controller is pointing
  20165. * @param length the length the resulting ray should be
  20166. * @returns a ray in the direction the controller is pointing
  20167. */
  20168. getForwardRay(length?: number): Ray;
  20169. }
  20170. }
  20171. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20172. import { Observable } from "babylonjs/Misc/observable";
  20173. import { Scene } from "babylonjs/scene";
  20174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20175. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20176. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20177. import { Nullable } from "babylonjs/types";
  20178. /**
  20179. * Defines the WebVRController object that represents controllers tracked in 3D space
  20180. */
  20181. export abstract class WebVRController extends PoseEnabledController {
  20182. /**
  20183. * Internal, the default controller model for the controller
  20184. */
  20185. protected _defaultModel: Nullable<AbstractMesh>;
  20186. /**
  20187. * Fired when the trigger state has changed
  20188. */
  20189. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20190. /**
  20191. * Fired when the main button state has changed
  20192. */
  20193. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20194. /**
  20195. * Fired when the secondary button state has changed
  20196. */
  20197. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20198. /**
  20199. * Fired when the pad state has changed
  20200. */
  20201. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20202. /**
  20203. * Fired when controllers stick values have changed
  20204. */
  20205. onPadValuesChangedObservable: Observable<StickValues>;
  20206. /**
  20207. * Array of button availible on the controller
  20208. */
  20209. protected _buttons: Array<MutableGamepadButton>;
  20210. private _onButtonStateChange;
  20211. /**
  20212. * Fired when a controller button's state has changed
  20213. * @param callback the callback containing the button that was modified
  20214. */
  20215. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20216. /**
  20217. * X and Y axis corresponding to the controllers joystick
  20218. */
  20219. pad: StickValues;
  20220. /**
  20221. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20222. */
  20223. hand: string;
  20224. /**
  20225. * The default controller model for the controller
  20226. */
  20227. get defaultModel(): Nullable<AbstractMesh>;
  20228. /**
  20229. * Creates a new WebVRController from a gamepad
  20230. * @param vrGamepad the gamepad that the WebVRController should be created from
  20231. */
  20232. constructor(vrGamepad: any);
  20233. /**
  20234. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20235. */
  20236. update(): void;
  20237. /**
  20238. * Function to be called when a button is modified
  20239. */
  20240. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20241. /**
  20242. * Loads a mesh and attaches it to the controller
  20243. * @param scene the scene the mesh should be added to
  20244. * @param meshLoaded callback for when the mesh has been loaded
  20245. */
  20246. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20247. private _setButtonValue;
  20248. private _changes;
  20249. private _checkChanges;
  20250. /**
  20251. * Disposes of th webVRCOntroller
  20252. */
  20253. dispose(): void;
  20254. }
  20255. }
  20256. declare module "babylonjs/Lights/hemisphericLight" {
  20257. import { Nullable } from "babylonjs/types";
  20258. import { Scene } from "babylonjs/scene";
  20259. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20260. import { Color3 } from "babylonjs/Maths/math.color";
  20261. import { Effect } from "babylonjs/Materials/effect";
  20262. import { Light } from "babylonjs/Lights/light";
  20263. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20264. /**
  20265. * The HemisphericLight simulates the ambient environment light,
  20266. * so the passed direction is the light reflection direction, not the incoming direction.
  20267. */
  20268. export class HemisphericLight extends Light {
  20269. /**
  20270. * The groundColor is the light in the opposite direction to the one specified during creation.
  20271. * 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.
  20272. */
  20273. groundColor: Color3;
  20274. /**
  20275. * The light reflection direction, not the incoming direction.
  20276. */
  20277. direction: Vector3;
  20278. /**
  20279. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20280. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20281. * The HemisphericLight can't cast shadows.
  20282. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20283. * @param name The friendly name of the light
  20284. * @param direction The direction of the light reflection
  20285. * @param scene The scene the light belongs to
  20286. */
  20287. constructor(name: string, direction: Vector3, scene: Scene);
  20288. protected _buildUniformLayout(): void;
  20289. /**
  20290. * Returns the string "HemisphericLight".
  20291. * @return The class name
  20292. */
  20293. getClassName(): string;
  20294. /**
  20295. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20296. * Returns the updated direction.
  20297. * @param target The target the direction should point to
  20298. * @return The computed direction
  20299. */
  20300. setDirectionToTarget(target: Vector3): Vector3;
  20301. /**
  20302. * Returns the shadow generator associated to the light.
  20303. * @returns Always null for hemispheric lights because it does not support shadows.
  20304. */
  20305. getShadowGenerator(): Nullable<IShadowGenerator>;
  20306. /**
  20307. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20308. * @param effect The effect to update
  20309. * @param lightIndex The index of the light in the effect to update
  20310. * @returns The hemispheric light
  20311. */
  20312. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20313. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20314. /**
  20315. * Computes the world matrix of the node
  20316. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20317. * @param useWasUpdatedFlag defines a reserved property
  20318. * @returns the world matrix
  20319. */
  20320. computeWorldMatrix(): Matrix;
  20321. /**
  20322. * Returns the integer 3.
  20323. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20324. */
  20325. getTypeID(): number;
  20326. /**
  20327. * Prepares the list of defines specific to the light type.
  20328. * @param defines the list of defines
  20329. * @param lightIndex defines the index of the light for the effect
  20330. */
  20331. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20332. }
  20333. }
  20334. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20335. /** @hidden */
  20336. export var vrMultiviewToSingleviewPixelShader: {
  20337. name: string;
  20338. shader: string;
  20339. };
  20340. }
  20341. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20342. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20343. import { Scene } from "babylonjs/scene";
  20344. /**
  20345. * Renders to multiple views with a single draw call
  20346. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20347. */
  20348. export class MultiviewRenderTarget extends RenderTargetTexture {
  20349. /**
  20350. * Creates a multiview render target
  20351. * @param scene scene used with the render target
  20352. * @param size the size of the render target (used for each view)
  20353. */
  20354. constructor(scene: Scene, size?: number | {
  20355. width: number;
  20356. height: number;
  20357. } | {
  20358. ratio: number;
  20359. });
  20360. /**
  20361. * @hidden
  20362. * @param faceIndex the face index, if its a cube texture
  20363. */
  20364. _bindFrameBuffer(faceIndex?: number): void;
  20365. /**
  20366. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20367. * @returns the view count
  20368. */
  20369. getViewCount(): number;
  20370. }
  20371. }
  20372. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20373. import { Camera } from "babylonjs/Cameras/camera";
  20374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20375. import { Nullable } from "babylonjs/types";
  20376. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20377. import { Matrix } from "babylonjs/Maths/math.vector";
  20378. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20379. module "babylonjs/Engines/engine" {
  20380. interface Engine {
  20381. /**
  20382. * Creates a new multiview render target
  20383. * @param width defines the width of the texture
  20384. * @param height defines the height of the texture
  20385. * @returns the created multiview texture
  20386. */
  20387. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20388. /**
  20389. * Binds a multiview framebuffer to be drawn to
  20390. * @param multiviewTexture texture to bind
  20391. */
  20392. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20393. }
  20394. }
  20395. module "babylonjs/Cameras/camera" {
  20396. interface Camera {
  20397. /**
  20398. * @hidden
  20399. * 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)
  20400. */
  20401. _useMultiviewToSingleView: boolean;
  20402. /**
  20403. * @hidden
  20404. * 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)
  20405. */
  20406. _multiviewTexture: Nullable<RenderTargetTexture>;
  20407. /**
  20408. * @hidden
  20409. * ensures the multiview texture of the camera exists and has the specified width/height
  20410. * @param width height to set on the multiview texture
  20411. * @param height width to set on the multiview texture
  20412. */
  20413. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20414. }
  20415. }
  20416. module "babylonjs/scene" {
  20417. interface Scene {
  20418. /** @hidden */
  20419. _transformMatrixR: Matrix;
  20420. /** @hidden */
  20421. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20422. /** @hidden */
  20423. _createMultiviewUbo(): void;
  20424. /** @hidden */
  20425. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20426. /** @hidden */
  20427. _renderMultiviewToSingleView(camera: Camera): void;
  20428. }
  20429. }
  20430. }
  20431. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20432. import { Camera } from "babylonjs/Cameras/camera";
  20433. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20434. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20435. import "babylonjs/Engines/Extensions/engine.multiview";
  20436. /**
  20437. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20438. * This will not be used for webXR as it supports displaying texture arrays directly
  20439. */
  20440. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20441. /**
  20442. * Gets a string identifying the name of the class
  20443. * @returns "VRMultiviewToSingleviewPostProcess" string
  20444. */
  20445. getClassName(): string;
  20446. /**
  20447. * Initializes a VRMultiviewToSingleview
  20448. * @param name name of the post process
  20449. * @param camera camera to be applied to
  20450. * @param scaleFactor scaling factor to the size of the output texture
  20451. */
  20452. constructor(name: string, camera: Camera, scaleFactor: number);
  20453. }
  20454. }
  20455. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20456. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20457. import { Nullable } from "babylonjs/types";
  20458. import { Size } from "babylonjs/Maths/math.size";
  20459. import { Observable } from "babylonjs/Misc/observable";
  20460. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20461. /**
  20462. * Interface used to define additional presentation attributes
  20463. */
  20464. export interface IVRPresentationAttributes {
  20465. /**
  20466. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20467. */
  20468. highRefreshRate: boolean;
  20469. /**
  20470. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20471. */
  20472. foveationLevel: number;
  20473. }
  20474. module "babylonjs/Engines/engine" {
  20475. interface Engine {
  20476. /** @hidden */
  20477. _vrDisplay: any;
  20478. /** @hidden */
  20479. _vrSupported: boolean;
  20480. /** @hidden */
  20481. _oldSize: Size;
  20482. /** @hidden */
  20483. _oldHardwareScaleFactor: number;
  20484. /** @hidden */
  20485. _vrExclusivePointerMode: boolean;
  20486. /** @hidden */
  20487. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20488. /** @hidden */
  20489. _onVRDisplayPointerRestricted: () => void;
  20490. /** @hidden */
  20491. _onVRDisplayPointerUnrestricted: () => void;
  20492. /** @hidden */
  20493. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20494. /** @hidden */
  20495. _onVrDisplayDisconnect: Nullable<() => void>;
  20496. /** @hidden */
  20497. _onVrDisplayPresentChange: Nullable<() => void>;
  20498. /**
  20499. * Observable signaled when VR display mode changes
  20500. */
  20501. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20502. /**
  20503. * Observable signaled when VR request present is complete
  20504. */
  20505. onVRRequestPresentComplete: Observable<boolean>;
  20506. /**
  20507. * Observable signaled when VR request present starts
  20508. */
  20509. onVRRequestPresentStart: Observable<Engine>;
  20510. /**
  20511. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20512. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20513. */
  20514. isInVRExclusivePointerMode: boolean;
  20515. /**
  20516. * Gets a boolean indicating if a webVR device was detected
  20517. * @returns true if a webVR device was detected
  20518. */
  20519. isVRDevicePresent(): boolean;
  20520. /**
  20521. * Gets the current webVR device
  20522. * @returns the current webVR device (or null)
  20523. */
  20524. getVRDevice(): any;
  20525. /**
  20526. * Initializes a webVR display and starts listening to display change events
  20527. * The onVRDisplayChangedObservable will be notified upon these changes
  20528. * @returns A promise containing a VRDisplay and if vr is supported
  20529. */
  20530. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20531. /** @hidden */
  20532. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20533. /**
  20534. * Gets or sets the presentation attributes used to configure VR rendering
  20535. */
  20536. vrPresentationAttributes?: IVRPresentationAttributes;
  20537. /**
  20538. * Call this function to switch to webVR mode
  20539. * Will do nothing if webVR is not supported or if there is no webVR device
  20540. * @param options the webvr options provided to the camera. mainly used for multiview
  20541. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20542. */
  20543. enableVR(options: WebVROptions): void;
  20544. /** @hidden */
  20545. _onVRFullScreenTriggered(): void;
  20546. }
  20547. }
  20548. }
  20549. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20550. import { Nullable } from "babylonjs/types";
  20551. import { Observable } from "babylonjs/Misc/observable";
  20552. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20553. import { Scene } from "babylonjs/scene";
  20554. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20555. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20556. import { Node } from "babylonjs/node";
  20557. import { Ray } from "babylonjs/Culling/ray";
  20558. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20559. import "babylonjs/Engines/Extensions/engine.webVR";
  20560. /**
  20561. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20562. * IMPORTANT!! The data is right-hand data.
  20563. * @export
  20564. * @interface DevicePose
  20565. */
  20566. export interface DevicePose {
  20567. /**
  20568. * The position of the device, values in array are [x,y,z].
  20569. */
  20570. readonly position: Nullable<Float32Array>;
  20571. /**
  20572. * The linearVelocity of the device, values in array are [x,y,z].
  20573. */
  20574. readonly linearVelocity: Nullable<Float32Array>;
  20575. /**
  20576. * The linearAcceleration of the device, values in array are [x,y,z].
  20577. */
  20578. readonly linearAcceleration: Nullable<Float32Array>;
  20579. /**
  20580. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20581. */
  20582. readonly orientation: Nullable<Float32Array>;
  20583. /**
  20584. * The angularVelocity of the device, values in array are [x,y,z].
  20585. */
  20586. readonly angularVelocity: Nullable<Float32Array>;
  20587. /**
  20588. * The angularAcceleration of the device, values in array are [x,y,z].
  20589. */
  20590. readonly angularAcceleration: Nullable<Float32Array>;
  20591. }
  20592. /**
  20593. * Interface representing a pose controlled object in Babylon.
  20594. * A pose controlled object has both regular pose values as well as pose values
  20595. * from an external device such as a VR head mounted display
  20596. */
  20597. export interface PoseControlled {
  20598. /**
  20599. * The position of the object in babylon space.
  20600. */
  20601. position: Vector3;
  20602. /**
  20603. * The rotation quaternion of the object in babylon space.
  20604. */
  20605. rotationQuaternion: Quaternion;
  20606. /**
  20607. * The position of the device in babylon space.
  20608. */
  20609. devicePosition?: Vector3;
  20610. /**
  20611. * The rotation quaternion of the device in babylon space.
  20612. */
  20613. deviceRotationQuaternion: Quaternion;
  20614. /**
  20615. * The raw pose coming from the device.
  20616. */
  20617. rawPose: Nullable<DevicePose>;
  20618. /**
  20619. * The scale of the device to be used when translating from device space to babylon space.
  20620. */
  20621. deviceScaleFactor: number;
  20622. /**
  20623. * Updates the poseControlled values based on the input device pose.
  20624. * @param poseData the pose data to update the object with
  20625. */
  20626. updateFromDevice(poseData: DevicePose): void;
  20627. }
  20628. /**
  20629. * Set of options to customize the webVRCamera
  20630. */
  20631. export interface WebVROptions {
  20632. /**
  20633. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20634. */
  20635. trackPosition?: boolean;
  20636. /**
  20637. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20638. */
  20639. positionScale?: number;
  20640. /**
  20641. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20642. */
  20643. displayName?: string;
  20644. /**
  20645. * Should the native controller meshes be initialized. (default: true)
  20646. */
  20647. controllerMeshes?: boolean;
  20648. /**
  20649. * Creating a default HemiLight only on controllers. (default: true)
  20650. */
  20651. defaultLightingOnControllers?: boolean;
  20652. /**
  20653. * If you don't want to use the default VR button of the helper. (default: false)
  20654. */
  20655. useCustomVRButton?: boolean;
  20656. /**
  20657. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20658. */
  20659. customVRButton?: HTMLButtonElement;
  20660. /**
  20661. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20662. */
  20663. rayLength?: number;
  20664. /**
  20665. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20666. */
  20667. defaultHeight?: number;
  20668. /**
  20669. * If multiview should be used if availible (default: false)
  20670. */
  20671. useMultiview?: boolean;
  20672. }
  20673. /**
  20674. * This represents a WebVR camera.
  20675. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20676. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20677. */
  20678. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20679. private webVROptions;
  20680. /**
  20681. * @hidden
  20682. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20683. */
  20684. _vrDevice: any;
  20685. /**
  20686. * The rawPose of the vrDevice.
  20687. */
  20688. rawPose: Nullable<DevicePose>;
  20689. private _onVREnabled;
  20690. private _specsVersion;
  20691. private _attached;
  20692. private _frameData;
  20693. protected _descendants: Array<Node>;
  20694. private _deviceRoomPosition;
  20695. /** @hidden */
  20696. _deviceRoomRotationQuaternion: Quaternion;
  20697. private _standingMatrix;
  20698. /**
  20699. * Represents device position in babylon space.
  20700. */
  20701. devicePosition: Vector3;
  20702. /**
  20703. * Represents device rotation in babylon space.
  20704. */
  20705. deviceRotationQuaternion: Quaternion;
  20706. /**
  20707. * The scale of the device to be used when translating from device space to babylon space.
  20708. */
  20709. deviceScaleFactor: number;
  20710. private _deviceToWorld;
  20711. private _worldToDevice;
  20712. /**
  20713. * References to the webVR controllers for the vrDevice.
  20714. */
  20715. controllers: Array<WebVRController>;
  20716. /**
  20717. * Emits an event when a controller is attached.
  20718. */
  20719. onControllersAttachedObservable: Observable<WebVRController[]>;
  20720. /**
  20721. * Emits an event when a controller's mesh has been loaded;
  20722. */
  20723. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20724. /**
  20725. * Emits an event when the HMD's pose has been updated.
  20726. */
  20727. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20728. private _poseSet;
  20729. /**
  20730. * If the rig cameras be used as parent instead of this camera.
  20731. */
  20732. rigParenting: boolean;
  20733. private _lightOnControllers;
  20734. private _defaultHeight?;
  20735. /**
  20736. * Instantiates a WebVRFreeCamera.
  20737. * @param name The name of the WebVRFreeCamera
  20738. * @param position The starting anchor position for the camera
  20739. * @param scene The scene the camera belongs to
  20740. * @param webVROptions a set of customizable options for the webVRCamera
  20741. */
  20742. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20743. /**
  20744. * Gets the device distance from the ground in meters.
  20745. * @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.
  20746. */
  20747. deviceDistanceToRoomGround(): number;
  20748. /**
  20749. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20750. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20751. */
  20752. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20753. /**
  20754. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20755. * @returns A promise with a boolean set to if the standing matrix is supported.
  20756. */
  20757. useStandingMatrixAsync(): Promise<boolean>;
  20758. /**
  20759. * Disposes the camera
  20760. */
  20761. dispose(): void;
  20762. /**
  20763. * Gets a vrController by name.
  20764. * @param name The name of the controller to retreive
  20765. * @returns the controller matching the name specified or null if not found
  20766. */
  20767. getControllerByName(name: string): Nullable<WebVRController>;
  20768. private _leftController;
  20769. /**
  20770. * The controller corresponding to the users left hand.
  20771. */
  20772. get leftController(): Nullable<WebVRController>;
  20773. private _rightController;
  20774. /**
  20775. * The controller corresponding to the users right hand.
  20776. */
  20777. get rightController(): Nullable<WebVRController>;
  20778. /**
  20779. * Casts a ray forward from the vrCamera's gaze.
  20780. * @param length Length of the ray (default: 100)
  20781. * @returns the ray corresponding to the gaze
  20782. */
  20783. getForwardRay(length?: number): Ray;
  20784. /**
  20785. * @hidden
  20786. * Updates the camera based on device's frame data
  20787. */
  20788. _checkInputs(): void;
  20789. /**
  20790. * Updates the poseControlled values based on the input device pose.
  20791. * @param poseData Pose coming from the device
  20792. */
  20793. updateFromDevice(poseData: DevicePose): void;
  20794. private _htmlElementAttached;
  20795. private _detachIfAttached;
  20796. /**
  20797. * WebVR's attach control will start broadcasting frames to the device.
  20798. * Note that in certain browsers (chrome for example) this function must be called
  20799. * within a user-interaction callback. Example:
  20800. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20801. *
  20802. * @param element html element to attach the vrDevice to
  20803. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20804. */
  20805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20806. /**
  20807. * Detaches the camera from the html element and disables VR
  20808. *
  20809. * @param element html element to detach from
  20810. */
  20811. detachControl(element: HTMLElement): void;
  20812. /**
  20813. * @returns the name of this class
  20814. */
  20815. getClassName(): string;
  20816. /**
  20817. * Calls resetPose on the vrDisplay
  20818. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20819. */
  20820. resetToCurrentRotation(): void;
  20821. /**
  20822. * @hidden
  20823. * Updates the rig cameras (left and right eye)
  20824. */
  20825. _updateRigCameras(): void;
  20826. private _workingVector;
  20827. private _oneVector;
  20828. private _workingMatrix;
  20829. private updateCacheCalled;
  20830. private _correctPositionIfNotTrackPosition;
  20831. /**
  20832. * @hidden
  20833. * Updates the cached values of the camera
  20834. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20835. */
  20836. _updateCache(ignoreParentClass?: boolean): void;
  20837. /**
  20838. * @hidden
  20839. * Get current device position in babylon world
  20840. */
  20841. _computeDevicePosition(): void;
  20842. /**
  20843. * Updates the current device position and rotation in the babylon world
  20844. */
  20845. update(): void;
  20846. /**
  20847. * @hidden
  20848. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20849. * @returns an identity matrix
  20850. */
  20851. _getViewMatrix(): Matrix;
  20852. private _tmpMatrix;
  20853. /**
  20854. * This function is called by the two RIG cameras.
  20855. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20856. * @hidden
  20857. */
  20858. _getWebVRViewMatrix(): Matrix;
  20859. /** @hidden */
  20860. _getWebVRProjectionMatrix(): Matrix;
  20861. private _onGamepadConnectedObserver;
  20862. private _onGamepadDisconnectedObserver;
  20863. private _updateCacheWhenTrackingDisabledObserver;
  20864. /**
  20865. * Initializes the controllers and their meshes
  20866. */
  20867. initControllers(): void;
  20868. }
  20869. }
  20870. declare module "babylonjs/Materials/materialHelper" {
  20871. import { Nullable } from "babylonjs/types";
  20872. import { Scene } from "babylonjs/scene";
  20873. import { Engine } from "babylonjs/Engines/engine";
  20874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20875. import { Light } from "babylonjs/Lights/light";
  20876. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20877. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20879. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20880. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20881. /**
  20882. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20883. *
  20884. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20885. *
  20886. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20887. */
  20888. export class MaterialHelper {
  20889. /**
  20890. * Bind the current view position to an effect.
  20891. * @param effect The effect to be bound
  20892. * @param scene The scene the eyes position is used from
  20893. * @param variableName name of the shader variable that will hold the eye position
  20894. */
  20895. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20896. /**
  20897. * Helps preparing the defines values about the UVs in used in the effect.
  20898. * UVs are shared as much as we can accross channels in the shaders.
  20899. * @param texture The texture we are preparing the UVs for
  20900. * @param defines The defines to update
  20901. * @param key The channel key "diffuse", "specular"... used in the shader
  20902. */
  20903. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20904. /**
  20905. * Binds a texture matrix value to its corrsponding uniform
  20906. * @param texture The texture to bind the matrix for
  20907. * @param uniformBuffer The uniform buffer receivin the data
  20908. * @param key The channel key "diffuse", "specular"... used in the shader
  20909. */
  20910. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20911. /**
  20912. * Gets the current status of the fog (should it be enabled?)
  20913. * @param mesh defines the mesh to evaluate for fog support
  20914. * @param scene defines the hosting scene
  20915. * @returns true if fog must be enabled
  20916. */
  20917. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20918. /**
  20919. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20920. * @param mesh defines the current mesh
  20921. * @param scene defines the current scene
  20922. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20923. * @param pointsCloud defines if point cloud rendering has to be turned on
  20924. * @param fogEnabled defines if fog has to be turned on
  20925. * @param alphaTest defines if alpha testing has to be turned on
  20926. * @param defines defines the current list of defines
  20927. */
  20928. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20929. /**
  20930. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20931. * @param scene defines the current scene
  20932. * @param engine defines the current engine
  20933. * @param defines specifies the list of active defines
  20934. * @param useInstances defines if instances have to be turned on
  20935. * @param useClipPlane defines if clip plane have to be turned on
  20936. * @param useInstances defines if instances have to be turned on
  20937. * @param useThinInstances defines if thin instances have to be turned on
  20938. */
  20939. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20940. /**
  20941. * Prepares the defines for bones
  20942. * @param mesh The mesh containing the geometry data we will draw
  20943. * @param defines The defines to update
  20944. */
  20945. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20946. /**
  20947. * Prepares the defines for morph targets
  20948. * @param mesh The mesh containing the geometry data we will draw
  20949. * @param defines The defines to update
  20950. */
  20951. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20952. /**
  20953. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20954. * @param mesh The mesh containing the geometry data we will draw
  20955. * @param defines The defines to update
  20956. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20957. * @param useBones Precise whether bones should be used or not (override mesh info)
  20958. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20959. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20960. * @returns false if defines are considered not dirty and have not been checked
  20961. */
  20962. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20963. /**
  20964. * Prepares the defines related to multiview
  20965. * @param scene The scene we are intending to draw
  20966. * @param defines The defines to update
  20967. */
  20968. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20969. /**
  20970. * Prepares the defines related to the prepass
  20971. * @param scene The scene we are intending to draw
  20972. * @param defines The defines to update
  20973. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20974. */
  20975. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20976. /**
  20977. * Prepares the defines related to the light information passed in parameter
  20978. * @param scene The scene we are intending to draw
  20979. * @param mesh The mesh the effect is compiling for
  20980. * @param light The light the effect is compiling for
  20981. * @param lightIndex The index of the light
  20982. * @param defines The defines to update
  20983. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20984. * @param state Defines the current state regarding what is needed (normals, etc...)
  20985. */
  20986. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20987. needNormals: boolean;
  20988. needRebuild: boolean;
  20989. shadowEnabled: boolean;
  20990. specularEnabled: boolean;
  20991. lightmapMode: boolean;
  20992. }): void;
  20993. /**
  20994. * Prepares the defines related to the light information passed in parameter
  20995. * @param scene The scene we are intending to draw
  20996. * @param mesh The mesh the effect is compiling for
  20997. * @param defines The defines to update
  20998. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20999. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21000. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21001. * @returns true if normals will be required for the rest of the effect
  21002. */
  21003. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21004. /**
  21005. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21006. * @param lightIndex defines the light index
  21007. * @param uniformsList The uniform list
  21008. * @param samplersList The sampler list
  21009. * @param projectedLightTexture defines if projected texture must be used
  21010. * @param uniformBuffersList defines an optional list of uniform buffers
  21011. */
  21012. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21013. /**
  21014. * Prepares the uniforms and samplers list to be used in the effect
  21015. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21016. * @param samplersList The sampler list
  21017. * @param defines The defines helping in the list generation
  21018. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21019. */
  21020. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21021. /**
  21022. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21023. * @param defines The defines to update while falling back
  21024. * @param fallbacks The authorized effect fallbacks
  21025. * @param maxSimultaneousLights The maximum number of lights allowed
  21026. * @param rank the current rank of the Effect
  21027. * @returns The newly affected rank
  21028. */
  21029. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21030. private static _TmpMorphInfluencers;
  21031. /**
  21032. * Prepares the list of attributes required for morph targets according to the effect defines.
  21033. * @param attribs The current list of supported attribs
  21034. * @param mesh The mesh to prepare the morph targets attributes for
  21035. * @param influencers The number of influencers
  21036. */
  21037. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21038. /**
  21039. * Prepares the list of attributes required for morph targets according to the effect defines.
  21040. * @param attribs The current list of supported attribs
  21041. * @param mesh The mesh to prepare the morph targets attributes for
  21042. * @param defines The current Defines of the effect
  21043. */
  21044. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21045. /**
  21046. * Prepares the list of attributes required for bones according to the effect defines.
  21047. * @param attribs The current list of supported attribs
  21048. * @param mesh The mesh to prepare the bones attributes for
  21049. * @param defines The current Defines of the effect
  21050. * @param fallbacks The current efffect fallback strategy
  21051. */
  21052. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21053. /**
  21054. * Check and prepare the list of attributes required for instances according to the effect defines.
  21055. * @param attribs The current list of supported attribs
  21056. * @param defines The current MaterialDefines of the effect
  21057. */
  21058. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21059. /**
  21060. * Add the list of attributes required for instances to the attribs array.
  21061. * @param attribs The current list of supported attribs
  21062. */
  21063. static PushAttributesForInstances(attribs: string[]): void;
  21064. /**
  21065. * Binds the light information to the effect.
  21066. * @param light The light containing the generator
  21067. * @param effect The effect we are binding the data to
  21068. * @param lightIndex The light index in the effect used to render
  21069. */
  21070. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21071. /**
  21072. * Binds the lights information from the scene to the effect for the given mesh.
  21073. * @param light Light to bind
  21074. * @param lightIndex Light index
  21075. * @param scene The scene where the light belongs to
  21076. * @param effect The effect we are binding the data to
  21077. * @param useSpecular Defines if specular is supported
  21078. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21079. */
  21080. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21081. /**
  21082. * Binds the lights information from the scene to the effect for the given mesh.
  21083. * @param scene The scene the lights belongs to
  21084. * @param mesh The mesh we are binding the information to render
  21085. * @param effect The effect we are binding the data to
  21086. * @param defines The generated defines for the effect
  21087. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21088. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21089. */
  21090. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21091. private static _tempFogColor;
  21092. /**
  21093. * Binds the fog information from the scene to the effect for the given mesh.
  21094. * @param scene The scene the lights belongs to
  21095. * @param mesh The mesh we are binding the information to render
  21096. * @param effect The effect we are binding the data to
  21097. * @param linearSpace Defines if the fog effect is applied in linear space
  21098. */
  21099. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21100. /**
  21101. * Binds the bones information from the mesh to the effect.
  21102. * @param mesh The mesh we are binding the information to render
  21103. * @param effect The effect we are binding the data to
  21104. */
  21105. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21106. /**
  21107. * Binds the morph targets information from the mesh to the effect.
  21108. * @param abstractMesh The mesh we are binding the information to render
  21109. * @param effect The effect we are binding the data to
  21110. */
  21111. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21112. /**
  21113. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21114. * @param defines The generated defines used in the effect
  21115. * @param effect The effect we are binding the data to
  21116. * @param scene The scene we are willing to render with logarithmic scale for
  21117. */
  21118. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21119. /**
  21120. * Binds the clip plane information from the scene to the effect.
  21121. * @param scene The scene the clip plane information are extracted from
  21122. * @param effect The effect we are binding the data to
  21123. */
  21124. static BindClipPlane(effect: Effect, scene: Scene): void;
  21125. }
  21126. }
  21127. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21129. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21130. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21131. import { Nullable } from "babylonjs/types";
  21132. import { Effect } from "babylonjs/Materials/effect";
  21133. import { Matrix } from "babylonjs/Maths/math.vector";
  21134. import { Scene } from "babylonjs/scene";
  21135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21137. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21138. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21139. import { Observable } from "babylonjs/Misc/observable";
  21140. /**
  21141. * Block used to expose an input value
  21142. */
  21143. export class InputBlock extends NodeMaterialBlock {
  21144. private _mode;
  21145. private _associatedVariableName;
  21146. private _storedValue;
  21147. private _valueCallback;
  21148. private _type;
  21149. private _animationType;
  21150. /** Gets or set a value used to limit the range of float values */
  21151. min: number;
  21152. /** Gets or set a value used to limit the range of float values */
  21153. max: number;
  21154. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21155. isBoolean: boolean;
  21156. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21157. matrixMode: number;
  21158. /** @hidden */
  21159. _systemValue: Nullable<NodeMaterialSystemValues>;
  21160. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21161. isConstant: boolean;
  21162. /** Gets or sets the group to use to display this block in the Inspector */
  21163. groupInInspector: string;
  21164. /** Gets an observable raised when the value is changed */
  21165. onValueChangedObservable: Observable<InputBlock>;
  21166. /**
  21167. * Gets or sets the connection point type (default is float)
  21168. */
  21169. get type(): NodeMaterialBlockConnectionPointTypes;
  21170. /**
  21171. * Creates a new InputBlock
  21172. * @param name defines the block name
  21173. * @param target defines the target of that block (Vertex by default)
  21174. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21175. */
  21176. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21177. /**
  21178. * Validates if a name is a reserve word.
  21179. * @param newName the new name to be given to the node.
  21180. * @returns false if the name is a reserve word, else true.
  21181. */
  21182. validateBlockName(newName: string): boolean;
  21183. /**
  21184. * Gets the output component
  21185. */
  21186. get output(): NodeMaterialConnectionPoint;
  21187. /**
  21188. * Set the source of this connection point to a vertex attribute
  21189. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21190. * @returns the current connection point
  21191. */
  21192. setAsAttribute(attributeName?: string): InputBlock;
  21193. /**
  21194. * Set the source of this connection point to a system value
  21195. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21196. * @returns the current connection point
  21197. */
  21198. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21199. /**
  21200. * Gets or sets the value of that point.
  21201. * Please note that this value will be ignored if valueCallback is defined
  21202. */
  21203. get value(): any;
  21204. set value(value: any);
  21205. /**
  21206. * Gets or sets a callback used to get the value of that point.
  21207. * Please note that setting this value will force the connection point to ignore the value property
  21208. */
  21209. get valueCallback(): () => any;
  21210. set valueCallback(value: () => any);
  21211. /**
  21212. * Gets or sets the associated variable name in the shader
  21213. */
  21214. get associatedVariableName(): string;
  21215. set associatedVariableName(value: string);
  21216. /** Gets or sets the type of animation applied to the input */
  21217. get animationType(): AnimatedInputBlockTypes;
  21218. set animationType(value: AnimatedInputBlockTypes);
  21219. /**
  21220. * Gets a boolean indicating that this connection point not defined yet
  21221. */
  21222. get isUndefined(): boolean;
  21223. /**
  21224. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21225. * In this case the connection point name must be the name of the uniform to use.
  21226. * Can only be set on inputs
  21227. */
  21228. get isUniform(): boolean;
  21229. set isUniform(value: boolean);
  21230. /**
  21231. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21232. * In this case the connection point name must be the name of the attribute to use
  21233. * Can only be set on inputs
  21234. */
  21235. get isAttribute(): boolean;
  21236. set isAttribute(value: boolean);
  21237. /**
  21238. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21239. * Can only be set on exit points
  21240. */
  21241. get isVarying(): boolean;
  21242. set isVarying(value: boolean);
  21243. /**
  21244. * Gets a boolean indicating that the current connection point is a system value
  21245. */
  21246. get isSystemValue(): boolean;
  21247. /**
  21248. * Gets or sets the current well known value or null if not defined as a system value
  21249. */
  21250. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21251. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21252. /**
  21253. * Gets the current class name
  21254. * @returns the class name
  21255. */
  21256. getClassName(): string;
  21257. /**
  21258. * Animate the input if animationType !== None
  21259. * @param scene defines the rendering scene
  21260. */
  21261. animate(scene: Scene): void;
  21262. private _emitDefine;
  21263. initialize(state: NodeMaterialBuildState): void;
  21264. /**
  21265. * Set the input block to its default value (based on its type)
  21266. */
  21267. setDefaultValue(): void;
  21268. private _emitConstant;
  21269. /** @hidden */
  21270. get _noContextSwitch(): boolean;
  21271. private _emit;
  21272. /** @hidden */
  21273. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21274. /** @hidden */
  21275. _transmit(effect: Effect, scene: Scene): void;
  21276. protected _buildBlock(state: NodeMaterialBuildState): void;
  21277. protected _dumpPropertiesCode(): string;
  21278. dispose(): void;
  21279. serialize(): any;
  21280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21281. }
  21282. }
  21283. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21284. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21285. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21286. import { Nullable } from "babylonjs/types";
  21287. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21288. import { Observable } from "babylonjs/Misc/observable";
  21289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21290. /**
  21291. * Enum used to define the compatibility state between two connection points
  21292. */
  21293. export enum NodeMaterialConnectionPointCompatibilityStates {
  21294. /** Points are compatibles */
  21295. Compatible = 0,
  21296. /** Points are incompatible because of their types */
  21297. TypeIncompatible = 1,
  21298. /** Points are incompatible because of their targets (vertex vs fragment) */
  21299. TargetIncompatible = 2
  21300. }
  21301. /**
  21302. * Defines the direction of a connection point
  21303. */
  21304. export enum NodeMaterialConnectionPointDirection {
  21305. /** Input */
  21306. Input = 0,
  21307. /** Output */
  21308. Output = 1
  21309. }
  21310. /**
  21311. * Defines a connection point for a block
  21312. */
  21313. export class NodeMaterialConnectionPoint {
  21314. /** @hidden */
  21315. _ownerBlock: NodeMaterialBlock;
  21316. /** @hidden */
  21317. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21318. private _endpoints;
  21319. private _associatedVariableName;
  21320. private _direction;
  21321. /** @hidden */
  21322. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21323. /** @hidden */
  21324. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21325. private _type;
  21326. /** @hidden */
  21327. _enforceAssociatedVariableName: boolean;
  21328. /** Gets the direction of the point */
  21329. get direction(): NodeMaterialConnectionPointDirection;
  21330. /** Indicates that this connection point needs dual validation before being connected to another point */
  21331. needDualDirectionValidation: boolean;
  21332. /**
  21333. * Gets or sets the additional types supported by this connection point
  21334. */
  21335. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21336. /**
  21337. * Gets or sets the additional types excluded by this connection point
  21338. */
  21339. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21340. /**
  21341. * Observable triggered when this point is connected
  21342. */
  21343. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21344. /**
  21345. * Gets or sets the associated variable name in the shader
  21346. */
  21347. get associatedVariableName(): string;
  21348. set associatedVariableName(value: string);
  21349. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21350. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21351. /**
  21352. * Gets or sets the connection point type (default is float)
  21353. */
  21354. get type(): NodeMaterialBlockConnectionPointTypes;
  21355. set type(value: NodeMaterialBlockConnectionPointTypes);
  21356. /**
  21357. * Gets or sets the connection point name
  21358. */
  21359. name: string;
  21360. /**
  21361. * Gets or sets the connection point name
  21362. */
  21363. displayName: string;
  21364. /**
  21365. * Gets or sets a boolean indicating that this connection point can be omitted
  21366. */
  21367. isOptional: boolean;
  21368. /**
  21369. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21370. */
  21371. isExposedOnFrame: boolean;
  21372. /**
  21373. * Gets or sets number indicating the position that the port is exposed to on a frame
  21374. */
  21375. exposedPortPosition: number;
  21376. /**
  21377. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21378. */
  21379. define: string;
  21380. /** @hidden */
  21381. _prioritizeVertex: boolean;
  21382. private _target;
  21383. /** Gets or sets the target of that connection point */
  21384. get target(): NodeMaterialBlockTargets;
  21385. set target(value: NodeMaterialBlockTargets);
  21386. /**
  21387. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21388. */
  21389. get isConnected(): boolean;
  21390. /**
  21391. * Gets a boolean indicating that the current point is connected to an input block
  21392. */
  21393. get isConnectedToInputBlock(): boolean;
  21394. /**
  21395. * Gets a the connected input block (if any)
  21396. */
  21397. get connectInputBlock(): Nullable<InputBlock>;
  21398. /** Get the other side of the connection (if any) */
  21399. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21400. /** Get the block that owns this connection point */
  21401. get ownerBlock(): NodeMaterialBlock;
  21402. /** Get the block connected on the other side of this connection (if any) */
  21403. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21404. /** Get the block connected on the endpoints of this connection (if any) */
  21405. get connectedBlocks(): Array<NodeMaterialBlock>;
  21406. /** Gets the list of connected endpoints */
  21407. get endpoints(): NodeMaterialConnectionPoint[];
  21408. /** Gets a boolean indicating if that output point is connected to at least one input */
  21409. get hasEndpoints(): boolean;
  21410. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21411. get isConnectedInVertexShader(): boolean;
  21412. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21413. get isConnectedInFragmentShader(): boolean;
  21414. /**
  21415. * Creates a block suitable to be used as an input for this input point.
  21416. * If null is returned, a block based on the point type will be created.
  21417. * @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
  21418. */
  21419. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21420. /**
  21421. * Creates a new connection point
  21422. * @param name defines the connection point name
  21423. * @param ownerBlock defines the block hosting this connection point
  21424. * @param direction defines the direction of the connection point
  21425. */
  21426. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21427. /**
  21428. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21429. * @returns the class name
  21430. */
  21431. getClassName(): string;
  21432. /**
  21433. * Gets a boolean indicating if the current point can be connected to another point
  21434. * @param connectionPoint defines the other connection point
  21435. * @returns a boolean
  21436. */
  21437. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21438. /**
  21439. * Gets a number indicating if the current point can be connected to another point
  21440. * @param connectionPoint defines the other connection point
  21441. * @returns a number defining the compatibility state
  21442. */
  21443. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21444. /**
  21445. * Connect this point to another connection point
  21446. * @param connectionPoint defines the other connection point
  21447. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21448. * @returns the current connection point
  21449. */
  21450. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21451. /**
  21452. * Disconnect this point from one of his endpoint
  21453. * @param endpoint defines the other connection point
  21454. * @returns the current connection point
  21455. */
  21456. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21457. /**
  21458. * Serializes this point in a JSON representation
  21459. * @param isInput defines if the connection point is an input (default is true)
  21460. * @returns the serialized point object
  21461. */
  21462. serialize(isInput?: boolean): any;
  21463. /**
  21464. * Release resources
  21465. */
  21466. dispose(): void;
  21467. }
  21468. }
  21469. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21470. /**
  21471. * Enum used to define the material modes
  21472. */
  21473. export enum NodeMaterialModes {
  21474. /** Regular material */
  21475. Material = 0,
  21476. /** For post process */
  21477. PostProcess = 1,
  21478. /** For particle system */
  21479. Particle = 2,
  21480. /** For procedural texture */
  21481. ProceduralTexture = 3
  21482. }
  21483. }
  21484. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21485. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21487. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21490. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21491. import { Effect } from "babylonjs/Materials/effect";
  21492. import { Mesh } from "babylonjs/Meshes/mesh";
  21493. import { Nullable } from "babylonjs/types";
  21494. import { Texture } from "babylonjs/Materials/Textures/texture";
  21495. import { Scene } from "babylonjs/scene";
  21496. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21497. /**
  21498. * Block used to read a texture from a sampler
  21499. */
  21500. export class TextureBlock extends NodeMaterialBlock {
  21501. private _defineName;
  21502. private _linearDefineName;
  21503. private _gammaDefineName;
  21504. private _tempTextureRead;
  21505. private _samplerName;
  21506. private _transformedUVName;
  21507. private _textureTransformName;
  21508. private _textureInfoName;
  21509. private _mainUVName;
  21510. private _mainUVDefineName;
  21511. private _fragmentOnly;
  21512. /**
  21513. * Gets or sets the texture associated with the node
  21514. */
  21515. texture: Nullable<Texture>;
  21516. /**
  21517. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21518. */
  21519. convertToGammaSpace: boolean;
  21520. /**
  21521. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21522. */
  21523. convertToLinearSpace: boolean;
  21524. /**
  21525. * Create a new TextureBlock
  21526. * @param name defines the block name
  21527. */
  21528. constructor(name: string, fragmentOnly?: boolean);
  21529. /**
  21530. * Gets the current class name
  21531. * @returns the class name
  21532. */
  21533. getClassName(): string;
  21534. /**
  21535. * Gets the uv input component
  21536. */
  21537. get uv(): NodeMaterialConnectionPoint;
  21538. /**
  21539. * Gets the rgba output component
  21540. */
  21541. get rgba(): NodeMaterialConnectionPoint;
  21542. /**
  21543. * Gets the rgb output component
  21544. */
  21545. get rgb(): NodeMaterialConnectionPoint;
  21546. /**
  21547. * Gets the r output component
  21548. */
  21549. get r(): NodeMaterialConnectionPoint;
  21550. /**
  21551. * Gets the g output component
  21552. */
  21553. get g(): NodeMaterialConnectionPoint;
  21554. /**
  21555. * Gets the b output component
  21556. */
  21557. get b(): NodeMaterialConnectionPoint;
  21558. /**
  21559. * Gets the a output component
  21560. */
  21561. get a(): NodeMaterialConnectionPoint;
  21562. get target(): NodeMaterialBlockTargets;
  21563. autoConfigure(material: NodeMaterial): void;
  21564. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21565. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21566. isReady(): boolean;
  21567. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21568. private get _isMixed();
  21569. private _injectVertexCode;
  21570. private _writeTextureRead;
  21571. private _writeOutput;
  21572. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21573. protected _dumpPropertiesCode(): string;
  21574. serialize(): any;
  21575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21576. }
  21577. }
  21578. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21579. /** @hidden */
  21580. export var reflectionFunction: {
  21581. name: string;
  21582. shader: string;
  21583. };
  21584. }
  21585. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21591. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21592. import { Effect } from "babylonjs/Materials/effect";
  21593. import { Mesh } from "babylonjs/Meshes/mesh";
  21594. import { Nullable } from "babylonjs/types";
  21595. import { Scene } from "babylonjs/scene";
  21596. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21597. /**
  21598. * Base block used to read a reflection texture from a sampler
  21599. */
  21600. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21601. /** @hidden */
  21602. _define3DName: string;
  21603. /** @hidden */
  21604. _defineCubicName: string;
  21605. /** @hidden */
  21606. _defineExplicitName: string;
  21607. /** @hidden */
  21608. _defineProjectionName: string;
  21609. /** @hidden */
  21610. _defineLocalCubicName: string;
  21611. /** @hidden */
  21612. _defineSphericalName: string;
  21613. /** @hidden */
  21614. _definePlanarName: string;
  21615. /** @hidden */
  21616. _defineEquirectangularName: string;
  21617. /** @hidden */
  21618. _defineMirroredEquirectangularFixedName: string;
  21619. /** @hidden */
  21620. _defineEquirectangularFixedName: string;
  21621. /** @hidden */
  21622. _defineSkyboxName: string;
  21623. /** @hidden */
  21624. _defineOppositeZ: string;
  21625. /** @hidden */
  21626. _cubeSamplerName: string;
  21627. /** @hidden */
  21628. _2DSamplerName: string;
  21629. protected _positionUVWName: string;
  21630. protected _directionWName: string;
  21631. protected _reflectionVectorName: string;
  21632. /** @hidden */
  21633. _reflectionCoordsName: string;
  21634. /** @hidden */
  21635. _reflectionMatrixName: string;
  21636. protected _reflectionColorName: string;
  21637. /**
  21638. * Gets or sets the texture associated with the node
  21639. */
  21640. texture: Nullable<BaseTexture>;
  21641. /**
  21642. * Create a new ReflectionTextureBaseBlock
  21643. * @param name defines the block name
  21644. */
  21645. constructor(name: string);
  21646. /**
  21647. * Gets the current class name
  21648. * @returns the class name
  21649. */
  21650. getClassName(): string;
  21651. /**
  21652. * Gets the world position input component
  21653. */
  21654. abstract get position(): NodeMaterialConnectionPoint;
  21655. /**
  21656. * Gets the world position input component
  21657. */
  21658. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21659. /**
  21660. * Gets the world normal input component
  21661. */
  21662. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21663. /**
  21664. * Gets the world input component
  21665. */
  21666. abstract get world(): NodeMaterialConnectionPoint;
  21667. /**
  21668. * Gets the camera (or eye) position component
  21669. */
  21670. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21671. /**
  21672. * Gets the view input component
  21673. */
  21674. abstract get view(): NodeMaterialConnectionPoint;
  21675. protected _getTexture(): Nullable<BaseTexture>;
  21676. autoConfigure(material: NodeMaterial): void;
  21677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21678. isReady(): boolean;
  21679. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21680. /**
  21681. * Gets the code to inject in the vertex shader
  21682. * @param state current state of the node material building
  21683. * @returns the shader code
  21684. */
  21685. handleVertexSide(state: NodeMaterialBuildState): string;
  21686. /**
  21687. * Handles the inits for the fragment code path
  21688. * @param state node material build state
  21689. */
  21690. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21691. /**
  21692. * Generates the reflection coords code for the fragment code path
  21693. * @param worldNormalVarName name of the world normal variable
  21694. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21695. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21696. * @returns the shader code
  21697. */
  21698. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21699. /**
  21700. * Generates the reflection color code for the fragment code path
  21701. * @param lodVarName name of the lod variable
  21702. * @param swizzleLookupTexture swizzle to use for the final color variable
  21703. * @returns the shader code
  21704. */
  21705. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21706. /**
  21707. * Generates the code corresponding to the connected output points
  21708. * @param state node material build state
  21709. * @param varName name of the variable to output
  21710. * @returns the shader code
  21711. */
  21712. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21713. protected _buildBlock(state: NodeMaterialBuildState): this;
  21714. protected _dumpPropertiesCode(): string;
  21715. serialize(): any;
  21716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21717. }
  21718. }
  21719. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21721. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21722. import { Nullable } from "babylonjs/types";
  21723. /**
  21724. * Defines a connection point to be used for points with a custom object type
  21725. */
  21726. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21727. private _blockType;
  21728. private _blockName;
  21729. private _nameForCheking?;
  21730. /**
  21731. * Creates a new connection point
  21732. * @param name defines the connection point name
  21733. * @param ownerBlock defines the block hosting this connection point
  21734. * @param direction defines the direction of the connection point
  21735. */
  21736. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21737. /**
  21738. * Gets a number indicating if the current point can be connected to another point
  21739. * @param connectionPoint defines the other connection point
  21740. * @returns a number defining the compatibility state
  21741. */
  21742. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21743. /**
  21744. * Creates a block suitable to be used as an input for this input point.
  21745. * If null is returned, a block based on the point type will be created.
  21746. * @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
  21747. */
  21748. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21749. }
  21750. }
  21751. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21752. /**
  21753. * Enum defining the type of properties that can be edited in the property pages in the NME
  21754. */
  21755. export enum PropertyTypeForEdition {
  21756. /** property is a boolean */
  21757. Boolean = 0,
  21758. /** property is a float */
  21759. Float = 1,
  21760. /** property is a Vector2 */
  21761. Vector2 = 2,
  21762. /** property is a list of values */
  21763. List = 3
  21764. }
  21765. /**
  21766. * Interface that defines an option in a variable of type list
  21767. */
  21768. export interface IEditablePropertyListOption {
  21769. /** label of the option */
  21770. "label": string;
  21771. /** value of the option */
  21772. "value": number;
  21773. }
  21774. /**
  21775. * Interface that defines the options available for an editable property
  21776. */
  21777. export interface IEditablePropertyOption {
  21778. /** min value */
  21779. "min"?: number;
  21780. /** max value */
  21781. "max"?: number;
  21782. /** notifiers: indicates which actions to take when the property is changed */
  21783. "notifiers"?: {
  21784. /** the material should be rebuilt */
  21785. "rebuild"?: boolean;
  21786. /** the preview should be updated */
  21787. "update"?: boolean;
  21788. };
  21789. /** list of the options for a variable of type list */
  21790. "options"?: IEditablePropertyListOption[];
  21791. }
  21792. /**
  21793. * Interface that describes an editable property
  21794. */
  21795. export interface IPropertyDescriptionForEdition {
  21796. /** name of the property */
  21797. "propertyName": string;
  21798. /** display name of the property */
  21799. "displayName": string;
  21800. /** type of the property */
  21801. "type": PropertyTypeForEdition;
  21802. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21803. "groupName": string;
  21804. /** options for the property */
  21805. "options": IEditablePropertyOption;
  21806. }
  21807. /**
  21808. * Decorator that flags a property in a node material block as being editable
  21809. */
  21810. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21811. }
  21812. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21813. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21814. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21815. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21817. import { Nullable } from "babylonjs/types";
  21818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21819. import { Mesh } from "babylonjs/Meshes/mesh";
  21820. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21821. import { Effect } from "babylonjs/Materials/effect";
  21822. import { Scene } from "babylonjs/scene";
  21823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21824. /**
  21825. * Block used to implement the refraction part of the sub surface module of the PBR material
  21826. */
  21827. export class RefractionBlock extends NodeMaterialBlock {
  21828. /** @hidden */
  21829. _define3DName: string;
  21830. /** @hidden */
  21831. _refractionMatrixName: string;
  21832. /** @hidden */
  21833. _defineLODRefractionAlpha: string;
  21834. /** @hidden */
  21835. _defineLinearSpecularRefraction: string;
  21836. /** @hidden */
  21837. _defineOppositeZ: string;
  21838. /** @hidden */
  21839. _cubeSamplerName: string;
  21840. /** @hidden */
  21841. _2DSamplerName: string;
  21842. /** @hidden */
  21843. _vRefractionMicrosurfaceInfosName: string;
  21844. /** @hidden */
  21845. _vRefractionInfosName: string;
  21846. private _scene;
  21847. /**
  21848. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21849. * Materials half opaque for instance using refraction could benefit from this control.
  21850. */
  21851. linkRefractionWithTransparency: boolean;
  21852. /**
  21853. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21854. */
  21855. invertRefractionY: boolean;
  21856. /**
  21857. * Gets or sets the texture associated with the node
  21858. */
  21859. texture: Nullable<BaseTexture>;
  21860. /**
  21861. * Create a new RefractionBlock
  21862. * @param name defines the block name
  21863. */
  21864. constructor(name: string);
  21865. /**
  21866. * Gets the current class name
  21867. * @returns the class name
  21868. */
  21869. getClassName(): string;
  21870. /**
  21871. * Gets the intensity input component
  21872. */
  21873. get intensity(): NodeMaterialConnectionPoint;
  21874. /**
  21875. * Gets the index of refraction input component
  21876. */
  21877. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21878. /**
  21879. * Gets the tint at distance input component
  21880. */
  21881. get tintAtDistance(): NodeMaterialConnectionPoint;
  21882. /**
  21883. * Gets the view input component
  21884. */
  21885. get view(): NodeMaterialConnectionPoint;
  21886. /**
  21887. * Gets the refraction object output component
  21888. */
  21889. get refraction(): NodeMaterialConnectionPoint;
  21890. /**
  21891. * Returns true if the block has a texture
  21892. */
  21893. get hasTexture(): boolean;
  21894. protected _getTexture(): Nullable<BaseTexture>;
  21895. autoConfigure(material: NodeMaterial): void;
  21896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21897. isReady(): boolean;
  21898. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21899. /**
  21900. * Gets the main code of the block (fragment side)
  21901. * @param state current state of the node material building
  21902. * @returns the shader code
  21903. */
  21904. getCode(state: NodeMaterialBuildState): string;
  21905. protected _buildBlock(state: NodeMaterialBuildState): this;
  21906. protected _dumpPropertiesCode(): string;
  21907. serialize(): any;
  21908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21909. }
  21910. }
  21911. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21914. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21917. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21919. import { Nullable } from "babylonjs/types";
  21920. import { Scene } from "babylonjs/scene";
  21921. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21922. /**
  21923. * Base block used as input for post process
  21924. */
  21925. export class CurrentScreenBlock extends NodeMaterialBlock {
  21926. private _samplerName;
  21927. private _linearDefineName;
  21928. private _gammaDefineName;
  21929. private _mainUVName;
  21930. private _tempTextureRead;
  21931. /**
  21932. * Gets or sets the texture associated with the node
  21933. */
  21934. texture: Nullable<BaseTexture>;
  21935. /**
  21936. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21937. */
  21938. convertToGammaSpace: boolean;
  21939. /**
  21940. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21941. */
  21942. convertToLinearSpace: boolean;
  21943. /**
  21944. * Create a new CurrentScreenBlock
  21945. * @param name defines the block name
  21946. */
  21947. constructor(name: string);
  21948. /**
  21949. * Gets the current class name
  21950. * @returns the class name
  21951. */
  21952. getClassName(): string;
  21953. /**
  21954. * Gets the uv input component
  21955. */
  21956. get uv(): NodeMaterialConnectionPoint;
  21957. /**
  21958. * Gets the rgba output component
  21959. */
  21960. get rgba(): NodeMaterialConnectionPoint;
  21961. /**
  21962. * Gets the rgb output component
  21963. */
  21964. get rgb(): NodeMaterialConnectionPoint;
  21965. /**
  21966. * Gets the r output component
  21967. */
  21968. get r(): NodeMaterialConnectionPoint;
  21969. /**
  21970. * Gets the g output component
  21971. */
  21972. get g(): NodeMaterialConnectionPoint;
  21973. /**
  21974. * Gets the b output component
  21975. */
  21976. get b(): NodeMaterialConnectionPoint;
  21977. /**
  21978. * Gets the a output component
  21979. */
  21980. get a(): NodeMaterialConnectionPoint;
  21981. /**
  21982. * Initialize the block and prepare the context for build
  21983. * @param state defines the state that will be used for the build
  21984. */
  21985. initialize(state: NodeMaterialBuildState): void;
  21986. get target(): NodeMaterialBlockTargets;
  21987. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21988. isReady(): boolean;
  21989. private _injectVertexCode;
  21990. private _writeTextureRead;
  21991. private _writeOutput;
  21992. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21993. serialize(): any;
  21994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21995. }
  21996. }
  21997. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22002. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22004. import { Nullable } from "babylonjs/types";
  22005. import { Scene } from "babylonjs/scene";
  22006. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22007. /**
  22008. * Base block used for the particle texture
  22009. */
  22010. export class ParticleTextureBlock extends NodeMaterialBlock {
  22011. private _samplerName;
  22012. private _linearDefineName;
  22013. private _gammaDefineName;
  22014. private _tempTextureRead;
  22015. /**
  22016. * Gets or sets the texture associated with the node
  22017. */
  22018. texture: Nullable<BaseTexture>;
  22019. /**
  22020. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22021. */
  22022. convertToGammaSpace: boolean;
  22023. /**
  22024. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22025. */
  22026. convertToLinearSpace: boolean;
  22027. /**
  22028. * Create a new ParticleTextureBlock
  22029. * @param name defines the block name
  22030. */
  22031. constructor(name: string);
  22032. /**
  22033. * Gets the current class name
  22034. * @returns the class name
  22035. */
  22036. getClassName(): string;
  22037. /**
  22038. * Gets the uv input component
  22039. */
  22040. get uv(): NodeMaterialConnectionPoint;
  22041. /**
  22042. * Gets the rgba output component
  22043. */
  22044. get rgba(): NodeMaterialConnectionPoint;
  22045. /**
  22046. * Gets the rgb output component
  22047. */
  22048. get rgb(): NodeMaterialConnectionPoint;
  22049. /**
  22050. * Gets the r output component
  22051. */
  22052. get r(): NodeMaterialConnectionPoint;
  22053. /**
  22054. * Gets the g output component
  22055. */
  22056. get g(): NodeMaterialConnectionPoint;
  22057. /**
  22058. * Gets the b output component
  22059. */
  22060. get b(): NodeMaterialConnectionPoint;
  22061. /**
  22062. * Gets the a output component
  22063. */
  22064. get a(): NodeMaterialConnectionPoint;
  22065. /**
  22066. * Initialize the block and prepare the context for build
  22067. * @param state defines the state that will be used for the build
  22068. */
  22069. initialize(state: NodeMaterialBuildState): void;
  22070. autoConfigure(material: NodeMaterial): void;
  22071. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22072. isReady(): boolean;
  22073. private _writeOutput;
  22074. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22075. serialize(): any;
  22076. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22077. }
  22078. }
  22079. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22080. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22082. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22083. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22084. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22085. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22086. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22087. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22088. import { Scene } from "babylonjs/scene";
  22089. /**
  22090. * Class used to store shared data between 2 NodeMaterialBuildState
  22091. */
  22092. export class NodeMaterialBuildStateSharedData {
  22093. /**
  22094. * Gets the list of emitted varyings
  22095. */
  22096. temps: string[];
  22097. /**
  22098. * Gets the list of emitted varyings
  22099. */
  22100. varyings: string[];
  22101. /**
  22102. * Gets the varying declaration string
  22103. */
  22104. varyingDeclaration: string;
  22105. /**
  22106. * Input blocks
  22107. */
  22108. inputBlocks: InputBlock[];
  22109. /**
  22110. * Input blocks
  22111. */
  22112. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22113. /**
  22114. * Bindable blocks (Blocks that need to set data to the effect)
  22115. */
  22116. bindableBlocks: NodeMaterialBlock[];
  22117. /**
  22118. * List of blocks that can provide a compilation fallback
  22119. */
  22120. blocksWithFallbacks: NodeMaterialBlock[];
  22121. /**
  22122. * List of blocks that can provide a define update
  22123. */
  22124. blocksWithDefines: NodeMaterialBlock[];
  22125. /**
  22126. * List of blocks that can provide a repeatable content
  22127. */
  22128. repeatableContentBlocks: NodeMaterialBlock[];
  22129. /**
  22130. * List of blocks that can provide a dynamic list of uniforms
  22131. */
  22132. dynamicUniformBlocks: NodeMaterialBlock[];
  22133. /**
  22134. * List of blocks that can block the isReady function for the material
  22135. */
  22136. blockingBlocks: NodeMaterialBlock[];
  22137. /**
  22138. * Gets the list of animated inputs
  22139. */
  22140. animatedInputs: InputBlock[];
  22141. /**
  22142. * Build Id used to avoid multiple recompilations
  22143. */
  22144. buildId: number;
  22145. /** List of emitted variables */
  22146. variableNames: {
  22147. [key: string]: number;
  22148. };
  22149. /** List of emitted defines */
  22150. defineNames: {
  22151. [key: string]: number;
  22152. };
  22153. /** Should emit comments? */
  22154. emitComments: boolean;
  22155. /** Emit build activity */
  22156. verbose: boolean;
  22157. /** Gets or sets the hosting scene */
  22158. scene: Scene;
  22159. /**
  22160. * Gets the compilation hints emitted at compilation time
  22161. */
  22162. hints: {
  22163. needWorldViewMatrix: boolean;
  22164. needWorldViewProjectionMatrix: boolean;
  22165. needAlphaBlending: boolean;
  22166. needAlphaTesting: boolean;
  22167. };
  22168. /**
  22169. * List of compilation checks
  22170. */
  22171. checks: {
  22172. emitVertex: boolean;
  22173. emitFragment: boolean;
  22174. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22175. };
  22176. /**
  22177. * Is vertex program allowed to be empty?
  22178. */
  22179. allowEmptyVertexProgram: boolean;
  22180. /** Creates a new shared data */
  22181. constructor();
  22182. /**
  22183. * Emits console errors and exceptions if there is a failing check
  22184. */
  22185. emitErrors(): void;
  22186. }
  22187. }
  22188. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22189. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22190. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22191. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22192. /**
  22193. * Class used to store node based material build state
  22194. */
  22195. export class NodeMaterialBuildState {
  22196. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22197. supportUniformBuffers: boolean;
  22198. /**
  22199. * Gets the list of emitted attributes
  22200. */
  22201. attributes: string[];
  22202. /**
  22203. * Gets the list of emitted uniforms
  22204. */
  22205. uniforms: string[];
  22206. /**
  22207. * Gets the list of emitted constants
  22208. */
  22209. constants: string[];
  22210. /**
  22211. * Gets the list of emitted samplers
  22212. */
  22213. samplers: string[];
  22214. /**
  22215. * Gets the list of emitted functions
  22216. */
  22217. functions: {
  22218. [key: string]: string;
  22219. };
  22220. /**
  22221. * Gets the list of emitted extensions
  22222. */
  22223. extensions: {
  22224. [key: string]: string;
  22225. };
  22226. /**
  22227. * Gets the target of the compilation state
  22228. */
  22229. target: NodeMaterialBlockTargets;
  22230. /**
  22231. * Gets the list of emitted counters
  22232. */
  22233. counters: {
  22234. [key: string]: number;
  22235. };
  22236. /**
  22237. * Shared data between multiple NodeMaterialBuildState instances
  22238. */
  22239. sharedData: NodeMaterialBuildStateSharedData;
  22240. /** @hidden */
  22241. _vertexState: NodeMaterialBuildState;
  22242. /** @hidden */
  22243. _attributeDeclaration: string;
  22244. /** @hidden */
  22245. _uniformDeclaration: string;
  22246. /** @hidden */
  22247. _constantDeclaration: string;
  22248. /** @hidden */
  22249. _samplerDeclaration: string;
  22250. /** @hidden */
  22251. _varyingTransfer: string;
  22252. /** @hidden */
  22253. _injectAtEnd: string;
  22254. private _repeatableContentAnchorIndex;
  22255. /** @hidden */
  22256. _builtCompilationString: string;
  22257. /**
  22258. * Gets the emitted compilation strings
  22259. */
  22260. compilationString: string;
  22261. /**
  22262. * Finalize the compilation strings
  22263. * @param state defines the current compilation state
  22264. */
  22265. finalize(state: NodeMaterialBuildState): void;
  22266. /** @hidden */
  22267. get _repeatableContentAnchor(): string;
  22268. /** @hidden */
  22269. _getFreeVariableName(prefix: string): string;
  22270. /** @hidden */
  22271. _getFreeDefineName(prefix: string): string;
  22272. /** @hidden */
  22273. _excludeVariableName(name: string): void;
  22274. /** @hidden */
  22275. _emit2DSampler(name: string): void;
  22276. /** @hidden */
  22277. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22278. /** @hidden */
  22279. _emitExtension(name: string, extension: string, define?: string): void;
  22280. /** @hidden */
  22281. _emitFunction(name: string, code: string, comments: string): void;
  22282. /** @hidden */
  22283. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22284. replaceStrings?: {
  22285. search: RegExp;
  22286. replace: string;
  22287. }[];
  22288. repeatKey?: string;
  22289. }): string;
  22290. /** @hidden */
  22291. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22292. repeatKey?: string;
  22293. removeAttributes?: boolean;
  22294. removeUniforms?: boolean;
  22295. removeVaryings?: boolean;
  22296. removeIfDef?: boolean;
  22297. replaceStrings?: {
  22298. search: RegExp;
  22299. replace: string;
  22300. }[];
  22301. }, storeKey?: string): void;
  22302. /** @hidden */
  22303. _registerTempVariable(name: string): boolean;
  22304. /** @hidden */
  22305. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22306. /** @hidden */
  22307. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22308. /** @hidden */
  22309. _emitFloat(value: number): string;
  22310. }
  22311. }
  22312. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22313. /**
  22314. * Helper class used to generate session unique ID
  22315. */
  22316. export class UniqueIdGenerator {
  22317. private static _UniqueIdCounter;
  22318. /**
  22319. * Gets an unique (relatively to the current scene) Id
  22320. */
  22321. static get UniqueId(): number;
  22322. }
  22323. }
  22324. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22325. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22326. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22327. import { Nullable } from "babylonjs/types";
  22328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22329. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22330. import { Effect } from "babylonjs/Materials/effect";
  22331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22332. import { Mesh } from "babylonjs/Meshes/mesh";
  22333. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22334. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22335. import { Scene } from "babylonjs/scene";
  22336. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22337. /**
  22338. * Defines a block that can be used inside a node based material
  22339. */
  22340. export class NodeMaterialBlock {
  22341. private _buildId;
  22342. private _buildTarget;
  22343. private _target;
  22344. private _isFinalMerger;
  22345. private _isInput;
  22346. private _name;
  22347. protected _isUnique: boolean;
  22348. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22349. inputsAreExclusive: boolean;
  22350. /** @hidden */
  22351. _codeVariableName: string;
  22352. /** @hidden */
  22353. _inputs: NodeMaterialConnectionPoint[];
  22354. /** @hidden */
  22355. _outputs: NodeMaterialConnectionPoint[];
  22356. /** @hidden */
  22357. _preparationId: number;
  22358. /**
  22359. * Gets the name of the block
  22360. */
  22361. get name(): string;
  22362. /**
  22363. * Sets the name of the block. Will check if the name is valid.
  22364. */
  22365. set name(newName: string);
  22366. /**
  22367. * Gets or sets the unique id of the node
  22368. */
  22369. uniqueId: number;
  22370. /**
  22371. * Gets or sets the comments associated with this block
  22372. */
  22373. comments: string;
  22374. /**
  22375. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22376. */
  22377. get isUnique(): boolean;
  22378. /**
  22379. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22380. */
  22381. get isFinalMerger(): boolean;
  22382. /**
  22383. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22384. */
  22385. get isInput(): boolean;
  22386. /**
  22387. * Gets or sets the build Id
  22388. */
  22389. get buildId(): number;
  22390. set buildId(value: number);
  22391. /**
  22392. * Gets or sets the target of the block
  22393. */
  22394. get target(): NodeMaterialBlockTargets;
  22395. set target(value: NodeMaterialBlockTargets);
  22396. /**
  22397. * Gets the list of input points
  22398. */
  22399. get inputs(): NodeMaterialConnectionPoint[];
  22400. /** Gets the list of output points */
  22401. get outputs(): NodeMaterialConnectionPoint[];
  22402. /**
  22403. * Find an input by its name
  22404. * @param name defines the name of the input to look for
  22405. * @returns the input or null if not found
  22406. */
  22407. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22408. /**
  22409. * Find an output by its name
  22410. * @param name defines the name of the outputto look for
  22411. * @returns the output or null if not found
  22412. */
  22413. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22414. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22415. visibleInInspector: boolean;
  22416. /**
  22417. * Creates a new NodeMaterialBlock
  22418. * @param name defines the block name
  22419. * @param target defines the target of that block (Vertex by default)
  22420. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22421. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22422. */
  22423. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22424. /**
  22425. * Initialize the block and prepare the context for build
  22426. * @param state defines the state that will be used for the build
  22427. */
  22428. initialize(state: NodeMaterialBuildState): void;
  22429. /**
  22430. * Bind data to effect. Will only be called for blocks with isBindable === true
  22431. * @param effect defines the effect to bind data to
  22432. * @param nodeMaterial defines the hosting NodeMaterial
  22433. * @param mesh defines the mesh that will be rendered
  22434. * @param subMesh defines the submesh that will be rendered
  22435. */
  22436. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22437. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22438. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22439. protected _writeFloat(value: number): string;
  22440. /**
  22441. * Gets the current class name e.g. "NodeMaterialBlock"
  22442. * @returns the class name
  22443. */
  22444. getClassName(): string;
  22445. /**
  22446. * Register a new input. Must be called inside a block constructor
  22447. * @param name defines the connection point name
  22448. * @param type defines the connection point type
  22449. * @param isOptional defines a boolean indicating that this input can be omitted
  22450. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22451. * @param point an already created connection point. If not provided, create a new one
  22452. * @returns the current block
  22453. */
  22454. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22455. /**
  22456. * Register a new output. Must be called inside a block constructor
  22457. * @param name defines the connection point name
  22458. * @param type defines the connection point type
  22459. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22460. * @param point an already created connection point. If not provided, create a new one
  22461. * @returns the current block
  22462. */
  22463. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22464. /**
  22465. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22466. * @param forOutput defines an optional connection point to check compatibility with
  22467. * @returns the first available input or null
  22468. */
  22469. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22470. /**
  22471. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22472. * @param forBlock defines an optional block to check compatibility with
  22473. * @returns the first available input or null
  22474. */
  22475. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22476. /**
  22477. * Gets the sibling of the given output
  22478. * @param current defines the current output
  22479. * @returns the next output in the list or null
  22480. */
  22481. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22482. /**
  22483. * Connect current block with another block
  22484. * @param other defines the block to connect with
  22485. * @param options define the various options to help pick the right connections
  22486. * @returns the current block
  22487. */
  22488. connectTo(other: NodeMaterialBlock, options?: {
  22489. input?: string;
  22490. output?: string;
  22491. outputSwizzle?: string;
  22492. }): this | undefined;
  22493. protected _buildBlock(state: NodeMaterialBuildState): void;
  22494. /**
  22495. * Add uniforms, samplers and uniform buffers at compilation time
  22496. * @param state defines the state to update
  22497. * @param nodeMaterial defines the node material requesting the update
  22498. * @param defines defines the material defines to update
  22499. * @param uniformBuffers defines the list of uniform buffer names
  22500. */
  22501. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22502. /**
  22503. * Add potential fallbacks if shader compilation fails
  22504. * @param mesh defines the mesh to be rendered
  22505. * @param fallbacks defines the current prioritized list of fallbacks
  22506. */
  22507. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22508. /**
  22509. * Initialize defines for shader compilation
  22510. * @param mesh defines the mesh to be rendered
  22511. * @param nodeMaterial defines the node material requesting the update
  22512. * @param defines defines the material defines to update
  22513. * @param useInstances specifies that instances should be used
  22514. */
  22515. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22516. /**
  22517. * Update defines for shader compilation
  22518. * @param mesh defines the mesh to be rendered
  22519. * @param nodeMaterial defines the node material requesting the update
  22520. * @param defines defines the material defines to update
  22521. * @param useInstances specifies that instances should be used
  22522. * @param subMesh defines which submesh to render
  22523. */
  22524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22525. /**
  22526. * Lets the block try to connect some inputs automatically
  22527. * @param material defines the hosting NodeMaterial
  22528. */
  22529. autoConfigure(material: NodeMaterial): void;
  22530. /**
  22531. * Function called when a block is declared as repeatable content generator
  22532. * @param vertexShaderState defines the current compilation state for the vertex shader
  22533. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22534. * @param mesh defines the mesh to be rendered
  22535. * @param defines defines the material defines to update
  22536. */
  22537. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22538. /**
  22539. * Checks if the block is ready
  22540. * @param mesh defines the mesh to be rendered
  22541. * @param nodeMaterial defines the node material requesting the update
  22542. * @param defines defines the material defines to update
  22543. * @param useInstances specifies that instances should be used
  22544. * @returns true if the block is ready
  22545. */
  22546. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22547. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22548. private _processBuild;
  22549. /**
  22550. * Validates the new name for the block node.
  22551. * @param newName the new name to be given to the node.
  22552. * @returns false if the name is a reserve word, else true.
  22553. */
  22554. validateBlockName(newName: string): boolean;
  22555. /**
  22556. * Compile the current node and generate the shader code
  22557. * @param state defines the current compilation state (uniforms, samplers, current string)
  22558. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22559. * @returns true if already built
  22560. */
  22561. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22562. protected _inputRename(name: string): string;
  22563. protected _outputRename(name: string): string;
  22564. protected _dumpPropertiesCode(): string;
  22565. /** @hidden */
  22566. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22567. /** @hidden */
  22568. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22569. /**
  22570. * Clone the current block to a new identical block
  22571. * @param scene defines the hosting scene
  22572. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22573. * @returns a copy of the current block
  22574. */
  22575. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22576. /**
  22577. * Serializes this block in a JSON representation
  22578. * @returns the serialized block object
  22579. */
  22580. serialize(): any;
  22581. /** @hidden */
  22582. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22583. private _deserializePortDisplayNamesAndExposedOnFrame;
  22584. /**
  22585. * Release resources
  22586. */
  22587. dispose(): void;
  22588. }
  22589. }
  22590. declare module "babylonjs/Materials/pushMaterial" {
  22591. import { Nullable } from "babylonjs/types";
  22592. import { Scene } from "babylonjs/scene";
  22593. import { Matrix } from "babylonjs/Maths/math.vector";
  22594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22595. import { Mesh } from "babylonjs/Meshes/mesh";
  22596. import { Material } from "babylonjs/Materials/material";
  22597. import { Effect } from "babylonjs/Materials/effect";
  22598. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22599. /**
  22600. * Base class of materials working in push mode in babylon JS
  22601. * @hidden
  22602. */
  22603. export class PushMaterial extends Material {
  22604. protected _activeEffect: Effect;
  22605. protected _normalMatrix: Matrix;
  22606. constructor(name: string, scene: Scene);
  22607. getEffect(): Effect;
  22608. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22609. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22610. /**
  22611. * Binds the given world matrix to the active effect
  22612. *
  22613. * @param world the matrix to bind
  22614. */
  22615. bindOnlyWorldMatrix(world: Matrix): void;
  22616. /**
  22617. * Binds the given normal matrix to the active effect
  22618. *
  22619. * @param normalMatrix the matrix to bind
  22620. */
  22621. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22622. bind(world: Matrix, mesh?: Mesh): void;
  22623. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22624. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22625. }
  22626. }
  22627. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22629. /**
  22630. * Root class for all node material optimizers
  22631. */
  22632. export class NodeMaterialOptimizer {
  22633. /**
  22634. * Function used to optimize a NodeMaterial graph
  22635. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22636. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22637. */
  22638. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22639. }
  22640. }
  22641. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22645. import { Scene } from "babylonjs/scene";
  22646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22647. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22648. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22649. /**
  22650. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22651. */
  22652. export class TransformBlock extends NodeMaterialBlock {
  22653. /**
  22654. * Defines the value to use to complement W value to transform it to a Vector4
  22655. */
  22656. complementW: number;
  22657. /**
  22658. * Defines the value to use to complement z value to transform it to a Vector4
  22659. */
  22660. complementZ: number;
  22661. /**
  22662. * Creates a new TransformBlock
  22663. * @param name defines the block name
  22664. */
  22665. constructor(name: string);
  22666. /**
  22667. * Gets the current class name
  22668. * @returns the class name
  22669. */
  22670. getClassName(): string;
  22671. /**
  22672. * Gets the vector input
  22673. */
  22674. get vector(): NodeMaterialConnectionPoint;
  22675. /**
  22676. * Gets the output component
  22677. */
  22678. get output(): NodeMaterialConnectionPoint;
  22679. /**
  22680. * Gets the xyz output component
  22681. */
  22682. get xyz(): NodeMaterialConnectionPoint;
  22683. /**
  22684. * Gets the matrix transform input
  22685. */
  22686. get transform(): NodeMaterialConnectionPoint;
  22687. protected _buildBlock(state: NodeMaterialBuildState): this;
  22688. /**
  22689. * Update defines for shader compilation
  22690. * @param mesh defines the mesh to be rendered
  22691. * @param nodeMaterial defines the node material requesting the update
  22692. * @param defines defines the material defines to update
  22693. * @param useInstances specifies that instances should be used
  22694. * @param subMesh defines which submesh to render
  22695. */
  22696. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22697. serialize(): any;
  22698. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22699. protected _dumpPropertiesCode(): string;
  22700. }
  22701. }
  22702. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22706. /**
  22707. * Block used to output the vertex position
  22708. */
  22709. export class VertexOutputBlock extends NodeMaterialBlock {
  22710. /**
  22711. * Creates a new VertexOutputBlock
  22712. * @param name defines the block name
  22713. */
  22714. constructor(name: string);
  22715. /**
  22716. * Gets the current class name
  22717. * @returns the class name
  22718. */
  22719. getClassName(): string;
  22720. /**
  22721. * Gets the vector input component
  22722. */
  22723. get vector(): NodeMaterialConnectionPoint;
  22724. protected _buildBlock(state: NodeMaterialBuildState): this;
  22725. }
  22726. }
  22727. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22730. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22731. /**
  22732. * Block used to output the final color
  22733. */
  22734. export class FragmentOutputBlock extends NodeMaterialBlock {
  22735. /**
  22736. * Create a new FragmentOutputBlock
  22737. * @param name defines the block name
  22738. */
  22739. constructor(name: string);
  22740. /**
  22741. * Gets the current class name
  22742. * @returns the class name
  22743. */
  22744. getClassName(): string;
  22745. /**
  22746. * Gets the rgba input component
  22747. */
  22748. get rgba(): NodeMaterialConnectionPoint;
  22749. /**
  22750. * Gets the rgb input component
  22751. */
  22752. get rgb(): NodeMaterialConnectionPoint;
  22753. /**
  22754. * Gets the a input component
  22755. */
  22756. get a(): NodeMaterialConnectionPoint;
  22757. protected _buildBlock(state: NodeMaterialBuildState): this;
  22758. }
  22759. }
  22760. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22764. /**
  22765. * Block used for the particle ramp gradient section
  22766. */
  22767. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22768. /**
  22769. * Create a new ParticleRampGradientBlock
  22770. * @param name defines the block name
  22771. */
  22772. constructor(name: string);
  22773. /**
  22774. * Gets the current class name
  22775. * @returns the class name
  22776. */
  22777. getClassName(): string;
  22778. /**
  22779. * Gets the color input component
  22780. */
  22781. get color(): NodeMaterialConnectionPoint;
  22782. /**
  22783. * Gets the rampColor output component
  22784. */
  22785. get rampColor(): NodeMaterialConnectionPoint;
  22786. /**
  22787. * Initialize the block and prepare the context for build
  22788. * @param state defines the state that will be used for the build
  22789. */
  22790. initialize(state: NodeMaterialBuildState): void;
  22791. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22792. }
  22793. }
  22794. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22798. /**
  22799. * Block used for the particle blend multiply section
  22800. */
  22801. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22802. /**
  22803. * Create a new ParticleBlendMultiplyBlock
  22804. * @param name defines the block name
  22805. */
  22806. constructor(name: string);
  22807. /**
  22808. * Gets the current class name
  22809. * @returns the class name
  22810. */
  22811. getClassName(): string;
  22812. /**
  22813. * Gets the color input component
  22814. */
  22815. get color(): NodeMaterialConnectionPoint;
  22816. /**
  22817. * Gets the alphaTexture input component
  22818. */
  22819. get alphaTexture(): NodeMaterialConnectionPoint;
  22820. /**
  22821. * Gets the alphaColor input component
  22822. */
  22823. get alphaColor(): NodeMaterialConnectionPoint;
  22824. /**
  22825. * Gets the blendColor output component
  22826. */
  22827. get blendColor(): NodeMaterialConnectionPoint;
  22828. /**
  22829. * Initialize the block and prepare the context for build
  22830. * @param state defines the state that will be used for the build
  22831. */
  22832. initialize(state: NodeMaterialBuildState): void;
  22833. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22834. }
  22835. }
  22836. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22840. /**
  22841. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22842. */
  22843. export class VectorMergerBlock extends NodeMaterialBlock {
  22844. /**
  22845. * Create a new VectorMergerBlock
  22846. * @param name defines the block name
  22847. */
  22848. constructor(name: string);
  22849. /**
  22850. * Gets the current class name
  22851. * @returns the class name
  22852. */
  22853. getClassName(): string;
  22854. /**
  22855. * Gets the xyz component (input)
  22856. */
  22857. get xyzIn(): NodeMaterialConnectionPoint;
  22858. /**
  22859. * Gets the xy component (input)
  22860. */
  22861. get xyIn(): NodeMaterialConnectionPoint;
  22862. /**
  22863. * Gets the x component (input)
  22864. */
  22865. get x(): NodeMaterialConnectionPoint;
  22866. /**
  22867. * Gets the y component (input)
  22868. */
  22869. get y(): NodeMaterialConnectionPoint;
  22870. /**
  22871. * Gets the z component (input)
  22872. */
  22873. get z(): NodeMaterialConnectionPoint;
  22874. /**
  22875. * Gets the w component (input)
  22876. */
  22877. get w(): NodeMaterialConnectionPoint;
  22878. /**
  22879. * Gets the xyzw component (output)
  22880. */
  22881. get xyzw(): NodeMaterialConnectionPoint;
  22882. /**
  22883. * Gets the xyz component (output)
  22884. */
  22885. get xyzOut(): NodeMaterialConnectionPoint;
  22886. /**
  22887. * Gets the xy component (output)
  22888. */
  22889. get xyOut(): NodeMaterialConnectionPoint;
  22890. /**
  22891. * Gets the xy component (output)
  22892. * @deprecated Please use xyOut instead.
  22893. */
  22894. get xy(): NodeMaterialConnectionPoint;
  22895. /**
  22896. * Gets the xyz component (output)
  22897. * @deprecated Please use xyzOut instead.
  22898. */
  22899. get xyz(): NodeMaterialConnectionPoint;
  22900. protected _buildBlock(state: NodeMaterialBuildState): this;
  22901. }
  22902. }
  22903. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22904. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22905. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22906. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22907. import { Vector2 } from "babylonjs/Maths/math.vector";
  22908. import { Scene } from "babylonjs/scene";
  22909. /**
  22910. * Block used to remap a float from a range to a new one
  22911. */
  22912. export class RemapBlock extends NodeMaterialBlock {
  22913. /**
  22914. * Gets or sets the source range
  22915. */
  22916. sourceRange: Vector2;
  22917. /**
  22918. * Gets or sets the target range
  22919. */
  22920. targetRange: Vector2;
  22921. /**
  22922. * Creates a new RemapBlock
  22923. * @param name defines the block name
  22924. */
  22925. constructor(name: string);
  22926. /**
  22927. * Gets the current class name
  22928. * @returns the class name
  22929. */
  22930. getClassName(): string;
  22931. /**
  22932. * Gets the input component
  22933. */
  22934. get input(): NodeMaterialConnectionPoint;
  22935. /**
  22936. * Gets the source min input component
  22937. */
  22938. get sourceMin(): NodeMaterialConnectionPoint;
  22939. /**
  22940. * Gets the source max input component
  22941. */
  22942. get sourceMax(): NodeMaterialConnectionPoint;
  22943. /**
  22944. * Gets the target min input component
  22945. */
  22946. get targetMin(): NodeMaterialConnectionPoint;
  22947. /**
  22948. * Gets the target max input component
  22949. */
  22950. get targetMax(): NodeMaterialConnectionPoint;
  22951. /**
  22952. * Gets the output component
  22953. */
  22954. get output(): NodeMaterialConnectionPoint;
  22955. protected _buildBlock(state: NodeMaterialBuildState): this;
  22956. protected _dumpPropertiesCode(): string;
  22957. serialize(): any;
  22958. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22959. }
  22960. }
  22961. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22963. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22964. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22965. /**
  22966. * Block used to multiply 2 values
  22967. */
  22968. export class MultiplyBlock extends NodeMaterialBlock {
  22969. /**
  22970. * Creates a new MultiplyBlock
  22971. * @param name defines the block name
  22972. */
  22973. constructor(name: string);
  22974. /**
  22975. * Gets the current class name
  22976. * @returns the class name
  22977. */
  22978. getClassName(): string;
  22979. /**
  22980. * Gets the left operand input component
  22981. */
  22982. get left(): NodeMaterialConnectionPoint;
  22983. /**
  22984. * Gets the right operand input component
  22985. */
  22986. get right(): NodeMaterialConnectionPoint;
  22987. /**
  22988. * Gets the output component
  22989. */
  22990. get output(): NodeMaterialConnectionPoint;
  22991. protected _buildBlock(state: NodeMaterialBuildState): this;
  22992. }
  22993. }
  22994. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22998. /**
  22999. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23000. */
  23001. export class ColorSplitterBlock extends NodeMaterialBlock {
  23002. /**
  23003. * Create a new ColorSplitterBlock
  23004. * @param name defines the block name
  23005. */
  23006. constructor(name: string);
  23007. /**
  23008. * Gets the current class name
  23009. * @returns the class name
  23010. */
  23011. getClassName(): string;
  23012. /**
  23013. * Gets the rgba component (input)
  23014. */
  23015. get rgba(): NodeMaterialConnectionPoint;
  23016. /**
  23017. * Gets the rgb component (input)
  23018. */
  23019. get rgbIn(): NodeMaterialConnectionPoint;
  23020. /**
  23021. * Gets the rgb component (output)
  23022. */
  23023. get rgbOut(): NodeMaterialConnectionPoint;
  23024. /**
  23025. * Gets the r component (output)
  23026. */
  23027. get r(): NodeMaterialConnectionPoint;
  23028. /**
  23029. * Gets the g component (output)
  23030. */
  23031. get g(): NodeMaterialConnectionPoint;
  23032. /**
  23033. * Gets the b component (output)
  23034. */
  23035. get b(): NodeMaterialConnectionPoint;
  23036. /**
  23037. * Gets the a component (output)
  23038. */
  23039. get a(): NodeMaterialConnectionPoint;
  23040. protected _inputRename(name: string): string;
  23041. protected _outputRename(name: string): string;
  23042. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23043. }
  23044. }
  23045. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23049. import { Scene } from "babylonjs/scene";
  23050. /**
  23051. * Operations supported by the Trigonometry block
  23052. */
  23053. export enum TrigonometryBlockOperations {
  23054. /** Cos */
  23055. Cos = 0,
  23056. /** Sin */
  23057. Sin = 1,
  23058. /** Abs */
  23059. Abs = 2,
  23060. /** Exp */
  23061. Exp = 3,
  23062. /** Exp2 */
  23063. Exp2 = 4,
  23064. /** Round */
  23065. Round = 5,
  23066. /** Floor */
  23067. Floor = 6,
  23068. /** Ceiling */
  23069. Ceiling = 7,
  23070. /** Square root */
  23071. Sqrt = 8,
  23072. /** Log */
  23073. Log = 9,
  23074. /** Tangent */
  23075. Tan = 10,
  23076. /** Arc tangent */
  23077. ArcTan = 11,
  23078. /** Arc cosinus */
  23079. ArcCos = 12,
  23080. /** Arc sinus */
  23081. ArcSin = 13,
  23082. /** Fraction */
  23083. Fract = 14,
  23084. /** Sign */
  23085. Sign = 15,
  23086. /** To radians (from degrees) */
  23087. Radians = 16,
  23088. /** To degrees (from radians) */
  23089. Degrees = 17
  23090. }
  23091. /**
  23092. * Block used to apply trigonometry operation to floats
  23093. */
  23094. export class TrigonometryBlock extends NodeMaterialBlock {
  23095. /**
  23096. * Gets or sets the operation applied by the block
  23097. */
  23098. operation: TrigonometryBlockOperations;
  23099. /**
  23100. * Creates a new TrigonometryBlock
  23101. * @param name defines the block name
  23102. */
  23103. constructor(name: string);
  23104. /**
  23105. * Gets the current class name
  23106. * @returns the class name
  23107. */
  23108. getClassName(): string;
  23109. /**
  23110. * Gets the input component
  23111. */
  23112. get input(): NodeMaterialConnectionPoint;
  23113. /**
  23114. * Gets the output component
  23115. */
  23116. get output(): NodeMaterialConnectionPoint;
  23117. protected _buildBlock(state: NodeMaterialBuildState): this;
  23118. serialize(): any;
  23119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23120. protected _dumpPropertiesCode(): string;
  23121. }
  23122. }
  23123. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23125. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23126. import { Scene } from "babylonjs/scene";
  23127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23128. import { Matrix } from "babylonjs/Maths/math.vector";
  23129. import { Mesh } from "babylonjs/Meshes/mesh";
  23130. import { Engine } from "babylonjs/Engines/engine";
  23131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23132. import { Observable } from "babylonjs/Misc/observable";
  23133. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23134. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23135. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23136. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23137. import { Nullable } from "babylonjs/types";
  23138. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23139. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23140. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23141. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23142. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23143. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23144. import { Effect } from "babylonjs/Materials/effect";
  23145. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23146. import { Camera } from "babylonjs/Cameras/camera";
  23147. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23148. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23149. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23150. /**
  23151. * Interface used to configure the node material editor
  23152. */
  23153. export interface INodeMaterialEditorOptions {
  23154. /** Define the URl to load node editor script */
  23155. editorURL?: string;
  23156. }
  23157. /** @hidden */
  23158. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23159. NORMAL: boolean;
  23160. TANGENT: boolean;
  23161. UV1: boolean;
  23162. /** BONES */
  23163. NUM_BONE_INFLUENCERS: number;
  23164. BonesPerMesh: number;
  23165. BONETEXTURE: boolean;
  23166. /** MORPH TARGETS */
  23167. MORPHTARGETS: boolean;
  23168. MORPHTARGETS_NORMAL: boolean;
  23169. MORPHTARGETS_TANGENT: boolean;
  23170. MORPHTARGETS_UV: boolean;
  23171. NUM_MORPH_INFLUENCERS: number;
  23172. /** IMAGE PROCESSING */
  23173. IMAGEPROCESSING: boolean;
  23174. VIGNETTE: boolean;
  23175. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23176. VIGNETTEBLENDMODEOPAQUE: boolean;
  23177. TONEMAPPING: boolean;
  23178. TONEMAPPING_ACES: boolean;
  23179. CONTRAST: boolean;
  23180. EXPOSURE: boolean;
  23181. COLORCURVES: boolean;
  23182. COLORGRADING: boolean;
  23183. COLORGRADING3D: boolean;
  23184. SAMPLER3DGREENDEPTH: boolean;
  23185. SAMPLER3DBGRMAP: boolean;
  23186. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23187. /** MISC. */
  23188. BUMPDIRECTUV: number;
  23189. constructor();
  23190. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23191. }
  23192. /**
  23193. * Class used to configure NodeMaterial
  23194. */
  23195. export interface INodeMaterialOptions {
  23196. /**
  23197. * Defines if blocks should emit comments
  23198. */
  23199. emitComments: boolean;
  23200. }
  23201. /**
  23202. * Class used to create a node based material built by assembling shader blocks
  23203. */
  23204. export class NodeMaterial extends PushMaterial {
  23205. private static _BuildIdGenerator;
  23206. private _options;
  23207. private _vertexCompilationState;
  23208. private _fragmentCompilationState;
  23209. private _sharedData;
  23210. private _buildId;
  23211. private _buildWasSuccessful;
  23212. private _cachedWorldViewMatrix;
  23213. private _cachedWorldViewProjectionMatrix;
  23214. private _optimizers;
  23215. private _animationFrame;
  23216. /** Define the Url to load node editor script */
  23217. static EditorURL: string;
  23218. /** Define the Url to load snippets */
  23219. static SnippetUrl: string;
  23220. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23221. static IgnoreTexturesAtLoadTime: boolean;
  23222. private BJSNODEMATERIALEDITOR;
  23223. /** Get the inspector from bundle or global */
  23224. private _getGlobalNodeMaterialEditor;
  23225. /**
  23226. * Snippet ID if the material was created from the snippet server
  23227. */
  23228. snippetId: string;
  23229. /**
  23230. * Gets or sets data used by visual editor
  23231. * @see https://nme.babylonjs.com
  23232. */
  23233. editorData: any;
  23234. /**
  23235. * 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)
  23236. */
  23237. ignoreAlpha: boolean;
  23238. /**
  23239. * Defines the maximum number of lights that can be used in the material
  23240. */
  23241. maxSimultaneousLights: number;
  23242. /**
  23243. * Observable raised when the material is built
  23244. */
  23245. onBuildObservable: Observable<NodeMaterial>;
  23246. /**
  23247. * Gets or sets the root nodes of the material vertex shader
  23248. */
  23249. _vertexOutputNodes: NodeMaterialBlock[];
  23250. /**
  23251. * Gets or sets the root nodes of the material fragment (pixel) shader
  23252. */
  23253. _fragmentOutputNodes: NodeMaterialBlock[];
  23254. /** Gets or sets options to control the node material overall behavior */
  23255. get options(): INodeMaterialOptions;
  23256. set options(options: INodeMaterialOptions);
  23257. /**
  23258. * Default configuration related to image processing available in the standard Material.
  23259. */
  23260. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23261. /**
  23262. * Gets the image processing configuration used either in this material.
  23263. */
  23264. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23265. /**
  23266. * Sets the Default image processing configuration used either in the this material.
  23267. *
  23268. * If sets to null, the scene one is in use.
  23269. */
  23270. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23271. /**
  23272. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23273. */
  23274. attachedBlocks: NodeMaterialBlock[];
  23275. /**
  23276. * Specifies the mode of the node material
  23277. * @hidden
  23278. */
  23279. _mode: NodeMaterialModes;
  23280. /**
  23281. * Gets the mode property
  23282. */
  23283. get mode(): NodeMaterialModes;
  23284. /**
  23285. * Create a new node based material
  23286. * @param name defines the material name
  23287. * @param scene defines the hosting scene
  23288. * @param options defines creation option
  23289. */
  23290. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23291. /**
  23292. * Gets the current class name of the material e.g. "NodeMaterial"
  23293. * @returns the class name
  23294. */
  23295. getClassName(): string;
  23296. /**
  23297. * Keep track of the image processing observer to allow dispose and replace.
  23298. */
  23299. private _imageProcessingObserver;
  23300. /**
  23301. * Attaches a new image processing configuration to the Standard Material.
  23302. * @param configuration
  23303. */
  23304. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23305. /**
  23306. * Get a block by its name
  23307. * @param name defines the name of the block to retrieve
  23308. * @returns the required block or null if not found
  23309. */
  23310. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23311. /**
  23312. * Get a block by its name
  23313. * @param predicate defines the predicate used to find the good candidate
  23314. * @returns the required block or null if not found
  23315. */
  23316. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23317. /**
  23318. * Get an input block by its name
  23319. * @param predicate defines the predicate used to find the good candidate
  23320. * @returns the required input block or null if not found
  23321. */
  23322. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23323. /**
  23324. * Gets the list of input blocks attached to this material
  23325. * @returns an array of InputBlocks
  23326. */
  23327. getInputBlocks(): InputBlock[];
  23328. /**
  23329. * Adds a new optimizer to the list of optimizers
  23330. * @param optimizer defines the optimizers to add
  23331. * @returns the current material
  23332. */
  23333. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23334. /**
  23335. * Remove an optimizer from the list of optimizers
  23336. * @param optimizer defines the optimizers to remove
  23337. * @returns the current material
  23338. */
  23339. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23340. /**
  23341. * Add a new block to the list of output nodes
  23342. * @param node defines the node to add
  23343. * @returns the current material
  23344. */
  23345. addOutputNode(node: NodeMaterialBlock): this;
  23346. /**
  23347. * Remove a block from the list of root nodes
  23348. * @param node defines the node to remove
  23349. * @returns the current material
  23350. */
  23351. removeOutputNode(node: NodeMaterialBlock): this;
  23352. private _addVertexOutputNode;
  23353. private _removeVertexOutputNode;
  23354. private _addFragmentOutputNode;
  23355. private _removeFragmentOutputNode;
  23356. /**
  23357. * Specifies if the material will require alpha blending
  23358. * @returns a boolean specifying if alpha blending is needed
  23359. */
  23360. needAlphaBlending(): boolean;
  23361. /**
  23362. * Specifies if this material should be rendered in alpha test mode
  23363. * @returns a boolean specifying if an alpha test is needed.
  23364. */
  23365. needAlphaTesting(): boolean;
  23366. private _initializeBlock;
  23367. private _resetDualBlocks;
  23368. /**
  23369. * Remove a block from the current node material
  23370. * @param block defines the block to remove
  23371. */
  23372. removeBlock(block: NodeMaterialBlock): void;
  23373. /**
  23374. * Build the material and generates the inner effect
  23375. * @param verbose defines if the build should log activity
  23376. */
  23377. build(verbose?: boolean): void;
  23378. /**
  23379. * Runs an otpimization phase to try to improve the shader code
  23380. */
  23381. optimize(): void;
  23382. private _prepareDefinesForAttributes;
  23383. /**
  23384. * Create a post process from the material
  23385. * @param camera The camera to apply the render pass to.
  23386. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23388. * @param engine The engine which the post process will be applied. (default: current engine)
  23389. * @param reusable If the post process can be reused on the same frame. (default: false)
  23390. * @param textureType Type of textures used when performing the post process. (default: 0)
  23391. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23392. * @returns the post process created
  23393. */
  23394. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23395. /**
  23396. * Create the post process effect from the material
  23397. * @param postProcess The post process to create the effect for
  23398. */
  23399. createEffectForPostProcess(postProcess: PostProcess): void;
  23400. private _createEffectForPostProcess;
  23401. /**
  23402. * Create a new procedural texture based on this node material
  23403. * @param size defines the size of the texture
  23404. * @param scene defines the hosting scene
  23405. * @returns the new procedural texture attached to this node material
  23406. */
  23407. createProceduralTexture(size: number | {
  23408. width: number;
  23409. height: number;
  23410. layers?: number;
  23411. }, scene: Scene): Nullable<ProceduralTexture>;
  23412. private _createEffectForParticles;
  23413. private _checkInternals;
  23414. /**
  23415. * Create the effect to be used as the custom effect for a particle system
  23416. * @param particleSystem Particle system to create the effect for
  23417. * @param onCompiled defines a function to call when the effect creation is successful
  23418. * @param onError defines a function to call when the effect creation has failed
  23419. */
  23420. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23421. private _processDefines;
  23422. /**
  23423. * Get if the submesh is ready to be used and all its information available.
  23424. * Child classes can use it to update shaders
  23425. * @param mesh defines the mesh to check
  23426. * @param subMesh defines which submesh to check
  23427. * @param useInstances specifies that instances should be used
  23428. * @returns a boolean indicating that the submesh is ready or not
  23429. */
  23430. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23431. /**
  23432. * Get a string representing the shaders built by the current node graph
  23433. */
  23434. get compiledShaders(): string;
  23435. /**
  23436. * Binds the world matrix to the material
  23437. * @param world defines the world transformation matrix
  23438. */
  23439. bindOnlyWorldMatrix(world: Matrix): void;
  23440. /**
  23441. * Binds the submesh to this material by preparing the effect and shader to draw
  23442. * @param world defines the world transformation matrix
  23443. * @param mesh defines the mesh containing the submesh
  23444. * @param subMesh defines the submesh to bind the material to
  23445. */
  23446. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23447. /**
  23448. * Gets the active textures from the material
  23449. * @returns an array of textures
  23450. */
  23451. getActiveTextures(): BaseTexture[];
  23452. /**
  23453. * Gets the list of texture blocks
  23454. * @returns an array of texture blocks
  23455. */
  23456. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23457. /**
  23458. * Specifies if the material uses a texture
  23459. * @param texture defines the texture to check against the material
  23460. * @returns a boolean specifying if the material uses the texture
  23461. */
  23462. hasTexture(texture: BaseTexture): boolean;
  23463. /**
  23464. * Disposes the material
  23465. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23466. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23467. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23468. */
  23469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23470. /** Creates the node editor window. */
  23471. private _createNodeEditor;
  23472. /**
  23473. * Launch the node material editor
  23474. * @param config Define the configuration of the editor
  23475. * @return a promise fulfilled when the node editor is visible
  23476. */
  23477. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23478. /**
  23479. * Clear the current material
  23480. */
  23481. clear(): void;
  23482. /**
  23483. * Clear the current material and set it to a default state
  23484. */
  23485. setToDefault(): void;
  23486. /**
  23487. * Clear the current material and set it to a default state for post process
  23488. */
  23489. setToDefaultPostProcess(): void;
  23490. /**
  23491. * Clear the current material and set it to a default state for procedural texture
  23492. */
  23493. setToDefaultProceduralTexture(): void;
  23494. /**
  23495. * Clear the current material and set it to a default state for particle
  23496. */
  23497. setToDefaultParticle(): void;
  23498. /**
  23499. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23500. * @param url defines the url to load from
  23501. * @returns a promise that will fullfil when the material is fully loaded
  23502. */
  23503. loadAsync(url: string): Promise<void>;
  23504. private _gatherBlocks;
  23505. /**
  23506. * Generate a string containing the code declaration required to create an equivalent of this material
  23507. * @returns a string
  23508. */
  23509. generateCode(): string;
  23510. /**
  23511. * Serializes this material in a JSON representation
  23512. * @returns the serialized material object
  23513. */
  23514. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23515. private _restoreConnections;
  23516. /**
  23517. * Clear the current graph and load a new one from a serialization object
  23518. * @param source defines the JSON representation of the material
  23519. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23520. * @param merge defines whether or not the source must be merged or replace the current content
  23521. */
  23522. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23523. /**
  23524. * Makes a duplicate of the current material.
  23525. * @param name - name to use for the new material.
  23526. */
  23527. clone(name: string): NodeMaterial;
  23528. /**
  23529. * Creates a node material from parsed material data
  23530. * @param source defines the JSON representation of the material
  23531. * @param scene defines the hosting scene
  23532. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23533. * @returns a new node material
  23534. */
  23535. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23536. /**
  23537. * Creates a node material from a snippet saved in a remote file
  23538. * @param name defines the name of the material to create
  23539. * @param url defines the url to load from
  23540. * @param scene defines the hosting scene
  23541. * @returns a promise that will resolve to the new node material
  23542. */
  23543. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23544. /**
  23545. * Creates a node material from a snippet saved by the node material editor
  23546. * @param snippetId defines the snippet to load
  23547. * @param scene defines the hosting scene
  23548. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23549. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23550. * @returns a promise that will resolve to the new node material
  23551. */
  23552. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23553. /**
  23554. * Creates a new node material set to default basic configuration
  23555. * @param name defines the name of the material
  23556. * @param scene defines the hosting scene
  23557. * @returns a new NodeMaterial
  23558. */
  23559. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23560. }
  23561. }
  23562. declare module "babylonjs/PostProcesses/postProcess" {
  23563. import { Nullable } from "babylonjs/types";
  23564. import { SmartArray } from "babylonjs/Misc/smartArray";
  23565. import { Observable } from "babylonjs/Misc/observable";
  23566. import { Vector2 } from "babylonjs/Maths/math.vector";
  23567. import { Camera } from "babylonjs/Cameras/camera";
  23568. import { Effect } from "babylonjs/Materials/effect";
  23569. import "babylonjs/Shaders/postprocess.vertex";
  23570. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23571. import { Engine } from "babylonjs/Engines/engine";
  23572. import { Color4 } from "babylonjs/Maths/math.color";
  23573. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23574. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23575. import { Scene } from "babylonjs/scene";
  23576. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23577. /**
  23578. * Size options for a post process
  23579. */
  23580. export type PostProcessOptions = {
  23581. width: number;
  23582. height: number;
  23583. };
  23584. /**
  23585. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23586. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23587. */
  23588. export class PostProcess {
  23589. /**
  23590. * Gets or sets the unique id of the post process
  23591. */
  23592. uniqueId: number;
  23593. /** Name of the PostProcess. */
  23594. name: string;
  23595. /**
  23596. * Width of the texture to apply the post process on
  23597. */
  23598. width: number;
  23599. /**
  23600. * Height of the texture to apply the post process on
  23601. */
  23602. height: number;
  23603. /**
  23604. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23605. */
  23606. nodeMaterialSource: Nullable<NodeMaterial>;
  23607. /**
  23608. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23609. * @hidden
  23610. */
  23611. _outputTexture: Nullable<InternalTexture>;
  23612. /**
  23613. * Sampling mode used by the shader
  23614. * See https://doc.babylonjs.com/classes/3.1/texture
  23615. */
  23616. renderTargetSamplingMode: number;
  23617. /**
  23618. * Clear color to use when screen clearing
  23619. */
  23620. clearColor: Color4;
  23621. /**
  23622. * If the buffer needs to be cleared before applying the post process. (default: true)
  23623. * Should be set to false if shader will overwrite all previous pixels.
  23624. */
  23625. autoClear: boolean;
  23626. /**
  23627. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23628. */
  23629. alphaMode: number;
  23630. /**
  23631. * Sets the setAlphaBlendConstants of the babylon engine
  23632. */
  23633. alphaConstants: Color4;
  23634. /**
  23635. * Animations to be used for the post processing
  23636. */
  23637. animations: import("babylonjs/Animations/animation").Animation[];
  23638. /**
  23639. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23640. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23641. */
  23642. enablePixelPerfectMode: boolean;
  23643. /**
  23644. * Force the postprocess to be applied without taking in account viewport
  23645. */
  23646. forceFullscreenViewport: boolean;
  23647. /**
  23648. * List of inspectable custom properties (used by the Inspector)
  23649. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23650. */
  23651. inspectableCustomProperties: IInspectable[];
  23652. /**
  23653. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23654. *
  23655. * | Value | Type | Description |
  23656. * | ----- | ----------------------------------- | ----------- |
  23657. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23658. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23659. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23660. *
  23661. */
  23662. scaleMode: number;
  23663. /**
  23664. * Force textures to be a power of two (default: false)
  23665. */
  23666. alwaysForcePOT: boolean;
  23667. private _samples;
  23668. /**
  23669. * Number of sample textures (default: 1)
  23670. */
  23671. get samples(): number;
  23672. set samples(n: number);
  23673. /**
  23674. * Modify the scale of the post process to be the same as the viewport (default: false)
  23675. */
  23676. adaptScaleToCurrentViewport: boolean;
  23677. private _camera;
  23678. protected _scene: Scene;
  23679. private _engine;
  23680. private _options;
  23681. private _reusable;
  23682. private _textureType;
  23683. private _textureFormat;
  23684. /**
  23685. * Smart array of input and output textures for the post process.
  23686. * @hidden
  23687. */
  23688. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23689. /**
  23690. * The index in _textures that corresponds to the output texture.
  23691. * @hidden
  23692. */
  23693. _currentRenderTextureInd: number;
  23694. private _effect;
  23695. private _samplers;
  23696. private _fragmentUrl;
  23697. private _vertexUrl;
  23698. private _parameters;
  23699. private _scaleRatio;
  23700. protected _indexParameters: any;
  23701. private _shareOutputWithPostProcess;
  23702. private _texelSize;
  23703. private _forcedOutputTexture;
  23704. /**
  23705. * Returns the fragment url or shader name used in the post process.
  23706. * @returns the fragment url or name in the shader store.
  23707. */
  23708. getEffectName(): string;
  23709. /**
  23710. * An event triggered when the postprocess is activated.
  23711. */
  23712. onActivateObservable: Observable<Camera>;
  23713. private _onActivateObserver;
  23714. /**
  23715. * A function that is added to the onActivateObservable
  23716. */
  23717. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23718. /**
  23719. * An event triggered when the postprocess changes its size.
  23720. */
  23721. onSizeChangedObservable: Observable<PostProcess>;
  23722. private _onSizeChangedObserver;
  23723. /**
  23724. * A function that is added to the onSizeChangedObservable
  23725. */
  23726. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23727. /**
  23728. * An event triggered when the postprocess applies its effect.
  23729. */
  23730. onApplyObservable: Observable<Effect>;
  23731. private _onApplyObserver;
  23732. /**
  23733. * A function that is added to the onApplyObservable
  23734. */
  23735. set onApply(callback: (effect: Effect) => void);
  23736. /**
  23737. * An event triggered before rendering the postprocess
  23738. */
  23739. onBeforeRenderObservable: Observable<Effect>;
  23740. private _onBeforeRenderObserver;
  23741. /**
  23742. * A function that is added to the onBeforeRenderObservable
  23743. */
  23744. set onBeforeRender(callback: (effect: Effect) => void);
  23745. /**
  23746. * An event triggered after rendering the postprocess
  23747. */
  23748. onAfterRenderObservable: Observable<Effect>;
  23749. private _onAfterRenderObserver;
  23750. /**
  23751. * A function that is added to the onAfterRenderObservable
  23752. */
  23753. set onAfterRender(callback: (efect: Effect) => void);
  23754. /**
  23755. * 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
  23756. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23757. */
  23758. get inputTexture(): InternalTexture;
  23759. set inputTexture(value: InternalTexture);
  23760. /**
  23761. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23762. * the only way to unset it is to use this function to restore its internal state
  23763. */
  23764. restoreDefaultInputTexture(): void;
  23765. /**
  23766. * Gets the camera which post process is applied to.
  23767. * @returns The camera the post process is applied to.
  23768. */
  23769. getCamera(): Camera;
  23770. /**
  23771. * Gets the texel size of the postprocess.
  23772. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23773. */
  23774. get texelSize(): Vector2;
  23775. /**
  23776. * Creates a new instance PostProcess
  23777. * @param name The name of the PostProcess.
  23778. * @param fragmentUrl The url of the fragment shader to be used.
  23779. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23780. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23781. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23782. * @param camera The camera to apply the render pass to.
  23783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23784. * @param engine The engine which the post process will be applied. (default: current engine)
  23785. * @param reusable If the post process can be reused on the same frame. (default: false)
  23786. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23787. * @param textureType Type of textures used when performing the post process. (default: 0)
  23788. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23789. * @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
  23790. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23791. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23792. */
  23793. 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);
  23794. /**
  23795. * Gets a string identifying the name of the class
  23796. * @returns "PostProcess" string
  23797. */
  23798. getClassName(): string;
  23799. /**
  23800. * Gets the engine which this post process belongs to.
  23801. * @returns The engine the post process was enabled with.
  23802. */
  23803. getEngine(): Engine;
  23804. /**
  23805. * The effect that is created when initializing the post process.
  23806. * @returns The created effect corresponding the the postprocess.
  23807. */
  23808. getEffect(): Effect;
  23809. /**
  23810. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23811. * @param postProcess The post process to share the output with.
  23812. * @returns This post process.
  23813. */
  23814. shareOutputWith(postProcess: PostProcess): PostProcess;
  23815. /**
  23816. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23817. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23818. */
  23819. useOwnOutput(): void;
  23820. /**
  23821. * Updates the effect with the current post process compile time values and recompiles the shader.
  23822. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23823. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23824. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23825. * @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
  23826. * @param onCompiled Called when the shader has been compiled.
  23827. * @param onError Called if there is an error when compiling a shader.
  23828. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23829. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23830. */
  23831. 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;
  23832. /**
  23833. * The post process is reusable if it can be used multiple times within one frame.
  23834. * @returns If the post process is reusable
  23835. */
  23836. isReusable(): boolean;
  23837. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23838. markTextureDirty(): void;
  23839. /**
  23840. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23841. * 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.
  23842. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23843. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23844. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23845. * @returns The target texture that was bound to be written to.
  23846. */
  23847. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23848. /**
  23849. * If the post process is supported.
  23850. */
  23851. get isSupported(): boolean;
  23852. /**
  23853. * The aspect ratio of the output texture.
  23854. */
  23855. get aspectRatio(): number;
  23856. /**
  23857. * Get a value indicating if the post-process is ready to be used
  23858. * @returns true if the post-process is ready (shader is compiled)
  23859. */
  23860. isReady(): boolean;
  23861. /**
  23862. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23863. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23864. */
  23865. apply(): Nullable<Effect>;
  23866. private _disposeTextures;
  23867. /**
  23868. * Disposes the post process.
  23869. * @param camera The camera to dispose the post process on.
  23870. */
  23871. dispose(camera?: Camera): void;
  23872. /**
  23873. * Serializes the particle system to a JSON object
  23874. * @returns the JSON object
  23875. */
  23876. serialize(): any;
  23877. /**
  23878. * Creates a material from parsed material data
  23879. * @param parsedPostProcess defines parsed post process data
  23880. * @param scene defines the hosting scene
  23881. * @param rootUrl defines the root URL to use to load textures
  23882. * @returns a new post process
  23883. */
  23884. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23885. }
  23886. }
  23887. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23888. /** @hidden */
  23889. export var kernelBlurVaryingDeclaration: {
  23890. name: string;
  23891. shader: string;
  23892. };
  23893. }
  23894. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23895. /** @hidden */
  23896. export var kernelBlurFragment: {
  23897. name: string;
  23898. shader: string;
  23899. };
  23900. }
  23901. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23902. /** @hidden */
  23903. export var kernelBlurFragment2: {
  23904. name: string;
  23905. shader: string;
  23906. };
  23907. }
  23908. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23909. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23910. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23911. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23912. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23913. /** @hidden */
  23914. export var kernelBlurPixelShader: {
  23915. name: string;
  23916. shader: string;
  23917. };
  23918. }
  23919. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23920. /** @hidden */
  23921. export var kernelBlurVertex: {
  23922. name: string;
  23923. shader: string;
  23924. };
  23925. }
  23926. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23927. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23928. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23929. /** @hidden */
  23930. export var kernelBlurVertexShader: {
  23931. name: string;
  23932. shader: string;
  23933. };
  23934. }
  23935. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23936. import { Vector2 } from "babylonjs/Maths/math.vector";
  23937. import { Nullable } from "babylonjs/types";
  23938. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23939. import { Camera } from "babylonjs/Cameras/camera";
  23940. import { Effect } from "babylonjs/Materials/effect";
  23941. import { Engine } from "babylonjs/Engines/engine";
  23942. import "babylonjs/Shaders/kernelBlur.fragment";
  23943. import "babylonjs/Shaders/kernelBlur.vertex";
  23944. import { Scene } from "babylonjs/scene";
  23945. /**
  23946. * The Blur Post Process which blurs an image based on a kernel and direction.
  23947. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23948. */
  23949. export class BlurPostProcess extends PostProcess {
  23950. private blockCompilation;
  23951. protected _kernel: number;
  23952. protected _idealKernel: number;
  23953. protected _packedFloat: boolean;
  23954. private _staticDefines;
  23955. /** The direction in which to blur the image. */
  23956. direction: Vector2;
  23957. /**
  23958. * Sets the length in pixels of the blur sample region
  23959. */
  23960. set kernel(v: number);
  23961. /**
  23962. * Gets the length in pixels of the blur sample region
  23963. */
  23964. get kernel(): number;
  23965. /**
  23966. * Sets wether or not the blur needs to unpack/repack floats
  23967. */
  23968. set packedFloat(v: boolean);
  23969. /**
  23970. * Gets wether or not the blur is unpacking/repacking floats
  23971. */
  23972. get packedFloat(): boolean;
  23973. /**
  23974. * Gets a string identifying the name of the class
  23975. * @returns "BlurPostProcess" string
  23976. */
  23977. getClassName(): string;
  23978. /**
  23979. * Creates a new instance BlurPostProcess
  23980. * @param name The name of the effect.
  23981. * @param direction The direction in which to blur the image.
  23982. * @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.
  23983. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23984. * @param camera The camera to apply the render pass to.
  23985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23986. * @param engine The engine which the post process will be applied. (default: current engine)
  23987. * @param reusable If the post process can be reused on the same frame. (default: false)
  23988. * @param textureType Type of textures used when performing the post process. (default: 0)
  23989. * @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)
  23990. */
  23991. 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);
  23992. /**
  23993. * Updates the effect with the current post process compile time values and recompiles the shader.
  23994. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23995. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23996. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23997. * @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
  23998. * @param onCompiled Called when the shader has been compiled.
  23999. * @param onError Called if there is an error when compiling a shader.
  24000. */
  24001. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24002. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24003. /**
  24004. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24005. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24006. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24007. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24008. * The gaps between physical kernels are compensated for in the weighting of the samples
  24009. * @param idealKernel Ideal blur kernel.
  24010. * @return Nearest best kernel.
  24011. */
  24012. protected _nearestBestKernel(idealKernel: number): number;
  24013. /**
  24014. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24015. * @param x The point on the Gaussian distribution to sample.
  24016. * @return the value of the Gaussian function at x.
  24017. */
  24018. protected _gaussianWeight(x: number): number;
  24019. /**
  24020. * Generates a string that can be used as a floating point number in GLSL.
  24021. * @param x Value to print.
  24022. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24023. * @return GLSL float string.
  24024. */
  24025. protected _glslFloat(x: number, decimalFigures?: number): string;
  24026. /** @hidden */
  24027. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24028. }
  24029. }
  24030. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24031. import { Scene } from "babylonjs/scene";
  24032. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24033. import { Plane } from "babylonjs/Maths/math.plane";
  24034. /**
  24035. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24036. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24037. * You can then easily use it as a reflectionTexture on a flat surface.
  24038. * In case the surface is not a plane, please consider relying on reflection probes.
  24039. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24040. */
  24041. export class MirrorTexture extends RenderTargetTexture {
  24042. private scene;
  24043. /**
  24044. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24045. * 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.
  24046. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24047. */
  24048. mirrorPlane: Plane;
  24049. /**
  24050. * Define the blur ratio used to blur the reflection if needed.
  24051. */
  24052. set blurRatio(value: number);
  24053. get blurRatio(): number;
  24054. /**
  24055. * Define the adaptive blur kernel used to blur the reflection if needed.
  24056. * This will autocompute the closest best match for the `blurKernel`
  24057. */
  24058. set adaptiveBlurKernel(value: number);
  24059. /**
  24060. * Define the blur kernel used to blur the reflection if needed.
  24061. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24062. */
  24063. set blurKernel(value: number);
  24064. /**
  24065. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24066. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24067. */
  24068. set blurKernelX(value: number);
  24069. get blurKernelX(): number;
  24070. /**
  24071. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24072. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24073. */
  24074. set blurKernelY(value: number);
  24075. get blurKernelY(): number;
  24076. private _autoComputeBlurKernel;
  24077. protected _onRatioRescale(): void;
  24078. private _updateGammaSpace;
  24079. private _imageProcessingConfigChangeObserver;
  24080. private _transformMatrix;
  24081. private _mirrorMatrix;
  24082. private _savedViewMatrix;
  24083. private _blurX;
  24084. private _blurY;
  24085. private _adaptiveBlurKernel;
  24086. private _blurKernelX;
  24087. private _blurKernelY;
  24088. private _blurRatio;
  24089. /**
  24090. * Instantiates a Mirror Texture.
  24091. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24092. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24093. * You can then easily use it as a reflectionTexture on a flat surface.
  24094. * In case the surface is not a plane, please consider relying on reflection probes.
  24095. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24096. * @param name
  24097. * @param size
  24098. * @param scene
  24099. * @param generateMipMaps
  24100. * @param type
  24101. * @param samplingMode
  24102. * @param generateDepthBuffer
  24103. */
  24104. constructor(name: string, size: number | {
  24105. width: number;
  24106. height: number;
  24107. } | {
  24108. ratio: number;
  24109. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24110. private _preparePostProcesses;
  24111. /**
  24112. * Clone the mirror texture.
  24113. * @returns the cloned texture
  24114. */
  24115. clone(): MirrorTexture;
  24116. /**
  24117. * Serialize the texture to a JSON representation you could use in Parse later on
  24118. * @returns the serialized JSON representation
  24119. */
  24120. serialize(): any;
  24121. /**
  24122. * Dispose the texture and release its associated resources.
  24123. */
  24124. dispose(): void;
  24125. }
  24126. }
  24127. declare module "babylonjs/Materials/Textures/texture" {
  24128. import { Observable } from "babylonjs/Misc/observable";
  24129. import { Nullable } from "babylonjs/types";
  24130. import { Matrix } from "babylonjs/Maths/math.vector";
  24131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24132. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24133. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24134. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24135. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24136. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24137. import { Scene } from "babylonjs/scene";
  24138. /**
  24139. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24140. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24141. */
  24142. export class Texture extends BaseTexture {
  24143. /**
  24144. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24145. */
  24146. static SerializeBuffers: boolean;
  24147. /** @hidden */
  24148. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24149. /** @hidden */
  24150. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24151. /** @hidden */
  24152. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24153. /** nearest is mag = nearest and min = nearest and mip = linear */
  24154. static readonly NEAREST_SAMPLINGMODE: number;
  24155. /** nearest is mag = nearest and min = nearest and mip = linear */
  24156. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24157. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24158. static readonly BILINEAR_SAMPLINGMODE: number;
  24159. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24160. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24161. /** Trilinear is mag = linear and min = linear and mip = linear */
  24162. static readonly TRILINEAR_SAMPLINGMODE: number;
  24163. /** Trilinear is mag = linear and min = linear and mip = linear */
  24164. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24165. /** mag = nearest and min = nearest and mip = nearest */
  24166. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24167. /** mag = nearest and min = linear and mip = nearest */
  24168. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24169. /** mag = nearest and min = linear and mip = linear */
  24170. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24171. /** mag = nearest and min = linear and mip = none */
  24172. static readonly NEAREST_LINEAR: number;
  24173. /** mag = nearest and min = nearest and mip = none */
  24174. static readonly NEAREST_NEAREST: number;
  24175. /** mag = linear and min = nearest and mip = nearest */
  24176. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24177. /** mag = linear and min = nearest and mip = linear */
  24178. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24179. /** mag = linear and min = linear and mip = none */
  24180. static readonly LINEAR_LINEAR: number;
  24181. /** mag = linear and min = nearest and mip = none */
  24182. static readonly LINEAR_NEAREST: number;
  24183. /** Explicit coordinates mode */
  24184. static readonly EXPLICIT_MODE: number;
  24185. /** Spherical coordinates mode */
  24186. static readonly SPHERICAL_MODE: number;
  24187. /** Planar coordinates mode */
  24188. static readonly PLANAR_MODE: number;
  24189. /** Cubic coordinates mode */
  24190. static readonly CUBIC_MODE: number;
  24191. /** Projection coordinates mode */
  24192. static readonly PROJECTION_MODE: number;
  24193. /** Inverse Cubic coordinates mode */
  24194. static readonly SKYBOX_MODE: number;
  24195. /** Inverse Cubic coordinates mode */
  24196. static readonly INVCUBIC_MODE: number;
  24197. /** Equirectangular coordinates mode */
  24198. static readonly EQUIRECTANGULAR_MODE: number;
  24199. /** Equirectangular Fixed coordinates mode */
  24200. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24201. /** Equirectangular Fixed Mirrored coordinates mode */
  24202. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24203. /** Texture is not repeating outside of 0..1 UVs */
  24204. static readonly CLAMP_ADDRESSMODE: number;
  24205. /** Texture is repeating outside of 0..1 UVs */
  24206. static readonly WRAP_ADDRESSMODE: number;
  24207. /** Texture is repeating and mirrored */
  24208. static readonly MIRROR_ADDRESSMODE: number;
  24209. /**
  24210. * 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
  24211. */
  24212. static UseSerializedUrlIfAny: boolean;
  24213. /**
  24214. * Define the url of the texture.
  24215. */
  24216. url: Nullable<string>;
  24217. /**
  24218. * Define an offset on the texture to offset the u coordinates of the UVs
  24219. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24220. */
  24221. uOffset: number;
  24222. /**
  24223. * Define an offset on the texture to offset the v coordinates of the UVs
  24224. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24225. */
  24226. vOffset: number;
  24227. /**
  24228. * Define an offset on the texture to scale the u coordinates of the UVs
  24229. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24230. */
  24231. uScale: number;
  24232. /**
  24233. * Define an offset on the texture to scale the v coordinates of the UVs
  24234. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24235. */
  24236. vScale: number;
  24237. /**
  24238. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24239. * @see https://doc.babylonjs.com/how_to/more_materials
  24240. */
  24241. uAng: number;
  24242. /**
  24243. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24244. * @see https://doc.babylonjs.com/how_to/more_materials
  24245. */
  24246. vAng: number;
  24247. /**
  24248. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24249. * @see https://doc.babylonjs.com/how_to/more_materials
  24250. */
  24251. wAng: number;
  24252. /**
  24253. * Defines the center of rotation (U)
  24254. */
  24255. uRotationCenter: number;
  24256. /**
  24257. * Defines the center of rotation (V)
  24258. */
  24259. vRotationCenter: number;
  24260. /**
  24261. * Defines the center of rotation (W)
  24262. */
  24263. wRotationCenter: number;
  24264. /**
  24265. * Are mip maps generated for this texture or not.
  24266. */
  24267. get noMipmap(): boolean;
  24268. /**
  24269. * List of inspectable custom properties (used by the Inspector)
  24270. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24271. */
  24272. inspectableCustomProperties: Nullable<IInspectable[]>;
  24273. private _noMipmap;
  24274. /** @hidden */
  24275. _invertY: boolean;
  24276. private _rowGenerationMatrix;
  24277. private _cachedTextureMatrix;
  24278. private _projectionModeMatrix;
  24279. private _t0;
  24280. private _t1;
  24281. private _t2;
  24282. private _cachedUOffset;
  24283. private _cachedVOffset;
  24284. private _cachedUScale;
  24285. private _cachedVScale;
  24286. private _cachedUAng;
  24287. private _cachedVAng;
  24288. private _cachedWAng;
  24289. private _cachedProjectionMatrixId;
  24290. private _cachedCoordinatesMode;
  24291. /** @hidden */
  24292. protected _initialSamplingMode: number;
  24293. /** @hidden */
  24294. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24295. private _deleteBuffer;
  24296. protected _format: Nullable<number>;
  24297. private _delayedOnLoad;
  24298. private _delayedOnError;
  24299. private _mimeType?;
  24300. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24301. get mimeType(): string | undefined;
  24302. /**
  24303. * Observable triggered once the texture has been loaded.
  24304. */
  24305. onLoadObservable: Observable<Texture>;
  24306. protected _isBlocking: boolean;
  24307. /**
  24308. * Is the texture preventing material to render while loading.
  24309. * If false, a default texture will be used instead of the loading one during the preparation step.
  24310. */
  24311. set isBlocking(value: boolean);
  24312. get isBlocking(): boolean;
  24313. /**
  24314. * Get the current sampling mode associated with the texture.
  24315. */
  24316. get samplingMode(): number;
  24317. /**
  24318. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24319. */
  24320. get invertY(): boolean;
  24321. /**
  24322. * Instantiates a new texture.
  24323. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24324. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24325. * @param url defines the url of the picture to load as a texture
  24326. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24327. * @param noMipmap defines if the texture will require mip maps or not
  24328. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24329. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24330. * @param onLoad defines a callback triggered when the texture has been loaded
  24331. * @param onError defines a callback triggered when an error occurred during the loading session
  24332. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24333. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24334. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24335. * @param mimeType defines an optional mime type information
  24336. */
  24337. 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);
  24338. /**
  24339. * Update the url (and optional buffer) of this texture if url was null during construction.
  24340. * @param url the url of the texture
  24341. * @param buffer the buffer of the texture (defaults to null)
  24342. * @param onLoad callback called when the texture is loaded (defaults to null)
  24343. */
  24344. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24345. /**
  24346. * Finish the loading sequence of a texture flagged as delayed load.
  24347. * @hidden
  24348. */
  24349. delayLoad(): void;
  24350. private _prepareRowForTextureGeneration;
  24351. /**
  24352. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24353. * @returns the transform matrix of the texture.
  24354. */
  24355. getTextureMatrix(uBase?: number): Matrix;
  24356. /**
  24357. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24358. * @returns The reflection texture transform
  24359. */
  24360. getReflectionTextureMatrix(): Matrix;
  24361. /**
  24362. * Clones the texture.
  24363. * @returns the cloned texture
  24364. */
  24365. clone(): Texture;
  24366. /**
  24367. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24368. * @returns The JSON representation of the texture
  24369. */
  24370. serialize(): any;
  24371. /**
  24372. * Get the current class name of the texture useful for serialization or dynamic coding.
  24373. * @returns "Texture"
  24374. */
  24375. getClassName(): string;
  24376. /**
  24377. * Dispose the texture and release its associated resources.
  24378. */
  24379. dispose(): void;
  24380. /**
  24381. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24382. * @param parsedTexture Define the JSON representation of the texture
  24383. * @param scene Define the scene the parsed texture should be instantiated in
  24384. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24385. * @returns The parsed texture if successful
  24386. */
  24387. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24388. /**
  24389. * Creates a texture from its base 64 representation.
  24390. * @param data Define the base64 payload without the data: prefix
  24391. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24392. * @param scene Define the scene the texture should belong to
  24393. * @param noMipmap Forces the texture to not create mip map information if true
  24394. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24395. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24396. * @param onLoad define a callback triggered when the texture has been loaded
  24397. * @param onError define a callback triggered when an error occurred during the loading session
  24398. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24399. * @returns the created texture
  24400. */
  24401. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24402. /**
  24403. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24404. * @param data Define the base64 payload without the data: prefix
  24405. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24406. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24407. * @param scene Define the scene the texture should belong to
  24408. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24409. * @param noMipmap Forces the texture to not create mip map information if true
  24410. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24411. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24412. * @param onLoad define a callback triggered when the texture has been loaded
  24413. * @param onError define a callback triggered when an error occurred during the loading session
  24414. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24415. * @returns the created texture
  24416. */
  24417. 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;
  24418. }
  24419. }
  24420. declare module "babylonjs/PostProcesses/postProcessManager" {
  24421. import { Nullable } from "babylonjs/types";
  24422. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24423. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24424. import { Scene } from "babylonjs/scene";
  24425. /**
  24426. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24427. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24428. */
  24429. export class PostProcessManager {
  24430. private _scene;
  24431. private _indexBuffer;
  24432. private _vertexBuffers;
  24433. /**
  24434. * Creates a new instance PostProcess
  24435. * @param scene The scene that the post process is associated with.
  24436. */
  24437. constructor(scene: Scene);
  24438. private _prepareBuffers;
  24439. private _buildIndexBuffer;
  24440. /**
  24441. * Rebuilds the vertex buffers of the manager.
  24442. * @hidden
  24443. */
  24444. _rebuild(): void;
  24445. /**
  24446. * Prepares a frame to be run through a post process.
  24447. * @param sourceTexture The input texture to the post procesess. (default: null)
  24448. * @param postProcesses An array of post processes to be run. (default: null)
  24449. * @returns True if the post processes were able to be run.
  24450. * @hidden
  24451. */
  24452. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24453. /**
  24454. * Manually render a set of post processes to a texture.
  24455. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24456. * @param postProcesses An array of post processes to be run.
  24457. * @param targetTexture The target texture to render to.
  24458. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24459. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24460. * @param lodLevel defines which lod of the texture to render to
  24461. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24462. */
  24463. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24464. /**
  24465. * Finalize the result of the output of the postprocesses.
  24466. * @param doNotPresent If true the result will not be displayed to the screen.
  24467. * @param targetTexture The target texture to render to.
  24468. * @param faceIndex The index of the face to bind the target texture to.
  24469. * @param postProcesses The array of post processes to render.
  24470. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24471. * @hidden
  24472. */
  24473. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24474. /**
  24475. * Disposes of the post process manager.
  24476. */
  24477. dispose(): void;
  24478. }
  24479. }
  24480. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24481. import { Observable } from "babylonjs/Misc/observable";
  24482. import { SmartArray } from "babylonjs/Misc/smartArray";
  24483. import { Nullable, Immutable } from "babylonjs/types";
  24484. import { Camera } from "babylonjs/Cameras/camera";
  24485. import { Scene } from "babylonjs/scene";
  24486. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24487. import { Color4 } from "babylonjs/Maths/math.color";
  24488. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24490. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24491. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24492. import { Texture } from "babylonjs/Materials/Textures/texture";
  24493. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24494. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24495. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24496. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24497. import { Engine } from "babylonjs/Engines/engine";
  24498. /**
  24499. * This Helps creating a texture that will be created from a camera in your scene.
  24500. * It is basically a dynamic texture that could be used to create special effects for instance.
  24501. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24502. */
  24503. export class RenderTargetTexture extends Texture {
  24504. /**
  24505. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24506. */
  24507. static readonly REFRESHRATE_RENDER_ONCE: number;
  24508. /**
  24509. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24510. */
  24511. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24512. /**
  24513. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24514. * the central point of your effect and can save a lot of performances.
  24515. */
  24516. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24517. /**
  24518. * Use this predicate to dynamically define the list of mesh you want to render.
  24519. * If set, the renderList property will be overwritten.
  24520. */
  24521. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24522. private _renderList;
  24523. /**
  24524. * Use this list to define the list of mesh you want to render.
  24525. */
  24526. get renderList(): Nullable<Array<AbstractMesh>>;
  24527. set renderList(value: Nullable<Array<AbstractMesh>>);
  24528. /**
  24529. * Use this function to overload the renderList array at rendering time.
  24530. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24531. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24532. * the cube (if the RTT is a cube, else layerOrFace=0).
  24533. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24534. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24535. * hold dummy elements!
  24536. */
  24537. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24538. private _hookArray;
  24539. /**
  24540. * Define if particles should be rendered in your texture.
  24541. */
  24542. renderParticles: boolean;
  24543. /**
  24544. * Define if sprites should be rendered in your texture.
  24545. */
  24546. renderSprites: boolean;
  24547. /**
  24548. * Define the camera used to render the texture.
  24549. */
  24550. activeCamera: Nullable<Camera>;
  24551. /**
  24552. * Override the mesh isReady function with your own one.
  24553. */
  24554. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24555. /**
  24556. * Override the render function of the texture with your own one.
  24557. */
  24558. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24559. /**
  24560. * Define if camera post processes should be use while rendering the texture.
  24561. */
  24562. useCameraPostProcesses: boolean;
  24563. /**
  24564. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24565. */
  24566. ignoreCameraViewport: boolean;
  24567. private _postProcessManager;
  24568. private _postProcesses;
  24569. private _resizeObserver;
  24570. /**
  24571. * An event triggered when the texture is unbind.
  24572. */
  24573. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24574. /**
  24575. * An event triggered when the texture is unbind.
  24576. */
  24577. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24578. private _onAfterUnbindObserver;
  24579. /**
  24580. * Set a after unbind callback in the texture.
  24581. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24582. */
  24583. set onAfterUnbind(callback: () => void);
  24584. /**
  24585. * An event triggered before rendering the texture
  24586. */
  24587. onBeforeRenderObservable: Observable<number>;
  24588. private _onBeforeRenderObserver;
  24589. /**
  24590. * Set a before render callback in the texture.
  24591. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24592. */
  24593. set onBeforeRender(callback: (faceIndex: number) => void);
  24594. /**
  24595. * An event triggered after rendering the texture
  24596. */
  24597. onAfterRenderObservable: Observable<number>;
  24598. private _onAfterRenderObserver;
  24599. /**
  24600. * Set a after render callback in the texture.
  24601. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24602. */
  24603. set onAfterRender(callback: (faceIndex: number) => void);
  24604. /**
  24605. * An event triggered after the texture clear
  24606. */
  24607. onClearObservable: Observable<Engine>;
  24608. private _onClearObserver;
  24609. /**
  24610. * Set a clear callback in the texture.
  24611. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24612. */
  24613. set onClear(callback: (Engine: Engine) => void);
  24614. /**
  24615. * An event triggered when the texture is resized.
  24616. */
  24617. onResizeObservable: Observable<RenderTargetTexture>;
  24618. /**
  24619. * Define the clear color of the Render Target if it should be different from the scene.
  24620. */
  24621. clearColor: Color4;
  24622. protected _size: number | {
  24623. width: number;
  24624. height: number;
  24625. layers?: number;
  24626. };
  24627. protected _initialSizeParameter: number | {
  24628. width: number;
  24629. height: number;
  24630. } | {
  24631. ratio: number;
  24632. };
  24633. protected _sizeRatio: Nullable<number>;
  24634. /** @hidden */
  24635. _generateMipMaps: boolean;
  24636. protected _renderingManager: RenderingManager;
  24637. /** @hidden */
  24638. _waitingRenderList?: string[];
  24639. protected _doNotChangeAspectRatio: boolean;
  24640. protected _currentRefreshId: number;
  24641. protected _refreshRate: number;
  24642. protected _textureMatrix: Matrix;
  24643. protected _samples: number;
  24644. protected _renderTargetOptions: RenderTargetCreationOptions;
  24645. /**
  24646. * Gets render target creation options that were used.
  24647. */
  24648. get renderTargetOptions(): RenderTargetCreationOptions;
  24649. protected _onRatioRescale(): void;
  24650. /**
  24651. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24652. * It must define where the camera used to render the texture is set
  24653. */
  24654. boundingBoxPosition: Vector3;
  24655. private _boundingBoxSize;
  24656. /**
  24657. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24658. * When defined, the cubemap will switch to local mode
  24659. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24660. * @example https://www.babylonjs-playground.com/#RNASML
  24661. */
  24662. set boundingBoxSize(value: Vector3);
  24663. get boundingBoxSize(): Vector3;
  24664. /**
  24665. * In case the RTT has been created with a depth texture, get the associated
  24666. * depth texture.
  24667. * Otherwise, return null.
  24668. */
  24669. get depthStencilTexture(): Nullable<InternalTexture>;
  24670. /**
  24671. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24672. * or used a shadow, depth texture...
  24673. * @param name The friendly name of the texture
  24674. * @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)
  24675. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24676. * @param generateMipMaps True if mip maps need to be generated after render.
  24677. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24678. * @param type The type of the buffer in the RTT (int, half float, float...)
  24679. * @param isCube True if a cube texture needs to be created
  24680. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24681. * @param generateDepthBuffer True to generate a depth buffer
  24682. * @param generateStencilBuffer True to generate a stencil buffer
  24683. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24684. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24685. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24686. */
  24687. constructor(name: string, size: number | {
  24688. width: number;
  24689. height: number;
  24690. layers?: number;
  24691. } | {
  24692. ratio: number;
  24693. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24694. /**
  24695. * Creates a depth stencil texture.
  24696. * This is only available in WebGL 2 or with the depth texture extension available.
  24697. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24698. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24699. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24700. */
  24701. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24702. private _processSizeParameter;
  24703. /**
  24704. * Define the number of samples to use in case of MSAA.
  24705. * It defaults to one meaning no MSAA has been enabled.
  24706. */
  24707. get samples(): number;
  24708. set samples(value: number);
  24709. /**
  24710. * Resets the refresh counter of the texture and start bak from scratch.
  24711. * Could be useful to regenerate the texture if it is setup to render only once.
  24712. */
  24713. resetRefreshCounter(): void;
  24714. /**
  24715. * Define the refresh rate of the texture or the rendering frequency.
  24716. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24717. */
  24718. get refreshRate(): number;
  24719. set refreshRate(value: number);
  24720. /**
  24721. * Adds a post process to the render target rendering passes.
  24722. * @param postProcess define the post process to add
  24723. */
  24724. addPostProcess(postProcess: PostProcess): void;
  24725. /**
  24726. * Clear all the post processes attached to the render target
  24727. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24728. */
  24729. clearPostProcesses(dispose?: boolean): void;
  24730. /**
  24731. * Remove one of the post process from the list of attached post processes to the texture
  24732. * @param postProcess define the post process to remove from the list
  24733. */
  24734. removePostProcess(postProcess: PostProcess): void;
  24735. /** @hidden */
  24736. _shouldRender(): boolean;
  24737. /**
  24738. * Gets the actual render size of the texture.
  24739. * @returns the width of the render size
  24740. */
  24741. getRenderSize(): number;
  24742. /**
  24743. * Gets the actual render width of the texture.
  24744. * @returns the width of the render size
  24745. */
  24746. getRenderWidth(): number;
  24747. /**
  24748. * Gets the actual render height of the texture.
  24749. * @returns the height of the render size
  24750. */
  24751. getRenderHeight(): number;
  24752. /**
  24753. * Gets the actual number of layers of the texture.
  24754. * @returns the number of layers
  24755. */
  24756. getRenderLayers(): number;
  24757. /**
  24758. * Get if the texture can be rescaled or not.
  24759. */
  24760. get canRescale(): boolean;
  24761. /**
  24762. * Resize the texture using a ratio.
  24763. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24764. */
  24765. scale(ratio: number): void;
  24766. /**
  24767. * Get the texture reflection matrix used to rotate/transform the reflection.
  24768. * @returns the reflection matrix
  24769. */
  24770. getReflectionTextureMatrix(): Matrix;
  24771. /**
  24772. * Resize the texture to a new desired size.
  24773. * Be carrefull as it will recreate all the data in the new texture.
  24774. * @param size Define the new size. It can be:
  24775. * - a number for squared texture,
  24776. * - an object containing { width: number, height: number }
  24777. * - or an object containing a ratio { ratio: number }
  24778. */
  24779. resize(size: number | {
  24780. width: number;
  24781. height: number;
  24782. } | {
  24783. ratio: number;
  24784. }): void;
  24785. private _defaultRenderListPrepared;
  24786. /**
  24787. * Renders all the objects from the render list into the texture.
  24788. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24789. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24790. */
  24791. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24792. private _bestReflectionRenderTargetDimension;
  24793. private _prepareRenderingManager;
  24794. /**
  24795. * @hidden
  24796. * @param faceIndex face index to bind to if this is a cubetexture
  24797. * @param layer defines the index of the texture to bind in the array
  24798. */
  24799. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24800. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24801. private renderToTarget;
  24802. /**
  24803. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24804. * This allowed control for front to back rendering or reversly depending of the special needs.
  24805. *
  24806. * @param renderingGroupId The rendering group id corresponding to its index
  24807. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24808. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24809. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24810. */
  24811. 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;
  24812. /**
  24813. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24814. *
  24815. * @param renderingGroupId The rendering group id corresponding to its index
  24816. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24817. */
  24818. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24819. /**
  24820. * Clones the texture.
  24821. * @returns the cloned texture
  24822. */
  24823. clone(): RenderTargetTexture;
  24824. /**
  24825. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24826. * @returns The JSON representation of the texture
  24827. */
  24828. serialize(): any;
  24829. /**
  24830. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24831. */
  24832. disposeFramebufferObjects(): void;
  24833. /**
  24834. * Dispose the texture and release its associated resources.
  24835. */
  24836. dispose(): void;
  24837. /** @hidden */
  24838. _rebuild(): void;
  24839. /**
  24840. * Clear the info related to rendering groups preventing retention point in material dispose.
  24841. */
  24842. freeRenderingGroups(): void;
  24843. /**
  24844. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24845. * @returns the view count
  24846. */
  24847. getViewCount(): number;
  24848. }
  24849. }
  24850. declare module "babylonjs/Misc/guid" {
  24851. /**
  24852. * Class used to manipulate GUIDs
  24853. */
  24854. export class GUID {
  24855. /**
  24856. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24857. * Be aware Math.random() could cause collisions, but:
  24858. * "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"
  24859. * @returns a pseudo random id
  24860. */
  24861. static RandomId(): string;
  24862. }
  24863. }
  24864. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24865. import { Nullable } from "babylonjs/types";
  24866. import { Scene } from "babylonjs/scene";
  24867. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24868. import { Material } from "babylonjs/Materials/material";
  24869. import { Effect } from "babylonjs/Materials/effect";
  24870. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24871. /**
  24872. * Options to be used when creating a shadow depth material
  24873. */
  24874. export interface IIOptionShadowDepthMaterial {
  24875. /** Variables in the vertex shader code that need to have their names remapped.
  24876. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24877. * "var_name" should be either: worldPos or vNormalW
  24878. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24879. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24880. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24881. */
  24882. remappedVariables?: string[];
  24883. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24884. standalone?: boolean;
  24885. }
  24886. /**
  24887. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24888. */
  24889. export class ShadowDepthWrapper {
  24890. private _scene;
  24891. private _options?;
  24892. private _baseMaterial;
  24893. private _onEffectCreatedObserver;
  24894. private _subMeshToEffect;
  24895. private _subMeshToDepthEffect;
  24896. private _meshes;
  24897. /** @hidden */
  24898. _matriceNames: any;
  24899. /** Gets the standalone status of the wrapper */
  24900. get standalone(): boolean;
  24901. /** Gets the base material the wrapper is built upon */
  24902. get baseMaterial(): Material;
  24903. /**
  24904. * Instantiate a new shadow depth wrapper.
  24905. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24906. * generate the shadow depth map. For more information, please refer to the documentation:
  24907. * https://doc.babylonjs.com/babylon101/shadows
  24908. * @param baseMaterial Material to wrap
  24909. * @param scene Define the scene the material belongs to
  24910. * @param options Options used to create the wrapper
  24911. */
  24912. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24913. /**
  24914. * Gets the effect to use to generate the depth map
  24915. * @param subMesh subMesh to get the effect for
  24916. * @param shadowGenerator shadow generator to get the effect for
  24917. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24918. */
  24919. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24920. /**
  24921. * Specifies that the submesh is ready to be used for depth rendering
  24922. * @param subMesh submesh to check
  24923. * @param defines the list of defines to take into account when checking the effect
  24924. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24925. * @param useInstances specifies that instances should be used
  24926. * @returns a boolean indicating that the submesh is ready or not
  24927. */
  24928. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24929. /**
  24930. * Disposes the resources
  24931. */
  24932. dispose(): void;
  24933. private _makeEffect;
  24934. }
  24935. }
  24936. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24937. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24938. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24939. import { Nullable } from "babylonjs/types";
  24940. module "babylonjs/Engines/thinEngine" {
  24941. interface ThinEngine {
  24942. /**
  24943. * Unbind a list of render target textures from the webGL context
  24944. * This is used only when drawBuffer extension or webGL2 are active
  24945. * @param textures defines the render target textures to unbind
  24946. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24947. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24948. */
  24949. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24950. /**
  24951. * Create a multi render target texture
  24952. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24953. * @param size defines the size of the texture
  24954. * @param options defines the creation options
  24955. * @returns the cube texture as an InternalTexture
  24956. */
  24957. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24958. /**
  24959. * Update the sample count for a given multiple render target texture
  24960. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24961. * @param textures defines the textures to update
  24962. * @param samples defines the sample count to set
  24963. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24964. */
  24965. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24966. /**
  24967. * Select a subsets of attachments to draw to.
  24968. * @param attachments gl attachments
  24969. */
  24970. bindAttachments(attachments: number[]): void;
  24971. }
  24972. }
  24973. }
  24974. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24975. import { Scene } from "babylonjs/scene";
  24976. import { Engine } from "babylonjs/Engines/engine";
  24977. import { Texture } from "babylonjs/Materials/Textures/texture";
  24978. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24979. import "babylonjs/Engines/Extensions/engine.multiRender";
  24980. /**
  24981. * Creation options of the multi render target texture.
  24982. */
  24983. export interface IMultiRenderTargetOptions {
  24984. /**
  24985. * Define if the texture needs to create mip maps after render.
  24986. */
  24987. generateMipMaps?: boolean;
  24988. /**
  24989. * Define the types of all the draw buffers we want to create
  24990. */
  24991. types?: number[];
  24992. /**
  24993. * Define the sampling modes of all the draw buffers we want to create
  24994. */
  24995. samplingModes?: number[];
  24996. /**
  24997. * Define if a depth buffer is required
  24998. */
  24999. generateDepthBuffer?: boolean;
  25000. /**
  25001. * Define if a stencil buffer is required
  25002. */
  25003. generateStencilBuffer?: boolean;
  25004. /**
  25005. * Define if a depth texture is required instead of a depth buffer
  25006. */
  25007. generateDepthTexture?: boolean;
  25008. /**
  25009. * Define the number of desired draw buffers
  25010. */
  25011. textureCount?: number;
  25012. /**
  25013. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25014. */
  25015. doNotChangeAspectRatio?: boolean;
  25016. /**
  25017. * Define the default type of the buffers we are creating
  25018. */
  25019. defaultType?: number;
  25020. }
  25021. /**
  25022. * A multi render target, like a render target provides the ability to render to a texture.
  25023. * Unlike the render target, it can render to several draw buffers in one draw.
  25024. * This is specially interesting in deferred rendering or for any effects requiring more than
  25025. * just one color from a single pass.
  25026. */
  25027. export class MultiRenderTarget extends RenderTargetTexture {
  25028. private _internalTextures;
  25029. private _textures;
  25030. private _multiRenderTargetOptions;
  25031. private _count;
  25032. /**
  25033. * Get if draw buffers are currently supported by the used hardware and browser.
  25034. */
  25035. get isSupported(): boolean;
  25036. /**
  25037. * Get the list of textures generated by the multi render target.
  25038. */
  25039. get textures(): Texture[];
  25040. /**
  25041. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  25042. */
  25043. get count(): number;
  25044. /**
  25045. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25046. */
  25047. get depthTexture(): Texture;
  25048. /**
  25049. * Set the wrapping mode on U of all the textures we are rendering to.
  25050. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25051. */
  25052. set wrapU(wrap: number);
  25053. /**
  25054. * Set the wrapping mode on V of all the textures we are rendering to.
  25055. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25056. */
  25057. set wrapV(wrap: number);
  25058. /**
  25059. * Instantiate a new multi render target texture.
  25060. * A multi render target, like a render target provides the ability to render to a texture.
  25061. * Unlike the render target, it can render to several draw buffers in one draw.
  25062. * This is specially interesting in deferred rendering or for any effects requiring more than
  25063. * just one color from a single pass.
  25064. * @param name Define the name of the texture
  25065. * @param size Define the size of the buffers to render to
  25066. * @param count Define the number of target we are rendering into
  25067. * @param scene Define the scene the texture belongs to
  25068. * @param options Define the options used to create the multi render target
  25069. */
  25070. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25071. private _initTypes;
  25072. /** @hidden */
  25073. _rebuild(forceFullRebuild?: boolean): void;
  25074. private _createInternalTextures;
  25075. private _createTextures;
  25076. /**
  25077. * Define the number of samples used if MSAA is enabled.
  25078. */
  25079. get samples(): number;
  25080. set samples(value: number);
  25081. /**
  25082. * Resize all the textures in the multi render target.
  25083. * Be careful as it will recreate all the data in the new texture.
  25084. * @param size Define the new size
  25085. */
  25086. resize(size: any): void;
  25087. /**
  25088. * Changes the number of render targets in this MRT
  25089. * Be careful as it will recreate all the data in the new texture.
  25090. * @param count new texture count
  25091. * @param options Specifies texture types and sampling modes for new textures
  25092. */
  25093. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  25094. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25095. /**
  25096. * Dispose the render targets and their associated resources
  25097. */
  25098. dispose(): void;
  25099. /**
  25100. * Release all the underlying texture used as draw buffers.
  25101. */
  25102. releaseInternalTextures(): void;
  25103. }
  25104. }
  25105. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  25106. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  25107. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25108. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  25109. /** @hidden */
  25110. export var imageProcessingPixelShader: {
  25111. name: string;
  25112. shader: string;
  25113. };
  25114. }
  25115. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  25116. import { Nullable } from "babylonjs/types";
  25117. import { Color4 } from "babylonjs/Maths/math.color";
  25118. import { Camera } from "babylonjs/Cameras/camera";
  25119. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25120. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  25121. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  25122. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25123. import { Engine } from "babylonjs/Engines/engine";
  25124. import "babylonjs/Shaders/imageProcessing.fragment";
  25125. import "babylonjs/Shaders/postprocess.vertex";
  25126. /**
  25127. * ImageProcessingPostProcess
  25128. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  25129. */
  25130. export class ImageProcessingPostProcess extends PostProcess {
  25131. /**
  25132. * Default configuration related to image processing available in the PBR Material.
  25133. */
  25134. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25135. /**
  25136. * Gets the image processing configuration used either in this material.
  25137. */
  25138. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25139. /**
  25140. * Sets the Default image processing configuration used either in the this material.
  25141. *
  25142. * If sets to null, the scene one is in use.
  25143. */
  25144. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25145. /**
  25146. * Keep track of the image processing observer to allow dispose and replace.
  25147. */
  25148. private _imageProcessingObserver;
  25149. /**
  25150. * Attaches a new image processing configuration to the PBR Material.
  25151. * @param configuration
  25152. */
  25153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25154. /**
  25155. * If the post process is supported.
  25156. */
  25157. get isSupported(): boolean;
  25158. /**
  25159. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25160. */
  25161. get colorCurves(): Nullable<ColorCurves>;
  25162. /**
  25163. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25164. */
  25165. set colorCurves(value: Nullable<ColorCurves>);
  25166. /**
  25167. * Gets wether the color curves effect is enabled.
  25168. */
  25169. get colorCurvesEnabled(): boolean;
  25170. /**
  25171. * Sets wether the color curves effect is enabled.
  25172. */
  25173. set colorCurvesEnabled(value: boolean);
  25174. /**
  25175. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25176. */
  25177. get colorGradingTexture(): Nullable<BaseTexture>;
  25178. /**
  25179. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25180. */
  25181. set colorGradingTexture(value: Nullable<BaseTexture>);
  25182. /**
  25183. * Gets wether the color grading effect is enabled.
  25184. */
  25185. get colorGradingEnabled(): boolean;
  25186. /**
  25187. * Gets wether the color grading effect is enabled.
  25188. */
  25189. set colorGradingEnabled(value: boolean);
  25190. /**
  25191. * Gets exposure used in the effect.
  25192. */
  25193. get exposure(): number;
  25194. /**
  25195. * Sets exposure used in the effect.
  25196. */
  25197. set exposure(value: number);
  25198. /**
  25199. * Gets wether tonemapping is enabled or not.
  25200. */
  25201. get toneMappingEnabled(): boolean;
  25202. /**
  25203. * Sets wether tonemapping is enabled or not
  25204. */
  25205. set toneMappingEnabled(value: boolean);
  25206. /**
  25207. * Gets the type of tone mapping effect.
  25208. */
  25209. get toneMappingType(): number;
  25210. /**
  25211. * Sets the type of tone mapping effect.
  25212. */
  25213. set toneMappingType(value: number);
  25214. /**
  25215. * Gets contrast used in the effect.
  25216. */
  25217. get contrast(): number;
  25218. /**
  25219. * Sets contrast used in the effect.
  25220. */
  25221. set contrast(value: number);
  25222. /**
  25223. * Gets Vignette stretch size.
  25224. */
  25225. get vignetteStretch(): number;
  25226. /**
  25227. * Sets Vignette stretch size.
  25228. */
  25229. set vignetteStretch(value: number);
  25230. /**
  25231. * Gets Vignette centre X Offset.
  25232. */
  25233. get vignetteCentreX(): number;
  25234. /**
  25235. * Sets Vignette centre X Offset.
  25236. */
  25237. set vignetteCentreX(value: number);
  25238. /**
  25239. * Gets Vignette centre Y Offset.
  25240. */
  25241. get vignetteCentreY(): number;
  25242. /**
  25243. * Sets Vignette centre Y Offset.
  25244. */
  25245. set vignetteCentreY(value: number);
  25246. /**
  25247. * Gets Vignette weight or intensity of the vignette effect.
  25248. */
  25249. get vignetteWeight(): number;
  25250. /**
  25251. * Sets Vignette weight or intensity of the vignette effect.
  25252. */
  25253. set vignetteWeight(value: number);
  25254. /**
  25255. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25256. * if vignetteEnabled is set to true.
  25257. */
  25258. get vignetteColor(): Color4;
  25259. /**
  25260. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25261. * if vignetteEnabled is set to true.
  25262. */
  25263. set vignetteColor(value: Color4);
  25264. /**
  25265. * Gets Camera field of view used by the Vignette effect.
  25266. */
  25267. get vignetteCameraFov(): number;
  25268. /**
  25269. * Sets Camera field of view used by the Vignette effect.
  25270. */
  25271. set vignetteCameraFov(value: number);
  25272. /**
  25273. * Gets the vignette blend mode allowing different kind of effect.
  25274. */
  25275. get vignetteBlendMode(): number;
  25276. /**
  25277. * Sets the vignette blend mode allowing different kind of effect.
  25278. */
  25279. set vignetteBlendMode(value: number);
  25280. /**
  25281. * Gets wether the vignette effect is enabled.
  25282. */
  25283. get vignetteEnabled(): boolean;
  25284. /**
  25285. * Sets wether the vignette effect is enabled.
  25286. */
  25287. set vignetteEnabled(value: boolean);
  25288. private _fromLinearSpace;
  25289. /**
  25290. * Gets wether the input of the processing is in Gamma or Linear Space.
  25291. */
  25292. get fromLinearSpace(): boolean;
  25293. /**
  25294. * Sets wether the input of the processing is in Gamma or Linear Space.
  25295. */
  25296. set fromLinearSpace(value: boolean);
  25297. /**
  25298. * Defines cache preventing GC.
  25299. */
  25300. private _defines;
  25301. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25302. /**
  25303. * "ImageProcessingPostProcess"
  25304. * @returns "ImageProcessingPostProcess"
  25305. */
  25306. getClassName(): string;
  25307. /**
  25308. * @hidden
  25309. */
  25310. _updateParameters(): void;
  25311. dispose(camera?: Camera): void;
  25312. }
  25313. }
  25314. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25315. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25316. /**
  25317. * Interface for defining prepass effects in the prepass post-process pipeline
  25318. */
  25319. export interface PrePassEffectConfiguration {
  25320. /**
  25321. * Name of the effect
  25322. */
  25323. name: string;
  25324. /**
  25325. * Post process to attach for this effect
  25326. */
  25327. postProcess?: PostProcess;
  25328. /**
  25329. * Textures required in the MRT
  25330. */
  25331. texturesRequired: number[];
  25332. /**
  25333. * Is the effect enabled
  25334. */
  25335. enabled: boolean;
  25336. /**
  25337. * Disposes the effect configuration
  25338. */
  25339. dispose(): void;
  25340. /**
  25341. * Creates the associated post process
  25342. */
  25343. createPostProcess?: () => PostProcess;
  25344. }
  25345. }
  25346. declare module "babylonjs/Rendering/prePassRenderer" {
  25347. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25348. import { Scene } from "babylonjs/scene";
  25349. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25350. import { Effect } from "babylonjs/Materials/effect";
  25351. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25352. /**
  25353. * Renders a pre pass of the scene
  25354. * This means every mesh in the scene will be rendered to a render target texture
  25355. * And then this texture will be composited to the rendering canvas with post processes
  25356. * It is necessary for effects like subsurface scattering or deferred shading
  25357. */
  25358. export class PrePassRenderer {
  25359. /** @hidden */
  25360. static _SceneComponentInitialization: (scene: Scene) => void;
  25361. private _textureFormats;
  25362. private _textureIndices;
  25363. private _scene;
  25364. private _engine;
  25365. private _isDirty;
  25366. /**
  25367. * Number of textures in the multi render target texture where the scene is directly rendered
  25368. */
  25369. mrtCount: number;
  25370. /**
  25371. * The render target where the scene is directly rendered
  25372. */
  25373. prePassRT: MultiRenderTarget;
  25374. private _multiRenderAttachments;
  25375. private _defaultAttachments;
  25376. private _clearAttachments;
  25377. private _postProcesses;
  25378. private readonly _clearColor;
  25379. /**
  25380. * Image processing post process for composition
  25381. */
  25382. imageProcessingPostProcess: ImageProcessingPostProcess;
  25383. /**
  25384. * Configuration for prepass effects
  25385. */
  25386. private _effectConfigurations;
  25387. /**
  25388. * Should materials render their geometry on the MRT
  25389. */
  25390. materialsShouldRenderGeometry: boolean;
  25391. /**
  25392. * Should materials render the irradiance information on the MRT
  25393. */
  25394. materialsShouldRenderIrradiance: boolean;
  25395. private _mrtFormats;
  25396. private _mrtLayout;
  25397. private _enabled;
  25398. /**
  25399. * Indicates if the prepass is enabled
  25400. */
  25401. get enabled(): boolean;
  25402. /**
  25403. * How many samples are used for MSAA of the scene render target
  25404. */
  25405. get samples(): number;
  25406. set samples(n: number);
  25407. /**
  25408. * Instanciates a prepass renderer
  25409. * @param scene The scene
  25410. */
  25411. constructor(scene: Scene);
  25412. private _initializeAttachments;
  25413. private _createCompositionEffect;
  25414. /**
  25415. * Indicates if rendering a prepass is supported
  25416. */
  25417. get isSupported(): boolean;
  25418. /**
  25419. * Sets the proper output textures to draw in the engine.
  25420. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25421. */
  25422. bindAttachmentsForEffect(effect: Effect): void;
  25423. /**
  25424. * @hidden
  25425. */
  25426. _beforeCameraDraw(): void;
  25427. /**
  25428. * @hidden
  25429. */
  25430. _afterCameraDraw(): void;
  25431. private _checkRTSize;
  25432. private _bindFrameBuffer;
  25433. /**
  25434. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25435. */
  25436. clear(): void;
  25437. private _setState;
  25438. private _checkTextureType;
  25439. /**
  25440. * Adds an effect configuration to the prepass.
  25441. * If an effect has already been added, it won't add it twice and will return the configuration
  25442. * already present.
  25443. * @param cfg the effect configuration
  25444. * @return the effect configuration now used by the prepass
  25445. */
  25446. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  25447. /**
  25448. * Returns the index of a texture in the multi render target texture array.
  25449. * @param type Texture type
  25450. * @return The index
  25451. */
  25452. getIndex(type: number): number;
  25453. private _enable;
  25454. private _disable;
  25455. private _resetLayout;
  25456. private _resetPostProcessChain;
  25457. private _bindPostProcessChain;
  25458. /**
  25459. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25460. */
  25461. markAsDirty(): void;
  25462. /**
  25463. * Enables a texture on the MultiRenderTarget for prepass
  25464. */
  25465. private _enableTextures;
  25466. private _update;
  25467. /**
  25468. * Disposes the prepass renderer.
  25469. */
  25470. dispose(): void;
  25471. }
  25472. }
  25473. declare module "babylonjs/Materials/material" {
  25474. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25475. import { SmartArray } from "babylonjs/Misc/smartArray";
  25476. import { Observable } from "babylonjs/Misc/observable";
  25477. import { Nullable } from "babylonjs/types";
  25478. import { Scene } from "babylonjs/scene";
  25479. import { Matrix } from "babylonjs/Maths/math.vector";
  25480. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25482. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25483. import { Effect } from "babylonjs/Materials/effect";
  25484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25485. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25486. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25487. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25488. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25489. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25490. import { Mesh } from "babylonjs/Meshes/mesh";
  25491. import { Animation } from "babylonjs/Animations/animation";
  25492. /**
  25493. * Options for compiling materials.
  25494. */
  25495. export interface IMaterialCompilationOptions {
  25496. /**
  25497. * Defines whether clip planes are enabled.
  25498. */
  25499. clipPlane: boolean;
  25500. /**
  25501. * Defines whether instances are enabled.
  25502. */
  25503. useInstances: boolean;
  25504. }
  25505. /**
  25506. * Options passed when calling customShaderNameResolve
  25507. */
  25508. export interface ICustomShaderNameResolveOptions {
  25509. /**
  25510. * 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
  25511. */
  25512. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25513. }
  25514. /**
  25515. * Base class for the main features of a material in Babylon.js
  25516. */
  25517. export class Material implements IAnimatable {
  25518. /**
  25519. * Returns the triangle fill mode
  25520. */
  25521. static readonly TriangleFillMode: number;
  25522. /**
  25523. * Returns the wireframe mode
  25524. */
  25525. static readonly WireFrameFillMode: number;
  25526. /**
  25527. * Returns the point fill mode
  25528. */
  25529. static readonly PointFillMode: number;
  25530. /**
  25531. * Returns the point list draw mode
  25532. */
  25533. static readonly PointListDrawMode: number;
  25534. /**
  25535. * Returns the line list draw mode
  25536. */
  25537. static readonly LineListDrawMode: number;
  25538. /**
  25539. * Returns the line loop draw mode
  25540. */
  25541. static readonly LineLoopDrawMode: number;
  25542. /**
  25543. * Returns the line strip draw mode
  25544. */
  25545. static readonly LineStripDrawMode: number;
  25546. /**
  25547. * Returns the triangle strip draw mode
  25548. */
  25549. static readonly TriangleStripDrawMode: number;
  25550. /**
  25551. * Returns the triangle fan draw mode
  25552. */
  25553. static readonly TriangleFanDrawMode: number;
  25554. /**
  25555. * Stores the clock-wise side orientation
  25556. */
  25557. static readonly ClockWiseSideOrientation: number;
  25558. /**
  25559. * Stores the counter clock-wise side orientation
  25560. */
  25561. static readonly CounterClockWiseSideOrientation: number;
  25562. /**
  25563. * The dirty texture flag value
  25564. */
  25565. static readonly TextureDirtyFlag: number;
  25566. /**
  25567. * The dirty light flag value
  25568. */
  25569. static readonly LightDirtyFlag: number;
  25570. /**
  25571. * The dirty fresnel flag value
  25572. */
  25573. static readonly FresnelDirtyFlag: number;
  25574. /**
  25575. * The dirty attribute flag value
  25576. */
  25577. static readonly AttributesDirtyFlag: number;
  25578. /**
  25579. * The dirty misc flag value
  25580. */
  25581. static readonly MiscDirtyFlag: number;
  25582. /**
  25583. * The all dirty flag value
  25584. */
  25585. static readonly AllDirtyFlag: number;
  25586. /**
  25587. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25588. */
  25589. static readonly MATERIAL_OPAQUE: number;
  25590. /**
  25591. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25592. */
  25593. static readonly MATERIAL_ALPHATEST: number;
  25594. /**
  25595. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25596. */
  25597. static readonly MATERIAL_ALPHABLEND: number;
  25598. /**
  25599. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25600. * They are also discarded below the alpha cutoff threshold to improve performances.
  25601. */
  25602. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25603. /**
  25604. * The Whiteout method is used to blend normals.
  25605. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25606. */
  25607. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25608. /**
  25609. * The Reoriented Normal Mapping method is used to blend normals.
  25610. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25611. */
  25612. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25613. /**
  25614. * Custom callback helping to override the default shader used in the material.
  25615. */
  25616. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25617. /**
  25618. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25619. */
  25620. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25621. /**
  25622. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25623. * This means that the material can keep using a previous shader while a new one is being compiled.
  25624. * This is mostly used when shader parallel compilation is supported (true by default)
  25625. */
  25626. allowShaderHotSwapping: boolean;
  25627. /**
  25628. * The ID of the material
  25629. */
  25630. id: string;
  25631. /**
  25632. * Gets or sets the unique id of the material
  25633. */
  25634. uniqueId: number;
  25635. /**
  25636. * The name of the material
  25637. */
  25638. name: string;
  25639. /**
  25640. * Gets or sets user defined metadata
  25641. */
  25642. metadata: any;
  25643. /**
  25644. * For internal use only. Please do not use.
  25645. */
  25646. reservedDataStore: any;
  25647. /**
  25648. * Specifies if the ready state should be checked on each call
  25649. */
  25650. checkReadyOnEveryCall: boolean;
  25651. /**
  25652. * Specifies if the ready state should be checked once
  25653. */
  25654. checkReadyOnlyOnce: boolean;
  25655. /**
  25656. * The state of the material
  25657. */
  25658. state: string;
  25659. /**
  25660. * If the material can be rendered to several textures with MRT extension
  25661. */
  25662. get canRenderToMRT(): boolean;
  25663. /**
  25664. * The alpha value of the material
  25665. */
  25666. protected _alpha: number;
  25667. /**
  25668. * List of inspectable custom properties (used by the Inspector)
  25669. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25670. */
  25671. inspectableCustomProperties: IInspectable[];
  25672. /**
  25673. * Sets the alpha value of the material
  25674. */
  25675. set alpha(value: number);
  25676. /**
  25677. * Gets the alpha value of the material
  25678. */
  25679. get alpha(): number;
  25680. /**
  25681. * Specifies if back face culling is enabled
  25682. */
  25683. protected _backFaceCulling: boolean;
  25684. /**
  25685. * Sets the back-face culling state
  25686. */
  25687. set backFaceCulling(value: boolean);
  25688. /**
  25689. * Gets the back-face culling state
  25690. */
  25691. get backFaceCulling(): boolean;
  25692. /**
  25693. * Stores the value for side orientation
  25694. */
  25695. sideOrientation: number;
  25696. /**
  25697. * Callback triggered when the material is compiled
  25698. */
  25699. onCompiled: Nullable<(effect: Effect) => void>;
  25700. /**
  25701. * Callback triggered when an error occurs
  25702. */
  25703. onError: Nullable<(effect: Effect, errors: string) => void>;
  25704. /**
  25705. * Callback triggered to get the render target textures
  25706. */
  25707. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25708. /**
  25709. * Gets a boolean indicating that current material needs to register RTT
  25710. */
  25711. get hasRenderTargetTextures(): boolean;
  25712. /**
  25713. * Specifies if the material should be serialized
  25714. */
  25715. doNotSerialize: boolean;
  25716. /**
  25717. * @hidden
  25718. */
  25719. _storeEffectOnSubMeshes: boolean;
  25720. /**
  25721. * Stores the animations for the material
  25722. */
  25723. animations: Nullable<Array<Animation>>;
  25724. /**
  25725. * An event triggered when the material is disposed
  25726. */
  25727. onDisposeObservable: Observable<Material>;
  25728. /**
  25729. * An observer which watches for dispose events
  25730. */
  25731. private _onDisposeObserver;
  25732. private _onUnBindObservable;
  25733. /**
  25734. * Called during a dispose event
  25735. */
  25736. set onDispose(callback: () => void);
  25737. private _onBindObservable;
  25738. /**
  25739. * An event triggered when the material is bound
  25740. */
  25741. get onBindObservable(): Observable<AbstractMesh>;
  25742. /**
  25743. * An observer which watches for bind events
  25744. */
  25745. private _onBindObserver;
  25746. /**
  25747. * Called during a bind event
  25748. */
  25749. set onBind(callback: (Mesh: AbstractMesh) => void);
  25750. /**
  25751. * An event triggered when the material is unbound
  25752. */
  25753. get onUnBindObservable(): Observable<Material>;
  25754. protected _onEffectCreatedObservable: Nullable<Observable<{
  25755. effect: Effect;
  25756. subMesh: Nullable<SubMesh>;
  25757. }>>;
  25758. /**
  25759. * An event triggered when the effect is (re)created
  25760. */
  25761. get onEffectCreatedObservable(): Observable<{
  25762. effect: Effect;
  25763. subMesh: Nullable<SubMesh>;
  25764. }>;
  25765. /**
  25766. * Stores the value of the alpha mode
  25767. */
  25768. private _alphaMode;
  25769. /**
  25770. * Sets the value of the alpha mode.
  25771. *
  25772. * | Value | Type | Description |
  25773. * | --- | --- | --- |
  25774. * | 0 | ALPHA_DISABLE | |
  25775. * | 1 | ALPHA_ADD | |
  25776. * | 2 | ALPHA_COMBINE | |
  25777. * | 3 | ALPHA_SUBTRACT | |
  25778. * | 4 | ALPHA_MULTIPLY | |
  25779. * | 5 | ALPHA_MAXIMIZED | |
  25780. * | 6 | ALPHA_ONEONE | |
  25781. * | 7 | ALPHA_PREMULTIPLIED | |
  25782. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25783. * | 9 | ALPHA_INTERPOLATE | |
  25784. * | 10 | ALPHA_SCREENMODE | |
  25785. *
  25786. */
  25787. set alphaMode(value: number);
  25788. /**
  25789. * Gets the value of the alpha mode
  25790. */
  25791. get alphaMode(): number;
  25792. /**
  25793. * Stores the state of the need depth pre-pass value
  25794. */
  25795. private _needDepthPrePass;
  25796. /**
  25797. * Sets the need depth pre-pass value
  25798. */
  25799. set needDepthPrePass(value: boolean);
  25800. /**
  25801. * Gets the depth pre-pass value
  25802. */
  25803. get needDepthPrePass(): boolean;
  25804. /**
  25805. * Specifies if depth writing should be disabled
  25806. */
  25807. disableDepthWrite: boolean;
  25808. /**
  25809. * Specifies if color writing should be disabled
  25810. */
  25811. disableColorWrite: boolean;
  25812. /**
  25813. * Specifies if depth writing should be forced
  25814. */
  25815. forceDepthWrite: boolean;
  25816. /**
  25817. * Specifies the depth function that should be used. 0 means the default engine function
  25818. */
  25819. depthFunction: number;
  25820. /**
  25821. * Specifies if there should be a separate pass for culling
  25822. */
  25823. separateCullingPass: boolean;
  25824. /**
  25825. * Stores the state specifing if fog should be enabled
  25826. */
  25827. private _fogEnabled;
  25828. /**
  25829. * Sets the state for enabling fog
  25830. */
  25831. set fogEnabled(value: boolean);
  25832. /**
  25833. * Gets the value of the fog enabled state
  25834. */
  25835. get fogEnabled(): boolean;
  25836. /**
  25837. * Stores the size of points
  25838. */
  25839. pointSize: number;
  25840. /**
  25841. * Stores the z offset value
  25842. */
  25843. zOffset: number;
  25844. get wireframe(): boolean;
  25845. /**
  25846. * Sets the state of wireframe mode
  25847. */
  25848. set wireframe(value: boolean);
  25849. /**
  25850. * Gets the value specifying if point clouds are enabled
  25851. */
  25852. get pointsCloud(): boolean;
  25853. /**
  25854. * Sets the state of point cloud mode
  25855. */
  25856. set pointsCloud(value: boolean);
  25857. /**
  25858. * Gets the material fill mode
  25859. */
  25860. get fillMode(): number;
  25861. /**
  25862. * Sets the material fill mode
  25863. */
  25864. set fillMode(value: number);
  25865. /**
  25866. * @hidden
  25867. * Stores the effects for the material
  25868. */
  25869. _effect: Nullable<Effect>;
  25870. /**
  25871. * Specifies if uniform buffers should be used
  25872. */
  25873. private _useUBO;
  25874. /**
  25875. * Stores a reference to the scene
  25876. */
  25877. private _scene;
  25878. /**
  25879. * Stores the fill mode state
  25880. */
  25881. private _fillMode;
  25882. /**
  25883. * Specifies if the depth write state should be cached
  25884. */
  25885. private _cachedDepthWriteState;
  25886. /**
  25887. * Specifies if the color write state should be cached
  25888. */
  25889. private _cachedColorWriteState;
  25890. /**
  25891. * Specifies if the depth function state should be cached
  25892. */
  25893. private _cachedDepthFunctionState;
  25894. /**
  25895. * Stores the uniform buffer
  25896. */
  25897. protected _uniformBuffer: UniformBuffer;
  25898. /** @hidden */
  25899. _indexInSceneMaterialArray: number;
  25900. /** @hidden */
  25901. meshMap: Nullable<{
  25902. [id: string]: AbstractMesh | undefined;
  25903. }>;
  25904. /**
  25905. * Creates a material instance
  25906. * @param name defines the name of the material
  25907. * @param scene defines the scene to reference
  25908. * @param doNotAdd specifies if the material should be added to the scene
  25909. */
  25910. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25911. /**
  25912. * Returns a string representation of the current material
  25913. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25914. * @returns a string with material information
  25915. */
  25916. toString(fullDetails?: boolean): string;
  25917. /**
  25918. * Gets the class name of the material
  25919. * @returns a string with the class name of the material
  25920. */
  25921. getClassName(): string;
  25922. /**
  25923. * Specifies if updates for the material been locked
  25924. */
  25925. get isFrozen(): boolean;
  25926. /**
  25927. * Locks updates for the material
  25928. */
  25929. freeze(): void;
  25930. /**
  25931. * Unlocks updates for the material
  25932. */
  25933. unfreeze(): void;
  25934. /**
  25935. * Specifies if the material is ready to be used
  25936. * @param mesh defines the mesh to check
  25937. * @param useInstances specifies if instances should be used
  25938. * @returns a boolean indicating if the material is ready to be used
  25939. */
  25940. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25941. /**
  25942. * Specifies that the submesh is ready to be used
  25943. * @param mesh defines the mesh to check
  25944. * @param subMesh defines which submesh to check
  25945. * @param useInstances specifies that instances should be used
  25946. * @returns a boolean indicating that the submesh is ready or not
  25947. */
  25948. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25949. /**
  25950. * Returns the material effect
  25951. * @returns the effect associated with the material
  25952. */
  25953. getEffect(): Nullable<Effect>;
  25954. /**
  25955. * Returns the current scene
  25956. * @returns a Scene
  25957. */
  25958. getScene(): Scene;
  25959. /**
  25960. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25961. */
  25962. protected _forceAlphaTest: boolean;
  25963. /**
  25964. * The transparency mode of the material.
  25965. */
  25966. protected _transparencyMode: Nullable<number>;
  25967. /**
  25968. * Gets the current transparency mode.
  25969. */
  25970. get transparencyMode(): Nullable<number>;
  25971. /**
  25972. * Sets the transparency mode of the material.
  25973. *
  25974. * | Value | Type | Description |
  25975. * | ----- | ----------------------------------- | ----------- |
  25976. * | 0 | OPAQUE | |
  25977. * | 1 | ALPHATEST | |
  25978. * | 2 | ALPHABLEND | |
  25979. * | 3 | ALPHATESTANDBLEND | |
  25980. *
  25981. */
  25982. set transparencyMode(value: Nullable<number>);
  25983. /**
  25984. * Returns true if alpha blending should be disabled.
  25985. */
  25986. protected get _disableAlphaBlending(): boolean;
  25987. /**
  25988. * Specifies whether or not this material should be rendered in alpha blend mode.
  25989. * @returns a boolean specifying if alpha blending is needed
  25990. */
  25991. needAlphaBlending(): boolean;
  25992. /**
  25993. * Specifies if the mesh will require alpha blending
  25994. * @param mesh defines the mesh to check
  25995. * @returns a boolean specifying if alpha blending is needed for the mesh
  25996. */
  25997. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25998. /**
  25999. * Specifies whether or not this material should be rendered in alpha test mode.
  26000. * @returns a boolean specifying if an alpha test is needed.
  26001. */
  26002. needAlphaTesting(): boolean;
  26003. /**
  26004. * Specifies if material alpha testing should be turned on for the mesh
  26005. * @param mesh defines the mesh to check
  26006. */
  26007. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26008. /**
  26009. * Gets the texture used for the alpha test
  26010. * @returns the texture to use for alpha testing
  26011. */
  26012. getAlphaTestTexture(): Nullable<BaseTexture>;
  26013. /**
  26014. * Marks the material to indicate that it needs to be re-calculated
  26015. */
  26016. markDirty(): void;
  26017. /** @hidden */
  26018. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26019. /**
  26020. * Binds the material to the mesh
  26021. * @param world defines the world transformation matrix
  26022. * @param mesh defines the mesh to bind the material to
  26023. */
  26024. bind(world: Matrix, mesh?: Mesh): void;
  26025. /**
  26026. * Binds the submesh to the material
  26027. * @param world defines the world transformation matrix
  26028. * @param mesh defines the mesh containing the submesh
  26029. * @param subMesh defines the submesh to bind the material to
  26030. */
  26031. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26032. /**
  26033. * Binds the world matrix to the material
  26034. * @param world defines the world transformation matrix
  26035. */
  26036. bindOnlyWorldMatrix(world: Matrix): void;
  26037. /**
  26038. * Binds the scene's uniform buffer to the effect.
  26039. * @param effect defines the effect to bind to the scene uniform buffer
  26040. * @param sceneUbo defines the uniform buffer storing scene data
  26041. */
  26042. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26043. /**
  26044. * Binds the view matrix to the effect
  26045. * @param effect defines the effect to bind the view matrix to
  26046. */
  26047. bindView(effect: Effect): void;
  26048. /**
  26049. * Binds the view projection matrix to the effect
  26050. * @param effect defines the effect to bind the view projection matrix to
  26051. */
  26052. bindViewProjection(effect: Effect): void;
  26053. /**
  26054. * Processes to execute after binding the material to a mesh
  26055. * @param mesh defines the rendered mesh
  26056. */
  26057. protected _afterBind(mesh?: Mesh): void;
  26058. /**
  26059. * Unbinds the material from the mesh
  26060. */
  26061. unbind(): void;
  26062. /**
  26063. * Gets the active textures from the material
  26064. * @returns an array of textures
  26065. */
  26066. getActiveTextures(): BaseTexture[];
  26067. /**
  26068. * Specifies if the material uses a texture
  26069. * @param texture defines the texture to check against the material
  26070. * @returns a boolean specifying if the material uses the texture
  26071. */
  26072. hasTexture(texture: BaseTexture): boolean;
  26073. /**
  26074. * Makes a duplicate of the material, and gives it a new name
  26075. * @param name defines the new name for the duplicated material
  26076. * @returns the cloned material
  26077. */
  26078. clone(name: string): Nullable<Material>;
  26079. /**
  26080. * Gets the meshes bound to the material
  26081. * @returns an array of meshes bound to the material
  26082. */
  26083. getBindedMeshes(): AbstractMesh[];
  26084. /**
  26085. * Force shader compilation
  26086. * @param mesh defines the mesh associated with this material
  26087. * @param onCompiled defines a function to execute once the material is compiled
  26088. * @param options defines the options to configure the compilation
  26089. * @param onError defines a function to execute if the material fails compiling
  26090. */
  26091. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26092. /**
  26093. * Force shader compilation
  26094. * @param mesh defines the mesh that will use this material
  26095. * @param options defines additional options for compiling the shaders
  26096. * @returns a promise that resolves when the compilation completes
  26097. */
  26098. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26099. private static readonly _AllDirtyCallBack;
  26100. private static readonly _ImageProcessingDirtyCallBack;
  26101. private static readonly _TextureDirtyCallBack;
  26102. private static readonly _FresnelDirtyCallBack;
  26103. private static readonly _MiscDirtyCallBack;
  26104. private static readonly _LightsDirtyCallBack;
  26105. private static readonly _AttributeDirtyCallBack;
  26106. private static _FresnelAndMiscDirtyCallBack;
  26107. private static _TextureAndMiscDirtyCallBack;
  26108. private static readonly _DirtyCallbackArray;
  26109. private static readonly _RunDirtyCallBacks;
  26110. /**
  26111. * Marks a define in the material to indicate that it needs to be re-computed
  26112. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26113. */
  26114. markAsDirty(flag: number): void;
  26115. /**
  26116. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26117. * @param func defines a function which checks material defines against the submeshes
  26118. */
  26119. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26120. /**
  26121. * Indicates that the scene should check if the rendering now needs a prepass
  26122. */
  26123. protected _markScenePrePassDirty(): void;
  26124. /**
  26125. * Indicates that we need to re-calculated for all submeshes
  26126. */
  26127. protected _markAllSubMeshesAsAllDirty(): void;
  26128. /**
  26129. * Indicates that image processing needs to be re-calculated for all submeshes
  26130. */
  26131. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26132. /**
  26133. * Indicates that textures need to be re-calculated for all submeshes
  26134. */
  26135. protected _markAllSubMeshesAsTexturesDirty(): void;
  26136. /**
  26137. * Indicates that fresnel needs to be re-calculated for all submeshes
  26138. */
  26139. protected _markAllSubMeshesAsFresnelDirty(): void;
  26140. /**
  26141. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26142. */
  26143. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26144. /**
  26145. * Indicates that lights need to be re-calculated for all submeshes
  26146. */
  26147. protected _markAllSubMeshesAsLightsDirty(): void;
  26148. /**
  26149. * Indicates that attributes need to be re-calculated for all submeshes
  26150. */
  26151. protected _markAllSubMeshesAsAttributesDirty(): void;
  26152. /**
  26153. * Indicates that misc needs to be re-calculated for all submeshes
  26154. */
  26155. protected _markAllSubMeshesAsMiscDirty(): void;
  26156. /**
  26157. * Indicates that textures and misc need to be re-calculated for all submeshes
  26158. */
  26159. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26160. /**
  26161. * Sets the required values to the prepass renderer.
  26162. * @param prePassRenderer defines the prepass renderer to setup.
  26163. * @returns true if the pre pass is needed.
  26164. */
  26165. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26166. /**
  26167. * Disposes the material
  26168. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26169. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26170. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26171. */
  26172. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26173. /** @hidden */
  26174. private releaseVertexArrayObject;
  26175. /**
  26176. * Serializes this material
  26177. * @returns the serialized material object
  26178. */
  26179. serialize(): any;
  26180. /**
  26181. * Creates a material from parsed material data
  26182. * @param parsedMaterial defines parsed material data
  26183. * @param scene defines the hosting scene
  26184. * @param rootUrl defines the root URL to use to load textures
  26185. * @returns a new material
  26186. */
  26187. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26188. }
  26189. }
  26190. declare module "babylonjs/Materials/multiMaterial" {
  26191. import { Nullable } from "babylonjs/types";
  26192. import { Scene } from "babylonjs/scene";
  26193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26194. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26195. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26196. import { Material } from "babylonjs/Materials/material";
  26197. /**
  26198. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26199. * separate meshes. This can be use to improve performances.
  26200. * @see https://doc.babylonjs.com/how_to/multi_materials
  26201. */
  26202. export class MultiMaterial extends Material {
  26203. private _subMaterials;
  26204. /**
  26205. * Gets or Sets the list of Materials used within the multi material.
  26206. * They need to be ordered according to the submeshes order in the associated mesh
  26207. */
  26208. get subMaterials(): Nullable<Material>[];
  26209. set subMaterials(value: Nullable<Material>[]);
  26210. /**
  26211. * Function used to align with Node.getChildren()
  26212. * @returns the list of Materials used within the multi material
  26213. */
  26214. getChildren(): Nullable<Material>[];
  26215. /**
  26216. * Instantiates a new Multi Material
  26217. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26218. * separate meshes. This can be use to improve performances.
  26219. * @see https://doc.babylonjs.com/how_to/multi_materials
  26220. * @param name Define the name in the scene
  26221. * @param scene Define the scene the material belongs to
  26222. */
  26223. constructor(name: string, scene: Scene);
  26224. private _hookArray;
  26225. /**
  26226. * Get one of the submaterial by its index in the submaterials array
  26227. * @param index The index to look the sub material at
  26228. * @returns The Material if the index has been defined
  26229. */
  26230. getSubMaterial(index: number): Nullable<Material>;
  26231. /**
  26232. * Get the list of active textures for the whole sub materials list.
  26233. * @returns All the textures that will be used during the rendering
  26234. */
  26235. getActiveTextures(): BaseTexture[];
  26236. /**
  26237. * Gets the current class name of the material e.g. "MultiMaterial"
  26238. * Mainly use in serialization.
  26239. * @returns the class name
  26240. */
  26241. getClassName(): string;
  26242. /**
  26243. * Checks if the material is ready to render the requested sub mesh
  26244. * @param mesh Define the mesh the submesh belongs to
  26245. * @param subMesh Define the sub mesh to look readyness for
  26246. * @param useInstances Define whether or not the material is used with instances
  26247. * @returns true if ready, otherwise false
  26248. */
  26249. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26250. /**
  26251. * Clones the current material and its related sub materials
  26252. * @param name Define the name of the newly cloned material
  26253. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26254. * @returns the cloned material
  26255. */
  26256. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26257. /**
  26258. * Serializes the materials into a JSON representation.
  26259. * @returns the JSON representation
  26260. */
  26261. serialize(): any;
  26262. /**
  26263. * Dispose the material and release its associated resources
  26264. * @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)
  26265. * @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)
  26266. * @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)
  26267. */
  26268. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26269. /**
  26270. * Creates a MultiMaterial from parsed MultiMaterial data.
  26271. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26272. * @param scene defines the hosting scene
  26273. * @returns a new MultiMaterial
  26274. */
  26275. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26276. }
  26277. }
  26278. declare module "babylonjs/Meshes/subMesh" {
  26279. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26280. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26281. import { Engine } from "babylonjs/Engines/engine";
  26282. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26283. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26284. import { Effect } from "babylonjs/Materials/effect";
  26285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26286. import { Plane } from "babylonjs/Maths/math.plane";
  26287. import { Collider } from "babylonjs/Collisions/collider";
  26288. import { Material } from "babylonjs/Materials/material";
  26289. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26291. import { Mesh } from "babylonjs/Meshes/mesh";
  26292. import { Ray } from "babylonjs/Culling/ray";
  26293. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26294. /**
  26295. * Defines a subdivision inside a mesh
  26296. */
  26297. export class SubMesh implements ICullable {
  26298. /** the material index to use */
  26299. materialIndex: number;
  26300. /** vertex index start */
  26301. verticesStart: number;
  26302. /** vertices count */
  26303. verticesCount: number;
  26304. /** index start */
  26305. indexStart: number;
  26306. /** indices count */
  26307. indexCount: number;
  26308. /** @hidden */
  26309. _materialDefines: Nullable<MaterialDefines>;
  26310. /** @hidden */
  26311. _materialEffect: Nullable<Effect>;
  26312. /** @hidden */
  26313. _effectOverride: Nullable<Effect>;
  26314. /**
  26315. * Gets material defines used by the effect associated to the sub mesh
  26316. */
  26317. get materialDefines(): Nullable<MaterialDefines>;
  26318. /**
  26319. * Sets material defines used by the effect associated to the sub mesh
  26320. */
  26321. set materialDefines(defines: Nullable<MaterialDefines>);
  26322. /**
  26323. * Gets associated effect
  26324. */
  26325. get effect(): Nullable<Effect>;
  26326. /**
  26327. * Sets associated effect (effect used to render this submesh)
  26328. * @param effect defines the effect to associate with
  26329. * @param defines defines the set of defines used to compile this effect
  26330. */
  26331. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26332. /** @hidden */
  26333. _linesIndexCount: number;
  26334. private _mesh;
  26335. private _renderingMesh;
  26336. private _boundingInfo;
  26337. private _linesIndexBuffer;
  26338. /** @hidden */
  26339. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26340. /** @hidden */
  26341. _trianglePlanes: Plane[];
  26342. /** @hidden */
  26343. _lastColliderTransformMatrix: Nullable<Matrix>;
  26344. /** @hidden */
  26345. _renderId: number;
  26346. /** @hidden */
  26347. _alphaIndex: number;
  26348. /** @hidden */
  26349. _distanceToCamera: number;
  26350. /** @hidden */
  26351. _id: number;
  26352. private _currentMaterial;
  26353. /**
  26354. * Add a new submesh to a mesh
  26355. * @param materialIndex defines the material index to use
  26356. * @param verticesStart defines vertex index start
  26357. * @param verticesCount defines vertices count
  26358. * @param indexStart defines index start
  26359. * @param indexCount defines indices count
  26360. * @param mesh defines the parent mesh
  26361. * @param renderingMesh defines an optional rendering mesh
  26362. * @param createBoundingBox defines if bounding box should be created for this submesh
  26363. * @returns the new submesh
  26364. */
  26365. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26366. /**
  26367. * Creates a new submesh
  26368. * @param materialIndex defines the material index to use
  26369. * @param verticesStart defines vertex index start
  26370. * @param verticesCount defines vertices count
  26371. * @param indexStart defines index start
  26372. * @param indexCount defines indices count
  26373. * @param mesh defines the parent mesh
  26374. * @param renderingMesh defines an optional rendering mesh
  26375. * @param createBoundingBox defines if bounding box should be created for this submesh
  26376. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26377. */
  26378. constructor(
  26379. /** the material index to use */
  26380. materialIndex: number,
  26381. /** vertex index start */
  26382. verticesStart: number,
  26383. /** vertices count */
  26384. verticesCount: number,
  26385. /** index start */
  26386. indexStart: number,
  26387. /** indices count */
  26388. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26389. /**
  26390. * Returns true if this submesh covers the entire parent mesh
  26391. * @ignorenaming
  26392. */
  26393. get IsGlobal(): boolean;
  26394. /**
  26395. * Returns the submesh BoudingInfo object
  26396. * @returns current bounding info (or mesh's one if the submesh is global)
  26397. */
  26398. getBoundingInfo(): BoundingInfo;
  26399. /**
  26400. * Sets the submesh BoundingInfo
  26401. * @param boundingInfo defines the new bounding info to use
  26402. * @returns the SubMesh
  26403. */
  26404. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26405. /**
  26406. * Returns the mesh of the current submesh
  26407. * @return the parent mesh
  26408. */
  26409. getMesh(): AbstractMesh;
  26410. /**
  26411. * Returns the rendering mesh of the submesh
  26412. * @returns the rendering mesh (could be different from parent mesh)
  26413. */
  26414. getRenderingMesh(): Mesh;
  26415. /**
  26416. * Returns the replacement mesh of the submesh
  26417. * @returns the replacement mesh (could be different from parent mesh)
  26418. */
  26419. getReplacementMesh(): Nullable<AbstractMesh>;
  26420. /**
  26421. * Returns the effective mesh of the submesh
  26422. * @returns the effective mesh (could be different from parent mesh)
  26423. */
  26424. getEffectiveMesh(): AbstractMesh;
  26425. /**
  26426. * Returns the submesh material
  26427. * @returns null or the current material
  26428. */
  26429. getMaterial(): Nullable<Material>;
  26430. private _IsMultiMaterial;
  26431. /**
  26432. * Sets a new updated BoundingInfo object to the submesh
  26433. * @param data defines an optional position array to use to determine the bounding info
  26434. * @returns the SubMesh
  26435. */
  26436. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26437. /** @hidden */
  26438. _checkCollision(collider: Collider): boolean;
  26439. /**
  26440. * Updates the submesh BoundingInfo
  26441. * @param world defines the world matrix to use to update the bounding info
  26442. * @returns the submesh
  26443. */
  26444. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26445. /**
  26446. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26447. * @param frustumPlanes defines the frustum planes
  26448. * @returns true if the submesh is intersecting with the frustum
  26449. */
  26450. isInFrustum(frustumPlanes: Plane[]): boolean;
  26451. /**
  26452. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26453. * @param frustumPlanes defines the frustum planes
  26454. * @returns true if the submesh is inside the frustum
  26455. */
  26456. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26457. /**
  26458. * Renders the submesh
  26459. * @param enableAlphaMode defines if alpha needs to be used
  26460. * @returns the submesh
  26461. */
  26462. render(enableAlphaMode: boolean): SubMesh;
  26463. /**
  26464. * @hidden
  26465. */
  26466. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26467. /**
  26468. * Checks if the submesh intersects with a ray
  26469. * @param ray defines the ray to test
  26470. * @returns true is the passed ray intersects the submesh bounding box
  26471. */
  26472. canIntersects(ray: Ray): boolean;
  26473. /**
  26474. * Intersects current submesh with a ray
  26475. * @param ray defines the ray to test
  26476. * @param positions defines mesh's positions array
  26477. * @param indices defines mesh's indices array
  26478. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26479. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26480. * @returns intersection info or null if no intersection
  26481. */
  26482. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26483. /** @hidden */
  26484. private _intersectLines;
  26485. /** @hidden */
  26486. private _intersectUnIndexedLines;
  26487. /** @hidden */
  26488. private _intersectTriangles;
  26489. /** @hidden */
  26490. private _intersectUnIndexedTriangles;
  26491. /** @hidden */
  26492. _rebuild(): void;
  26493. /**
  26494. * Creates a new submesh from the passed mesh
  26495. * @param newMesh defines the new hosting mesh
  26496. * @param newRenderingMesh defines an optional rendering mesh
  26497. * @returns the new submesh
  26498. */
  26499. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26500. /**
  26501. * Release associated resources
  26502. */
  26503. dispose(): void;
  26504. /**
  26505. * Gets the class name
  26506. * @returns the string "SubMesh".
  26507. */
  26508. getClassName(): string;
  26509. /**
  26510. * Creates a new submesh from indices data
  26511. * @param materialIndex the index of the main mesh material
  26512. * @param startIndex the index where to start the copy in the mesh indices array
  26513. * @param indexCount the number of indices to copy then from the startIndex
  26514. * @param mesh the main mesh to create the submesh from
  26515. * @param renderingMesh the optional rendering mesh
  26516. * @returns a new submesh
  26517. */
  26518. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26519. }
  26520. }
  26521. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26522. /**
  26523. * Class used to represent data loading progression
  26524. */
  26525. export class SceneLoaderFlags {
  26526. private static _ForceFullSceneLoadingForIncremental;
  26527. private static _ShowLoadingScreen;
  26528. private static _CleanBoneMatrixWeights;
  26529. private static _loggingLevel;
  26530. /**
  26531. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26532. */
  26533. static get ForceFullSceneLoadingForIncremental(): boolean;
  26534. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26535. /**
  26536. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26537. */
  26538. static get ShowLoadingScreen(): boolean;
  26539. static set ShowLoadingScreen(value: boolean);
  26540. /**
  26541. * Defines the current logging level (while loading the scene)
  26542. * @ignorenaming
  26543. */
  26544. static get loggingLevel(): number;
  26545. static set loggingLevel(value: number);
  26546. /**
  26547. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26548. */
  26549. static get CleanBoneMatrixWeights(): boolean;
  26550. static set CleanBoneMatrixWeights(value: boolean);
  26551. }
  26552. }
  26553. declare module "babylonjs/Meshes/geometry" {
  26554. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26555. import { Scene } from "babylonjs/scene";
  26556. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26557. import { Engine } from "babylonjs/Engines/engine";
  26558. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26559. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26560. import { Effect } from "babylonjs/Materials/effect";
  26561. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26562. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26563. import { Mesh } from "babylonjs/Meshes/mesh";
  26564. /**
  26565. * Class used to store geometry data (vertex buffers + index buffer)
  26566. */
  26567. export class Geometry implements IGetSetVerticesData {
  26568. /**
  26569. * Gets or sets the ID of the geometry
  26570. */
  26571. id: string;
  26572. /**
  26573. * Gets or sets the unique ID of the geometry
  26574. */
  26575. uniqueId: number;
  26576. /**
  26577. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26578. */
  26579. delayLoadState: number;
  26580. /**
  26581. * Gets the file containing the data to load when running in delay load state
  26582. */
  26583. delayLoadingFile: Nullable<string>;
  26584. /**
  26585. * Callback called when the geometry is updated
  26586. */
  26587. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26588. private _scene;
  26589. private _engine;
  26590. private _meshes;
  26591. private _totalVertices;
  26592. /** @hidden */
  26593. _indices: IndicesArray;
  26594. /** @hidden */
  26595. _vertexBuffers: {
  26596. [key: string]: VertexBuffer;
  26597. };
  26598. private _isDisposed;
  26599. private _extend;
  26600. private _boundingBias;
  26601. /** @hidden */
  26602. _delayInfo: Array<string>;
  26603. private _indexBuffer;
  26604. private _indexBufferIsUpdatable;
  26605. /** @hidden */
  26606. _boundingInfo: Nullable<BoundingInfo>;
  26607. /** @hidden */
  26608. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26609. /** @hidden */
  26610. _softwareSkinningFrameId: number;
  26611. private _vertexArrayObjects;
  26612. private _updatable;
  26613. /** @hidden */
  26614. _positions: Nullable<Vector3[]>;
  26615. /**
  26616. * 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
  26617. */
  26618. get boundingBias(): Vector2;
  26619. /**
  26620. * 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
  26621. */
  26622. set boundingBias(value: Vector2);
  26623. /**
  26624. * Static function used to attach a new empty geometry to a mesh
  26625. * @param mesh defines the mesh to attach the geometry to
  26626. * @returns the new Geometry
  26627. */
  26628. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26629. /** Get the list of meshes using this geometry */
  26630. get meshes(): Mesh[];
  26631. /**
  26632. * 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
  26633. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26634. */
  26635. useBoundingInfoFromGeometry: boolean;
  26636. /**
  26637. * Creates a new geometry
  26638. * @param id defines the unique ID
  26639. * @param scene defines the hosting scene
  26640. * @param vertexData defines the VertexData used to get geometry data
  26641. * @param updatable defines if geometry must be updatable (false by default)
  26642. * @param mesh defines the mesh that will be associated with the geometry
  26643. */
  26644. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26645. /**
  26646. * Gets the current extend of the geometry
  26647. */
  26648. get extend(): {
  26649. minimum: Vector3;
  26650. maximum: Vector3;
  26651. };
  26652. /**
  26653. * Gets the hosting scene
  26654. * @returns the hosting Scene
  26655. */
  26656. getScene(): Scene;
  26657. /**
  26658. * Gets the hosting engine
  26659. * @returns the hosting Engine
  26660. */
  26661. getEngine(): Engine;
  26662. /**
  26663. * Defines if the geometry is ready to use
  26664. * @returns true if the geometry is ready to be used
  26665. */
  26666. isReady(): boolean;
  26667. /**
  26668. * Gets a value indicating that the geometry should not be serialized
  26669. */
  26670. get doNotSerialize(): boolean;
  26671. /** @hidden */
  26672. _rebuild(): void;
  26673. /**
  26674. * Affects all geometry data in one call
  26675. * @param vertexData defines the geometry data
  26676. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26677. */
  26678. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26679. /**
  26680. * Set specific vertex data
  26681. * @param kind defines the data kind (Position, normal, etc...)
  26682. * @param data defines the vertex data to use
  26683. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26684. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26685. */
  26686. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26687. /**
  26688. * Removes a specific vertex data
  26689. * @param kind defines the data kind (Position, normal, etc...)
  26690. */
  26691. removeVerticesData(kind: string): void;
  26692. /**
  26693. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26694. * @param buffer defines the vertex buffer to use
  26695. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26696. */
  26697. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26698. /**
  26699. * Update a specific vertex buffer
  26700. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26701. * It will do nothing if the buffer is not updatable
  26702. * @param kind defines the data kind (Position, normal, etc...)
  26703. * @param data defines the data to use
  26704. * @param offset defines the offset in the target buffer where to store the data
  26705. * @param useBytes set to true if the offset is in bytes
  26706. */
  26707. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26708. /**
  26709. * Update a specific vertex buffer
  26710. * This function will create a new buffer if the current one is not updatable
  26711. * @param kind defines the data kind (Position, normal, etc...)
  26712. * @param data defines the data to use
  26713. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26714. */
  26715. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26716. private _updateBoundingInfo;
  26717. /** @hidden */
  26718. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26719. /**
  26720. * Gets total number of vertices
  26721. * @returns the total number of vertices
  26722. */
  26723. getTotalVertices(): number;
  26724. /**
  26725. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26726. * @param kind defines the data kind (Position, normal, etc...)
  26727. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26728. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26729. * @returns a float array containing vertex data
  26730. */
  26731. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26732. /**
  26733. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26734. * @param kind defines the data kind (Position, normal, etc...)
  26735. * @returns true if the vertex buffer with the specified kind is updatable
  26736. */
  26737. isVertexBufferUpdatable(kind: string): boolean;
  26738. /**
  26739. * Gets a specific vertex buffer
  26740. * @param kind defines the data kind (Position, normal, etc...)
  26741. * @returns a VertexBuffer
  26742. */
  26743. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26744. /**
  26745. * Returns all vertex buffers
  26746. * @return an object holding all vertex buffers indexed by kind
  26747. */
  26748. getVertexBuffers(): Nullable<{
  26749. [key: string]: VertexBuffer;
  26750. }>;
  26751. /**
  26752. * Gets a boolean indicating if specific vertex buffer is present
  26753. * @param kind defines the data kind (Position, normal, etc...)
  26754. * @returns true if data is present
  26755. */
  26756. isVerticesDataPresent(kind: string): boolean;
  26757. /**
  26758. * Gets a list of all attached data kinds (Position, normal, etc...)
  26759. * @returns a list of string containing all kinds
  26760. */
  26761. getVerticesDataKinds(): string[];
  26762. /**
  26763. * Update index buffer
  26764. * @param indices defines the indices to store in the index buffer
  26765. * @param offset defines the offset in the target buffer where to store the data
  26766. * @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)
  26767. */
  26768. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26769. /**
  26770. * Creates a new index buffer
  26771. * @param indices defines the indices to store in the index buffer
  26772. * @param totalVertices defines the total number of vertices (could be null)
  26773. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26774. */
  26775. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26776. /**
  26777. * Return the total number of indices
  26778. * @returns the total number of indices
  26779. */
  26780. getTotalIndices(): number;
  26781. /**
  26782. * Gets the index buffer array
  26783. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26784. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26785. * @returns the index buffer array
  26786. */
  26787. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26788. /**
  26789. * Gets the index buffer
  26790. * @return the index buffer
  26791. */
  26792. getIndexBuffer(): Nullable<DataBuffer>;
  26793. /** @hidden */
  26794. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26795. /**
  26796. * Release the associated resources for a specific mesh
  26797. * @param mesh defines the source mesh
  26798. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26799. */
  26800. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26801. /**
  26802. * Apply current geometry to a given mesh
  26803. * @param mesh defines the mesh to apply geometry to
  26804. */
  26805. applyToMesh(mesh: Mesh): void;
  26806. private _updateExtend;
  26807. private _applyToMesh;
  26808. private notifyUpdate;
  26809. /**
  26810. * Load the geometry if it was flagged as delay loaded
  26811. * @param scene defines the hosting scene
  26812. * @param onLoaded defines a callback called when the geometry is loaded
  26813. */
  26814. load(scene: Scene, onLoaded?: () => void): void;
  26815. private _queueLoad;
  26816. /**
  26817. * Invert the geometry to move from a right handed system to a left handed one.
  26818. */
  26819. toLeftHanded(): void;
  26820. /** @hidden */
  26821. _resetPointsArrayCache(): void;
  26822. /** @hidden */
  26823. _generatePointsArray(): boolean;
  26824. /**
  26825. * Gets a value indicating if the geometry is disposed
  26826. * @returns true if the geometry was disposed
  26827. */
  26828. isDisposed(): boolean;
  26829. private _disposeVertexArrayObjects;
  26830. /**
  26831. * Free all associated resources
  26832. */
  26833. dispose(): void;
  26834. /**
  26835. * Clone the current geometry into a new geometry
  26836. * @param id defines the unique ID of the new geometry
  26837. * @returns a new geometry object
  26838. */
  26839. copy(id: string): Geometry;
  26840. /**
  26841. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26842. * @return a JSON representation of the current geometry data (without the vertices data)
  26843. */
  26844. serialize(): any;
  26845. private toNumberArray;
  26846. /**
  26847. * Serialize all vertices data into a JSON oject
  26848. * @returns a JSON representation of the current geometry data
  26849. */
  26850. serializeVerticeData(): any;
  26851. /**
  26852. * Extracts a clone of a mesh geometry
  26853. * @param mesh defines the source mesh
  26854. * @param id defines the unique ID of the new geometry object
  26855. * @returns the new geometry object
  26856. */
  26857. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26858. /**
  26859. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26860. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26861. * Be aware Math.random() could cause collisions, but:
  26862. * "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"
  26863. * @returns a string containing a new GUID
  26864. */
  26865. static RandomId(): string;
  26866. /** @hidden */
  26867. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26868. private static _CleanMatricesWeights;
  26869. /**
  26870. * Create a new geometry from persisted data (Using .babylon file format)
  26871. * @param parsedVertexData defines the persisted data
  26872. * @param scene defines the hosting scene
  26873. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26874. * @returns the new geometry object
  26875. */
  26876. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26877. }
  26878. }
  26879. declare module "babylonjs/Meshes/mesh.vertexData" {
  26880. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26881. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26882. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26883. import { Geometry } from "babylonjs/Meshes/geometry";
  26884. import { Mesh } from "babylonjs/Meshes/mesh";
  26885. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26886. /**
  26887. * Define an interface for all classes that will get and set the data on vertices
  26888. */
  26889. export interface IGetSetVerticesData {
  26890. /**
  26891. * Gets a boolean indicating if specific vertex data is present
  26892. * @param kind defines the vertex data kind to use
  26893. * @returns true is data kind is present
  26894. */
  26895. isVerticesDataPresent(kind: string): boolean;
  26896. /**
  26897. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26898. * @param kind defines the data kind (Position, normal, etc...)
  26899. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26900. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26901. * @returns a float array containing vertex data
  26902. */
  26903. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26904. /**
  26905. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26906. * @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.
  26907. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26908. * @returns the indices array or an empty array if the mesh has no geometry
  26909. */
  26910. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26911. /**
  26912. * Set specific vertex data
  26913. * @param kind defines the data kind (Position, normal, etc...)
  26914. * @param data defines the vertex data to use
  26915. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26916. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26917. */
  26918. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26919. /**
  26920. * Update a specific associated vertex buffer
  26921. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26922. * - VertexBuffer.PositionKind
  26923. * - VertexBuffer.UVKind
  26924. * - VertexBuffer.UV2Kind
  26925. * - VertexBuffer.UV3Kind
  26926. * - VertexBuffer.UV4Kind
  26927. * - VertexBuffer.UV5Kind
  26928. * - VertexBuffer.UV6Kind
  26929. * - VertexBuffer.ColorKind
  26930. * - VertexBuffer.MatricesIndicesKind
  26931. * - VertexBuffer.MatricesIndicesExtraKind
  26932. * - VertexBuffer.MatricesWeightsKind
  26933. * - VertexBuffer.MatricesWeightsExtraKind
  26934. * @param data defines the data source
  26935. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26936. * @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)
  26937. */
  26938. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26939. /**
  26940. * Creates a new index buffer
  26941. * @param indices defines the indices to store in the index buffer
  26942. * @param totalVertices defines the total number of vertices (could be null)
  26943. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26944. */
  26945. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26946. }
  26947. /**
  26948. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26949. */
  26950. export class VertexData {
  26951. /**
  26952. * Mesh side orientation : usually the external or front surface
  26953. */
  26954. static readonly FRONTSIDE: number;
  26955. /**
  26956. * Mesh side orientation : usually the internal or back surface
  26957. */
  26958. static readonly BACKSIDE: number;
  26959. /**
  26960. * Mesh side orientation : both internal and external or front and back surfaces
  26961. */
  26962. static readonly DOUBLESIDE: number;
  26963. /**
  26964. * Mesh side orientation : by default, `FRONTSIDE`
  26965. */
  26966. static readonly DEFAULTSIDE: number;
  26967. /**
  26968. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26969. */
  26970. positions: Nullable<FloatArray>;
  26971. /**
  26972. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26973. */
  26974. normals: Nullable<FloatArray>;
  26975. /**
  26976. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26977. */
  26978. tangents: Nullable<FloatArray>;
  26979. /**
  26980. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26981. */
  26982. uvs: Nullable<FloatArray>;
  26983. /**
  26984. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26985. */
  26986. uvs2: Nullable<FloatArray>;
  26987. /**
  26988. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26989. */
  26990. uvs3: Nullable<FloatArray>;
  26991. /**
  26992. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26993. */
  26994. uvs4: Nullable<FloatArray>;
  26995. /**
  26996. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26997. */
  26998. uvs5: Nullable<FloatArray>;
  26999. /**
  27000. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27001. */
  27002. uvs6: Nullable<FloatArray>;
  27003. /**
  27004. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27005. */
  27006. colors: Nullable<FloatArray>;
  27007. /**
  27008. * 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).
  27009. */
  27010. matricesIndices: Nullable<FloatArray>;
  27011. /**
  27012. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27013. */
  27014. matricesWeights: Nullable<FloatArray>;
  27015. /**
  27016. * An array extending the number of possible indices
  27017. */
  27018. matricesIndicesExtra: Nullable<FloatArray>;
  27019. /**
  27020. * An array extending the number of possible weights when the number of indices is extended
  27021. */
  27022. matricesWeightsExtra: Nullable<FloatArray>;
  27023. /**
  27024. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27025. */
  27026. indices: Nullable<IndicesArray>;
  27027. /**
  27028. * Uses the passed data array to set the set the values for the specified kind of data
  27029. * @param data a linear array of floating numbers
  27030. * @param kind the type of data that is being set, eg positions, colors etc
  27031. */
  27032. set(data: FloatArray, kind: string): void;
  27033. /**
  27034. * Associates the vertexData to the passed Mesh.
  27035. * Sets it as updatable or not (default `false`)
  27036. * @param mesh the mesh the vertexData is applied to
  27037. * @param updatable when used and having the value true allows new data to update the vertexData
  27038. * @returns the VertexData
  27039. */
  27040. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27041. /**
  27042. * Associates the vertexData to the passed Geometry.
  27043. * Sets it as updatable or not (default `false`)
  27044. * @param geometry the geometry the vertexData is applied to
  27045. * @param updatable when used and having the value true allows new data to update the vertexData
  27046. * @returns VertexData
  27047. */
  27048. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27049. /**
  27050. * Updates the associated mesh
  27051. * @param mesh the mesh to be updated
  27052. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27053. * @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
  27054. * @returns VertexData
  27055. */
  27056. updateMesh(mesh: Mesh): VertexData;
  27057. /**
  27058. * Updates the associated geometry
  27059. * @param geometry the geometry to be updated
  27060. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27061. * @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
  27062. * @returns VertexData.
  27063. */
  27064. updateGeometry(geometry: Geometry): VertexData;
  27065. private _applyTo;
  27066. private _update;
  27067. /**
  27068. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27069. * @param matrix the transforming matrix
  27070. * @returns the VertexData
  27071. */
  27072. transform(matrix: Matrix): VertexData;
  27073. /**
  27074. * Merges the passed VertexData into the current one
  27075. * @param other the VertexData to be merged into the current one
  27076. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27077. * @returns the modified VertexData
  27078. */
  27079. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27080. private _mergeElement;
  27081. private _validate;
  27082. /**
  27083. * Serializes the VertexData
  27084. * @returns a serialized object
  27085. */
  27086. serialize(): any;
  27087. /**
  27088. * Extracts the vertexData from a mesh
  27089. * @param mesh the mesh from which to extract the VertexData
  27090. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27091. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27092. * @returns the object VertexData associated to the passed mesh
  27093. */
  27094. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27095. /**
  27096. * Extracts the vertexData from the geometry
  27097. * @param geometry the geometry from which to extract the VertexData
  27098. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27099. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27100. * @returns the object VertexData associated to the passed mesh
  27101. */
  27102. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27103. private static _ExtractFrom;
  27104. /**
  27105. * Creates the VertexData for a Ribbon
  27106. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27107. * * pathArray array of paths, each of which an array of successive Vector3
  27108. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27109. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27110. * * 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
  27111. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27112. * * 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)
  27113. * * 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)
  27114. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27115. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27116. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27117. * @returns the VertexData of the ribbon
  27118. */
  27119. static CreateRibbon(options: {
  27120. pathArray: Vector3[][];
  27121. closeArray?: boolean;
  27122. closePath?: boolean;
  27123. offset?: number;
  27124. sideOrientation?: number;
  27125. frontUVs?: Vector4;
  27126. backUVs?: Vector4;
  27127. invertUV?: boolean;
  27128. uvs?: Vector2[];
  27129. colors?: Color4[];
  27130. }): VertexData;
  27131. /**
  27132. * Creates the VertexData for a box
  27133. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27134. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27135. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27136. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27137. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27138. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27139. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27140. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27141. * * 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)
  27142. * * 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)
  27143. * @returns the VertexData of the box
  27144. */
  27145. static CreateBox(options: {
  27146. size?: number;
  27147. width?: number;
  27148. height?: number;
  27149. depth?: number;
  27150. faceUV?: Vector4[];
  27151. faceColors?: Color4[];
  27152. sideOrientation?: number;
  27153. frontUVs?: Vector4;
  27154. backUVs?: Vector4;
  27155. }): VertexData;
  27156. /**
  27157. * Creates the VertexData for a tiled box
  27158. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27159. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27160. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27161. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27163. * @returns the VertexData of the box
  27164. */
  27165. static CreateTiledBox(options: {
  27166. pattern?: number;
  27167. width?: number;
  27168. height?: number;
  27169. depth?: number;
  27170. tileSize?: number;
  27171. tileWidth?: number;
  27172. tileHeight?: number;
  27173. alignHorizontal?: number;
  27174. alignVertical?: number;
  27175. faceUV?: Vector4[];
  27176. faceColors?: Color4[];
  27177. sideOrientation?: number;
  27178. }): VertexData;
  27179. /**
  27180. * Creates the VertexData for a tiled plane
  27181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27182. * * pattern a limited pattern arrangement depending on the number
  27183. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27184. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27185. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27187. * * 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)
  27188. * * 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)
  27189. * @returns the VertexData of the tiled plane
  27190. */
  27191. static CreateTiledPlane(options: {
  27192. pattern?: number;
  27193. tileSize?: number;
  27194. tileWidth?: number;
  27195. tileHeight?: number;
  27196. size?: number;
  27197. width?: number;
  27198. height?: number;
  27199. alignHorizontal?: number;
  27200. alignVertical?: number;
  27201. sideOrientation?: number;
  27202. frontUVs?: Vector4;
  27203. backUVs?: Vector4;
  27204. }): VertexData;
  27205. /**
  27206. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27207. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27208. * * segments sets the number of horizontal strips optional, default 32
  27209. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27210. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27211. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27212. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27213. * * 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
  27214. * * 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
  27215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27216. * * 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)
  27217. * * 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)
  27218. * @returns the VertexData of the ellipsoid
  27219. */
  27220. static CreateSphere(options: {
  27221. segments?: number;
  27222. diameter?: number;
  27223. diameterX?: number;
  27224. diameterY?: number;
  27225. diameterZ?: number;
  27226. arc?: number;
  27227. slice?: number;
  27228. sideOrientation?: number;
  27229. frontUVs?: Vector4;
  27230. backUVs?: Vector4;
  27231. }): VertexData;
  27232. /**
  27233. * Creates the VertexData for a cylinder, cone or prism
  27234. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27235. * * height sets the height (y direction) of the cylinder, optional, default 2
  27236. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27237. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27238. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27239. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27240. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27241. * * 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
  27242. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27243. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27244. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27245. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27247. * * 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)
  27248. * * 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)
  27249. * @returns the VertexData of the cylinder, cone or prism
  27250. */
  27251. static CreateCylinder(options: {
  27252. height?: number;
  27253. diameterTop?: number;
  27254. diameterBottom?: number;
  27255. diameter?: number;
  27256. tessellation?: number;
  27257. subdivisions?: number;
  27258. arc?: number;
  27259. faceColors?: Color4[];
  27260. faceUV?: Vector4[];
  27261. hasRings?: boolean;
  27262. enclose?: boolean;
  27263. sideOrientation?: number;
  27264. frontUVs?: Vector4;
  27265. backUVs?: Vector4;
  27266. }): VertexData;
  27267. /**
  27268. * Creates the VertexData for a torus
  27269. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27270. * * diameter the diameter of the torus, optional default 1
  27271. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27272. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27274. * * 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)
  27275. * * 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)
  27276. * @returns the VertexData of the torus
  27277. */
  27278. static CreateTorus(options: {
  27279. diameter?: number;
  27280. thickness?: number;
  27281. tessellation?: number;
  27282. sideOrientation?: number;
  27283. frontUVs?: Vector4;
  27284. backUVs?: Vector4;
  27285. }): VertexData;
  27286. /**
  27287. * Creates the VertexData of the LineSystem
  27288. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27289. * - lines an array of lines, each line being an array of successive Vector3
  27290. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27291. * @returns the VertexData of the LineSystem
  27292. */
  27293. static CreateLineSystem(options: {
  27294. lines: Vector3[][];
  27295. colors?: Nullable<Color4[][]>;
  27296. }): VertexData;
  27297. /**
  27298. * Create the VertexData for a DashedLines
  27299. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27300. * - points an array successive Vector3
  27301. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27302. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27303. * - dashNb the intended total number of dashes, optional, default 200
  27304. * @returns the VertexData for the DashedLines
  27305. */
  27306. static CreateDashedLines(options: {
  27307. points: Vector3[];
  27308. dashSize?: number;
  27309. gapSize?: number;
  27310. dashNb?: number;
  27311. }): VertexData;
  27312. /**
  27313. * Creates the VertexData for a Ground
  27314. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27315. * - width the width (x direction) of the ground, optional, default 1
  27316. * - height the height (z direction) of the ground, optional, default 1
  27317. * - subdivisions the number of subdivisions per side, optional, default 1
  27318. * @returns the VertexData of the Ground
  27319. */
  27320. static CreateGround(options: {
  27321. width?: number;
  27322. height?: number;
  27323. subdivisions?: number;
  27324. subdivisionsX?: number;
  27325. subdivisionsY?: number;
  27326. }): VertexData;
  27327. /**
  27328. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27329. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27330. * * xmin the ground minimum X coordinate, optional, default -1
  27331. * * zmin the ground minimum Z coordinate, optional, default -1
  27332. * * xmax the ground maximum X coordinate, optional, default 1
  27333. * * zmax the ground maximum Z coordinate, optional, default 1
  27334. * * 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}
  27335. * * 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}
  27336. * @returns the VertexData of the TiledGround
  27337. */
  27338. static CreateTiledGround(options: {
  27339. xmin: number;
  27340. zmin: number;
  27341. xmax: number;
  27342. zmax: number;
  27343. subdivisions?: {
  27344. w: number;
  27345. h: number;
  27346. };
  27347. precision?: {
  27348. w: number;
  27349. h: number;
  27350. };
  27351. }): VertexData;
  27352. /**
  27353. * Creates the VertexData of the Ground designed from a heightmap
  27354. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27355. * * width the width (x direction) of the ground
  27356. * * height the height (z direction) of the ground
  27357. * * subdivisions the number of subdivisions per side
  27358. * * minHeight the minimum altitude on the ground, optional, default 0
  27359. * * maxHeight the maximum altitude on the ground, optional default 1
  27360. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27361. * * buffer the array holding the image color data
  27362. * * bufferWidth the width of image
  27363. * * bufferHeight the height of image
  27364. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27365. * @returns the VertexData of the Ground designed from a heightmap
  27366. */
  27367. static CreateGroundFromHeightMap(options: {
  27368. width: number;
  27369. height: number;
  27370. subdivisions: number;
  27371. minHeight: number;
  27372. maxHeight: number;
  27373. colorFilter: Color3;
  27374. buffer: Uint8Array;
  27375. bufferWidth: number;
  27376. bufferHeight: number;
  27377. alphaFilter: number;
  27378. }): VertexData;
  27379. /**
  27380. * Creates the VertexData for a Plane
  27381. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27382. * * size sets the width and height of the plane to the value of size, optional default 1
  27383. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27384. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27386. * * 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)
  27387. * * 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)
  27388. * @returns the VertexData of the box
  27389. */
  27390. static CreatePlane(options: {
  27391. size?: number;
  27392. width?: number;
  27393. height?: number;
  27394. sideOrientation?: number;
  27395. frontUVs?: Vector4;
  27396. backUVs?: Vector4;
  27397. }): VertexData;
  27398. /**
  27399. * Creates the VertexData of the Disc or regular Polygon
  27400. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27401. * * radius the radius of the disc, optional default 0.5
  27402. * * tessellation the number of polygon sides, optional, default 64
  27403. * * 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
  27404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27405. * * 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)
  27406. * * 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)
  27407. * @returns the VertexData of the box
  27408. */
  27409. static CreateDisc(options: {
  27410. radius?: number;
  27411. tessellation?: number;
  27412. arc?: number;
  27413. sideOrientation?: number;
  27414. frontUVs?: Vector4;
  27415. backUVs?: Vector4;
  27416. }): VertexData;
  27417. /**
  27418. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27419. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27420. * @param polygon a mesh built from polygonTriangulation.build()
  27421. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27422. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27423. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27424. * @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)
  27425. * @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)
  27426. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27427. * @returns the VertexData of the Polygon
  27428. */
  27429. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27430. /**
  27431. * Creates the VertexData of the IcoSphere
  27432. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27433. * * radius the radius of the IcoSphere, optional default 1
  27434. * * radiusX allows stretching in the x direction, optional, default radius
  27435. * * radiusY allows stretching in the y direction, optional, default radius
  27436. * * radiusZ allows stretching in the z direction, optional, default radius
  27437. * * flat when true creates a flat shaded mesh, optional, default true
  27438. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27439. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27440. * * 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)
  27441. * * 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)
  27442. * @returns the VertexData of the IcoSphere
  27443. */
  27444. static CreateIcoSphere(options: {
  27445. radius?: number;
  27446. radiusX?: number;
  27447. radiusY?: number;
  27448. radiusZ?: number;
  27449. flat?: boolean;
  27450. subdivisions?: number;
  27451. sideOrientation?: number;
  27452. frontUVs?: Vector4;
  27453. backUVs?: Vector4;
  27454. }): VertexData;
  27455. /**
  27456. * Creates the VertexData for a Polyhedron
  27457. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27458. * * type provided types are:
  27459. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27460. * * 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)
  27461. * * size the size of the IcoSphere, optional default 1
  27462. * * sizeX allows stretching in the x direction, optional, default size
  27463. * * sizeY allows stretching in the y direction, optional, default size
  27464. * * sizeZ allows stretching in the z direction, optional, default size
  27465. * * 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
  27466. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27467. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27468. * * flat when true creates a flat shaded mesh, optional, default true
  27469. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27471. * * 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)
  27472. * * 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)
  27473. * @returns the VertexData of the Polyhedron
  27474. */
  27475. static CreatePolyhedron(options: {
  27476. type?: number;
  27477. size?: number;
  27478. sizeX?: number;
  27479. sizeY?: number;
  27480. sizeZ?: number;
  27481. custom?: any;
  27482. faceUV?: Vector4[];
  27483. faceColors?: Color4[];
  27484. flat?: boolean;
  27485. sideOrientation?: number;
  27486. frontUVs?: Vector4;
  27487. backUVs?: Vector4;
  27488. }): VertexData;
  27489. /**
  27490. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27491. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27492. * @returns the VertexData of the Capsule
  27493. */
  27494. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27495. /**
  27496. * Creates the VertexData for a TorusKnot
  27497. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27498. * * radius the radius of the torus knot, optional, default 2
  27499. * * tube the thickness of the tube, optional, default 0.5
  27500. * * radialSegments the number of sides on each tube segments, optional, default 32
  27501. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27502. * * p the number of windings around the z axis, optional, default 2
  27503. * * q the number of windings around the x axis, optional, default 3
  27504. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27505. * * 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)
  27506. * * 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)
  27507. * @returns the VertexData of the Torus Knot
  27508. */
  27509. static CreateTorusKnot(options: {
  27510. radius?: number;
  27511. tube?: number;
  27512. radialSegments?: number;
  27513. tubularSegments?: number;
  27514. p?: number;
  27515. q?: number;
  27516. sideOrientation?: number;
  27517. frontUVs?: Vector4;
  27518. backUVs?: Vector4;
  27519. }): VertexData;
  27520. /**
  27521. * Compute normals for given positions and indices
  27522. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27523. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27524. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27525. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27526. * * facetNormals : optional array of facet normals (vector3)
  27527. * * facetPositions : optional array of facet positions (vector3)
  27528. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27529. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27530. * * bInfo : optional bounding info, required for facetPartitioning computation
  27531. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27532. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27533. * * useRightHandedSystem: optional boolean to for right handed system computation
  27534. * * depthSort : optional boolean to enable the facet depth sort computation
  27535. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27536. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27537. */
  27538. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27539. facetNormals?: any;
  27540. facetPositions?: any;
  27541. facetPartitioning?: any;
  27542. ratio?: number;
  27543. bInfo?: any;
  27544. bbSize?: Vector3;
  27545. subDiv?: any;
  27546. useRightHandedSystem?: boolean;
  27547. depthSort?: boolean;
  27548. distanceTo?: Vector3;
  27549. depthSortedFacets?: any;
  27550. }): void;
  27551. /** @hidden */
  27552. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27553. /**
  27554. * Applies VertexData created from the imported parameters to the geometry
  27555. * @param parsedVertexData the parsed data from an imported file
  27556. * @param geometry the geometry to apply the VertexData to
  27557. */
  27558. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27559. }
  27560. }
  27561. declare module "babylonjs/Morph/morphTarget" {
  27562. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27563. import { Observable } from "babylonjs/Misc/observable";
  27564. import { Nullable, FloatArray } from "babylonjs/types";
  27565. import { Scene } from "babylonjs/scene";
  27566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27567. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27568. /**
  27569. * Defines a target to use with MorphTargetManager
  27570. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27571. */
  27572. export class MorphTarget implements IAnimatable {
  27573. /** defines the name of the target */
  27574. name: string;
  27575. /**
  27576. * Gets or sets the list of animations
  27577. */
  27578. animations: import("babylonjs/Animations/animation").Animation[];
  27579. private _scene;
  27580. private _positions;
  27581. private _normals;
  27582. private _tangents;
  27583. private _uvs;
  27584. private _influence;
  27585. private _uniqueId;
  27586. /**
  27587. * Observable raised when the influence changes
  27588. */
  27589. onInfluenceChanged: Observable<boolean>;
  27590. /** @hidden */
  27591. _onDataLayoutChanged: Observable<void>;
  27592. /**
  27593. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27594. */
  27595. get influence(): number;
  27596. set influence(influence: number);
  27597. /**
  27598. * Gets or sets the id of the morph Target
  27599. */
  27600. id: string;
  27601. private _animationPropertiesOverride;
  27602. /**
  27603. * Gets or sets the animation properties override
  27604. */
  27605. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27606. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27607. /**
  27608. * Creates a new MorphTarget
  27609. * @param name defines the name of the target
  27610. * @param influence defines the influence to use
  27611. * @param scene defines the scene the morphtarget belongs to
  27612. */
  27613. constructor(
  27614. /** defines the name of the target */
  27615. name: string, influence?: number, scene?: Nullable<Scene>);
  27616. /**
  27617. * Gets the unique ID of this manager
  27618. */
  27619. get uniqueId(): number;
  27620. /**
  27621. * Gets a boolean defining if the target contains position data
  27622. */
  27623. get hasPositions(): boolean;
  27624. /**
  27625. * Gets a boolean defining if the target contains normal data
  27626. */
  27627. get hasNormals(): boolean;
  27628. /**
  27629. * Gets a boolean defining if the target contains tangent data
  27630. */
  27631. get hasTangents(): boolean;
  27632. /**
  27633. * Gets a boolean defining if the target contains texture coordinates data
  27634. */
  27635. get hasUVs(): boolean;
  27636. /**
  27637. * Affects position data to this target
  27638. * @param data defines the position data to use
  27639. */
  27640. setPositions(data: Nullable<FloatArray>): void;
  27641. /**
  27642. * Gets the position data stored in this target
  27643. * @returns a FloatArray containing the position data (or null if not present)
  27644. */
  27645. getPositions(): Nullable<FloatArray>;
  27646. /**
  27647. * Affects normal data to this target
  27648. * @param data defines the normal data to use
  27649. */
  27650. setNormals(data: Nullable<FloatArray>): void;
  27651. /**
  27652. * Gets the normal data stored in this target
  27653. * @returns a FloatArray containing the normal data (or null if not present)
  27654. */
  27655. getNormals(): Nullable<FloatArray>;
  27656. /**
  27657. * Affects tangent data to this target
  27658. * @param data defines the tangent data to use
  27659. */
  27660. setTangents(data: Nullable<FloatArray>): void;
  27661. /**
  27662. * Gets the tangent data stored in this target
  27663. * @returns a FloatArray containing the tangent data (or null if not present)
  27664. */
  27665. getTangents(): Nullable<FloatArray>;
  27666. /**
  27667. * Affects texture coordinates data to this target
  27668. * @param data defines the texture coordinates data to use
  27669. */
  27670. setUVs(data: Nullable<FloatArray>): void;
  27671. /**
  27672. * Gets the texture coordinates data stored in this target
  27673. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27674. */
  27675. getUVs(): Nullable<FloatArray>;
  27676. /**
  27677. * Clone the current target
  27678. * @returns a new MorphTarget
  27679. */
  27680. clone(): MorphTarget;
  27681. /**
  27682. * Serializes the current target into a Serialization object
  27683. * @returns the serialized object
  27684. */
  27685. serialize(): any;
  27686. /**
  27687. * Returns the string "MorphTarget"
  27688. * @returns "MorphTarget"
  27689. */
  27690. getClassName(): string;
  27691. /**
  27692. * Creates a new target from serialized data
  27693. * @param serializationObject defines the serialized data to use
  27694. * @returns a new MorphTarget
  27695. */
  27696. static Parse(serializationObject: any): MorphTarget;
  27697. /**
  27698. * Creates a MorphTarget from mesh data
  27699. * @param mesh defines the source mesh
  27700. * @param name defines the name to use for the new target
  27701. * @param influence defines the influence to attach to the target
  27702. * @returns a new MorphTarget
  27703. */
  27704. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27705. }
  27706. }
  27707. declare module "babylonjs/Morph/morphTargetManager" {
  27708. import { Nullable } from "babylonjs/types";
  27709. import { Scene } from "babylonjs/scene";
  27710. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27711. /**
  27712. * This class is used to deform meshes using morphing between different targets
  27713. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27714. */
  27715. export class MorphTargetManager {
  27716. private _targets;
  27717. private _targetInfluenceChangedObservers;
  27718. private _targetDataLayoutChangedObservers;
  27719. private _activeTargets;
  27720. private _scene;
  27721. private _influences;
  27722. private _supportsNormals;
  27723. private _supportsTangents;
  27724. private _supportsUVs;
  27725. private _vertexCount;
  27726. private _uniqueId;
  27727. private _tempInfluences;
  27728. /**
  27729. * Gets or sets a boolean indicating if normals must be morphed
  27730. */
  27731. enableNormalMorphing: boolean;
  27732. /**
  27733. * Gets or sets a boolean indicating if tangents must be morphed
  27734. */
  27735. enableTangentMorphing: boolean;
  27736. /**
  27737. * Gets or sets a boolean indicating if UV must be morphed
  27738. */
  27739. enableUVMorphing: boolean;
  27740. /**
  27741. * Creates a new MorphTargetManager
  27742. * @param scene defines the current scene
  27743. */
  27744. constructor(scene?: Nullable<Scene>);
  27745. /**
  27746. * Gets the unique ID of this manager
  27747. */
  27748. get uniqueId(): number;
  27749. /**
  27750. * Gets the number of vertices handled by this manager
  27751. */
  27752. get vertexCount(): number;
  27753. /**
  27754. * Gets a boolean indicating if this manager supports morphing of normals
  27755. */
  27756. get supportsNormals(): boolean;
  27757. /**
  27758. * Gets a boolean indicating if this manager supports morphing of tangents
  27759. */
  27760. get supportsTangents(): boolean;
  27761. /**
  27762. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27763. */
  27764. get supportsUVs(): boolean;
  27765. /**
  27766. * Gets the number of targets stored in this manager
  27767. */
  27768. get numTargets(): number;
  27769. /**
  27770. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27771. */
  27772. get numInfluencers(): number;
  27773. /**
  27774. * Gets the list of influences (one per target)
  27775. */
  27776. get influences(): Float32Array;
  27777. /**
  27778. * Gets the active target at specified index. An active target is a target with an influence > 0
  27779. * @param index defines the index to check
  27780. * @returns the requested target
  27781. */
  27782. getActiveTarget(index: number): MorphTarget;
  27783. /**
  27784. * Gets the target at specified index
  27785. * @param index defines the index to check
  27786. * @returns the requested target
  27787. */
  27788. getTarget(index: number): MorphTarget;
  27789. /**
  27790. * Add a new target to this manager
  27791. * @param target defines the target to add
  27792. */
  27793. addTarget(target: MorphTarget): void;
  27794. /**
  27795. * Removes a target from the manager
  27796. * @param target defines the target to remove
  27797. */
  27798. removeTarget(target: MorphTarget): void;
  27799. /**
  27800. * Clone the current manager
  27801. * @returns a new MorphTargetManager
  27802. */
  27803. clone(): MorphTargetManager;
  27804. /**
  27805. * Serializes the current manager into a Serialization object
  27806. * @returns the serialized object
  27807. */
  27808. serialize(): any;
  27809. private _syncActiveTargets;
  27810. /**
  27811. * Syncrhonize the targets with all the meshes using this morph target manager
  27812. */
  27813. synchronize(): void;
  27814. /**
  27815. * Creates a new MorphTargetManager from serialized data
  27816. * @param serializationObject defines the serialized data
  27817. * @param scene defines the hosting scene
  27818. * @returns the new MorphTargetManager
  27819. */
  27820. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27821. }
  27822. }
  27823. declare module "babylonjs/Meshes/meshLODLevel" {
  27824. import { Mesh } from "babylonjs/Meshes/mesh";
  27825. import { Nullable } from "babylonjs/types";
  27826. /**
  27827. * Class used to represent a specific level of detail of a mesh
  27828. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27829. */
  27830. export class MeshLODLevel {
  27831. /** Defines the distance where this level should start being displayed */
  27832. distance: number;
  27833. /** Defines the mesh to use to render this level */
  27834. mesh: Nullable<Mesh>;
  27835. /**
  27836. * Creates a new LOD level
  27837. * @param distance defines the distance where this level should star being displayed
  27838. * @param mesh defines the mesh to use to render this level
  27839. */
  27840. constructor(
  27841. /** Defines the distance where this level should start being displayed */
  27842. distance: number,
  27843. /** Defines the mesh to use to render this level */
  27844. mesh: Nullable<Mesh>);
  27845. }
  27846. }
  27847. declare module "babylonjs/Misc/canvasGenerator" {
  27848. /**
  27849. * Helper class used to generate a canvas to manipulate images
  27850. */
  27851. export class CanvasGenerator {
  27852. /**
  27853. * Create a new canvas (or offscreen canvas depending on the context)
  27854. * @param width defines the expected width
  27855. * @param height defines the expected height
  27856. * @return a new canvas or offscreen canvas
  27857. */
  27858. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27859. }
  27860. }
  27861. declare module "babylonjs/Meshes/groundMesh" {
  27862. import { Scene } from "babylonjs/scene";
  27863. import { Vector3 } from "babylonjs/Maths/math.vector";
  27864. import { Mesh } from "babylonjs/Meshes/mesh";
  27865. /**
  27866. * Mesh representing the gorund
  27867. */
  27868. export class GroundMesh extends Mesh {
  27869. /** If octree should be generated */
  27870. generateOctree: boolean;
  27871. private _heightQuads;
  27872. /** @hidden */
  27873. _subdivisionsX: number;
  27874. /** @hidden */
  27875. _subdivisionsY: number;
  27876. /** @hidden */
  27877. _width: number;
  27878. /** @hidden */
  27879. _height: number;
  27880. /** @hidden */
  27881. _minX: number;
  27882. /** @hidden */
  27883. _maxX: number;
  27884. /** @hidden */
  27885. _minZ: number;
  27886. /** @hidden */
  27887. _maxZ: number;
  27888. constructor(name: string, scene: Scene);
  27889. /**
  27890. * "GroundMesh"
  27891. * @returns "GroundMesh"
  27892. */
  27893. getClassName(): string;
  27894. /**
  27895. * The minimum of x and y subdivisions
  27896. */
  27897. get subdivisions(): number;
  27898. /**
  27899. * X subdivisions
  27900. */
  27901. get subdivisionsX(): number;
  27902. /**
  27903. * Y subdivisions
  27904. */
  27905. get subdivisionsY(): number;
  27906. /**
  27907. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27908. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27909. * @param chunksCount the number of subdivisions for x and y
  27910. * @param octreeBlocksSize (Default: 32)
  27911. */
  27912. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27913. /**
  27914. * Returns a height (y) value in the Worl system :
  27915. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27916. * @param x x coordinate
  27917. * @param z z coordinate
  27918. * @returns the ground y position if (x, z) are outside the ground surface.
  27919. */
  27920. getHeightAtCoordinates(x: number, z: number): number;
  27921. /**
  27922. * Returns a normalized vector (Vector3) orthogonal to the ground
  27923. * at the ground coordinates (x, z) expressed in the World system.
  27924. * @param x x coordinate
  27925. * @param z z coordinate
  27926. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27927. */
  27928. getNormalAtCoordinates(x: number, z: number): Vector3;
  27929. /**
  27930. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27931. * at the ground coordinates (x, z) expressed in the World system.
  27932. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27933. * @param x x coordinate
  27934. * @param z z coordinate
  27935. * @param ref vector to store the result
  27936. * @returns the GroundMesh.
  27937. */
  27938. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27939. /**
  27940. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27941. * if the ground has been updated.
  27942. * This can be used in the render loop.
  27943. * @returns the GroundMesh.
  27944. */
  27945. updateCoordinateHeights(): GroundMesh;
  27946. private _getFacetAt;
  27947. private _initHeightQuads;
  27948. private _computeHeightQuads;
  27949. /**
  27950. * Serializes this ground mesh
  27951. * @param serializationObject object to write serialization to
  27952. */
  27953. serialize(serializationObject: any): void;
  27954. /**
  27955. * Parses a serialized ground mesh
  27956. * @param parsedMesh the serialized mesh
  27957. * @param scene the scene to create the ground mesh in
  27958. * @returns the created ground mesh
  27959. */
  27960. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27961. }
  27962. }
  27963. declare module "babylonjs/Physics/physicsJoint" {
  27964. import { Vector3 } from "babylonjs/Maths/math.vector";
  27965. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27966. /**
  27967. * Interface for Physics-Joint data
  27968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27969. */
  27970. export interface PhysicsJointData {
  27971. /**
  27972. * The main pivot of the joint
  27973. */
  27974. mainPivot?: Vector3;
  27975. /**
  27976. * The connected pivot of the joint
  27977. */
  27978. connectedPivot?: Vector3;
  27979. /**
  27980. * The main axis of the joint
  27981. */
  27982. mainAxis?: Vector3;
  27983. /**
  27984. * The connected axis of the joint
  27985. */
  27986. connectedAxis?: Vector3;
  27987. /**
  27988. * The collision of the joint
  27989. */
  27990. collision?: boolean;
  27991. /**
  27992. * Native Oimo/Cannon/Energy data
  27993. */
  27994. nativeParams?: any;
  27995. }
  27996. /**
  27997. * This is a holder class for the physics joint created by the physics plugin
  27998. * It holds a set of functions to control the underlying joint
  27999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28000. */
  28001. export class PhysicsJoint {
  28002. /**
  28003. * The type of the physics joint
  28004. */
  28005. type: number;
  28006. /**
  28007. * The data for the physics joint
  28008. */
  28009. jointData: PhysicsJointData;
  28010. private _physicsJoint;
  28011. protected _physicsPlugin: IPhysicsEnginePlugin;
  28012. /**
  28013. * Initializes the physics joint
  28014. * @param type The type of the physics joint
  28015. * @param jointData The data for the physics joint
  28016. */
  28017. constructor(
  28018. /**
  28019. * The type of the physics joint
  28020. */
  28021. type: number,
  28022. /**
  28023. * The data for the physics joint
  28024. */
  28025. jointData: PhysicsJointData);
  28026. /**
  28027. * Gets the physics joint
  28028. */
  28029. get physicsJoint(): any;
  28030. /**
  28031. * Sets the physics joint
  28032. */
  28033. set physicsJoint(newJoint: any);
  28034. /**
  28035. * Sets the physics plugin
  28036. */
  28037. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28038. /**
  28039. * Execute a function that is physics-plugin specific.
  28040. * @param {Function} func the function that will be executed.
  28041. * It accepts two parameters: the physics world and the physics joint
  28042. */
  28043. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28044. /**
  28045. * Distance-Joint type
  28046. */
  28047. static DistanceJoint: number;
  28048. /**
  28049. * Hinge-Joint type
  28050. */
  28051. static HingeJoint: number;
  28052. /**
  28053. * Ball-and-Socket joint type
  28054. */
  28055. static BallAndSocketJoint: number;
  28056. /**
  28057. * Wheel-Joint type
  28058. */
  28059. static WheelJoint: number;
  28060. /**
  28061. * Slider-Joint type
  28062. */
  28063. static SliderJoint: number;
  28064. /**
  28065. * Prismatic-Joint type
  28066. */
  28067. static PrismaticJoint: number;
  28068. /**
  28069. * Universal-Joint type
  28070. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28071. */
  28072. static UniversalJoint: number;
  28073. /**
  28074. * Hinge-Joint 2 type
  28075. */
  28076. static Hinge2Joint: number;
  28077. /**
  28078. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28079. */
  28080. static PointToPointJoint: number;
  28081. /**
  28082. * Spring-Joint type
  28083. */
  28084. static SpringJoint: number;
  28085. /**
  28086. * Lock-Joint type
  28087. */
  28088. static LockJoint: number;
  28089. }
  28090. /**
  28091. * A class representing a physics distance joint
  28092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28093. */
  28094. export class DistanceJoint extends PhysicsJoint {
  28095. /**
  28096. *
  28097. * @param jointData The data for the Distance-Joint
  28098. */
  28099. constructor(jointData: DistanceJointData);
  28100. /**
  28101. * Update the predefined distance.
  28102. * @param maxDistance The maximum preferred distance
  28103. * @param minDistance The minimum preferred distance
  28104. */
  28105. updateDistance(maxDistance: number, minDistance?: number): void;
  28106. }
  28107. /**
  28108. * Represents a Motor-Enabled Joint
  28109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28110. */
  28111. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28112. /**
  28113. * Initializes the Motor-Enabled Joint
  28114. * @param type The type of the joint
  28115. * @param jointData The physica joint data for the joint
  28116. */
  28117. constructor(type: number, jointData: PhysicsJointData);
  28118. /**
  28119. * Set the motor values.
  28120. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28121. * @param force the force to apply
  28122. * @param maxForce max force for this motor.
  28123. */
  28124. setMotor(force?: number, maxForce?: number): void;
  28125. /**
  28126. * Set the motor's limits.
  28127. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28128. * @param upperLimit The upper limit of the motor
  28129. * @param lowerLimit The lower limit of the motor
  28130. */
  28131. setLimit(upperLimit: number, lowerLimit?: number): void;
  28132. }
  28133. /**
  28134. * This class represents a single physics Hinge-Joint
  28135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28136. */
  28137. export class HingeJoint extends MotorEnabledJoint {
  28138. /**
  28139. * Initializes the Hinge-Joint
  28140. * @param jointData The joint data for the Hinge-Joint
  28141. */
  28142. constructor(jointData: PhysicsJointData);
  28143. /**
  28144. * Set the motor values.
  28145. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28146. * @param {number} force the force to apply
  28147. * @param {number} maxForce max force for this motor.
  28148. */
  28149. setMotor(force?: number, maxForce?: number): void;
  28150. /**
  28151. * Set the motor's limits.
  28152. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28153. * @param upperLimit The upper limit of the motor
  28154. * @param lowerLimit The lower limit of the motor
  28155. */
  28156. setLimit(upperLimit: number, lowerLimit?: number): void;
  28157. }
  28158. /**
  28159. * This class represents a dual hinge physics joint (same as wheel joint)
  28160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28161. */
  28162. export class Hinge2Joint extends MotorEnabledJoint {
  28163. /**
  28164. * Initializes the Hinge2-Joint
  28165. * @param jointData The joint data for the Hinge2-Joint
  28166. */
  28167. constructor(jointData: PhysicsJointData);
  28168. /**
  28169. * Set the motor values.
  28170. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28171. * @param {number} targetSpeed the speed the motor is to reach
  28172. * @param {number} maxForce max force for this motor.
  28173. * @param {motorIndex} the motor's index, 0 or 1.
  28174. */
  28175. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28176. /**
  28177. * Set the motor limits.
  28178. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28179. * @param {number} upperLimit the upper limit
  28180. * @param {number} lowerLimit lower limit
  28181. * @param {motorIndex} the motor's index, 0 or 1.
  28182. */
  28183. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28184. }
  28185. /**
  28186. * Interface for a motor enabled joint
  28187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28188. */
  28189. export interface IMotorEnabledJoint {
  28190. /**
  28191. * Physics joint
  28192. */
  28193. physicsJoint: any;
  28194. /**
  28195. * Sets the motor of the motor-enabled joint
  28196. * @param force The force of the motor
  28197. * @param maxForce The maximum force of the motor
  28198. * @param motorIndex The index of the motor
  28199. */
  28200. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28201. /**
  28202. * Sets the limit of the motor
  28203. * @param upperLimit The upper limit of the motor
  28204. * @param lowerLimit The lower limit of the motor
  28205. * @param motorIndex The index of the motor
  28206. */
  28207. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28208. }
  28209. /**
  28210. * Joint data for a Distance-Joint
  28211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28212. */
  28213. export interface DistanceJointData extends PhysicsJointData {
  28214. /**
  28215. * Max distance the 2 joint objects can be apart
  28216. */
  28217. maxDistance: number;
  28218. }
  28219. /**
  28220. * Joint data from a spring joint
  28221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28222. */
  28223. export interface SpringJointData extends PhysicsJointData {
  28224. /**
  28225. * Length of the spring
  28226. */
  28227. length: number;
  28228. /**
  28229. * Stiffness of the spring
  28230. */
  28231. stiffness: number;
  28232. /**
  28233. * Damping of the spring
  28234. */
  28235. damping: number;
  28236. /** this callback will be called when applying the force to the impostors. */
  28237. forceApplicationCallback: () => void;
  28238. }
  28239. }
  28240. declare module "babylonjs/Physics/physicsRaycastResult" {
  28241. import { Vector3 } from "babylonjs/Maths/math.vector";
  28242. /**
  28243. * Holds the data for the raycast result
  28244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28245. */
  28246. export class PhysicsRaycastResult {
  28247. private _hasHit;
  28248. private _hitDistance;
  28249. private _hitNormalWorld;
  28250. private _hitPointWorld;
  28251. private _rayFromWorld;
  28252. private _rayToWorld;
  28253. /**
  28254. * Gets if there was a hit
  28255. */
  28256. get hasHit(): boolean;
  28257. /**
  28258. * Gets the distance from the hit
  28259. */
  28260. get hitDistance(): number;
  28261. /**
  28262. * Gets the hit normal/direction in the world
  28263. */
  28264. get hitNormalWorld(): Vector3;
  28265. /**
  28266. * Gets the hit point in the world
  28267. */
  28268. get hitPointWorld(): Vector3;
  28269. /**
  28270. * Gets the ray "start point" of the ray in the world
  28271. */
  28272. get rayFromWorld(): Vector3;
  28273. /**
  28274. * Gets the ray "end point" of the ray in the world
  28275. */
  28276. get rayToWorld(): Vector3;
  28277. /**
  28278. * Sets the hit data (normal & point in world space)
  28279. * @param hitNormalWorld defines the normal in world space
  28280. * @param hitPointWorld defines the point in world space
  28281. */
  28282. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28283. /**
  28284. * Sets the distance from the start point to the hit point
  28285. * @param distance
  28286. */
  28287. setHitDistance(distance: number): void;
  28288. /**
  28289. * Calculates the distance manually
  28290. */
  28291. calculateHitDistance(): void;
  28292. /**
  28293. * Resets all the values to default
  28294. * @param from The from point on world space
  28295. * @param to The to point on world space
  28296. */
  28297. reset(from?: Vector3, to?: Vector3): void;
  28298. }
  28299. /**
  28300. * Interface for the size containing width and height
  28301. */
  28302. interface IXYZ {
  28303. /**
  28304. * X
  28305. */
  28306. x: number;
  28307. /**
  28308. * Y
  28309. */
  28310. y: number;
  28311. /**
  28312. * Z
  28313. */
  28314. z: number;
  28315. }
  28316. }
  28317. declare module "babylonjs/Physics/IPhysicsEngine" {
  28318. import { Nullable } from "babylonjs/types";
  28319. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28321. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28322. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28323. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28324. /**
  28325. * Interface used to describe a physics joint
  28326. */
  28327. export interface PhysicsImpostorJoint {
  28328. /** Defines the main impostor to which the joint is linked */
  28329. mainImpostor: PhysicsImpostor;
  28330. /** Defines the impostor that is connected to the main impostor using this joint */
  28331. connectedImpostor: PhysicsImpostor;
  28332. /** Defines the joint itself */
  28333. joint: PhysicsJoint;
  28334. }
  28335. /** @hidden */
  28336. export interface IPhysicsEnginePlugin {
  28337. world: any;
  28338. name: string;
  28339. setGravity(gravity: Vector3): void;
  28340. setTimeStep(timeStep: number): void;
  28341. getTimeStep(): number;
  28342. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28343. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28344. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28345. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28346. removePhysicsBody(impostor: PhysicsImpostor): void;
  28347. generateJoint(joint: PhysicsImpostorJoint): void;
  28348. removeJoint(joint: PhysicsImpostorJoint): void;
  28349. isSupported(): boolean;
  28350. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28351. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28352. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28353. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28354. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28355. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28356. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28357. getBodyMass(impostor: PhysicsImpostor): number;
  28358. getBodyFriction(impostor: PhysicsImpostor): number;
  28359. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28360. getBodyRestitution(impostor: PhysicsImpostor): number;
  28361. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28362. getBodyPressure?(impostor: PhysicsImpostor): number;
  28363. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28364. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28365. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28366. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28367. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28368. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28369. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28370. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28371. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28372. sleepBody(impostor: PhysicsImpostor): void;
  28373. wakeUpBody(impostor: PhysicsImpostor): void;
  28374. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28375. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28376. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28377. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28378. getRadius(impostor: PhysicsImpostor): number;
  28379. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28380. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28381. dispose(): void;
  28382. }
  28383. /**
  28384. * Interface used to define a physics engine
  28385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28386. */
  28387. export interface IPhysicsEngine {
  28388. /**
  28389. * Gets the gravity vector used by the simulation
  28390. */
  28391. gravity: Vector3;
  28392. /**
  28393. * Sets the gravity vector used by the simulation
  28394. * @param gravity defines the gravity vector to use
  28395. */
  28396. setGravity(gravity: Vector3): void;
  28397. /**
  28398. * Set the time step of the physics engine.
  28399. * Default is 1/60.
  28400. * To slow it down, enter 1/600 for example.
  28401. * To speed it up, 1/30
  28402. * @param newTimeStep the new timestep to apply to this world.
  28403. */
  28404. setTimeStep(newTimeStep: number): void;
  28405. /**
  28406. * Get the time step of the physics engine.
  28407. * @returns the current time step
  28408. */
  28409. getTimeStep(): number;
  28410. /**
  28411. * Set the sub time step of the physics engine.
  28412. * Default is 0 meaning there is no sub steps
  28413. * To increase physics resolution precision, set a small value (like 1 ms)
  28414. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28415. */
  28416. setSubTimeStep(subTimeStep: number): void;
  28417. /**
  28418. * Get the sub time step of the physics engine.
  28419. * @returns the current sub time step
  28420. */
  28421. getSubTimeStep(): number;
  28422. /**
  28423. * Release all resources
  28424. */
  28425. dispose(): void;
  28426. /**
  28427. * Gets the name of the current physics plugin
  28428. * @returns the name of the plugin
  28429. */
  28430. getPhysicsPluginName(): string;
  28431. /**
  28432. * Adding a new impostor for the impostor tracking.
  28433. * This will be done by the impostor itself.
  28434. * @param impostor the impostor to add
  28435. */
  28436. addImpostor(impostor: PhysicsImpostor): void;
  28437. /**
  28438. * Remove an impostor from the engine.
  28439. * This impostor and its mesh will not longer be updated by the physics engine.
  28440. * @param impostor the impostor to remove
  28441. */
  28442. removeImpostor(impostor: PhysicsImpostor): void;
  28443. /**
  28444. * Add a joint to the physics engine
  28445. * @param mainImpostor defines the main impostor to which the joint is added.
  28446. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28447. * @param joint defines the joint that will connect both impostors.
  28448. */
  28449. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28450. /**
  28451. * Removes a joint from the simulation
  28452. * @param mainImpostor defines the impostor used with the joint
  28453. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28454. * @param joint defines the joint to remove
  28455. */
  28456. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28457. /**
  28458. * Gets the current plugin used to run the simulation
  28459. * @returns current plugin
  28460. */
  28461. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28462. /**
  28463. * Gets the list of physic impostors
  28464. * @returns an array of PhysicsImpostor
  28465. */
  28466. getImpostors(): Array<PhysicsImpostor>;
  28467. /**
  28468. * Gets the impostor for a physics enabled object
  28469. * @param object defines the object impersonated by the impostor
  28470. * @returns the PhysicsImpostor or null if not found
  28471. */
  28472. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28473. /**
  28474. * Gets the impostor for a physics body object
  28475. * @param body defines physics body used by the impostor
  28476. * @returns the PhysicsImpostor or null if not found
  28477. */
  28478. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28479. /**
  28480. * Does a raycast in the physics world
  28481. * @param from when should the ray start?
  28482. * @param to when should the ray end?
  28483. * @returns PhysicsRaycastResult
  28484. */
  28485. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28486. /**
  28487. * Called by the scene. No need to call it.
  28488. * @param delta defines the timespam between frames
  28489. */
  28490. _step(delta: number): void;
  28491. }
  28492. }
  28493. declare module "babylonjs/Physics/physicsImpostor" {
  28494. import { Nullable, IndicesArray } from "babylonjs/types";
  28495. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28496. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28498. import { Scene } from "babylonjs/scene";
  28499. import { Bone } from "babylonjs/Bones/bone";
  28500. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28501. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28502. import { Space } from "babylonjs/Maths/math.axis";
  28503. /**
  28504. * The interface for the physics imposter parameters
  28505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28506. */
  28507. export interface PhysicsImpostorParameters {
  28508. /**
  28509. * The mass of the physics imposter
  28510. */
  28511. mass: number;
  28512. /**
  28513. * The friction of the physics imposter
  28514. */
  28515. friction?: number;
  28516. /**
  28517. * The coefficient of restitution of the physics imposter
  28518. */
  28519. restitution?: number;
  28520. /**
  28521. * The native options of the physics imposter
  28522. */
  28523. nativeOptions?: any;
  28524. /**
  28525. * Specifies if the parent should be ignored
  28526. */
  28527. ignoreParent?: boolean;
  28528. /**
  28529. * Specifies if bi-directional transformations should be disabled
  28530. */
  28531. disableBidirectionalTransformation?: boolean;
  28532. /**
  28533. * The pressure inside the physics imposter, soft object only
  28534. */
  28535. pressure?: number;
  28536. /**
  28537. * The stiffness the physics imposter, soft object only
  28538. */
  28539. stiffness?: number;
  28540. /**
  28541. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28542. */
  28543. velocityIterations?: number;
  28544. /**
  28545. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28546. */
  28547. positionIterations?: number;
  28548. /**
  28549. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28550. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28551. * Add to fix multiple points
  28552. */
  28553. fixedPoints?: number;
  28554. /**
  28555. * The collision margin around a soft object
  28556. */
  28557. margin?: number;
  28558. /**
  28559. * The collision margin around a soft object
  28560. */
  28561. damping?: number;
  28562. /**
  28563. * The path for a rope based on an extrusion
  28564. */
  28565. path?: any;
  28566. /**
  28567. * The shape of an extrusion used for a rope based on an extrusion
  28568. */
  28569. shape?: any;
  28570. }
  28571. /**
  28572. * Interface for a physics-enabled object
  28573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28574. */
  28575. export interface IPhysicsEnabledObject {
  28576. /**
  28577. * The position of the physics-enabled object
  28578. */
  28579. position: Vector3;
  28580. /**
  28581. * The rotation of the physics-enabled object
  28582. */
  28583. rotationQuaternion: Nullable<Quaternion>;
  28584. /**
  28585. * The scale of the physics-enabled object
  28586. */
  28587. scaling: Vector3;
  28588. /**
  28589. * The rotation of the physics-enabled object
  28590. */
  28591. rotation?: Vector3;
  28592. /**
  28593. * The parent of the physics-enabled object
  28594. */
  28595. parent?: any;
  28596. /**
  28597. * The bounding info of the physics-enabled object
  28598. * @returns The bounding info of the physics-enabled object
  28599. */
  28600. getBoundingInfo(): BoundingInfo;
  28601. /**
  28602. * Computes the world matrix
  28603. * @param force Specifies if the world matrix should be computed by force
  28604. * @returns A world matrix
  28605. */
  28606. computeWorldMatrix(force: boolean): Matrix;
  28607. /**
  28608. * Gets the world matrix
  28609. * @returns A world matrix
  28610. */
  28611. getWorldMatrix?(): Matrix;
  28612. /**
  28613. * Gets the child meshes
  28614. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28615. * @returns An array of abstract meshes
  28616. */
  28617. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28618. /**
  28619. * Gets the vertex data
  28620. * @param kind The type of vertex data
  28621. * @returns A nullable array of numbers, or a float32 array
  28622. */
  28623. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28624. /**
  28625. * Gets the indices from the mesh
  28626. * @returns A nullable array of index arrays
  28627. */
  28628. getIndices?(): Nullable<IndicesArray>;
  28629. /**
  28630. * Gets the scene from the mesh
  28631. * @returns the indices array or null
  28632. */
  28633. getScene?(): Scene;
  28634. /**
  28635. * Gets the absolute position from the mesh
  28636. * @returns the absolute position
  28637. */
  28638. getAbsolutePosition(): Vector3;
  28639. /**
  28640. * Gets the absolute pivot point from the mesh
  28641. * @returns the absolute pivot point
  28642. */
  28643. getAbsolutePivotPoint(): Vector3;
  28644. /**
  28645. * Rotates the mesh
  28646. * @param axis The axis of rotation
  28647. * @param amount The amount of rotation
  28648. * @param space The space of the rotation
  28649. * @returns The rotation transform node
  28650. */
  28651. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28652. /**
  28653. * Translates the mesh
  28654. * @param axis The axis of translation
  28655. * @param distance The distance of translation
  28656. * @param space The space of the translation
  28657. * @returns The transform node
  28658. */
  28659. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28660. /**
  28661. * Sets the absolute position of the mesh
  28662. * @param absolutePosition The absolute position of the mesh
  28663. * @returns The transform node
  28664. */
  28665. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28666. /**
  28667. * Gets the class name of the mesh
  28668. * @returns The class name
  28669. */
  28670. getClassName(): string;
  28671. }
  28672. /**
  28673. * Represents a physics imposter
  28674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28675. */
  28676. export class PhysicsImpostor {
  28677. /**
  28678. * The physics-enabled object used as the physics imposter
  28679. */
  28680. object: IPhysicsEnabledObject;
  28681. /**
  28682. * The type of the physics imposter
  28683. */
  28684. type: number;
  28685. private _options;
  28686. private _scene?;
  28687. /**
  28688. * The default object size of the imposter
  28689. */
  28690. static DEFAULT_OBJECT_SIZE: Vector3;
  28691. /**
  28692. * The identity quaternion of the imposter
  28693. */
  28694. static IDENTITY_QUATERNION: Quaternion;
  28695. /** @hidden */
  28696. _pluginData: any;
  28697. private _physicsEngine;
  28698. private _physicsBody;
  28699. private _bodyUpdateRequired;
  28700. private _onBeforePhysicsStepCallbacks;
  28701. private _onAfterPhysicsStepCallbacks;
  28702. /** @hidden */
  28703. _onPhysicsCollideCallbacks: Array<{
  28704. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28705. otherImpostors: Array<PhysicsImpostor>;
  28706. }>;
  28707. private _deltaPosition;
  28708. private _deltaRotation;
  28709. private _deltaRotationConjugated;
  28710. /** @hidden */
  28711. _isFromLine: boolean;
  28712. private _parent;
  28713. private _isDisposed;
  28714. private static _tmpVecs;
  28715. private static _tmpQuat;
  28716. /**
  28717. * Specifies if the physics imposter is disposed
  28718. */
  28719. get isDisposed(): boolean;
  28720. /**
  28721. * Gets the mass of the physics imposter
  28722. */
  28723. get mass(): number;
  28724. set mass(value: number);
  28725. /**
  28726. * Gets the coefficient of friction
  28727. */
  28728. get friction(): number;
  28729. /**
  28730. * Sets the coefficient of friction
  28731. */
  28732. set friction(value: number);
  28733. /**
  28734. * Gets the coefficient of restitution
  28735. */
  28736. get restitution(): number;
  28737. /**
  28738. * Sets the coefficient of restitution
  28739. */
  28740. set restitution(value: number);
  28741. /**
  28742. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28743. */
  28744. get pressure(): number;
  28745. /**
  28746. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28747. */
  28748. set pressure(value: number);
  28749. /**
  28750. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28751. */
  28752. get stiffness(): number;
  28753. /**
  28754. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28755. */
  28756. set stiffness(value: number);
  28757. /**
  28758. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28759. */
  28760. get velocityIterations(): number;
  28761. /**
  28762. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28763. */
  28764. set velocityIterations(value: number);
  28765. /**
  28766. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28767. */
  28768. get positionIterations(): number;
  28769. /**
  28770. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28771. */
  28772. set positionIterations(value: number);
  28773. /**
  28774. * The unique id of the physics imposter
  28775. * set by the physics engine when adding this impostor to the array
  28776. */
  28777. uniqueId: number;
  28778. /**
  28779. * @hidden
  28780. */
  28781. soft: boolean;
  28782. /**
  28783. * @hidden
  28784. */
  28785. segments: number;
  28786. private _joints;
  28787. /**
  28788. * Initializes the physics imposter
  28789. * @param object The physics-enabled object used as the physics imposter
  28790. * @param type The type of the physics imposter
  28791. * @param _options The options for the physics imposter
  28792. * @param _scene The Babylon scene
  28793. */
  28794. constructor(
  28795. /**
  28796. * The physics-enabled object used as the physics imposter
  28797. */
  28798. object: IPhysicsEnabledObject,
  28799. /**
  28800. * The type of the physics imposter
  28801. */
  28802. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28803. /**
  28804. * This function will completly initialize this impostor.
  28805. * It will create a new body - but only if this mesh has no parent.
  28806. * If it has, this impostor will not be used other than to define the impostor
  28807. * of the child mesh.
  28808. * @hidden
  28809. */
  28810. _init(): void;
  28811. private _getPhysicsParent;
  28812. /**
  28813. * Should a new body be generated.
  28814. * @returns boolean specifying if body initialization is required
  28815. */
  28816. isBodyInitRequired(): boolean;
  28817. /**
  28818. * Sets the updated scaling
  28819. * @param updated Specifies if the scaling is updated
  28820. */
  28821. setScalingUpdated(): void;
  28822. /**
  28823. * Force a regeneration of this or the parent's impostor's body.
  28824. * Use under cautious - This will remove all joints already implemented.
  28825. */
  28826. forceUpdate(): void;
  28827. /**
  28828. * Gets the body that holds this impostor. Either its own, or its parent.
  28829. */
  28830. get physicsBody(): any;
  28831. /**
  28832. * Get the parent of the physics imposter
  28833. * @returns Physics imposter or null
  28834. */
  28835. get parent(): Nullable<PhysicsImpostor>;
  28836. /**
  28837. * Sets the parent of the physics imposter
  28838. */
  28839. set parent(value: Nullable<PhysicsImpostor>);
  28840. /**
  28841. * Set the physics body. Used mainly by the physics engine/plugin
  28842. */
  28843. set physicsBody(physicsBody: any);
  28844. /**
  28845. * Resets the update flags
  28846. */
  28847. resetUpdateFlags(): void;
  28848. /**
  28849. * Gets the object extend size
  28850. * @returns the object extend size
  28851. */
  28852. getObjectExtendSize(): Vector3;
  28853. /**
  28854. * Gets the object center
  28855. * @returns The object center
  28856. */
  28857. getObjectCenter(): Vector3;
  28858. /**
  28859. * Get a specific parameter from the options parameters
  28860. * @param paramName The object parameter name
  28861. * @returns The object parameter
  28862. */
  28863. getParam(paramName: string): any;
  28864. /**
  28865. * Sets a specific parameter in the options given to the physics plugin
  28866. * @param paramName The parameter name
  28867. * @param value The value of the parameter
  28868. */
  28869. setParam(paramName: string, value: number): void;
  28870. /**
  28871. * Specifically change the body's mass option. Won't recreate the physics body object
  28872. * @param mass The mass of the physics imposter
  28873. */
  28874. setMass(mass: number): void;
  28875. /**
  28876. * Gets the linear velocity
  28877. * @returns linear velocity or null
  28878. */
  28879. getLinearVelocity(): Nullable<Vector3>;
  28880. /**
  28881. * Sets the linear velocity
  28882. * @param velocity linear velocity or null
  28883. */
  28884. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28885. /**
  28886. * Gets the angular velocity
  28887. * @returns angular velocity or null
  28888. */
  28889. getAngularVelocity(): Nullable<Vector3>;
  28890. /**
  28891. * Sets the angular velocity
  28892. * @param velocity The velocity or null
  28893. */
  28894. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28895. /**
  28896. * Execute a function with the physics plugin native code
  28897. * Provide a function the will have two variables - the world object and the physics body object
  28898. * @param func The function to execute with the physics plugin native code
  28899. */
  28900. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28901. /**
  28902. * Register a function that will be executed before the physics world is stepping forward
  28903. * @param func The function to execute before the physics world is stepped forward
  28904. */
  28905. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28906. /**
  28907. * Unregister a function that will be executed before the physics world is stepping forward
  28908. * @param func The function to execute before the physics world is stepped forward
  28909. */
  28910. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28911. /**
  28912. * Register a function that will be executed after the physics step
  28913. * @param func The function to execute after physics step
  28914. */
  28915. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28916. /**
  28917. * Unregisters a function that will be executed after the physics step
  28918. * @param func The function to execute after physics step
  28919. */
  28920. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28921. /**
  28922. * register a function that will be executed when this impostor collides against a different body
  28923. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28924. * @param func Callback that is executed on collision
  28925. */
  28926. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28927. /**
  28928. * Unregisters the physics imposter on contact
  28929. * @param collideAgainst The physics object to collide against
  28930. * @param func Callback to execute on collision
  28931. */
  28932. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28933. private _tmpQuat;
  28934. private _tmpQuat2;
  28935. /**
  28936. * Get the parent rotation
  28937. * @returns The parent rotation
  28938. */
  28939. getParentsRotation(): Quaternion;
  28940. /**
  28941. * this function is executed by the physics engine.
  28942. */
  28943. beforeStep: () => void;
  28944. /**
  28945. * this function is executed by the physics engine
  28946. */
  28947. afterStep: () => void;
  28948. /**
  28949. * Legacy collision detection event support
  28950. */
  28951. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28952. /**
  28953. * event and body object due to cannon's event-based architecture.
  28954. */
  28955. onCollide: (e: {
  28956. body: any;
  28957. }) => void;
  28958. /**
  28959. * Apply a force
  28960. * @param force The force to apply
  28961. * @param contactPoint The contact point for the force
  28962. * @returns The physics imposter
  28963. */
  28964. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28965. /**
  28966. * Apply an impulse
  28967. * @param force The impulse force
  28968. * @param contactPoint The contact point for the impulse force
  28969. * @returns The physics imposter
  28970. */
  28971. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28972. /**
  28973. * A help function to create a joint
  28974. * @param otherImpostor A physics imposter used to create a joint
  28975. * @param jointType The type of joint
  28976. * @param jointData The data for the joint
  28977. * @returns The physics imposter
  28978. */
  28979. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28980. /**
  28981. * Add a joint to this impostor with a different impostor
  28982. * @param otherImpostor A physics imposter used to add a joint
  28983. * @param joint The joint to add
  28984. * @returns The physics imposter
  28985. */
  28986. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28987. /**
  28988. * Add an anchor to a cloth impostor
  28989. * @param otherImpostor rigid impostor to anchor to
  28990. * @param width ratio across width from 0 to 1
  28991. * @param height ratio up height from 0 to 1
  28992. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28993. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28994. * @returns impostor the soft imposter
  28995. */
  28996. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28997. /**
  28998. * Add a hook to a rope impostor
  28999. * @param otherImpostor rigid impostor to anchor to
  29000. * @param length ratio across rope from 0 to 1
  29001. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  29002. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  29003. * @returns impostor the rope imposter
  29004. */
  29005. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29006. /**
  29007. * Will keep this body still, in a sleep mode.
  29008. * @returns the physics imposter
  29009. */
  29010. sleep(): PhysicsImpostor;
  29011. /**
  29012. * Wake the body up.
  29013. * @returns The physics imposter
  29014. */
  29015. wakeUp(): PhysicsImpostor;
  29016. /**
  29017. * Clones the physics imposter
  29018. * @param newObject The physics imposter clones to this physics-enabled object
  29019. * @returns A nullable physics imposter
  29020. */
  29021. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29022. /**
  29023. * Disposes the physics imposter
  29024. */
  29025. dispose(): void;
  29026. /**
  29027. * Sets the delta position
  29028. * @param position The delta position amount
  29029. */
  29030. setDeltaPosition(position: Vector3): void;
  29031. /**
  29032. * Sets the delta rotation
  29033. * @param rotation The delta rotation amount
  29034. */
  29035. setDeltaRotation(rotation: Quaternion): void;
  29036. /**
  29037. * Gets the box size of the physics imposter and stores the result in the input parameter
  29038. * @param result Stores the box size
  29039. * @returns The physics imposter
  29040. */
  29041. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29042. /**
  29043. * Gets the radius of the physics imposter
  29044. * @returns Radius of the physics imposter
  29045. */
  29046. getRadius(): number;
  29047. /**
  29048. * Sync a bone with this impostor
  29049. * @param bone The bone to sync to the impostor.
  29050. * @param boneMesh The mesh that the bone is influencing.
  29051. * @param jointPivot The pivot of the joint / bone in local space.
  29052. * @param distToJoint Optional distance from the impostor to the joint.
  29053. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29054. */
  29055. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29056. /**
  29057. * Sync impostor to a bone
  29058. * @param bone The bone that the impostor will be synced to.
  29059. * @param boneMesh The mesh that the bone is influencing.
  29060. * @param jointPivot The pivot of the joint / bone in local space.
  29061. * @param distToJoint Optional distance from the impostor to the joint.
  29062. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29063. * @param boneAxis Optional vector3 axis the bone is aligned with
  29064. */
  29065. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29066. /**
  29067. * No-Imposter type
  29068. */
  29069. static NoImpostor: number;
  29070. /**
  29071. * Sphere-Imposter type
  29072. */
  29073. static SphereImpostor: number;
  29074. /**
  29075. * Box-Imposter type
  29076. */
  29077. static BoxImpostor: number;
  29078. /**
  29079. * Plane-Imposter type
  29080. */
  29081. static PlaneImpostor: number;
  29082. /**
  29083. * Mesh-imposter type
  29084. */
  29085. static MeshImpostor: number;
  29086. /**
  29087. * Capsule-Impostor type (Ammo.js plugin only)
  29088. */
  29089. static CapsuleImpostor: number;
  29090. /**
  29091. * Cylinder-Imposter type
  29092. */
  29093. static CylinderImpostor: number;
  29094. /**
  29095. * Particle-Imposter type
  29096. */
  29097. static ParticleImpostor: number;
  29098. /**
  29099. * Heightmap-Imposter type
  29100. */
  29101. static HeightmapImpostor: number;
  29102. /**
  29103. * ConvexHull-Impostor type (Ammo.js plugin only)
  29104. */
  29105. static ConvexHullImpostor: number;
  29106. /**
  29107. * Custom-Imposter type (Ammo.js plugin only)
  29108. */
  29109. static CustomImpostor: number;
  29110. /**
  29111. * Rope-Imposter type
  29112. */
  29113. static RopeImpostor: number;
  29114. /**
  29115. * Cloth-Imposter type
  29116. */
  29117. static ClothImpostor: number;
  29118. /**
  29119. * Softbody-Imposter type
  29120. */
  29121. static SoftbodyImpostor: number;
  29122. }
  29123. }
  29124. declare module "babylonjs/Meshes/mesh" {
  29125. import { Observable } from "babylonjs/Misc/observable";
  29126. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29127. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29128. import { Camera } from "babylonjs/Cameras/camera";
  29129. import { Scene } from "babylonjs/scene";
  29130. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29131. import { Color4 } from "babylonjs/Maths/math.color";
  29132. import { Engine } from "babylonjs/Engines/engine";
  29133. import { Node } from "babylonjs/node";
  29134. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29135. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29136. import { Buffer } from "babylonjs/Meshes/buffer";
  29137. import { Geometry } from "babylonjs/Meshes/geometry";
  29138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29139. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29140. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29141. import { Effect } from "babylonjs/Materials/effect";
  29142. import { Material } from "babylonjs/Materials/material";
  29143. import { Skeleton } from "babylonjs/Bones/skeleton";
  29144. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29145. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29146. import { Path3D } from "babylonjs/Maths/math.path";
  29147. import { Plane } from "babylonjs/Maths/math.plane";
  29148. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29149. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29150. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29151. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29152. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29153. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29154. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29155. /**
  29156. * @hidden
  29157. **/
  29158. export class _CreationDataStorage {
  29159. closePath?: boolean;
  29160. closeArray?: boolean;
  29161. idx: number[];
  29162. dashSize: number;
  29163. gapSize: number;
  29164. path3D: Path3D;
  29165. pathArray: Vector3[][];
  29166. arc: number;
  29167. radius: number;
  29168. cap: number;
  29169. tessellation: number;
  29170. }
  29171. /**
  29172. * @hidden
  29173. **/
  29174. class _InstanceDataStorage {
  29175. visibleInstances: any;
  29176. batchCache: _InstancesBatch;
  29177. instancesBufferSize: number;
  29178. instancesBuffer: Nullable<Buffer>;
  29179. instancesData: Float32Array;
  29180. overridenInstanceCount: number;
  29181. isFrozen: boolean;
  29182. previousBatch: Nullable<_InstancesBatch>;
  29183. hardwareInstancedRendering: boolean;
  29184. sideOrientation: number;
  29185. manualUpdate: boolean;
  29186. previousRenderId: number;
  29187. }
  29188. /**
  29189. * @hidden
  29190. **/
  29191. export class _InstancesBatch {
  29192. mustReturn: boolean;
  29193. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29194. renderSelf: boolean[];
  29195. hardwareInstancedRendering: boolean[];
  29196. }
  29197. /**
  29198. * @hidden
  29199. **/
  29200. class _ThinInstanceDataStorage {
  29201. instancesCount: number;
  29202. matrixBuffer: Nullable<Buffer>;
  29203. matrixBufferSize: number;
  29204. matrixData: Nullable<Float32Array>;
  29205. boundingVectors: Array<Vector3>;
  29206. worldMatrices: Nullable<Matrix[]>;
  29207. }
  29208. /**
  29209. * Class used to represent renderable models
  29210. */
  29211. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29212. /**
  29213. * Mesh side orientation : usually the external or front surface
  29214. */
  29215. static readonly FRONTSIDE: number;
  29216. /**
  29217. * Mesh side orientation : usually the internal or back surface
  29218. */
  29219. static readonly BACKSIDE: number;
  29220. /**
  29221. * Mesh side orientation : both internal and external or front and back surfaces
  29222. */
  29223. static readonly DOUBLESIDE: number;
  29224. /**
  29225. * Mesh side orientation : by default, `FRONTSIDE`
  29226. */
  29227. static readonly DEFAULTSIDE: number;
  29228. /**
  29229. * Mesh cap setting : no cap
  29230. */
  29231. static readonly NO_CAP: number;
  29232. /**
  29233. * Mesh cap setting : one cap at the beginning of the mesh
  29234. */
  29235. static readonly CAP_START: number;
  29236. /**
  29237. * Mesh cap setting : one cap at the end of the mesh
  29238. */
  29239. static readonly CAP_END: number;
  29240. /**
  29241. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29242. */
  29243. static readonly CAP_ALL: number;
  29244. /**
  29245. * Mesh pattern setting : no flip or rotate
  29246. */
  29247. static readonly NO_FLIP: number;
  29248. /**
  29249. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29250. */
  29251. static readonly FLIP_TILE: number;
  29252. /**
  29253. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29254. */
  29255. static readonly ROTATE_TILE: number;
  29256. /**
  29257. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29258. */
  29259. static readonly FLIP_ROW: number;
  29260. /**
  29261. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29262. */
  29263. static readonly ROTATE_ROW: number;
  29264. /**
  29265. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29266. */
  29267. static readonly FLIP_N_ROTATE_TILE: number;
  29268. /**
  29269. * Mesh pattern setting : rotate pattern and rotate
  29270. */
  29271. static readonly FLIP_N_ROTATE_ROW: number;
  29272. /**
  29273. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29274. */
  29275. static readonly CENTER: number;
  29276. /**
  29277. * Mesh tile positioning : part tiles on left
  29278. */
  29279. static readonly LEFT: number;
  29280. /**
  29281. * Mesh tile positioning : part tiles on right
  29282. */
  29283. static readonly RIGHT: number;
  29284. /**
  29285. * Mesh tile positioning : part tiles on top
  29286. */
  29287. static readonly TOP: number;
  29288. /**
  29289. * Mesh tile positioning : part tiles on bottom
  29290. */
  29291. static readonly BOTTOM: number;
  29292. /**
  29293. * Gets the default side orientation.
  29294. * @param orientation the orientation to value to attempt to get
  29295. * @returns the default orientation
  29296. * @hidden
  29297. */
  29298. static _GetDefaultSideOrientation(orientation?: number): number;
  29299. private _internalMeshDataInfo;
  29300. get computeBonesUsingShaders(): boolean;
  29301. set computeBonesUsingShaders(value: boolean);
  29302. /**
  29303. * An event triggered before rendering the mesh
  29304. */
  29305. get onBeforeRenderObservable(): Observable<Mesh>;
  29306. /**
  29307. * An event triggered before binding the mesh
  29308. */
  29309. get onBeforeBindObservable(): Observable<Mesh>;
  29310. /**
  29311. * An event triggered after rendering the mesh
  29312. */
  29313. get onAfterRenderObservable(): Observable<Mesh>;
  29314. /**
  29315. * An event triggered before drawing the mesh
  29316. */
  29317. get onBeforeDrawObservable(): Observable<Mesh>;
  29318. private _onBeforeDrawObserver;
  29319. /**
  29320. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29321. */
  29322. set onBeforeDraw(callback: () => void);
  29323. get hasInstances(): boolean;
  29324. get hasThinInstances(): boolean;
  29325. /**
  29326. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29327. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29328. */
  29329. delayLoadState: number;
  29330. /**
  29331. * Gets the list of instances created from this mesh
  29332. * it is not supposed to be modified manually.
  29333. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29334. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29335. */
  29336. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29337. /**
  29338. * Gets the file containing delay loading data for this mesh
  29339. */
  29340. delayLoadingFile: string;
  29341. /** @hidden */
  29342. _binaryInfo: any;
  29343. /**
  29344. * User defined function used to change how LOD level selection is done
  29345. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29346. */
  29347. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29348. /**
  29349. * Gets or sets the morph target manager
  29350. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29351. */
  29352. get morphTargetManager(): Nullable<MorphTargetManager>;
  29353. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29354. /** @hidden */
  29355. _creationDataStorage: Nullable<_CreationDataStorage>;
  29356. /** @hidden */
  29357. _geometry: Nullable<Geometry>;
  29358. /** @hidden */
  29359. _delayInfo: Array<string>;
  29360. /** @hidden */
  29361. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29362. /** @hidden */
  29363. _instanceDataStorage: _InstanceDataStorage;
  29364. /** @hidden */
  29365. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29366. private _effectiveMaterial;
  29367. /** @hidden */
  29368. _shouldGenerateFlatShading: boolean;
  29369. /** @hidden */
  29370. _originalBuilderSideOrientation: number;
  29371. /**
  29372. * Use this property to change the original side orientation defined at construction time
  29373. */
  29374. overrideMaterialSideOrientation: Nullable<number>;
  29375. /**
  29376. * Gets the source mesh (the one used to clone this one from)
  29377. */
  29378. get source(): Nullable<Mesh>;
  29379. /**
  29380. * Gets the list of clones of this mesh
  29381. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29382. * Note that useClonedMeshMap=true is the default setting
  29383. */
  29384. get cloneMeshMap(): Nullable<{
  29385. [id: string]: Mesh | undefined;
  29386. }>;
  29387. /**
  29388. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29389. */
  29390. get isUnIndexed(): boolean;
  29391. set isUnIndexed(value: boolean);
  29392. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29393. get worldMatrixInstancedBuffer(): Float32Array;
  29394. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29395. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29396. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29397. /**
  29398. * @constructor
  29399. * @param name The value used by scene.getMeshByName() to do a lookup.
  29400. * @param scene The scene to add this mesh to.
  29401. * @param parent The parent of this mesh, if it has one
  29402. * @param source An optional Mesh from which geometry is shared, cloned.
  29403. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29404. * When false, achieved by calling a clone(), also passing False.
  29405. * This will make creation of children, recursive.
  29406. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29407. */
  29408. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29409. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29410. doNotInstantiate: boolean;
  29411. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29412. /**
  29413. * Gets the class name
  29414. * @returns the string "Mesh".
  29415. */
  29416. getClassName(): string;
  29417. /** @hidden */
  29418. get _isMesh(): boolean;
  29419. /**
  29420. * Returns a description of this mesh
  29421. * @param fullDetails define if full details about this mesh must be used
  29422. * @returns a descriptive string representing this mesh
  29423. */
  29424. toString(fullDetails?: boolean): string;
  29425. /** @hidden */
  29426. _unBindEffect(): void;
  29427. /**
  29428. * Gets a boolean indicating if this mesh has LOD
  29429. */
  29430. get hasLODLevels(): boolean;
  29431. /**
  29432. * Gets the list of MeshLODLevel associated with the current mesh
  29433. * @returns an array of MeshLODLevel
  29434. */
  29435. getLODLevels(): MeshLODLevel[];
  29436. private _sortLODLevels;
  29437. /**
  29438. * Add a mesh as LOD level triggered at the given distance.
  29439. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29440. * @param distance The distance from the center of the object to show this level
  29441. * @param mesh The mesh to be added as LOD level (can be null)
  29442. * @return This mesh (for chaining)
  29443. */
  29444. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29445. /**
  29446. * Returns the LOD level mesh at the passed distance or null if not found.
  29447. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29448. * @param distance The distance from the center of the object to show this level
  29449. * @returns a Mesh or `null`
  29450. */
  29451. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29452. /**
  29453. * Remove a mesh from the LOD array
  29454. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29455. * @param mesh defines the mesh to be removed
  29456. * @return This mesh (for chaining)
  29457. */
  29458. removeLODLevel(mesh: Mesh): Mesh;
  29459. /**
  29460. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29461. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29462. * @param camera defines the camera to use to compute distance
  29463. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29464. * @return This mesh (for chaining)
  29465. */
  29466. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29467. /**
  29468. * Gets the mesh internal Geometry object
  29469. */
  29470. get geometry(): Nullable<Geometry>;
  29471. /**
  29472. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29473. * @returns the total number of vertices
  29474. */
  29475. getTotalVertices(): number;
  29476. /**
  29477. * Returns the content of an associated vertex buffer
  29478. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29479. * - VertexBuffer.PositionKind
  29480. * - VertexBuffer.UVKind
  29481. * - VertexBuffer.UV2Kind
  29482. * - VertexBuffer.UV3Kind
  29483. * - VertexBuffer.UV4Kind
  29484. * - VertexBuffer.UV5Kind
  29485. * - VertexBuffer.UV6Kind
  29486. * - VertexBuffer.ColorKind
  29487. * - VertexBuffer.MatricesIndicesKind
  29488. * - VertexBuffer.MatricesIndicesExtraKind
  29489. * - VertexBuffer.MatricesWeightsKind
  29490. * - VertexBuffer.MatricesWeightsExtraKind
  29491. * @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
  29492. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29493. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29494. */
  29495. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29496. /**
  29497. * Returns the mesh VertexBuffer object from the requested `kind`
  29498. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29499. * - VertexBuffer.PositionKind
  29500. * - VertexBuffer.NormalKind
  29501. * - VertexBuffer.UVKind
  29502. * - VertexBuffer.UV2Kind
  29503. * - VertexBuffer.UV3Kind
  29504. * - VertexBuffer.UV4Kind
  29505. * - VertexBuffer.UV5Kind
  29506. * - VertexBuffer.UV6Kind
  29507. * - VertexBuffer.ColorKind
  29508. * - VertexBuffer.MatricesIndicesKind
  29509. * - VertexBuffer.MatricesIndicesExtraKind
  29510. * - VertexBuffer.MatricesWeightsKind
  29511. * - VertexBuffer.MatricesWeightsExtraKind
  29512. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29513. */
  29514. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29515. /**
  29516. * Tests if a specific vertex buffer is associated with this mesh
  29517. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29518. * - VertexBuffer.PositionKind
  29519. * - VertexBuffer.NormalKind
  29520. * - VertexBuffer.UVKind
  29521. * - VertexBuffer.UV2Kind
  29522. * - VertexBuffer.UV3Kind
  29523. * - VertexBuffer.UV4Kind
  29524. * - VertexBuffer.UV5Kind
  29525. * - VertexBuffer.UV6Kind
  29526. * - VertexBuffer.ColorKind
  29527. * - VertexBuffer.MatricesIndicesKind
  29528. * - VertexBuffer.MatricesIndicesExtraKind
  29529. * - VertexBuffer.MatricesWeightsKind
  29530. * - VertexBuffer.MatricesWeightsExtraKind
  29531. * @returns a boolean
  29532. */
  29533. isVerticesDataPresent(kind: string): boolean;
  29534. /**
  29535. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29536. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29537. * - VertexBuffer.PositionKind
  29538. * - VertexBuffer.UVKind
  29539. * - VertexBuffer.UV2Kind
  29540. * - VertexBuffer.UV3Kind
  29541. * - VertexBuffer.UV4Kind
  29542. * - VertexBuffer.UV5Kind
  29543. * - VertexBuffer.UV6Kind
  29544. * - VertexBuffer.ColorKind
  29545. * - VertexBuffer.MatricesIndicesKind
  29546. * - VertexBuffer.MatricesIndicesExtraKind
  29547. * - VertexBuffer.MatricesWeightsKind
  29548. * - VertexBuffer.MatricesWeightsExtraKind
  29549. * @returns a boolean
  29550. */
  29551. isVertexBufferUpdatable(kind: string): boolean;
  29552. /**
  29553. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29554. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29555. * - VertexBuffer.PositionKind
  29556. * - VertexBuffer.NormalKind
  29557. * - VertexBuffer.UVKind
  29558. * - VertexBuffer.UV2Kind
  29559. * - VertexBuffer.UV3Kind
  29560. * - VertexBuffer.UV4Kind
  29561. * - VertexBuffer.UV5Kind
  29562. * - VertexBuffer.UV6Kind
  29563. * - VertexBuffer.ColorKind
  29564. * - VertexBuffer.MatricesIndicesKind
  29565. * - VertexBuffer.MatricesIndicesExtraKind
  29566. * - VertexBuffer.MatricesWeightsKind
  29567. * - VertexBuffer.MatricesWeightsExtraKind
  29568. * @returns an array of strings
  29569. */
  29570. getVerticesDataKinds(): string[];
  29571. /**
  29572. * Returns a positive integer : the total number of indices in this mesh geometry.
  29573. * @returns the numner of indices or zero if the mesh has no geometry.
  29574. */
  29575. getTotalIndices(): number;
  29576. /**
  29577. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29578. * @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.
  29579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29580. * @returns the indices array or an empty array if the mesh has no geometry
  29581. */
  29582. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29583. get isBlocked(): boolean;
  29584. /**
  29585. * Determine if the current mesh is ready to be rendered
  29586. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29587. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29588. * @returns true if all associated assets are ready (material, textures, shaders)
  29589. */
  29590. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29591. /**
  29592. * 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.
  29593. */
  29594. get areNormalsFrozen(): boolean;
  29595. /**
  29596. * 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.
  29597. * @returns the current mesh
  29598. */
  29599. freezeNormals(): Mesh;
  29600. /**
  29601. * 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
  29602. * @returns the current mesh
  29603. */
  29604. unfreezeNormals(): Mesh;
  29605. /**
  29606. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29607. */
  29608. set overridenInstanceCount(count: number);
  29609. /** @hidden */
  29610. _preActivate(): Mesh;
  29611. /** @hidden */
  29612. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29613. /** @hidden */
  29614. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29615. protected _afterComputeWorldMatrix(): void;
  29616. /** @hidden */
  29617. _postActivate(): void;
  29618. /**
  29619. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29620. * This means the mesh underlying bounding box and sphere are recomputed.
  29621. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29622. * @returns the current mesh
  29623. */
  29624. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29625. /** @hidden */
  29626. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29627. /**
  29628. * This function will subdivide the mesh into multiple submeshes
  29629. * @param count defines the expected number of submeshes
  29630. */
  29631. subdivide(count: number): void;
  29632. /**
  29633. * Copy a FloatArray into a specific associated vertex buffer
  29634. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29635. * - VertexBuffer.PositionKind
  29636. * - VertexBuffer.UVKind
  29637. * - VertexBuffer.UV2Kind
  29638. * - VertexBuffer.UV3Kind
  29639. * - VertexBuffer.UV4Kind
  29640. * - VertexBuffer.UV5Kind
  29641. * - VertexBuffer.UV6Kind
  29642. * - VertexBuffer.ColorKind
  29643. * - VertexBuffer.MatricesIndicesKind
  29644. * - VertexBuffer.MatricesIndicesExtraKind
  29645. * - VertexBuffer.MatricesWeightsKind
  29646. * - VertexBuffer.MatricesWeightsExtraKind
  29647. * @param data defines the data source
  29648. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29649. * @param stride defines the data stride size (can be null)
  29650. * @returns the current mesh
  29651. */
  29652. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29653. /**
  29654. * Delete a vertex buffer associated with this mesh
  29655. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29656. * - VertexBuffer.PositionKind
  29657. * - VertexBuffer.UVKind
  29658. * - VertexBuffer.UV2Kind
  29659. * - VertexBuffer.UV3Kind
  29660. * - VertexBuffer.UV4Kind
  29661. * - VertexBuffer.UV5Kind
  29662. * - VertexBuffer.UV6Kind
  29663. * - VertexBuffer.ColorKind
  29664. * - VertexBuffer.MatricesIndicesKind
  29665. * - VertexBuffer.MatricesIndicesExtraKind
  29666. * - VertexBuffer.MatricesWeightsKind
  29667. * - VertexBuffer.MatricesWeightsExtraKind
  29668. */
  29669. removeVerticesData(kind: string): void;
  29670. /**
  29671. * Flags an associated vertex buffer as updatable
  29672. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29673. * - VertexBuffer.PositionKind
  29674. * - VertexBuffer.UVKind
  29675. * - VertexBuffer.UV2Kind
  29676. * - VertexBuffer.UV3Kind
  29677. * - VertexBuffer.UV4Kind
  29678. * - VertexBuffer.UV5Kind
  29679. * - VertexBuffer.UV6Kind
  29680. * - VertexBuffer.ColorKind
  29681. * - VertexBuffer.MatricesIndicesKind
  29682. * - VertexBuffer.MatricesIndicesExtraKind
  29683. * - VertexBuffer.MatricesWeightsKind
  29684. * - VertexBuffer.MatricesWeightsExtraKind
  29685. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29686. */
  29687. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29688. /**
  29689. * Sets the mesh global Vertex Buffer
  29690. * @param buffer defines the buffer to use
  29691. * @returns the current mesh
  29692. */
  29693. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29694. /**
  29695. * Update a specific associated vertex buffer
  29696. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29697. * - VertexBuffer.PositionKind
  29698. * - VertexBuffer.UVKind
  29699. * - VertexBuffer.UV2Kind
  29700. * - VertexBuffer.UV3Kind
  29701. * - VertexBuffer.UV4Kind
  29702. * - VertexBuffer.UV5Kind
  29703. * - VertexBuffer.UV6Kind
  29704. * - VertexBuffer.ColorKind
  29705. * - VertexBuffer.MatricesIndicesKind
  29706. * - VertexBuffer.MatricesIndicesExtraKind
  29707. * - VertexBuffer.MatricesWeightsKind
  29708. * - VertexBuffer.MatricesWeightsExtraKind
  29709. * @param data defines the data source
  29710. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29711. * @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)
  29712. * @returns the current mesh
  29713. */
  29714. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29715. /**
  29716. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29717. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29718. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29719. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29720. * @returns the current mesh
  29721. */
  29722. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29723. /**
  29724. * Creates a un-shared specific occurence of the geometry for the mesh.
  29725. * @returns the current mesh
  29726. */
  29727. makeGeometryUnique(): Mesh;
  29728. /**
  29729. * Set the index buffer of this mesh
  29730. * @param indices defines the source data
  29731. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29732. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29733. * @returns the current mesh
  29734. */
  29735. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29736. /**
  29737. * Update the current index buffer
  29738. * @param indices defines the source data
  29739. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29740. * @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)
  29741. * @returns the current mesh
  29742. */
  29743. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29744. /**
  29745. * Invert the geometry to move from a right handed system to a left handed one.
  29746. * @returns the current mesh
  29747. */
  29748. toLeftHanded(): Mesh;
  29749. /** @hidden */
  29750. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29751. /** @hidden */
  29752. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29753. /**
  29754. * Registers for this mesh a javascript function called just before the rendering process
  29755. * @param func defines the function to call before rendering this mesh
  29756. * @returns the current mesh
  29757. */
  29758. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29759. /**
  29760. * Disposes a previously registered javascript function called before the rendering
  29761. * @param func defines the function to remove
  29762. * @returns the current mesh
  29763. */
  29764. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29765. /**
  29766. * Registers for this mesh a javascript function called just after the rendering is complete
  29767. * @param func defines the function to call after rendering this mesh
  29768. * @returns the current mesh
  29769. */
  29770. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29771. /**
  29772. * Disposes a previously registered javascript function called after the rendering.
  29773. * @param func defines the function to remove
  29774. * @returns the current mesh
  29775. */
  29776. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29777. /** @hidden */
  29778. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29779. /** @hidden */
  29780. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29781. /** @hidden */
  29782. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29783. /** @hidden */
  29784. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29785. /** @hidden */
  29786. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29787. /** @hidden */
  29788. _rebuild(): void;
  29789. /** @hidden */
  29790. _freeze(): void;
  29791. /** @hidden */
  29792. _unFreeze(): void;
  29793. /**
  29794. * 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
  29795. * @param subMesh defines the subMesh to render
  29796. * @param enableAlphaMode defines if alpha mode can be changed
  29797. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29798. * @returns the current mesh
  29799. */
  29800. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29801. private _onBeforeDraw;
  29802. /**
  29803. * Renormalize the mesh and patch it up if there are no weights
  29804. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29805. * However in the case of zero weights then we set just a single influence to 1.
  29806. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29807. */
  29808. cleanMatrixWeights(): void;
  29809. private normalizeSkinFourWeights;
  29810. private normalizeSkinWeightsAndExtra;
  29811. /**
  29812. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29813. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29814. * the user know there was an issue with importing the mesh
  29815. * @returns a validation object with skinned, valid and report string
  29816. */
  29817. validateSkinning(): {
  29818. skinned: boolean;
  29819. valid: boolean;
  29820. report: string;
  29821. };
  29822. /** @hidden */
  29823. _checkDelayState(): Mesh;
  29824. private _queueLoad;
  29825. /**
  29826. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29827. * A mesh is in the frustum if its bounding box intersects the frustum
  29828. * @param frustumPlanes defines the frustum to test
  29829. * @returns true if the mesh is in the frustum planes
  29830. */
  29831. isInFrustum(frustumPlanes: Plane[]): boolean;
  29832. /**
  29833. * Sets the mesh material by the material or multiMaterial `id` property
  29834. * @param id is a string identifying the material or the multiMaterial
  29835. * @returns the current mesh
  29836. */
  29837. setMaterialByID(id: string): Mesh;
  29838. /**
  29839. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29840. * @returns an array of IAnimatable
  29841. */
  29842. getAnimatables(): IAnimatable[];
  29843. /**
  29844. * Modifies the mesh geometry according to the passed transformation matrix.
  29845. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29846. * The mesh normals are modified using the same transformation.
  29847. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29848. * @param transform defines the transform matrix to use
  29849. * @see https://doc.babylonjs.com/resources/baking_transformations
  29850. * @returns the current mesh
  29851. */
  29852. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29853. /**
  29854. * Modifies the mesh geometry according to its own current World Matrix.
  29855. * The mesh World Matrix is then reset.
  29856. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29857. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29858. * @see https://doc.babylonjs.com/resources/baking_transformations
  29859. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29860. * @returns the current mesh
  29861. */
  29862. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29863. /** @hidden */
  29864. get _positions(): Nullable<Vector3[]>;
  29865. /** @hidden */
  29866. _resetPointsArrayCache(): Mesh;
  29867. /** @hidden */
  29868. _generatePointsArray(): boolean;
  29869. /**
  29870. * Returns a new Mesh object generated from the current mesh properties.
  29871. * This method must not get confused with createInstance()
  29872. * @param name is a string, the name given to the new mesh
  29873. * @param newParent can be any Node object (default `null`)
  29874. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29875. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29876. * @returns a new mesh
  29877. */
  29878. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29879. /**
  29880. * Releases resources associated with this mesh.
  29881. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29882. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29883. */
  29884. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29885. /** @hidden */
  29886. _disposeInstanceSpecificData(): void;
  29887. /** @hidden */
  29888. _disposeThinInstanceSpecificData(): void;
  29889. /**
  29890. * Modifies the mesh geometry according to a displacement map.
  29891. * 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.
  29892. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29893. * @param url is a string, the URL from the image file is to be downloaded.
  29894. * @param minHeight is the lower limit of the displacement.
  29895. * @param maxHeight is the upper limit of the displacement.
  29896. * @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.
  29897. * @param uvOffset is an optional vector2 used to offset UV.
  29898. * @param uvScale is an optional vector2 used to scale UV.
  29899. * @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.
  29900. * @returns the Mesh.
  29901. */
  29902. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29903. /**
  29904. * Modifies the mesh geometry according to a displacementMap buffer.
  29905. * 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.
  29906. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29907. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29908. * @param heightMapWidth is the width of the buffer image.
  29909. * @param heightMapHeight is the height of the buffer image.
  29910. * @param minHeight is the lower limit of the displacement.
  29911. * @param maxHeight is the upper limit of the displacement.
  29912. * @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.
  29913. * @param uvOffset is an optional vector2 used to offset UV.
  29914. * @param uvScale is an optional vector2 used to scale UV.
  29915. * @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.
  29916. * @returns the Mesh.
  29917. */
  29918. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29919. /**
  29920. * Modify the mesh to get a flat shading rendering.
  29921. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29922. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29923. * @returns current mesh
  29924. */
  29925. convertToFlatShadedMesh(): Mesh;
  29926. /**
  29927. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29928. * In other words, more vertices, no more indices and a single bigger VBO.
  29929. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29930. * @returns current mesh
  29931. */
  29932. convertToUnIndexedMesh(): Mesh;
  29933. /**
  29934. * Inverses facet orientations.
  29935. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29936. * @param flipNormals will also inverts the normals
  29937. * @returns current mesh
  29938. */
  29939. flipFaces(flipNormals?: boolean): Mesh;
  29940. /**
  29941. * Increase the number of facets and hence vertices in a mesh
  29942. * Vertex normals are interpolated from existing vertex normals
  29943. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29944. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29945. */
  29946. increaseVertices(numberPerEdge: number): void;
  29947. /**
  29948. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29949. * This will undo any application of covertToFlatShadedMesh
  29950. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29951. */
  29952. forceSharedVertices(): void;
  29953. /** @hidden */
  29954. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29955. /** @hidden */
  29956. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29957. /**
  29958. * Creates a new InstancedMesh object from the mesh model.
  29959. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29960. * @param name defines the name of the new instance
  29961. * @returns a new InstancedMesh
  29962. */
  29963. createInstance(name: string): InstancedMesh;
  29964. /**
  29965. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29966. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29967. * @returns the current mesh
  29968. */
  29969. synchronizeInstances(): Mesh;
  29970. /**
  29971. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29972. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29973. * This should be used together with the simplification to avoid disappearing triangles.
  29974. * @param successCallback an optional success callback to be called after the optimization finished.
  29975. * @returns the current mesh
  29976. */
  29977. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29978. /**
  29979. * Serialize current mesh
  29980. * @param serializationObject defines the object which will receive the serialization data
  29981. */
  29982. serialize(serializationObject: any): void;
  29983. /** @hidden */
  29984. _syncGeometryWithMorphTargetManager(): void;
  29985. /** @hidden */
  29986. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29987. /**
  29988. * Returns a new Mesh object parsed from the source provided.
  29989. * @param parsedMesh is the source
  29990. * @param scene defines the hosting scene
  29991. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29992. * @returns a new Mesh
  29993. */
  29994. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29995. /**
  29996. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29997. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29998. * @param name defines the name of the mesh to create
  29999. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  30000. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  30001. * @param closePath creates a seam between the first and the last points of each path of the path array
  30002. * @param offset is taken in account only if the `pathArray` is containing a single path
  30003. * @param scene defines the hosting scene
  30004. * @param updatable defines if the mesh must be flagged as updatable
  30005. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30006. * @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)
  30007. * @returns a new Mesh
  30008. */
  30009. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30010. /**
  30011. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  30012. * @param name defines the name of the mesh to create
  30013. * @param radius sets the radius size (float) of the polygon (default 0.5)
  30014. * @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
  30015. * @param scene defines the hosting scene
  30016. * @param updatable defines if the mesh must be flagged as updatable
  30017. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30018. * @returns a new Mesh
  30019. */
  30020. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30021. /**
  30022. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  30023. * @param name defines the name of the mesh to create
  30024. * @param size sets the size (float) of each box side (default 1)
  30025. * @param scene defines the hosting scene
  30026. * @param updatable defines if the mesh must be flagged as updatable
  30027. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30028. * @returns a new Mesh
  30029. */
  30030. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30031. /**
  30032. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30033. * @param name defines the name of the mesh to create
  30034. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30035. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30036. * @param scene defines the hosting scene
  30037. * @param updatable defines if the mesh must be flagged as updatable
  30038. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30039. * @returns a new Mesh
  30040. */
  30041. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30042. /**
  30043. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  30044. * @param name defines the name of the mesh to create
  30045. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30046. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30047. * @param scene defines the hosting scene
  30048. * @returns a new Mesh
  30049. */
  30050. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30051. /**
  30052. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30053. * @param name defines the name of the mesh to create
  30054. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30055. * @param diameterTop set the top cap diameter (floats, default 1)
  30056. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30057. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30058. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30059. * @param scene defines the hosting scene
  30060. * @param updatable defines if the mesh must be flagged as updatable
  30061. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30062. * @returns a new Mesh
  30063. */
  30064. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30065. /**
  30066. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30067. * @param name defines the name of the mesh to create
  30068. * @param diameter sets the diameter size (float) of the torus (default 1)
  30069. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30070. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30071. * @param scene defines the hosting scene
  30072. * @param updatable defines if the mesh must be flagged as updatable
  30073. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30074. * @returns a new Mesh
  30075. */
  30076. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30077. /**
  30078. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30079. * @param name defines the name of the mesh to create
  30080. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30081. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30082. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30083. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30084. * @param p the number of windings on X axis (positive integers, default 2)
  30085. * @param q the number of windings on Y axis (positive integers, default 3)
  30086. * @param scene defines the hosting scene
  30087. * @param updatable defines if the mesh must be flagged as updatable
  30088. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30089. * @returns a new Mesh
  30090. */
  30091. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30092. /**
  30093. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30094. * @param name defines the name of the mesh to create
  30095. * @param points is an array successive Vector3
  30096. * @param scene defines the hosting scene
  30097. * @param updatable defines if the mesh must be flagged as updatable
  30098. * @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).
  30099. * @returns a new Mesh
  30100. */
  30101. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30102. /**
  30103. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30104. * @param name defines the name of the mesh to create
  30105. * @param points is an array successive Vector3
  30106. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30107. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30108. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30109. * @param scene defines the hosting scene
  30110. * @param updatable defines if the mesh must be flagged as updatable
  30111. * @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)
  30112. * @returns a new Mesh
  30113. */
  30114. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30115. /**
  30116. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30117. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30118. * 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.
  30119. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30120. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30121. * Remember you can only change the shape positions, not their number when updating a polygon.
  30122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30123. * @param name defines the name of the mesh to create
  30124. * @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
  30125. * @param scene defines the hosting scene
  30126. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30127. * @param updatable defines if the mesh must be flagged as updatable
  30128. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30129. * @param earcutInjection can be used to inject your own earcut reference
  30130. * @returns a new Mesh
  30131. */
  30132. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30133. /**
  30134. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30136. * @param name defines the name of the mesh to create
  30137. * @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
  30138. * @param depth defines the height of extrusion
  30139. * @param scene defines the hosting scene
  30140. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30141. * @param updatable defines if the mesh must be flagged as updatable
  30142. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30143. * @param earcutInjection can be used to inject your own earcut reference
  30144. * @returns a new Mesh
  30145. */
  30146. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30147. /**
  30148. * Creates an extruded shape mesh.
  30149. * 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
  30150. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30152. * @param name defines the name of the mesh to create
  30153. * @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
  30154. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30155. * @param scale is the value to scale the shape
  30156. * @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
  30157. * @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
  30158. * @param scene defines the hosting scene
  30159. * @param updatable defines if the mesh must be flagged as updatable
  30160. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30161. * @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)
  30162. * @returns a new Mesh
  30163. */
  30164. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30165. /**
  30166. * Creates an custom extruded shape mesh.
  30167. * The custom extrusion is a parametric shape.
  30168. * It has no predefined shape. Its final shape will depend on the input parameters.
  30169. * Please consider using the same method from the MeshBuilder class instead
  30170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30171. * @param name defines the name of the mesh to create
  30172. * @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
  30173. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30174. * @param scaleFunction is a custom Javascript function called on each path point
  30175. * @param rotationFunction is a custom Javascript function called on each path point
  30176. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30177. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30178. * @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
  30179. * @param scene defines the hosting scene
  30180. * @param updatable defines if the mesh must be flagged as updatable
  30181. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30182. * @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)
  30183. * @returns a new Mesh
  30184. */
  30185. 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;
  30186. /**
  30187. * Creates lathe mesh.
  30188. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30189. * Please consider using the same method from the MeshBuilder class instead
  30190. * @param name defines the name of the mesh to create
  30191. * @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
  30192. * @param radius is the radius value of the lathe
  30193. * @param tessellation is the side number of the lathe.
  30194. * @param scene defines the hosting scene
  30195. * @param updatable defines if the mesh must be flagged as updatable
  30196. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30197. * @returns a new Mesh
  30198. */
  30199. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30200. /**
  30201. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30202. * @param name defines the name of the mesh to create
  30203. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30204. * @param scene defines the hosting scene
  30205. * @param updatable defines if the mesh must be flagged as updatable
  30206. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30207. * @returns a new Mesh
  30208. */
  30209. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30210. /**
  30211. * Creates a ground mesh.
  30212. * Please consider using the same method from the MeshBuilder class instead
  30213. * @param name defines the name of the mesh to create
  30214. * @param width set the width of the ground
  30215. * @param height set the height of the ground
  30216. * @param subdivisions sets the number of subdivisions per side
  30217. * @param scene defines the hosting scene
  30218. * @param updatable defines if the mesh must be flagged as updatable
  30219. * @returns a new Mesh
  30220. */
  30221. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30222. /**
  30223. * Creates a tiled ground mesh.
  30224. * Please consider using the same method from the MeshBuilder class instead
  30225. * @param name defines the name of the mesh to create
  30226. * @param xmin set the ground minimum X coordinate
  30227. * @param zmin set the ground minimum Y coordinate
  30228. * @param xmax set the ground maximum X coordinate
  30229. * @param zmax set the ground maximum Z coordinate
  30230. * @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
  30231. * @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
  30232. * @param scene defines the hosting scene
  30233. * @param updatable defines if the mesh must be flagged as updatable
  30234. * @returns a new Mesh
  30235. */
  30236. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30237. w: number;
  30238. h: number;
  30239. }, precision: {
  30240. w: number;
  30241. h: number;
  30242. }, scene: Scene, updatable?: boolean): Mesh;
  30243. /**
  30244. * Creates a ground mesh from a height map.
  30245. * Please consider using the same method from the MeshBuilder class instead
  30246. * @see https://doc.babylonjs.com/babylon101/height_map
  30247. * @param name defines the name of the mesh to create
  30248. * @param url sets the URL of the height map image resource
  30249. * @param width set the ground width size
  30250. * @param height set the ground height size
  30251. * @param subdivisions sets the number of subdivision per side
  30252. * @param minHeight is the minimum altitude on the ground
  30253. * @param maxHeight is the maximum altitude on the ground
  30254. * @param scene defines the hosting scene
  30255. * @param updatable defines if the mesh must be flagged as updatable
  30256. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30257. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30258. * @returns a new Mesh
  30259. */
  30260. 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;
  30261. /**
  30262. * Creates a tube mesh.
  30263. * The tube is a parametric shape.
  30264. * It has no predefined shape. Its final shape will depend on the input parameters.
  30265. * Please consider using the same method from the MeshBuilder class instead
  30266. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30267. * @param name defines the name of the mesh to create
  30268. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30269. * @param radius sets the tube radius size
  30270. * @param tessellation is the number of sides on the tubular surface
  30271. * @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
  30272. * @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
  30273. * @param scene defines the hosting scene
  30274. * @param updatable defines if the mesh must be flagged as updatable
  30275. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30276. * @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)
  30277. * @returns a new Mesh
  30278. */
  30279. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30280. (i: number, distance: number): number;
  30281. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30282. /**
  30283. * Creates a polyhedron mesh.
  30284. * Please consider using the same method from the MeshBuilder class instead.
  30285. * * 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
  30286. * * The parameter `size` (positive float, default 1) sets the polygon size
  30287. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30288. * * 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`
  30289. * * 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
  30290. * * 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)`)
  30291. * * 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
  30292. * * 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
  30293. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30296. * @param name defines the name of the mesh to create
  30297. * @param options defines the options used to create the mesh
  30298. * @param scene defines the hosting scene
  30299. * @returns a new Mesh
  30300. */
  30301. static CreatePolyhedron(name: string, options: {
  30302. type?: number;
  30303. size?: number;
  30304. sizeX?: number;
  30305. sizeY?: number;
  30306. sizeZ?: number;
  30307. custom?: any;
  30308. faceUV?: Vector4[];
  30309. faceColors?: Color4[];
  30310. updatable?: boolean;
  30311. sideOrientation?: number;
  30312. }, scene: Scene): Mesh;
  30313. /**
  30314. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30315. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30316. * * 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`)
  30317. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30318. * * 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
  30319. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30322. * @param name defines the name of the mesh
  30323. * @param options defines the options used to create the mesh
  30324. * @param scene defines the hosting scene
  30325. * @returns a new Mesh
  30326. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30327. */
  30328. static CreateIcoSphere(name: string, options: {
  30329. radius?: number;
  30330. flat?: boolean;
  30331. subdivisions?: number;
  30332. sideOrientation?: number;
  30333. updatable?: boolean;
  30334. }, scene: Scene): Mesh;
  30335. /**
  30336. * Creates a decal mesh.
  30337. * Please consider using the same method from the MeshBuilder class instead.
  30338. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30339. * @param name defines the name of the mesh
  30340. * @param sourceMesh defines the mesh receiving the decal
  30341. * @param position sets the position of the decal in world coordinates
  30342. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30343. * @param size sets the decal scaling
  30344. * @param angle sets the angle to rotate the decal
  30345. * @returns a new Mesh
  30346. */
  30347. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30348. /** Creates a Capsule Mesh
  30349. * @param name defines the name of the mesh.
  30350. * @param options the constructors options used to shape the mesh.
  30351. * @param scene defines the scene the mesh is scoped to.
  30352. * @returns the capsule mesh
  30353. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30354. */
  30355. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30356. /**
  30357. * Prepare internal position array for software CPU skinning
  30358. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30359. */
  30360. setPositionsForCPUSkinning(): Float32Array;
  30361. /**
  30362. * Prepare internal normal array for software CPU skinning
  30363. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30364. */
  30365. setNormalsForCPUSkinning(): Float32Array;
  30366. /**
  30367. * Updates the vertex buffer by applying transformation from the bones
  30368. * @param skeleton defines the skeleton to apply to current mesh
  30369. * @returns the current mesh
  30370. */
  30371. applySkeleton(skeleton: Skeleton): Mesh;
  30372. /**
  30373. * 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
  30374. * @param meshes defines the list of meshes to scan
  30375. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30376. */
  30377. static MinMax(meshes: AbstractMesh[]): {
  30378. min: Vector3;
  30379. max: Vector3;
  30380. };
  30381. /**
  30382. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30383. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30384. * @returns a vector3
  30385. */
  30386. static Center(meshesOrMinMaxVector: {
  30387. min: Vector3;
  30388. max: Vector3;
  30389. } | AbstractMesh[]): Vector3;
  30390. /**
  30391. * Merge the array of meshes into a single mesh for performance reasons.
  30392. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30393. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30394. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30395. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30396. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30397. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30398. * @returns a new mesh
  30399. */
  30400. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30401. /** @hidden */
  30402. addInstance(instance: InstancedMesh): void;
  30403. /** @hidden */
  30404. removeInstance(instance: InstancedMesh): void;
  30405. }
  30406. }
  30407. declare module "babylonjs/Cameras/camera" {
  30408. import { SmartArray } from "babylonjs/Misc/smartArray";
  30409. import { Observable } from "babylonjs/Misc/observable";
  30410. import { Nullable } from "babylonjs/types";
  30411. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30412. import { Scene } from "babylonjs/scene";
  30413. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30414. import { Node } from "babylonjs/node";
  30415. import { Mesh } from "babylonjs/Meshes/mesh";
  30416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30417. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30418. import { Viewport } from "babylonjs/Maths/math.viewport";
  30419. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30420. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30421. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30422. import { Ray } from "babylonjs/Culling/ray";
  30423. /**
  30424. * This is the base class of all the camera used in the application.
  30425. * @see https://doc.babylonjs.com/features/cameras
  30426. */
  30427. export class Camera extends Node {
  30428. /** @hidden */
  30429. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30430. /**
  30431. * This is the default projection mode used by the cameras.
  30432. * It helps recreating a feeling of perspective and better appreciate depth.
  30433. * This is the best way to simulate real life cameras.
  30434. */
  30435. static readonly PERSPECTIVE_CAMERA: number;
  30436. /**
  30437. * This helps creating camera with an orthographic mode.
  30438. * 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.
  30439. */
  30440. static readonly ORTHOGRAPHIC_CAMERA: number;
  30441. /**
  30442. * This is the default FOV mode for perspective cameras.
  30443. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30444. */
  30445. static readonly FOVMODE_VERTICAL_FIXED: number;
  30446. /**
  30447. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30448. */
  30449. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30450. /**
  30451. * This specifies ther is no need for a camera rig.
  30452. * Basically only one eye is rendered corresponding to the camera.
  30453. */
  30454. static readonly RIG_MODE_NONE: number;
  30455. /**
  30456. * Simulates a camera Rig with one blue eye and one red eye.
  30457. * This can be use with 3d blue and red glasses.
  30458. */
  30459. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30460. /**
  30461. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30462. */
  30463. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30464. /**
  30465. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30466. */
  30467. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30468. /**
  30469. * Defines that both eyes of the camera will be rendered over under each other.
  30470. */
  30471. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30472. /**
  30473. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30474. */
  30475. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30476. /**
  30477. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30478. */
  30479. static readonly RIG_MODE_VR: number;
  30480. /**
  30481. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30482. */
  30483. static readonly RIG_MODE_WEBVR: number;
  30484. /**
  30485. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30486. */
  30487. static readonly RIG_MODE_CUSTOM: number;
  30488. /**
  30489. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30490. */
  30491. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30492. /**
  30493. * Define the input manager associated with the camera.
  30494. */
  30495. inputs: CameraInputsManager<Camera>;
  30496. /** @hidden */
  30497. _position: Vector3;
  30498. /**
  30499. * Define the current local position of the camera in the scene
  30500. */
  30501. get position(): Vector3;
  30502. set position(newPosition: Vector3);
  30503. protected _upVector: Vector3;
  30504. /**
  30505. * The vector the camera should consider as up.
  30506. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30507. */
  30508. set upVector(vec: Vector3);
  30509. get upVector(): Vector3;
  30510. /**
  30511. * Define the current limit on the left side for an orthographic camera
  30512. * In scene unit
  30513. */
  30514. orthoLeft: Nullable<number>;
  30515. /**
  30516. * Define the current limit on the right side for an orthographic camera
  30517. * In scene unit
  30518. */
  30519. orthoRight: Nullable<number>;
  30520. /**
  30521. * Define the current limit on the bottom side for an orthographic camera
  30522. * In scene unit
  30523. */
  30524. orthoBottom: Nullable<number>;
  30525. /**
  30526. * Define the current limit on the top side for an orthographic camera
  30527. * In scene unit
  30528. */
  30529. orthoTop: Nullable<number>;
  30530. /**
  30531. * Field Of View is set in Radians. (default is 0.8)
  30532. */
  30533. fov: number;
  30534. /**
  30535. * Define the minimum distance the camera can see from.
  30536. * This is important to note that the depth buffer are not infinite and the closer it starts
  30537. * the more your scene might encounter depth fighting issue.
  30538. */
  30539. minZ: number;
  30540. /**
  30541. * Define the maximum distance the camera can see to.
  30542. * This is important to note that the depth buffer are not infinite and the further it end
  30543. * the more your scene might encounter depth fighting issue.
  30544. */
  30545. maxZ: number;
  30546. /**
  30547. * Define the default inertia of the camera.
  30548. * This helps giving a smooth feeling to the camera movement.
  30549. */
  30550. inertia: number;
  30551. /**
  30552. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30553. */
  30554. mode: number;
  30555. /**
  30556. * Define whether the camera is intermediate.
  30557. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30558. */
  30559. isIntermediate: boolean;
  30560. /**
  30561. * Define the viewport of the camera.
  30562. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30563. */
  30564. viewport: Viewport;
  30565. /**
  30566. * Restricts the camera to viewing objects with the same layerMask.
  30567. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30568. */
  30569. layerMask: number;
  30570. /**
  30571. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30572. */
  30573. fovMode: number;
  30574. /**
  30575. * Rig mode of the camera.
  30576. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30577. * This is normally controlled byt the camera themselves as internal use.
  30578. */
  30579. cameraRigMode: number;
  30580. /**
  30581. * Defines the distance between both "eyes" in case of a RIG
  30582. */
  30583. interaxialDistance: number;
  30584. /**
  30585. * Defines if stereoscopic rendering is done side by side or over under.
  30586. */
  30587. isStereoscopicSideBySide: boolean;
  30588. /**
  30589. * 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
  30590. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30591. * else in the scene. (Eg. security camera)
  30592. *
  30593. * 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)
  30594. */
  30595. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30596. /**
  30597. * When set, the camera will render to this render target instead of the default canvas
  30598. *
  30599. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30600. */
  30601. outputRenderTarget: Nullable<RenderTargetTexture>;
  30602. /**
  30603. * Observable triggered when the camera view matrix has changed.
  30604. */
  30605. onViewMatrixChangedObservable: Observable<Camera>;
  30606. /**
  30607. * Observable triggered when the camera Projection matrix has changed.
  30608. */
  30609. onProjectionMatrixChangedObservable: Observable<Camera>;
  30610. /**
  30611. * Observable triggered when the inputs have been processed.
  30612. */
  30613. onAfterCheckInputsObservable: Observable<Camera>;
  30614. /**
  30615. * Observable triggered when reset has been called and applied to the camera.
  30616. */
  30617. onRestoreStateObservable: Observable<Camera>;
  30618. /**
  30619. * Is this camera a part of a rig system?
  30620. */
  30621. isRigCamera: boolean;
  30622. /**
  30623. * If isRigCamera set to true this will be set with the parent camera.
  30624. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30625. */
  30626. rigParent?: Camera;
  30627. /** @hidden */
  30628. _cameraRigParams: any;
  30629. /** @hidden */
  30630. _rigCameras: Camera[];
  30631. /** @hidden */
  30632. _rigPostProcess: Nullable<PostProcess>;
  30633. protected _webvrViewMatrix: Matrix;
  30634. /** @hidden */
  30635. _skipRendering: boolean;
  30636. /** @hidden */
  30637. _projectionMatrix: Matrix;
  30638. /** @hidden */
  30639. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30640. /** @hidden */
  30641. _activeMeshes: SmartArray<AbstractMesh>;
  30642. protected _globalPosition: Vector3;
  30643. /** @hidden */
  30644. _computedViewMatrix: Matrix;
  30645. private _doNotComputeProjectionMatrix;
  30646. private _transformMatrix;
  30647. private _frustumPlanes;
  30648. private _refreshFrustumPlanes;
  30649. private _storedFov;
  30650. private _stateStored;
  30651. /**
  30652. * Instantiates a new camera object.
  30653. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30654. * @see https://doc.babylonjs.com/features/cameras
  30655. * @param name Defines the name of the camera in the scene
  30656. * @param position Defines the position of the camera
  30657. * @param scene Defines the scene the camera belongs too
  30658. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30659. */
  30660. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30661. /**
  30662. * Store current camera state (fov, position, etc..)
  30663. * @returns the camera
  30664. */
  30665. storeState(): Camera;
  30666. /**
  30667. * Restores the camera state values if it has been stored. You must call storeState() first
  30668. */
  30669. protected _restoreStateValues(): boolean;
  30670. /**
  30671. * Restored camera state. You must call storeState() first.
  30672. * @returns true if restored and false otherwise
  30673. */
  30674. restoreState(): boolean;
  30675. /**
  30676. * Gets the class name of the camera.
  30677. * @returns the class name
  30678. */
  30679. getClassName(): string;
  30680. /** @hidden */
  30681. readonly _isCamera: boolean;
  30682. /**
  30683. * Gets a string representation of the camera useful for debug purpose.
  30684. * @param fullDetails Defines that a more verboe level of logging is required
  30685. * @returns the string representation
  30686. */
  30687. toString(fullDetails?: boolean): string;
  30688. /**
  30689. * Gets the current world space position of the camera.
  30690. */
  30691. get globalPosition(): Vector3;
  30692. /**
  30693. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30694. * @returns the active meshe list
  30695. */
  30696. getActiveMeshes(): SmartArray<AbstractMesh>;
  30697. /**
  30698. * Check whether a mesh is part of the current active mesh list of the camera
  30699. * @param mesh Defines the mesh to check
  30700. * @returns true if active, false otherwise
  30701. */
  30702. isActiveMesh(mesh: Mesh): boolean;
  30703. /**
  30704. * Is this camera ready to be used/rendered
  30705. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30706. * @return true if the camera is ready
  30707. */
  30708. isReady(completeCheck?: boolean): boolean;
  30709. /** @hidden */
  30710. _initCache(): void;
  30711. /** @hidden */
  30712. _updateCache(ignoreParentClass?: boolean): void;
  30713. /** @hidden */
  30714. _isSynchronized(): boolean;
  30715. /** @hidden */
  30716. _isSynchronizedViewMatrix(): boolean;
  30717. /** @hidden */
  30718. _isSynchronizedProjectionMatrix(): boolean;
  30719. /**
  30720. * Attach the input controls to a specific dom element to get the input from.
  30721. * @param element Defines the element the controls should be listened from
  30722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30723. */
  30724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30725. /**
  30726. * Detach the current controls from the specified dom element.
  30727. * @param element Defines the element to stop listening the inputs from
  30728. */
  30729. detachControl(element: HTMLElement): void;
  30730. /**
  30731. * Update the camera state according to the different inputs gathered during the frame.
  30732. */
  30733. update(): void;
  30734. /** @hidden */
  30735. _checkInputs(): void;
  30736. /** @hidden */
  30737. get rigCameras(): Camera[];
  30738. /**
  30739. * Gets the post process used by the rig cameras
  30740. */
  30741. get rigPostProcess(): Nullable<PostProcess>;
  30742. /**
  30743. * Internal, gets the first post proces.
  30744. * @returns the first post process to be run on this camera.
  30745. */
  30746. _getFirstPostProcess(): Nullable<PostProcess>;
  30747. private _cascadePostProcessesToRigCams;
  30748. /**
  30749. * Attach a post process to the camera.
  30750. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30751. * @param postProcess The post process to attach to the camera
  30752. * @param insertAt The position of the post process in case several of them are in use in the scene
  30753. * @returns the position the post process has been inserted at
  30754. */
  30755. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30756. /**
  30757. * Detach a post process to the camera.
  30758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30759. * @param postProcess The post process to detach from the camera
  30760. */
  30761. detachPostProcess(postProcess: PostProcess): void;
  30762. /**
  30763. * Gets the current world matrix of the camera
  30764. */
  30765. getWorldMatrix(): Matrix;
  30766. /** @hidden */
  30767. _getViewMatrix(): Matrix;
  30768. /**
  30769. * Gets the current view matrix of the camera.
  30770. * @param force forces the camera to recompute the matrix without looking at the cached state
  30771. * @returns the view matrix
  30772. */
  30773. getViewMatrix(force?: boolean): Matrix;
  30774. /**
  30775. * Freeze the projection matrix.
  30776. * It will prevent the cache check of the camera projection compute and can speed up perf
  30777. * if no parameter of the camera are meant to change
  30778. * @param projection Defines manually a projection if necessary
  30779. */
  30780. freezeProjectionMatrix(projection?: Matrix): void;
  30781. /**
  30782. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30783. */
  30784. unfreezeProjectionMatrix(): void;
  30785. /**
  30786. * Gets the current projection matrix of the camera.
  30787. * @param force forces the camera to recompute the matrix without looking at the cached state
  30788. * @returns the projection matrix
  30789. */
  30790. getProjectionMatrix(force?: boolean): Matrix;
  30791. /**
  30792. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30793. * @returns a Matrix
  30794. */
  30795. getTransformationMatrix(): Matrix;
  30796. private _updateFrustumPlanes;
  30797. /**
  30798. * Checks if a cullable object (mesh...) is in the camera frustum
  30799. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30800. * @param target The object to check
  30801. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30802. * @returns true if the object is in frustum otherwise false
  30803. */
  30804. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30805. /**
  30806. * Checks if a cullable object (mesh...) is in the camera frustum
  30807. * Unlike isInFrustum this cheks the full bounding box
  30808. * @param target The object to check
  30809. * @returns true if the object is in frustum otherwise false
  30810. */
  30811. isCompletelyInFrustum(target: ICullable): boolean;
  30812. /**
  30813. * Gets a ray in the forward direction from the camera.
  30814. * @param length Defines the length of the ray to create
  30815. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30816. * @param origin Defines the start point of the ray which defaults to the camera position
  30817. * @returns the forward ray
  30818. */
  30819. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30820. /**
  30821. * Gets a ray in the forward direction from the camera.
  30822. * @param refRay the ray to (re)use when setting the values
  30823. * @param length Defines the length of the ray to create
  30824. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30825. * @param origin Defines the start point of the ray which defaults to the camera position
  30826. * @returns the forward ray
  30827. */
  30828. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30829. /**
  30830. * Releases resources associated with this node.
  30831. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30832. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30833. */
  30834. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30835. /** @hidden */
  30836. _isLeftCamera: boolean;
  30837. /**
  30838. * Gets the left camera of a rig setup in case of Rigged Camera
  30839. */
  30840. get isLeftCamera(): boolean;
  30841. /** @hidden */
  30842. _isRightCamera: boolean;
  30843. /**
  30844. * Gets the right camera of a rig setup in case of Rigged Camera
  30845. */
  30846. get isRightCamera(): boolean;
  30847. /**
  30848. * Gets the left camera of a rig setup in case of Rigged Camera
  30849. */
  30850. get leftCamera(): Nullable<FreeCamera>;
  30851. /**
  30852. * Gets the right camera of a rig setup in case of Rigged Camera
  30853. */
  30854. get rightCamera(): Nullable<FreeCamera>;
  30855. /**
  30856. * Gets the left camera target of a rig setup in case of Rigged Camera
  30857. * @returns the target position
  30858. */
  30859. getLeftTarget(): Nullable<Vector3>;
  30860. /**
  30861. * Gets the right camera target of a rig setup in case of Rigged Camera
  30862. * @returns the target position
  30863. */
  30864. getRightTarget(): Nullable<Vector3>;
  30865. /**
  30866. * @hidden
  30867. */
  30868. setCameraRigMode(mode: number, rigParams: any): void;
  30869. /** @hidden */
  30870. static _setStereoscopicRigMode(camera: Camera): void;
  30871. /** @hidden */
  30872. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30873. /** @hidden */
  30874. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30875. /** @hidden */
  30876. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30877. /** @hidden */
  30878. _getVRProjectionMatrix(): Matrix;
  30879. protected _updateCameraRotationMatrix(): void;
  30880. protected _updateWebVRCameraRotationMatrix(): void;
  30881. /**
  30882. * This function MUST be overwritten by the different WebVR cameras available.
  30883. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30884. * @hidden
  30885. */
  30886. _getWebVRProjectionMatrix(): Matrix;
  30887. /**
  30888. * This function MUST be overwritten by the different WebVR cameras available.
  30889. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30890. * @hidden
  30891. */
  30892. _getWebVRViewMatrix(): Matrix;
  30893. /** @hidden */
  30894. setCameraRigParameter(name: string, value: any): void;
  30895. /**
  30896. * needs to be overridden by children so sub has required properties to be copied
  30897. * @hidden
  30898. */
  30899. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30900. /**
  30901. * May need to be overridden by children
  30902. * @hidden
  30903. */
  30904. _updateRigCameras(): void;
  30905. /** @hidden */
  30906. _setupInputs(): void;
  30907. /**
  30908. * Serialiaze the camera setup to a json represention
  30909. * @returns the JSON representation
  30910. */
  30911. serialize(): any;
  30912. /**
  30913. * Clones the current camera.
  30914. * @param name The cloned camera name
  30915. * @returns the cloned camera
  30916. */
  30917. clone(name: string): Camera;
  30918. /**
  30919. * Gets the direction of the camera relative to a given local axis.
  30920. * @param localAxis Defines the reference axis to provide a relative direction.
  30921. * @return the direction
  30922. */
  30923. getDirection(localAxis: Vector3): Vector3;
  30924. /**
  30925. * Returns the current camera absolute rotation
  30926. */
  30927. get absoluteRotation(): Quaternion;
  30928. /**
  30929. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30930. * @param localAxis Defines the reference axis to provide a relative direction.
  30931. * @param result Defines the vector to store the result in
  30932. */
  30933. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30934. /**
  30935. * Gets a camera constructor for a given camera type
  30936. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30937. * @param name The name of the camera the result will be able to instantiate
  30938. * @param scene The scene the result will construct the camera in
  30939. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30940. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30941. * @returns a factory method to construc the camera
  30942. */
  30943. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30944. /**
  30945. * Compute the world matrix of the camera.
  30946. * @returns the camera world matrix
  30947. */
  30948. computeWorldMatrix(): Matrix;
  30949. /**
  30950. * Parse a JSON and creates the camera from the parsed information
  30951. * @param parsedCamera The JSON to parse
  30952. * @param scene The scene to instantiate the camera in
  30953. * @returns the newly constructed camera
  30954. */
  30955. static Parse(parsedCamera: any, scene: Scene): Camera;
  30956. }
  30957. }
  30958. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30959. import { Nullable } from "babylonjs/types";
  30960. import { Scene } from "babylonjs/scene";
  30961. import { Vector4 } from "babylonjs/Maths/math.vector";
  30962. import { Mesh } from "babylonjs/Meshes/mesh";
  30963. /**
  30964. * Class containing static functions to help procedurally build meshes
  30965. */
  30966. export class DiscBuilder {
  30967. /**
  30968. * Creates a plane polygonal mesh. By default, this is a disc
  30969. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30970. * * 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
  30971. * * 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
  30972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30975. * @param name defines the name of the mesh
  30976. * @param options defines the options used to create the mesh
  30977. * @param scene defines the hosting scene
  30978. * @returns the plane polygonal mesh
  30979. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30980. */
  30981. static CreateDisc(name: string, options: {
  30982. radius?: number;
  30983. tessellation?: number;
  30984. arc?: number;
  30985. updatable?: boolean;
  30986. sideOrientation?: number;
  30987. frontUVs?: Vector4;
  30988. backUVs?: Vector4;
  30989. }, scene?: Nullable<Scene>): Mesh;
  30990. }
  30991. }
  30992. declare module "babylonjs/Materials/fresnelParameters" {
  30993. import { DeepImmutable } from "babylonjs/types";
  30994. import { Color3 } from "babylonjs/Maths/math.color";
  30995. /**
  30996. * Options to be used when creating a FresnelParameters.
  30997. */
  30998. export type IFresnelParametersCreationOptions = {
  30999. /**
  31000. * Define the color used on edges (grazing angle)
  31001. */
  31002. leftColor?: Color3;
  31003. /**
  31004. * Define the color used on center
  31005. */
  31006. rightColor?: Color3;
  31007. /**
  31008. * Define bias applied to computed fresnel term
  31009. */
  31010. bias?: number;
  31011. /**
  31012. * Defined the power exponent applied to fresnel term
  31013. */
  31014. power?: number;
  31015. /**
  31016. * Define if the fresnel effect is enable or not.
  31017. */
  31018. isEnabled?: boolean;
  31019. };
  31020. /**
  31021. * Serialized format for FresnelParameters.
  31022. */
  31023. export type IFresnelParametersSerialized = {
  31024. /**
  31025. * Define the color used on edges (grazing angle) [as an array]
  31026. */
  31027. leftColor: number[];
  31028. /**
  31029. * Define the color used on center [as an array]
  31030. */
  31031. rightColor: number[];
  31032. /**
  31033. * Define bias applied to computed fresnel term
  31034. */
  31035. bias: number;
  31036. /**
  31037. * Defined the power exponent applied to fresnel term
  31038. */
  31039. power?: number;
  31040. /**
  31041. * Define if the fresnel effect is enable or not.
  31042. */
  31043. isEnabled: boolean;
  31044. };
  31045. /**
  31046. * This represents all the required information to add a fresnel effect on a material:
  31047. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31048. */
  31049. export class FresnelParameters {
  31050. private _isEnabled;
  31051. /**
  31052. * Define if the fresnel effect is enable or not.
  31053. */
  31054. get isEnabled(): boolean;
  31055. set isEnabled(value: boolean);
  31056. /**
  31057. * Define the color used on edges (grazing angle)
  31058. */
  31059. leftColor: Color3;
  31060. /**
  31061. * Define the color used on center
  31062. */
  31063. rightColor: Color3;
  31064. /**
  31065. * Define bias applied to computed fresnel term
  31066. */
  31067. bias: number;
  31068. /**
  31069. * Defined the power exponent applied to fresnel term
  31070. */
  31071. power: number;
  31072. /**
  31073. * Creates a new FresnelParameters object.
  31074. *
  31075. * @param options provide your own settings to optionally to override defaults
  31076. */
  31077. constructor(options?: IFresnelParametersCreationOptions);
  31078. /**
  31079. * Clones the current fresnel and its valuues
  31080. * @returns a clone fresnel configuration
  31081. */
  31082. clone(): FresnelParameters;
  31083. /**
  31084. * Determines equality between FresnelParameters objects
  31085. * @param otherFresnelParameters defines the second operand
  31086. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31087. */
  31088. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31089. /**
  31090. * Serializes the current fresnel parameters to a JSON representation.
  31091. * @return the JSON serialization
  31092. */
  31093. serialize(): IFresnelParametersSerialized;
  31094. /**
  31095. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31096. * @param parsedFresnelParameters Define the JSON representation
  31097. * @returns the parsed parameters
  31098. */
  31099. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31100. }
  31101. }
  31102. declare module "babylonjs/Materials/materialFlags" {
  31103. /**
  31104. * This groups all the flags used to control the materials channel.
  31105. */
  31106. export class MaterialFlags {
  31107. private static _DiffuseTextureEnabled;
  31108. /**
  31109. * Are diffuse textures enabled in the application.
  31110. */
  31111. static get DiffuseTextureEnabled(): boolean;
  31112. static set DiffuseTextureEnabled(value: boolean);
  31113. private static _DetailTextureEnabled;
  31114. /**
  31115. * Are detail textures enabled in the application.
  31116. */
  31117. static get DetailTextureEnabled(): boolean;
  31118. static set DetailTextureEnabled(value: boolean);
  31119. private static _AmbientTextureEnabled;
  31120. /**
  31121. * Are ambient textures enabled in the application.
  31122. */
  31123. static get AmbientTextureEnabled(): boolean;
  31124. static set AmbientTextureEnabled(value: boolean);
  31125. private static _OpacityTextureEnabled;
  31126. /**
  31127. * Are opacity textures enabled in the application.
  31128. */
  31129. static get OpacityTextureEnabled(): boolean;
  31130. static set OpacityTextureEnabled(value: boolean);
  31131. private static _ReflectionTextureEnabled;
  31132. /**
  31133. * Are reflection textures enabled in the application.
  31134. */
  31135. static get ReflectionTextureEnabled(): boolean;
  31136. static set ReflectionTextureEnabled(value: boolean);
  31137. private static _EmissiveTextureEnabled;
  31138. /**
  31139. * Are emissive textures enabled in the application.
  31140. */
  31141. static get EmissiveTextureEnabled(): boolean;
  31142. static set EmissiveTextureEnabled(value: boolean);
  31143. private static _SpecularTextureEnabled;
  31144. /**
  31145. * Are specular textures enabled in the application.
  31146. */
  31147. static get SpecularTextureEnabled(): boolean;
  31148. static set SpecularTextureEnabled(value: boolean);
  31149. private static _BumpTextureEnabled;
  31150. /**
  31151. * Are bump textures enabled in the application.
  31152. */
  31153. static get BumpTextureEnabled(): boolean;
  31154. static set BumpTextureEnabled(value: boolean);
  31155. private static _LightmapTextureEnabled;
  31156. /**
  31157. * Are lightmap textures enabled in the application.
  31158. */
  31159. static get LightmapTextureEnabled(): boolean;
  31160. static set LightmapTextureEnabled(value: boolean);
  31161. private static _RefractionTextureEnabled;
  31162. /**
  31163. * Are refraction textures enabled in the application.
  31164. */
  31165. static get RefractionTextureEnabled(): boolean;
  31166. static set RefractionTextureEnabled(value: boolean);
  31167. private static _ColorGradingTextureEnabled;
  31168. /**
  31169. * Are color grading textures enabled in the application.
  31170. */
  31171. static get ColorGradingTextureEnabled(): boolean;
  31172. static set ColorGradingTextureEnabled(value: boolean);
  31173. private static _FresnelEnabled;
  31174. /**
  31175. * Are fresnels enabled in the application.
  31176. */
  31177. static get FresnelEnabled(): boolean;
  31178. static set FresnelEnabled(value: boolean);
  31179. private static _ClearCoatTextureEnabled;
  31180. /**
  31181. * Are clear coat textures enabled in the application.
  31182. */
  31183. static get ClearCoatTextureEnabled(): boolean;
  31184. static set ClearCoatTextureEnabled(value: boolean);
  31185. private static _ClearCoatBumpTextureEnabled;
  31186. /**
  31187. * Are clear coat bump textures enabled in the application.
  31188. */
  31189. static get ClearCoatBumpTextureEnabled(): boolean;
  31190. static set ClearCoatBumpTextureEnabled(value: boolean);
  31191. private static _ClearCoatTintTextureEnabled;
  31192. /**
  31193. * Are clear coat tint textures enabled in the application.
  31194. */
  31195. static get ClearCoatTintTextureEnabled(): boolean;
  31196. static set ClearCoatTintTextureEnabled(value: boolean);
  31197. private static _SheenTextureEnabled;
  31198. /**
  31199. * Are sheen textures enabled in the application.
  31200. */
  31201. static get SheenTextureEnabled(): boolean;
  31202. static set SheenTextureEnabled(value: boolean);
  31203. private static _AnisotropicTextureEnabled;
  31204. /**
  31205. * Are anisotropic textures enabled in the application.
  31206. */
  31207. static get AnisotropicTextureEnabled(): boolean;
  31208. static set AnisotropicTextureEnabled(value: boolean);
  31209. private static _ThicknessTextureEnabled;
  31210. /**
  31211. * Are thickness textures enabled in the application.
  31212. */
  31213. static get ThicknessTextureEnabled(): boolean;
  31214. static set ThicknessTextureEnabled(value: boolean);
  31215. }
  31216. }
  31217. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31218. /** @hidden */
  31219. export var defaultFragmentDeclaration: {
  31220. name: string;
  31221. shader: string;
  31222. };
  31223. }
  31224. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31225. /** @hidden */
  31226. export var defaultUboDeclaration: {
  31227. name: string;
  31228. shader: string;
  31229. };
  31230. }
  31231. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31232. /** @hidden */
  31233. export var prePassDeclaration: {
  31234. name: string;
  31235. shader: string;
  31236. };
  31237. }
  31238. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31239. /** @hidden */
  31240. export var lightFragmentDeclaration: {
  31241. name: string;
  31242. shader: string;
  31243. };
  31244. }
  31245. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31246. /** @hidden */
  31247. export var lightUboDeclaration: {
  31248. name: string;
  31249. shader: string;
  31250. };
  31251. }
  31252. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31253. /** @hidden */
  31254. export var lightsFragmentFunctions: {
  31255. name: string;
  31256. shader: string;
  31257. };
  31258. }
  31259. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31260. /** @hidden */
  31261. export var shadowsFragmentFunctions: {
  31262. name: string;
  31263. shader: string;
  31264. };
  31265. }
  31266. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31267. /** @hidden */
  31268. export var fresnelFunction: {
  31269. name: string;
  31270. shader: string;
  31271. };
  31272. }
  31273. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31274. /** @hidden */
  31275. export var bumpFragmentMainFunctions: {
  31276. name: string;
  31277. shader: string;
  31278. };
  31279. }
  31280. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31281. /** @hidden */
  31282. export var bumpFragmentFunctions: {
  31283. name: string;
  31284. shader: string;
  31285. };
  31286. }
  31287. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31288. /** @hidden */
  31289. export var logDepthDeclaration: {
  31290. name: string;
  31291. shader: string;
  31292. };
  31293. }
  31294. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31295. /** @hidden */
  31296. export var bumpFragment: {
  31297. name: string;
  31298. shader: string;
  31299. };
  31300. }
  31301. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31302. /** @hidden */
  31303. export var depthPrePass: {
  31304. name: string;
  31305. shader: string;
  31306. };
  31307. }
  31308. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31309. /** @hidden */
  31310. export var lightFragment: {
  31311. name: string;
  31312. shader: string;
  31313. };
  31314. }
  31315. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31316. /** @hidden */
  31317. export var logDepthFragment: {
  31318. name: string;
  31319. shader: string;
  31320. };
  31321. }
  31322. declare module "babylonjs/Shaders/default.fragment" {
  31323. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31324. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31325. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31326. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31327. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31328. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31329. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31330. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31331. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31332. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31333. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31334. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31335. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31336. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31337. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31338. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31339. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31340. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31341. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31342. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31343. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31344. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31345. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31346. /** @hidden */
  31347. export var defaultPixelShader: {
  31348. name: string;
  31349. shader: string;
  31350. };
  31351. }
  31352. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31353. /** @hidden */
  31354. export var defaultVertexDeclaration: {
  31355. name: string;
  31356. shader: string;
  31357. };
  31358. }
  31359. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31360. /** @hidden */
  31361. export var bumpVertexDeclaration: {
  31362. name: string;
  31363. shader: string;
  31364. };
  31365. }
  31366. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31367. /** @hidden */
  31368. export var bumpVertex: {
  31369. name: string;
  31370. shader: string;
  31371. };
  31372. }
  31373. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31374. /** @hidden */
  31375. export var fogVertex: {
  31376. name: string;
  31377. shader: string;
  31378. };
  31379. }
  31380. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31381. /** @hidden */
  31382. export var shadowsVertex: {
  31383. name: string;
  31384. shader: string;
  31385. };
  31386. }
  31387. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31388. /** @hidden */
  31389. export var pointCloudVertex: {
  31390. name: string;
  31391. shader: string;
  31392. };
  31393. }
  31394. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31395. /** @hidden */
  31396. export var logDepthVertex: {
  31397. name: string;
  31398. shader: string;
  31399. };
  31400. }
  31401. declare module "babylonjs/Shaders/default.vertex" {
  31402. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31403. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31404. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31405. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31406. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31407. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31408. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31409. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31410. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31411. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31412. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31413. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31414. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31415. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31416. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31417. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31418. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31419. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31420. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31421. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31422. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31423. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31424. /** @hidden */
  31425. export var defaultVertexShader: {
  31426. name: string;
  31427. shader: string;
  31428. };
  31429. }
  31430. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31431. import { Nullable } from "babylonjs/types";
  31432. import { Scene } from "babylonjs/scene";
  31433. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31434. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31435. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31436. /**
  31437. * @hidden
  31438. */
  31439. export interface IMaterialDetailMapDefines {
  31440. DETAIL: boolean;
  31441. DETAILDIRECTUV: number;
  31442. DETAIL_NORMALBLENDMETHOD: number;
  31443. /** @hidden */
  31444. _areTexturesDirty: boolean;
  31445. }
  31446. /**
  31447. * Define the code related to the detail map parameters of a material
  31448. *
  31449. * Inspired from:
  31450. * 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
  31451. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31452. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31453. */
  31454. export class DetailMapConfiguration {
  31455. private _texture;
  31456. /**
  31457. * The detail texture of the material.
  31458. */
  31459. texture: Nullable<BaseTexture>;
  31460. /**
  31461. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31462. * Bigger values mean stronger blending
  31463. */
  31464. diffuseBlendLevel: number;
  31465. /**
  31466. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31467. * Bigger values mean stronger blending. Only used with PBR materials
  31468. */
  31469. roughnessBlendLevel: number;
  31470. /**
  31471. * Defines how strong the bump effect from the detail map is
  31472. * Bigger values mean stronger effect
  31473. */
  31474. bumpLevel: number;
  31475. private _normalBlendMethod;
  31476. /**
  31477. * The method used to blend the bump and detail normals together
  31478. */
  31479. normalBlendMethod: number;
  31480. private _isEnabled;
  31481. /**
  31482. * Enable or disable the detail map on this material
  31483. */
  31484. isEnabled: boolean;
  31485. /** @hidden */
  31486. private _internalMarkAllSubMeshesAsTexturesDirty;
  31487. /** @hidden */
  31488. _markAllSubMeshesAsTexturesDirty(): void;
  31489. /**
  31490. * Instantiate a new detail map
  31491. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31492. */
  31493. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31494. /**
  31495. * Gets whether the submesh is ready to be used or not.
  31496. * @param defines the list of "defines" to update.
  31497. * @param scene defines the scene the material belongs to.
  31498. * @returns - boolean indicating that the submesh is ready or not.
  31499. */
  31500. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31501. /**
  31502. * Update the defines for detail map usage
  31503. * @param defines the list of "defines" to update.
  31504. * @param scene defines the scene the material belongs to.
  31505. */
  31506. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31507. /**
  31508. * Binds the material data.
  31509. * @param uniformBuffer defines the Uniform buffer to fill in.
  31510. * @param scene defines the scene the material belongs to.
  31511. * @param isFrozen defines whether the material is frozen or not.
  31512. */
  31513. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31514. /**
  31515. * Checks to see if a texture is used in the material.
  31516. * @param texture - Base texture to use.
  31517. * @returns - Boolean specifying if a texture is used in the material.
  31518. */
  31519. hasTexture(texture: BaseTexture): boolean;
  31520. /**
  31521. * Returns an array of the actively used textures.
  31522. * @param activeTextures Array of BaseTextures
  31523. */
  31524. getActiveTextures(activeTextures: BaseTexture[]): void;
  31525. /**
  31526. * Returns the animatable textures.
  31527. * @param animatables Array of animatable textures.
  31528. */
  31529. getAnimatables(animatables: IAnimatable[]): void;
  31530. /**
  31531. * Disposes the resources of the material.
  31532. * @param forceDisposeTextures - Forces the disposal of all textures.
  31533. */
  31534. dispose(forceDisposeTextures?: boolean): void;
  31535. /**
  31536. * Get the current class name useful for serialization or dynamic coding.
  31537. * @returns "DetailMap"
  31538. */
  31539. getClassName(): string;
  31540. /**
  31541. * Add the required uniforms to the current list.
  31542. * @param uniforms defines the current uniform list.
  31543. */
  31544. static AddUniforms(uniforms: string[]): void;
  31545. /**
  31546. * Add the required samplers to the current list.
  31547. * @param samplers defines the current sampler list.
  31548. */
  31549. static AddSamplers(samplers: string[]): void;
  31550. /**
  31551. * Add the required uniforms to the current buffer.
  31552. * @param uniformBuffer defines the current uniform buffer.
  31553. */
  31554. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31555. /**
  31556. * Makes a duplicate of the current instance into another one.
  31557. * @param detailMap define the instance where to copy the info
  31558. */
  31559. copyTo(detailMap: DetailMapConfiguration): void;
  31560. /**
  31561. * Serializes this detail map instance
  31562. * @returns - An object with the serialized instance.
  31563. */
  31564. serialize(): any;
  31565. /**
  31566. * Parses a detail map setting from a serialized object.
  31567. * @param source - Serialized object.
  31568. * @param scene Defines the scene we are parsing for
  31569. * @param rootUrl Defines the rootUrl to load from
  31570. */
  31571. parse(source: any, scene: Scene, rootUrl: string): void;
  31572. }
  31573. }
  31574. declare module "babylonjs/Materials/standardMaterial" {
  31575. import { SmartArray } from "babylonjs/Misc/smartArray";
  31576. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31577. import { Nullable } from "babylonjs/types";
  31578. import { Scene } from "babylonjs/scene";
  31579. import { Matrix } from "babylonjs/Maths/math.vector";
  31580. import { Color3 } from "babylonjs/Maths/math.color";
  31581. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31583. import { Mesh } from "babylonjs/Meshes/mesh";
  31584. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31585. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31586. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31587. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31588. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31590. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31591. import "babylonjs/Shaders/default.fragment";
  31592. import "babylonjs/Shaders/default.vertex";
  31593. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31594. /** @hidden */
  31595. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31596. MAINUV1: boolean;
  31597. MAINUV2: boolean;
  31598. DIFFUSE: boolean;
  31599. DIFFUSEDIRECTUV: number;
  31600. DETAIL: boolean;
  31601. DETAILDIRECTUV: number;
  31602. DETAIL_NORMALBLENDMETHOD: number;
  31603. AMBIENT: boolean;
  31604. AMBIENTDIRECTUV: number;
  31605. OPACITY: boolean;
  31606. OPACITYDIRECTUV: number;
  31607. OPACITYRGB: boolean;
  31608. REFLECTION: boolean;
  31609. EMISSIVE: boolean;
  31610. EMISSIVEDIRECTUV: number;
  31611. SPECULAR: boolean;
  31612. SPECULARDIRECTUV: number;
  31613. BUMP: boolean;
  31614. BUMPDIRECTUV: number;
  31615. PARALLAX: boolean;
  31616. PARALLAXOCCLUSION: boolean;
  31617. SPECULAROVERALPHA: boolean;
  31618. CLIPPLANE: boolean;
  31619. CLIPPLANE2: boolean;
  31620. CLIPPLANE3: boolean;
  31621. CLIPPLANE4: boolean;
  31622. CLIPPLANE5: boolean;
  31623. CLIPPLANE6: boolean;
  31624. ALPHATEST: boolean;
  31625. DEPTHPREPASS: boolean;
  31626. ALPHAFROMDIFFUSE: boolean;
  31627. POINTSIZE: boolean;
  31628. FOG: boolean;
  31629. SPECULARTERM: boolean;
  31630. DIFFUSEFRESNEL: boolean;
  31631. OPACITYFRESNEL: boolean;
  31632. REFLECTIONFRESNEL: boolean;
  31633. REFRACTIONFRESNEL: boolean;
  31634. EMISSIVEFRESNEL: boolean;
  31635. FRESNEL: boolean;
  31636. NORMAL: boolean;
  31637. UV1: boolean;
  31638. UV2: boolean;
  31639. VERTEXCOLOR: boolean;
  31640. VERTEXALPHA: boolean;
  31641. NUM_BONE_INFLUENCERS: number;
  31642. BonesPerMesh: number;
  31643. BONETEXTURE: boolean;
  31644. INSTANCES: boolean;
  31645. THIN_INSTANCES: boolean;
  31646. GLOSSINESS: boolean;
  31647. ROUGHNESS: boolean;
  31648. EMISSIVEASILLUMINATION: boolean;
  31649. LINKEMISSIVEWITHDIFFUSE: boolean;
  31650. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31651. LIGHTMAP: boolean;
  31652. LIGHTMAPDIRECTUV: number;
  31653. OBJECTSPACE_NORMALMAP: boolean;
  31654. USELIGHTMAPASSHADOWMAP: boolean;
  31655. REFLECTIONMAP_3D: boolean;
  31656. REFLECTIONMAP_SPHERICAL: boolean;
  31657. REFLECTIONMAP_PLANAR: boolean;
  31658. REFLECTIONMAP_CUBIC: boolean;
  31659. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31660. REFLECTIONMAP_PROJECTION: boolean;
  31661. REFLECTIONMAP_SKYBOX: boolean;
  31662. REFLECTIONMAP_EXPLICIT: boolean;
  31663. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31664. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31665. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31666. INVERTCUBICMAP: boolean;
  31667. LOGARITHMICDEPTH: boolean;
  31668. REFRACTION: boolean;
  31669. REFRACTIONMAP_3D: boolean;
  31670. REFLECTIONOVERALPHA: boolean;
  31671. TWOSIDEDLIGHTING: boolean;
  31672. SHADOWFLOAT: boolean;
  31673. MORPHTARGETS: boolean;
  31674. MORPHTARGETS_NORMAL: boolean;
  31675. MORPHTARGETS_TANGENT: boolean;
  31676. MORPHTARGETS_UV: boolean;
  31677. NUM_MORPH_INFLUENCERS: number;
  31678. NONUNIFORMSCALING: boolean;
  31679. PREMULTIPLYALPHA: boolean;
  31680. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31681. ALPHABLEND: boolean;
  31682. PREPASS: boolean;
  31683. PREPASS_IRRADIANCE: boolean;
  31684. PREPASS_IRRADIANCE_INDEX: number;
  31685. PREPASS_ALBEDO: boolean;
  31686. PREPASS_ALBEDO_INDEX: number;
  31687. PREPASS_DEPTHNORMAL: boolean;
  31688. PREPASS_DEPTHNORMAL_INDEX: number;
  31689. SCENE_MRT_COUNT: number;
  31690. RGBDLIGHTMAP: boolean;
  31691. RGBDREFLECTION: boolean;
  31692. RGBDREFRACTION: boolean;
  31693. IMAGEPROCESSING: boolean;
  31694. VIGNETTE: boolean;
  31695. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31696. VIGNETTEBLENDMODEOPAQUE: boolean;
  31697. TONEMAPPING: boolean;
  31698. TONEMAPPING_ACES: boolean;
  31699. CONTRAST: boolean;
  31700. COLORCURVES: boolean;
  31701. COLORGRADING: boolean;
  31702. COLORGRADING3D: boolean;
  31703. SAMPLER3DGREENDEPTH: boolean;
  31704. SAMPLER3DBGRMAP: boolean;
  31705. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31706. MULTIVIEW: boolean;
  31707. /**
  31708. * If the reflection texture on this material is in linear color space
  31709. * @hidden
  31710. */
  31711. IS_REFLECTION_LINEAR: boolean;
  31712. /**
  31713. * If the refraction texture on this material is in linear color space
  31714. * @hidden
  31715. */
  31716. IS_REFRACTION_LINEAR: boolean;
  31717. EXPOSURE: boolean;
  31718. constructor();
  31719. setReflectionMode(modeToEnable: string): void;
  31720. }
  31721. /**
  31722. * This is the default material used in Babylon. It is the best trade off between quality
  31723. * and performances.
  31724. * @see https://doc.babylonjs.com/babylon101/materials
  31725. */
  31726. export class StandardMaterial extends PushMaterial {
  31727. private _diffuseTexture;
  31728. /**
  31729. * The basic texture of the material as viewed under a light.
  31730. */
  31731. diffuseTexture: Nullable<BaseTexture>;
  31732. private _ambientTexture;
  31733. /**
  31734. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31735. */
  31736. ambientTexture: Nullable<BaseTexture>;
  31737. private _opacityTexture;
  31738. /**
  31739. * Define the transparency of the material from a texture.
  31740. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31741. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31742. */
  31743. opacityTexture: Nullable<BaseTexture>;
  31744. private _reflectionTexture;
  31745. /**
  31746. * Define the texture used to display the reflection.
  31747. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31748. */
  31749. reflectionTexture: Nullable<BaseTexture>;
  31750. private _emissiveTexture;
  31751. /**
  31752. * Define texture of the material as if self lit.
  31753. * This will be mixed in the final result even in the absence of light.
  31754. */
  31755. emissiveTexture: Nullable<BaseTexture>;
  31756. private _specularTexture;
  31757. /**
  31758. * Define how the color and intensity of the highlight given by the light in the material.
  31759. */
  31760. specularTexture: Nullable<BaseTexture>;
  31761. private _bumpTexture;
  31762. /**
  31763. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31764. * 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.
  31765. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31766. */
  31767. bumpTexture: Nullable<BaseTexture>;
  31768. private _lightmapTexture;
  31769. /**
  31770. * Complex lighting can be computationally expensive to compute at runtime.
  31771. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31772. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31773. */
  31774. lightmapTexture: Nullable<BaseTexture>;
  31775. private _refractionTexture;
  31776. /**
  31777. * Define the texture used to display the refraction.
  31778. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31779. */
  31780. refractionTexture: Nullable<BaseTexture>;
  31781. /**
  31782. * The color of the material lit by the environmental background lighting.
  31783. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31784. */
  31785. ambientColor: Color3;
  31786. /**
  31787. * The basic color of the material as viewed under a light.
  31788. */
  31789. diffuseColor: Color3;
  31790. /**
  31791. * Define how the color and intensity of the highlight given by the light in the material.
  31792. */
  31793. specularColor: Color3;
  31794. /**
  31795. * Define the color of the material as if self lit.
  31796. * This will be mixed in the final result even in the absence of light.
  31797. */
  31798. emissiveColor: Color3;
  31799. /**
  31800. * Defines how sharp are the highlights in the material.
  31801. * The bigger the value the sharper giving a more glossy feeling to the result.
  31802. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31803. */
  31804. specularPower: number;
  31805. private _useAlphaFromDiffuseTexture;
  31806. /**
  31807. * Does the transparency come from the diffuse texture alpha channel.
  31808. */
  31809. useAlphaFromDiffuseTexture: boolean;
  31810. private _useEmissiveAsIllumination;
  31811. /**
  31812. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31813. */
  31814. useEmissiveAsIllumination: boolean;
  31815. private _linkEmissiveWithDiffuse;
  31816. /**
  31817. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31818. * the emissive level when the final color is close to one.
  31819. */
  31820. linkEmissiveWithDiffuse: boolean;
  31821. private _useSpecularOverAlpha;
  31822. /**
  31823. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31824. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31825. */
  31826. useSpecularOverAlpha: boolean;
  31827. private _useReflectionOverAlpha;
  31828. /**
  31829. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31830. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31831. */
  31832. useReflectionOverAlpha: boolean;
  31833. private _disableLighting;
  31834. /**
  31835. * Does lights from the scene impacts this material.
  31836. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31837. */
  31838. disableLighting: boolean;
  31839. private _useObjectSpaceNormalMap;
  31840. /**
  31841. * Allows using an object space normal map (instead of tangent space).
  31842. */
  31843. useObjectSpaceNormalMap: boolean;
  31844. private _useParallax;
  31845. /**
  31846. * Is parallax enabled or not.
  31847. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31848. */
  31849. useParallax: boolean;
  31850. private _useParallaxOcclusion;
  31851. /**
  31852. * Is parallax occlusion enabled or not.
  31853. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31854. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31855. */
  31856. useParallaxOcclusion: boolean;
  31857. /**
  31858. * 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.
  31859. */
  31860. parallaxScaleBias: number;
  31861. private _roughness;
  31862. /**
  31863. * Helps to define how blurry the reflections should appears in the material.
  31864. */
  31865. roughness: number;
  31866. /**
  31867. * In case of refraction, define the value of the index of refraction.
  31868. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31869. */
  31870. indexOfRefraction: number;
  31871. /**
  31872. * Invert the refraction texture alongside the y axis.
  31873. * It can be useful with procedural textures or probe for instance.
  31874. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31875. */
  31876. invertRefractionY: boolean;
  31877. /**
  31878. * Defines the alpha limits in alpha test mode.
  31879. */
  31880. alphaCutOff: number;
  31881. private _useLightmapAsShadowmap;
  31882. /**
  31883. * In case of light mapping, define whether the map contains light or shadow informations.
  31884. */
  31885. useLightmapAsShadowmap: boolean;
  31886. private _diffuseFresnelParameters;
  31887. /**
  31888. * Define the diffuse fresnel parameters of the material.
  31889. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31890. */
  31891. diffuseFresnelParameters: FresnelParameters;
  31892. private _opacityFresnelParameters;
  31893. /**
  31894. * Define the opacity fresnel parameters of the material.
  31895. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31896. */
  31897. opacityFresnelParameters: FresnelParameters;
  31898. private _reflectionFresnelParameters;
  31899. /**
  31900. * Define the reflection fresnel parameters of the material.
  31901. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31902. */
  31903. reflectionFresnelParameters: FresnelParameters;
  31904. private _refractionFresnelParameters;
  31905. /**
  31906. * Define the refraction fresnel parameters of the material.
  31907. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31908. */
  31909. refractionFresnelParameters: FresnelParameters;
  31910. private _emissiveFresnelParameters;
  31911. /**
  31912. * Define the emissive fresnel parameters of the material.
  31913. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31914. */
  31915. emissiveFresnelParameters: FresnelParameters;
  31916. private _useReflectionFresnelFromSpecular;
  31917. /**
  31918. * If true automatically deducts the fresnels values from the material specularity.
  31919. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31920. */
  31921. useReflectionFresnelFromSpecular: boolean;
  31922. private _useGlossinessFromSpecularMapAlpha;
  31923. /**
  31924. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31925. */
  31926. useGlossinessFromSpecularMapAlpha: boolean;
  31927. private _maxSimultaneousLights;
  31928. /**
  31929. * Defines the maximum number of lights that can be used in the material
  31930. */
  31931. maxSimultaneousLights: number;
  31932. private _invertNormalMapX;
  31933. /**
  31934. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31935. */
  31936. invertNormalMapX: boolean;
  31937. private _invertNormalMapY;
  31938. /**
  31939. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31940. */
  31941. invertNormalMapY: boolean;
  31942. private _twoSidedLighting;
  31943. /**
  31944. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31945. */
  31946. twoSidedLighting: boolean;
  31947. /**
  31948. * Default configuration related to image processing available in the standard Material.
  31949. */
  31950. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31951. /**
  31952. * Gets the image processing configuration used either in this material.
  31953. */
  31954. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31955. /**
  31956. * Sets the Default image processing configuration used either in the this material.
  31957. *
  31958. * If sets to null, the scene one is in use.
  31959. */
  31960. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31961. /**
  31962. * Keep track of the image processing observer to allow dispose and replace.
  31963. */
  31964. private _imageProcessingObserver;
  31965. /**
  31966. * Attaches a new image processing configuration to the Standard Material.
  31967. * @param configuration
  31968. */
  31969. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31970. /**
  31971. * Gets wether the color curves effect is enabled.
  31972. */
  31973. get cameraColorCurvesEnabled(): boolean;
  31974. /**
  31975. * Sets wether the color curves effect is enabled.
  31976. */
  31977. set cameraColorCurvesEnabled(value: boolean);
  31978. /**
  31979. * Gets wether the color grading effect is enabled.
  31980. */
  31981. get cameraColorGradingEnabled(): boolean;
  31982. /**
  31983. * Gets wether the color grading effect is enabled.
  31984. */
  31985. set cameraColorGradingEnabled(value: boolean);
  31986. /**
  31987. * Gets wether tonemapping is enabled or not.
  31988. */
  31989. get cameraToneMappingEnabled(): boolean;
  31990. /**
  31991. * Sets wether tonemapping is enabled or not
  31992. */
  31993. set cameraToneMappingEnabled(value: boolean);
  31994. /**
  31995. * The camera exposure used on this material.
  31996. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31997. * This corresponds to a photographic exposure.
  31998. */
  31999. get cameraExposure(): number;
  32000. /**
  32001. * The camera exposure used on this material.
  32002. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32003. * This corresponds to a photographic exposure.
  32004. */
  32005. set cameraExposure(value: number);
  32006. /**
  32007. * Gets The camera contrast used on this material.
  32008. */
  32009. get cameraContrast(): number;
  32010. /**
  32011. * Sets The camera contrast used on this material.
  32012. */
  32013. set cameraContrast(value: number);
  32014. /**
  32015. * Gets the Color Grading 2D Lookup Texture.
  32016. */
  32017. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  32018. /**
  32019. * Sets the Color Grading 2D Lookup Texture.
  32020. */
  32021. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  32022. /**
  32023. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32024. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32025. * 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;
  32026. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32027. */
  32028. get cameraColorCurves(): Nullable<ColorCurves>;
  32029. /**
  32030. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32031. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32032. * 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;
  32033. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32034. */
  32035. set cameraColorCurves(value: Nullable<ColorCurves>);
  32036. /**
  32037. * Can this material render to several textures at once
  32038. */
  32039. get canRenderToMRT(): boolean;
  32040. /**
  32041. * Defines the detail map parameters for the material.
  32042. */
  32043. readonly detailMap: DetailMapConfiguration;
  32044. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32045. protected _worldViewProjectionMatrix: Matrix;
  32046. protected _globalAmbientColor: Color3;
  32047. protected _useLogarithmicDepth: boolean;
  32048. protected _rebuildInParallel: boolean;
  32049. /**
  32050. * Instantiates a new standard material.
  32051. * This is the default material used in Babylon. It is the best trade off between quality
  32052. * and performances.
  32053. * @see https://doc.babylonjs.com/babylon101/materials
  32054. * @param name Define the name of the material in the scene
  32055. * @param scene Define the scene the material belong to
  32056. */
  32057. constructor(name: string, scene: Scene);
  32058. /**
  32059. * Gets a boolean indicating that current material needs to register RTT
  32060. */
  32061. get hasRenderTargetTextures(): boolean;
  32062. /**
  32063. * Gets the current class name of the material e.g. "StandardMaterial"
  32064. * Mainly use in serialization.
  32065. * @returns the class name
  32066. */
  32067. getClassName(): string;
  32068. /**
  32069. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32070. * You can try switching to logarithmic depth.
  32071. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32072. */
  32073. get useLogarithmicDepth(): boolean;
  32074. set useLogarithmicDepth(value: boolean);
  32075. /**
  32076. * Specifies if the material will require alpha blending
  32077. * @returns a boolean specifying if alpha blending is needed
  32078. */
  32079. needAlphaBlending(): boolean;
  32080. /**
  32081. * Specifies if this material should be rendered in alpha test mode
  32082. * @returns a boolean specifying if an alpha test is needed.
  32083. */
  32084. needAlphaTesting(): boolean;
  32085. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32086. /**
  32087. * Get the texture used for alpha test purpose.
  32088. * @returns the diffuse texture in case of the standard material.
  32089. */
  32090. getAlphaTestTexture(): Nullable<BaseTexture>;
  32091. /**
  32092. * Get if the submesh is ready to be used and all its information available.
  32093. * Child classes can use it to update shaders
  32094. * @param mesh defines the mesh to check
  32095. * @param subMesh defines which submesh to check
  32096. * @param useInstances specifies that instances should be used
  32097. * @returns a boolean indicating that the submesh is ready or not
  32098. */
  32099. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32100. /**
  32101. * Builds the material UBO layouts.
  32102. * Used internally during the effect preparation.
  32103. */
  32104. buildUniformLayout(): void;
  32105. /**
  32106. * Unbinds the material from the mesh
  32107. */
  32108. unbind(): void;
  32109. /**
  32110. * Binds the submesh to this material by preparing the effect and shader to draw
  32111. * @param world defines the world transformation matrix
  32112. * @param mesh defines the mesh containing the submesh
  32113. * @param subMesh defines the submesh to bind the material to
  32114. */
  32115. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32116. /**
  32117. * Get the list of animatables in the material.
  32118. * @returns the list of animatables object used in the material
  32119. */
  32120. getAnimatables(): IAnimatable[];
  32121. /**
  32122. * Gets the active textures from the material
  32123. * @returns an array of textures
  32124. */
  32125. getActiveTextures(): BaseTexture[];
  32126. /**
  32127. * Specifies if the material uses a texture
  32128. * @param texture defines the texture to check against the material
  32129. * @returns a boolean specifying if the material uses the texture
  32130. */
  32131. hasTexture(texture: BaseTexture): boolean;
  32132. /**
  32133. * Disposes the material
  32134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32136. */
  32137. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32138. /**
  32139. * Makes a duplicate of the material, and gives it a new name
  32140. * @param name defines the new name for the duplicated material
  32141. * @returns the cloned material
  32142. */
  32143. clone(name: string): StandardMaterial;
  32144. /**
  32145. * Serializes this material in a JSON representation
  32146. * @returns the serialized material object
  32147. */
  32148. serialize(): any;
  32149. /**
  32150. * Creates a standard material from parsed material data
  32151. * @param source defines the JSON representation of the material
  32152. * @param scene defines the hosting scene
  32153. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32154. * @returns a new standard material
  32155. */
  32156. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32157. /**
  32158. * Are diffuse textures enabled in the application.
  32159. */
  32160. static get DiffuseTextureEnabled(): boolean;
  32161. static set DiffuseTextureEnabled(value: boolean);
  32162. /**
  32163. * Are detail textures enabled in the application.
  32164. */
  32165. static get DetailTextureEnabled(): boolean;
  32166. static set DetailTextureEnabled(value: boolean);
  32167. /**
  32168. * Are ambient textures enabled in the application.
  32169. */
  32170. static get AmbientTextureEnabled(): boolean;
  32171. static set AmbientTextureEnabled(value: boolean);
  32172. /**
  32173. * Are opacity textures enabled in the application.
  32174. */
  32175. static get OpacityTextureEnabled(): boolean;
  32176. static set OpacityTextureEnabled(value: boolean);
  32177. /**
  32178. * Are reflection textures enabled in the application.
  32179. */
  32180. static get ReflectionTextureEnabled(): boolean;
  32181. static set ReflectionTextureEnabled(value: boolean);
  32182. /**
  32183. * Are emissive textures enabled in the application.
  32184. */
  32185. static get EmissiveTextureEnabled(): boolean;
  32186. static set EmissiveTextureEnabled(value: boolean);
  32187. /**
  32188. * Are specular textures enabled in the application.
  32189. */
  32190. static get SpecularTextureEnabled(): boolean;
  32191. static set SpecularTextureEnabled(value: boolean);
  32192. /**
  32193. * Are bump textures enabled in the application.
  32194. */
  32195. static get BumpTextureEnabled(): boolean;
  32196. static set BumpTextureEnabled(value: boolean);
  32197. /**
  32198. * Are lightmap textures enabled in the application.
  32199. */
  32200. static get LightmapTextureEnabled(): boolean;
  32201. static set LightmapTextureEnabled(value: boolean);
  32202. /**
  32203. * Are refraction textures enabled in the application.
  32204. */
  32205. static get RefractionTextureEnabled(): boolean;
  32206. static set RefractionTextureEnabled(value: boolean);
  32207. /**
  32208. * Are color grading textures enabled in the application.
  32209. */
  32210. static get ColorGradingTextureEnabled(): boolean;
  32211. static set ColorGradingTextureEnabled(value: boolean);
  32212. /**
  32213. * Are fresnels enabled in the application.
  32214. */
  32215. static get FresnelEnabled(): boolean;
  32216. static set FresnelEnabled(value: boolean);
  32217. }
  32218. }
  32219. declare module "babylonjs/Particles/solidParticleSystem" {
  32220. import { Nullable } from "babylonjs/types";
  32221. import { Mesh } from "babylonjs/Meshes/mesh";
  32222. import { Scene, IDisposable } from "babylonjs/scene";
  32223. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32224. import { Material } from "babylonjs/Materials/material";
  32225. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32226. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32227. /**
  32228. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32229. *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.
  32230. * The SPS is also a particle system. It provides some methods to manage the particles.
  32231. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32232. *
  32233. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32234. */
  32235. export class SolidParticleSystem implements IDisposable {
  32236. /**
  32237. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32238. * Example : var p = SPS.particles[i];
  32239. */
  32240. particles: SolidParticle[];
  32241. /**
  32242. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32243. */
  32244. nbParticles: number;
  32245. /**
  32246. * If the particles must ever face the camera (default false). Useful for planar particles.
  32247. */
  32248. billboard: boolean;
  32249. /**
  32250. * Recompute normals when adding a shape
  32251. */
  32252. recomputeNormals: boolean;
  32253. /**
  32254. * This a counter ofr your own usage. It's not set by any SPS functions.
  32255. */
  32256. counter: number;
  32257. /**
  32258. * The SPS name. This name is also given to the underlying mesh.
  32259. */
  32260. name: string;
  32261. /**
  32262. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32263. */
  32264. mesh: Mesh;
  32265. /**
  32266. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32267. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32268. */
  32269. vars: any;
  32270. /**
  32271. * This array is populated when the SPS is set as 'pickable'.
  32272. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32273. * Each element of this array is an object `{idx: int, faceId: int}`.
  32274. * `idx` is the picked particle index in the `SPS.particles` array
  32275. * `faceId` is the picked face index counted within this particle.
  32276. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32277. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32278. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32279. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32280. */
  32281. pickedParticles: {
  32282. idx: number;
  32283. faceId: number;
  32284. }[];
  32285. /**
  32286. * This array is populated when the SPS is set as 'pickable'
  32287. * Each key of this array is a submesh index.
  32288. * Each element of this array is a second array defined like this :
  32289. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32290. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32291. * `idx` is the picked particle index in the `SPS.particles` array
  32292. * `faceId` is the picked face index counted within this particle.
  32293. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32294. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32295. */
  32296. pickedBySubMesh: {
  32297. idx: number;
  32298. faceId: number;
  32299. }[][];
  32300. /**
  32301. * This array is populated when `enableDepthSort` is set to true.
  32302. * Each element of this array is an instance of the class DepthSortedParticle.
  32303. */
  32304. depthSortedParticles: DepthSortedParticle[];
  32305. /**
  32306. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32307. * @hidden
  32308. */
  32309. _bSphereOnly: boolean;
  32310. /**
  32311. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32312. * @hidden
  32313. */
  32314. _bSphereRadiusFactor: number;
  32315. private _scene;
  32316. private _positions;
  32317. private _indices;
  32318. private _normals;
  32319. private _colors;
  32320. private _uvs;
  32321. private _indices32;
  32322. private _positions32;
  32323. private _normals32;
  32324. private _fixedNormal32;
  32325. private _colors32;
  32326. private _uvs32;
  32327. private _index;
  32328. private _updatable;
  32329. private _pickable;
  32330. private _isVisibilityBoxLocked;
  32331. private _alwaysVisible;
  32332. private _depthSort;
  32333. private _expandable;
  32334. private _shapeCounter;
  32335. private _copy;
  32336. private _color;
  32337. private _computeParticleColor;
  32338. private _computeParticleTexture;
  32339. private _computeParticleRotation;
  32340. private _computeParticleVertex;
  32341. private _computeBoundingBox;
  32342. private _depthSortParticles;
  32343. private _camera;
  32344. private _mustUnrotateFixedNormals;
  32345. private _particlesIntersect;
  32346. private _needs32Bits;
  32347. private _isNotBuilt;
  32348. private _lastParticleId;
  32349. private _idxOfId;
  32350. private _multimaterialEnabled;
  32351. private _useModelMaterial;
  32352. private _indicesByMaterial;
  32353. private _materialIndexes;
  32354. private _depthSortFunction;
  32355. private _materialSortFunction;
  32356. private _materials;
  32357. private _multimaterial;
  32358. private _materialIndexesById;
  32359. private _defaultMaterial;
  32360. private _autoUpdateSubMeshes;
  32361. private _tmpVertex;
  32362. /**
  32363. * Creates a SPS (Solid Particle System) object.
  32364. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32365. * @param scene (Scene) is the scene in which the SPS is added.
  32366. * @param options defines the options of the sps e.g.
  32367. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32368. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32369. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32370. * * 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.
  32371. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32372. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32373. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32374. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32375. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32376. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32377. */
  32378. constructor(name: string, scene: Scene, options?: {
  32379. updatable?: boolean;
  32380. isPickable?: boolean;
  32381. enableDepthSort?: boolean;
  32382. particleIntersection?: boolean;
  32383. boundingSphereOnly?: boolean;
  32384. bSphereRadiusFactor?: number;
  32385. expandable?: boolean;
  32386. useModelMaterial?: boolean;
  32387. enableMultiMaterial?: boolean;
  32388. });
  32389. /**
  32390. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32391. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32392. * @returns the created mesh
  32393. */
  32394. buildMesh(): Mesh;
  32395. /**
  32396. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32397. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32398. * Thus the particles generated from `digest()` have their property `position` set yet.
  32399. * @param mesh ( Mesh ) is the mesh to be digested
  32400. * @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
  32401. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32402. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32403. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32404. * @returns the current SPS
  32405. */
  32406. digest(mesh: Mesh, options?: {
  32407. facetNb?: number;
  32408. number?: number;
  32409. delta?: number;
  32410. storage?: [];
  32411. }): SolidParticleSystem;
  32412. /**
  32413. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32414. * @hidden
  32415. */
  32416. private _unrotateFixedNormals;
  32417. /**
  32418. * Resets the temporary working copy particle
  32419. * @hidden
  32420. */
  32421. private _resetCopy;
  32422. /**
  32423. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32424. * @param p the current index in the positions array to be updated
  32425. * @param ind the current index in the indices array
  32426. * @param shape a Vector3 array, the shape geometry
  32427. * @param positions the positions array to be updated
  32428. * @param meshInd the shape indices array
  32429. * @param indices the indices array to be updated
  32430. * @param meshUV the shape uv array
  32431. * @param uvs the uv array to be updated
  32432. * @param meshCol the shape color array
  32433. * @param colors the color array to be updated
  32434. * @param meshNor the shape normals array
  32435. * @param normals the normals array to be updated
  32436. * @param idx the particle index
  32437. * @param idxInShape the particle index in its shape
  32438. * @param options the addShape() method passed options
  32439. * @model the particle model
  32440. * @hidden
  32441. */
  32442. private _meshBuilder;
  32443. /**
  32444. * Returns a shape Vector3 array from positions float array
  32445. * @param positions float array
  32446. * @returns a vector3 array
  32447. * @hidden
  32448. */
  32449. private _posToShape;
  32450. /**
  32451. * Returns a shapeUV array from a float uvs (array deep copy)
  32452. * @param uvs as a float array
  32453. * @returns a shapeUV array
  32454. * @hidden
  32455. */
  32456. private _uvsToShapeUV;
  32457. /**
  32458. * Adds a new particle object in the particles array
  32459. * @param idx particle index in particles array
  32460. * @param id particle id
  32461. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32462. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32463. * @param model particle ModelShape object
  32464. * @param shapeId model shape identifier
  32465. * @param idxInShape index of the particle in the current model
  32466. * @param bInfo model bounding info object
  32467. * @param storage target storage array, if any
  32468. * @hidden
  32469. */
  32470. private _addParticle;
  32471. /**
  32472. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32473. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32474. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32475. * @param nb (positive integer) the number of particles to be created from this model
  32476. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32477. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32478. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32479. * @returns the number of shapes in the system
  32480. */
  32481. addShape(mesh: Mesh, nb: number, options?: {
  32482. positionFunction?: any;
  32483. vertexFunction?: any;
  32484. storage?: [];
  32485. }): number;
  32486. /**
  32487. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32488. * @hidden
  32489. */
  32490. private _rebuildParticle;
  32491. /**
  32492. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32493. * @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.
  32494. * @returns the SPS.
  32495. */
  32496. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32497. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32498. * Returns an array with the removed particles.
  32499. * 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.
  32500. * The SPS can't be empty so at least one particle needs to remain in place.
  32501. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32502. * @param start index of the first particle to remove
  32503. * @param end index of the last particle to remove (included)
  32504. * @returns an array populated with the removed particles
  32505. */
  32506. removeParticles(start: number, end: number): SolidParticle[];
  32507. /**
  32508. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32509. * @param solidParticleArray an array populated with Solid Particles objects
  32510. * @returns the SPS
  32511. */
  32512. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32513. /**
  32514. * Creates a new particle and modifies the SPS mesh geometry :
  32515. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32516. * - calls _addParticle() to populate the particle array
  32517. * factorized code from addShape() and insertParticlesFromArray()
  32518. * @param idx particle index in the particles array
  32519. * @param i particle index in its shape
  32520. * @param modelShape particle ModelShape object
  32521. * @param shape shape vertex array
  32522. * @param meshInd shape indices array
  32523. * @param meshUV shape uv array
  32524. * @param meshCol shape color array
  32525. * @param meshNor shape normals array
  32526. * @param bbInfo shape bounding info
  32527. * @param storage target particle storage
  32528. * @options addShape() passed options
  32529. * @hidden
  32530. */
  32531. private _insertNewParticle;
  32532. /**
  32533. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32534. * This method calls `updateParticle()` for each particle of the SPS.
  32535. * For an animated SPS, it is usually called within the render loop.
  32536. * 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.
  32537. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32538. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32539. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32540. * @returns the SPS.
  32541. */
  32542. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32543. /**
  32544. * Disposes the SPS.
  32545. */
  32546. dispose(): void;
  32547. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32548. * idx is the particle index in the SPS
  32549. * faceId is the picked face index counted within this particle.
  32550. * Returns null if the pickInfo can't identify a picked particle.
  32551. * @param pickingInfo (PickingInfo object)
  32552. * @returns {idx: number, faceId: number} or null
  32553. */
  32554. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32555. idx: number;
  32556. faceId: number;
  32557. }>;
  32558. /**
  32559. * Returns a SolidParticle object from its identifier : particle.id
  32560. * @param id (integer) the particle Id
  32561. * @returns the searched particle or null if not found in the SPS.
  32562. */
  32563. getParticleById(id: number): Nullable<SolidParticle>;
  32564. /**
  32565. * Returns a new array populated with the particles having the passed shapeId.
  32566. * @param shapeId (integer) the shape identifier
  32567. * @returns a new solid particle array
  32568. */
  32569. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32570. /**
  32571. * Populates the passed array "ref" with the particles having the passed shapeId.
  32572. * @param shapeId the shape identifier
  32573. * @returns the SPS
  32574. * @param ref
  32575. */
  32576. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32577. /**
  32578. * Computes the required SubMeshes according the materials assigned to the particles.
  32579. * @returns the solid particle system.
  32580. * Does nothing if called before the SPS mesh is built.
  32581. */
  32582. computeSubMeshes(): SolidParticleSystem;
  32583. /**
  32584. * Sorts the solid particles by material when MultiMaterial is enabled.
  32585. * Updates the indices32 array.
  32586. * Updates the indicesByMaterial array.
  32587. * Updates the mesh indices array.
  32588. * @returns the SPS
  32589. * @hidden
  32590. */
  32591. private _sortParticlesByMaterial;
  32592. /**
  32593. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32594. * @hidden
  32595. */
  32596. private _setMaterialIndexesById;
  32597. /**
  32598. * Returns an array with unique values of Materials from the passed array
  32599. * @param array the material array to be checked and filtered
  32600. * @hidden
  32601. */
  32602. private _filterUniqueMaterialId;
  32603. /**
  32604. * Sets a new Standard Material as _defaultMaterial if not already set.
  32605. * @hidden
  32606. */
  32607. private _setDefaultMaterial;
  32608. /**
  32609. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32610. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32611. * @returns the SPS.
  32612. */
  32613. refreshVisibleSize(): SolidParticleSystem;
  32614. /**
  32615. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32616. * @param size the size (float) of the visibility box
  32617. * note : this doesn't lock the SPS mesh bounding box.
  32618. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32619. */
  32620. setVisibilityBox(size: number): void;
  32621. /**
  32622. * Gets whether the SPS as always visible or not
  32623. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32624. */
  32625. get isAlwaysVisible(): boolean;
  32626. /**
  32627. * Sets the SPS as always visible or not
  32628. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32629. */
  32630. set isAlwaysVisible(val: boolean);
  32631. /**
  32632. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32633. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32634. */
  32635. set isVisibilityBoxLocked(val: boolean);
  32636. /**
  32637. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32638. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32639. */
  32640. get isVisibilityBoxLocked(): boolean;
  32641. /**
  32642. * Tells to `setParticles()` to compute the particle rotations or not.
  32643. * Default value : true. The SPS is faster when it's set to false.
  32644. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32645. */
  32646. set computeParticleRotation(val: boolean);
  32647. /**
  32648. * Tells to `setParticles()` to compute the particle colors or not.
  32649. * Default value : true. The SPS is faster when it's set to false.
  32650. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32651. */
  32652. set computeParticleColor(val: boolean);
  32653. set computeParticleTexture(val: boolean);
  32654. /**
  32655. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32656. * Default value : false. The SPS is faster when it's set to false.
  32657. * Note : the particle custom vertex positions aren't stored values.
  32658. */
  32659. set computeParticleVertex(val: boolean);
  32660. /**
  32661. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32662. */
  32663. set computeBoundingBox(val: boolean);
  32664. /**
  32665. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32666. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32667. * Default : `true`
  32668. */
  32669. set depthSortParticles(val: boolean);
  32670. /**
  32671. * Gets if `setParticles()` computes the particle rotations or not.
  32672. * Default value : true. The SPS is faster when it's set to false.
  32673. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32674. */
  32675. get computeParticleRotation(): boolean;
  32676. /**
  32677. * Gets if `setParticles()` computes the particle colors or not.
  32678. * Default value : true. The SPS is faster when it's set to false.
  32679. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32680. */
  32681. get computeParticleColor(): boolean;
  32682. /**
  32683. * Gets if `setParticles()` computes the particle textures or not.
  32684. * Default value : true. The SPS is faster when it's set to false.
  32685. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32686. */
  32687. get computeParticleTexture(): boolean;
  32688. /**
  32689. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32690. * Default value : false. The SPS is faster when it's set to false.
  32691. * Note : the particle custom vertex positions aren't stored values.
  32692. */
  32693. get computeParticleVertex(): boolean;
  32694. /**
  32695. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32696. */
  32697. get computeBoundingBox(): boolean;
  32698. /**
  32699. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32700. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32701. * Default : `true`
  32702. */
  32703. get depthSortParticles(): boolean;
  32704. /**
  32705. * Gets if the SPS is created as expandable at construction time.
  32706. * Default : `false`
  32707. */
  32708. get expandable(): boolean;
  32709. /**
  32710. * Gets if the SPS supports the Multi Materials
  32711. */
  32712. get multimaterialEnabled(): boolean;
  32713. /**
  32714. * Gets if the SPS uses the model materials for its own multimaterial.
  32715. */
  32716. get useModelMaterial(): boolean;
  32717. /**
  32718. * The SPS used material array.
  32719. */
  32720. get materials(): Material[];
  32721. /**
  32722. * Sets the SPS MultiMaterial from the passed materials.
  32723. * Note : the passed array is internally copied and not used then by reference.
  32724. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32725. */
  32726. setMultiMaterial(materials: Material[]): void;
  32727. /**
  32728. * The SPS computed multimaterial object
  32729. */
  32730. get multimaterial(): MultiMaterial;
  32731. set multimaterial(mm: MultiMaterial);
  32732. /**
  32733. * If the subMeshes must be updated on the next call to setParticles()
  32734. */
  32735. get autoUpdateSubMeshes(): boolean;
  32736. set autoUpdateSubMeshes(val: boolean);
  32737. /**
  32738. * This function does nothing. It may be overwritten to set all the particle first values.
  32739. * The SPS doesn't call this function, you may have to call it by your own.
  32740. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32741. */
  32742. initParticles(): void;
  32743. /**
  32744. * This function does nothing. It may be overwritten to recycle a particle.
  32745. * The SPS doesn't call this function, you may have to call it by your own.
  32746. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32747. * @param particle The particle to recycle
  32748. * @returns the recycled particle
  32749. */
  32750. recycleParticle(particle: SolidParticle): SolidParticle;
  32751. /**
  32752. * Updates a particle : this function should be overwritten by the user.
  32753. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32754. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32755. * @example : just set a particle position or velocity and recycle conditions
  32756. * @param particle The particle to update
  32757. * @returns the updated particle
  32758. */
  32759. updateParticle(particle: SolidParticle): SolidParticle;
  32760. /**
  32761. * Updates a vertex of a particle : it can be overwritten by the user.
  32762. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32763. * @param particle the current particle
  32764. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32765. * @param pt the index of the current vertex in the particle shape
  32766. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32767. * @example : just set a vertex particle position or color
  32768. * @returns the sps
  32769. */
  32770. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32771. /**
  32772. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32773. * This does nothing and may be overwritten by the user.
  32774. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32775. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32776. * @param update the boolean update value actually passed to setParticles()
  32777. */
  32778. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32779. /**
  32780. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32781. * This will be passed three parameters.
  32782. * This does nothing and may be overwritten by the user.
  32783. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32784. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32785. * @param update the boolean update value actually passed to setParticles()
  32786. */
  32787. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32788. }
  32789. }
  32790. declare module "babylonjs/Particles/solidParticle" {
  32791. import { Nullable } from "babylonjs/types";
  32792. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32793. import { Color4 } from "babylonjs/Maths/math.color";
  32794. import { Mesh } from "babylonjs/Meshes/mesh";
  32795. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32796. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32797. import { Plane } from "babylonjs/Maths/math.plane";
  32798. import { Material } from "babylonjs/Materials/material";
  32799. /**
  32800. * Represents one particle of a solid particle system.
  32801. */
  32802. export class SolidParticle {
  32803. /**
  32804. * particle global index
  32805. */
  32806. idx: number;
  32807. /**
  32808. * particle identifier
  32809. */
  32810. id: number;
  32811. /**
  32812. * The color of the particle
  32813. */
  32814. color: Nullable<Color4>;
  32815. /**
  32816. * The world space position of the particle.
  32817. */
  32818. position: Vector3;
  32819. /**
  32820. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32821. */
  32822. rotation: Vector3;
  32823. /**
  32824. * The world space rotation quaternion of the particle.
  32825. */
  32826. rotationQuaternion: Nullable<Quaternion>;
  32827. /**
  32828. * The scaling of the particle.
  32829. */
  32830. scaling: Vector3;
  32831. /**
  32832. * The uvs of the particle.
  32833. */
  32834. uvs: Vector4;
  32835. /**
  32836. * The current speed of the particle.
  32837. */
  32838. velocity: Vector3;
  32839. /**
  32840. * The pivot point in the particle local space.
  32841. */
  32842. pivot: Vector3;
  32843. /**
  32844. * Must the particle be translated from its pivot point in its local space ?
  32845. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32846. * Default : false
  32847. */
  32848. translateFromPivot: boolean;
  32849. /**
  32850. * Is the particle active or not ?
  32851. */
  32852. alive: boolean;
  32853. /**
  32854. * Is the particle visible or not ?
  32855. */
  32856. isVisible: boolean;
  32857. /**
  32858. * Index of this particle in the global "positions" array (Internal use)
  32859. * @hidden
  32860. */
  32861. _pos: number;
  32862. /**
  32863. * @hidden Index of this particle in the global "indices" array (Internal use)
  32864. */
  32865. _ind: number;
  32866. /**
  32867. * @hidden ModelShape of this particle (Internal use)
  32868. */
  32869. _model: ModelShape;
  32870. /**
  32871. * ModelShape id of this particle
  32872. */
  32873. shapeId: number;
  32874. /**
  32875. * Index of the particle in its shape id
  32876. */
  32877. idxInShape: number;
  32878. /**
  32879. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32880. */
  32881. _modelBoundingInfo: BoundingInfo;
  32882. /**
  32883. * @hidden Particle BoundingInfo object (Internal use)
  32884. */
  32885. _boundingInfo: BoundingInfo;
  32886. /**
  32887. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32888. */
  32889. _sps: SolidParticleSystem;
  32890. /**
  32891. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32892. */
  32893. _stillInvisible: boolean;
  32894. /**
  32895. * @hidden Last computed particle rotation matrix
  32896. */
  32897. _rotationMatrix: number[];
  32898. /**
  32899. * Parent particle Id, if any.
  32900. * Default null.
  32901. */
  32902. parentId: Nullable<number>;
  32903. /**
  32904. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32905. */
  32906. materialIndex: Nullable<number>;
  32907. /**
  32908. * Custom object or properties.
  32909. */
  32910. props: Nullable<any>;
  32911. /**
  32912. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32913. * The possible values are :
  32914. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32915. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32916. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32917. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32918. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32919. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32920. * */
  32921. cullingStrategy: number;
  32922. /**
  32923. * @hidden Internal global position in the SPS.
  32924. */
  32925. _globalPosition: Vector3;
  32926. /**
  32927. * Creates a Solid Particle object.
  32928. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32929. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32930. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32931. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32932. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32933. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32934. * @param shapeId (integer) is the model shape identifier in the SPS.
  32935. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32936. * @param sps defines the sps it is associated to
  32937. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32938. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32939. */
  32940. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32941. /**
  32942. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32943. * @param target the particle target
  32944. * @returns the current particle
  32945. */
  32946. copyToRef(target: SolidParticle): SolidParticle;
  32947. /**
  32948. * Legacy support, changed scale to scaling
  32949. */
  32950. get scale(): Vector3;
  32951. /**
  32952. * Legacy support, changed scale to scaling
  32953. */
  32954. set scale(scale: Vector3);
  32955. /**
  32956. * Legacy support, changed quaternion to rotationQuaternion
  32957. */
  32958. get quaternion(): Nullable<Quaternion>;
  32959. /**
  32960. * Legacy support, changed quaternion to rotationQuaternion
  32961. */
  32962. set quaternion(q: Nullable<Quaternion>);
  32963. /**
  32964. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32965. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32966. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32967. * @returns true if it intersects
  32968. */
  32969. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32970. /**
  32971. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32972. * A particle is in the frustum if its bounding box intersects the frustum
  32973. * @param frustumPlanes defines the frustum to test
  32974. * @returns true if the particle is in the frustum planes
  32975. */
  32976. isInFrustum(frustumPlanes: Plane[]): boolean;
  32977. /**
  32978. * get the rotation matrix of the particle
  32979. * @hidden
  32980. */
  32981. getRotationMatrix(m: Matrix): void;
  32982. }
  32983. /**
  32984. * Represents the shape of the model used by one particle of a solid particle system.
  32985. * SPS internal tool, don't use it manually.
  32986. */
  32987. export class ModelShape {
  32988. /**
  32989. * The shape id
  32990. * @hidden
  32991. */
  32992. shapeID: number;
  32993. /**
  32994. * flat array of model positions (internal use)
  32995. * @hidden
  32996. */
  32997. _shape: Vector3[];
  32998. /**
  32999. * flat array of model UVs (internal use)
  33000. * @hidden
  33001. */
  33002. _shapeUV: number[];
  33003. /**
  33004. * color array of the model
  33005. * @hidden
  33006. */
  33007. _shapeColors: number[];
  33008. /**
  33009. * indices array of the model
  33010. * @hidden
  33011. */
  33012. _indices: number[];
  33013. /**
  33014. * normals array of the model
  33015. * @hidden
  33016. */
  33017. _normals: number[];
  33018. /**
  33019. * length of the shape in the model indices array (internal use)
  33020. * @hidden
  33021. */
  33022. _indicesLength: number;
  33023. /**
  33024. * Custom position function (internal use)
  33025. * @hidden
  33026. */
  33027. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33028. /**
  33029. * Custom vertex function (internal use)
  33030. * @hidden
  33031. */
  33032. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33033. /**
  33034. * Model material (internal use)
  33035. * @hidden
  33036. */
  33037. _material: Nullable<Material>;
  33038. /**
  33039. * 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.
  33040. * SPS internal tool, don't use it manually.
  33041. * @hidden
  33042. */
  33043. 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>);
  33044. }
  33045. /**
  33046. * Represents a Depth Sorted Particle in the solid particle system.
  33047. * @hidden
  33048. */
  33049. export class DepthSortedParticle {
  33050. /**
  33051. * Particle index
  33052. */
  33053. idx: number;
  33054. /**
  33055. * Index of the particle in the "indices" array
  33056. */
  33057. ind: number;
  33058. /**
  33059. * Length of the particle shape in the "indices" array
  33060. */
  33061. indicesLength: number;
  33062. /**
  33063. * Squared distance from the particle to the camera
  33064. */
  33065. sqDistance: number;
  33066. /**
  33067. * Material index when used with MultiMaterials
  33068. */
  33069. materialIndex: number;
  33070. /**
  33071. * Creates a new sorted particle
  33072. * @param materialIndex
  33073. */
  33074. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33075. }
  33076. /**
  33077. * Represents a solid particle vertex
  33078. */
  33079. export class SolidParticleVertex {
  33080. /**
  33081. * Vertex position
  33082. */
  33083. position: Vector3;
  33084. /**
  33085. * Vertex color
  33086. */
  33087. color: Color4;
  33088. /**
  33089. * Vertex UV
  33090. */
  33091. uv: Vector2;
  33092. /**
  33093. * Creates a new solid particle vertex
  33094. */
  33095. constructor();
  33096. /** Vertex x coordinate */
  33097. get x(): number;
  33098. set x(val: number);
  33099. /** Vertex y coordinate */
  33100. get y(): number;
  33101. set y(val: number);
  33102. /** Vertex z coordinate */
  33103. get z(): number;
  33104. set z(val: number);
  33105. }
  33106. }
  33107. declare module "babylonjs/Collisions/meshCollisionData" {
  33108. import { Collider } from "babylonjs/Collisions/collider";
  33109. import { Vector3 } from "babylonjs/Maths/math.vector";
  33110. import { Nullable } from "babylonjs/types";
  33111. import { Observer } from "babylonjs/Misc/observable";
  33112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33113. /**
  33114. * @hidden
  33115. */
  33116. export class _MeshCollisionData {
  33117. _checkCollisions: boolean;
  33118. _collisionMask: number;
  33119. _collisionGroup: number;
  33120. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33121. _collider: Nullable<Collider>;
  33122. _oldPositionForCollisions: Vector3;
  33123. _diffPositionForCollisions: Vector3;
  33124. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33125. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33126. _collisionResponse: boolean;
  33127. }
  33128. }
  33129. declare module "babylonjs/Meshes/abstractMesh" {
  33130. import { Observable } from "babylonjs/Misc/observable";
  33131. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33132. import { Camera } from "babylonjs/Cameras/camera";
  33133. import { Scene, IDisposable } from "babylonjs/scene";
  33134. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33135. import { Node } from "babylonjs/node";
  33136. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33137. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33138. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33139. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33140. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33141. import { Material } from "babylonjs/Materials/material";
  33142. import { Light } from "babylonjs/Lights/light";
  33143. import { Skeleton } from "babylonjs/Bones/skeleton";
  33144. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33145. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33146. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33147. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33148. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33149. import { Plane } from "babylonjs/Maths/math.plane";
  33150. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33151. import { Ray } from "babylonjs/Culling/ray";
  33152. import { Collider } from "babylonjs/Collisions/collider";
  33153. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33154. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33155. /** @hidden */
  33156. class _FacetDataStorage {
  33157. facetPositions: Vector3[];
  33158. facetNormals: Vector3[];
  33159. facetPartitioning: number[][];
  33160. facetNb: number;
  33161. partitioningSubdivisions: number;
  33162. partitioningBBoxRatio: number;
  33163. facetDataEnabled: boolean;
  33164. facetParameters: any;
  33165. bbSize: Vector3;
  33166. subDiv: {
  33167. max: number;
  33168. X: number;
  33169. Y: number;
  33170. Z: number;
  33171. };
  33172. facetDepthSort: boolean;
  33173. facetDepthSortEnabled: boolean;
  33174. depthSortedIndices: IndicesArray;
  33175. depthSortedFacets: {
  33176. ind: number;
  33177. sqDistance: number;
  33178. }[];
  33179. facetDepthSortFunction: (f1: {
  33180. ind: number;
  33181. sqDistance: number;
  33182. }, f2: {
  33183. ind: number;
  33184. sqDistance: number;
  33185. }) => number;
  33186. facetDepthSortFrom: Vector3;
  33187. facetDepthSortOrigin: Vector3;
  33188. invertedMatrix: Matrix;
  33189. }
  33190. /**
  33191. * @hidden
  33192. **/
  33193. class _InternalAbstractMeshDataInfo {
  33194. _hasVertexAlpha: boolean;
  33195. _useVertexColors: boolean;
  33196. _numBoneInfluencers: number;
  33197. _applyFog: boolean;
  33198. _receiveShadows: boolean;
  33199. _facetData: _FacetDataStorage;
  33200. _visibility: number;
  33201. _skeleton: Nullable<Skeleton>;
  33202. _layerMask: number;
  33203. _computeBonesUsingShaders: boolean;
  33204. _isActive: boolean;
  33205. _onlyForInstances: boolean;
  33206. _isActiveIntermediate: boolean;
  33207. _onlyForInstancesIntermediate: boolean;
  33208. _actAsRegularMesh: boolean;
  33209. }
  33210. /**
  33211. * Class used to store all common mesh properties
  33212. */
  33213. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33214. /** No occlusion */
  33215. static OCCLUSION_TYPE_NONE: number;
  33216. /** Occlusion set to optimisitic */
  33217. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33218. /** Occlusion set to strict */
  33219. static OCCLUSION_TYPE_STRICT: number;
  33220. /** Use an accurante occlusion algorithm */
  33221. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33222. /** Use a conservative occlusion algorithm */
  33223. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33224. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33225. * Test order :
  33226. * Is the bounding sphere outside the frustum ?
  33227. * If not, are the bounding box vertices outside the frustum ?
  33228. * It not, then the cullable object is in the frustum.
  33229. */
  33230. static readonly CULLINGSTRATEGY_STANDARD: number;
  33231. /** Culling strategy : Bounding Sphere Only.
  33232. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33233. * It's also less accurate than the standard because some not visible objects can still be selected.
  33234. * Test : is the bounding sphere outside the frustum ?
  33235. * If not, then the cullable object is in the frustum.
  33236. */
  33237. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33238. /** Culling strategy : Optimistic Inclusion.
  33239. * This in an inclusion test first, then the standard exclusion test.
  33240. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33241. * 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.
  33242. * Anyway, it's as accurate as the standard strategy.
  33243. * Test :
  33244. * Is the cullable object bounding sphere center in the frustum ?
  33245. * If not, apply the default culling strategy.
  33246. */
  33247. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33248. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33249. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33250. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33251. * 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.
  33252. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33253. * Test :
  33254. * Is the cullable object bounding sphere center in the frustum ?
  33255. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33256. */
  33257. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33258. /**
  33259. * No billboard
  33260. */
  33261. static get BILLBOARDMODE_NONE(): number;
  33262. /** Billboard on X axis */
  33263. static get BILLBOARDMODE_X(): number;
  33264. /** Billboard on Y axis */
  33265. static get BILLBOARDMODE_Y(): number;
  33266. /** Billboard on Z axis */
  33267. static get BILLBOARDMODE_Z(): number;
  33268. /** Billboard on all axes */
  33269. static get BILLBOARDMODE_ALL(): number;
  33270. /** Billboard on using position instead of orientation */
  33271. static get BILLBOARDMODE_USE_POSITION(): number;
  33272. /** @hidden */
  33273. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33274. /**
  33275. * The culling strategy to use to check whether the mesh must be rendered or not.
  33276. * This value can be changed at any time and will be used on the next render mesh selection.
  33277. * The possible values are :
  33278. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33279. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33280. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33281. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33282. * Please read each static variable documentation to get details about the culling process.
  33283. * */
  33284. cullingStrategy: number;
  33285. /**
  33286. * Gets the number of facets in the mesh
  33287. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33288. */
  33289. get facetNb(): number;
  33290. /**
  33291. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33292. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33293. */
  33294. get partitioningSubdivisions(): number;
  33295. set partitioningSubdivisions(nb: number);
  33296. /**
  33297. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33298. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33299. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33300. */
  33301. get partitioningBBoxRatio(): number;
  33302. set partitioningBBoxRatio(ratio: number);
  33303. /**
  33304. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33305. * Works only for updatable meshes.
  33306. * Doesn't work with multi-materials
  33307. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33308. */
  33309. get mustDepthSortFacets(): boolean;
  33310. set mustDepthSortFacets(sort: boolean);
  33311. /**
  33312. * The location (Vector3) where the facet depth sort must be computed from.
  33313. * By default, the active camera position.
  33314. * Used only when facet depth sort is enabled
  33315. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33316. */
  33317. get facetDepthSortFrom(): Vector3;
  33318. set facetDepthSortFrom(location: Vector3);
  33319. /**
  33320. * gets a boolean indicating if facetData is enabled
  33321. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33322. */
  33323. get isFacetDataEnabled(): boolean;
  33324. /** @hidden */
  33325. _updateNonUniformScalingState(value: boolean): boolean;
  33326. /**
  33327. * An event triggered when this mesh collides with another one
  33328. */
  33329. onCollideObservable: Observable<AbstractMesh>;
  33330. /** Set a function to call when this mesh collides with another one */
  33331. set onCollide(callback: () => void);
  33332. /**
  33333. * An event triggered when the collision's position changes
  33334. */
  33335. onCollisionPositionChangeObservable: Observable<Vector3>;
  33336. /** Set a function to call when the collision's position changes */
  33337. set onCollisionPositionChange(callback: () => void);
  33338. /**
  33339. * An event triggered when material is changed
  33340. */
  33341. onMaterialChangedObservable: Observable<AbstractMesh>;
  33342. /**
  33343. * Gets or sets the orientation for POV movement & rotation
  33344. */
  33345. definedFacingForward: boolean;
  33346. /** @hidden */
  33347. _occlusionQuery: Nullable<WebGLQuery>;
  33348. /** @hidden */
  33349. _renderingGroup: Nullable<RenderingGroup>;
  33350. /**
  33351. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33352. */
  33353. get visibility(): number;
  33354. /**
  33355. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33356. */
  33357. set visibility(value: number);
  33358. /** Gets or sets the alpha index used to sort transparent meshes
  33359. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33360. */
  33361. alphaIndex: number;
  33362. /**
  33363. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33364. */
  33365. isVisible: boolean;
  33366. /**
  33367. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33368. */
  33369. isPickable: boolean;
  33370. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33371. showSubMeshesBoundingBox: boolean;
  33372. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33373. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33374. */
  33375. isBlocker: boolean;
  33376. /**
  33377. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33378. */
  33379. enablePointerMoveEvents: boolean;
  33380. private _renderingGroupId;
  33381. /**
  33382. * Specifies the rendering group id for this mesh (0 by default)
  33383. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33384. */
  33385. get renderingGroupId(): number;
  33386. set renderingGroupId(value: number);
  33387. private _material;
  33388. /** Gets or sets current material */
  33389. get material(): Nullable<Material>;
  33390. set material(value: Nullable<Material>);
  33391. /**
  33392. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33393. * @see https://doc.babylonjs.com/babylon101/shadows
  33394. */
  33395. get receiveShadows(): boolean;
  33396. set receiveShadows(value: boolean);
  33397. /** Defines color to use when rendering outline */
  33398. outlineColor: Color3;
  33399. /** Define width to use when rendering outline */
  33400. outlineWidth: number;
  33401. /** Defines color to use when rendering overlay */
  33402. overlayColor: Color3;
  33403. /** Defines alpha to use when rendering overlay */
  33404. overlayAlpha: number;
  33405. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33406. get hasVertexAlpha(): boolean;
  33407. set hasVertexAlpha(value: boolean);
  33408. /** 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) */
  33409. get useVertexColors(): boolean;
  33410. set useVertexColors(value: boolean);
  33411. /**
  33412. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33413. */
  33414. get computeBonesUsingShaders(): boolean;
  33415. set computeBonesUsingShaders(value: boolean);
  33416. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33417. get numBoneInfluencers(): number;
  33418. set numBoneInfluencers(value: number);
  33419. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33420. get applyFog(): boolean;
  33421. set applyFog(value: boolean);
  33422. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33423. useOctreeForRenderingSelection: boolean;
  33424. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33425. useOctreeForPicking: boolean;
  33426. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33427. useOctreeForCollisions: boolean;
  33428. /**
  33429. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33430. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33431. */
  33432. get layerMask(): number;
  33433. set layerMask(value: number);
  33434. /**
  33435. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33436. */
  33437. alwaysSelectAsActiveMesh: boolean;
  33438. /**
  33439. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33440. */
  33441. doNotSyncBoundingInfo: boolean;
  33442. /**
  33443. * Gets or sets the current action manager
  33444. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33445. */
  33446. actionManager: Nullable<AbstractActionManager>;
  33447. private _meshCollisionData;
  33448. /**
  33449. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33450. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33451. */
  33452. ellipsoid: Vector3;
  33453. /**
  33454. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33455. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33456. */
  33457. ellipsoidOffset: Vector3;
  33458. /**
  33459. * Gets or sets a collision mask used to mask collisions (default is -1).
  33460. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33461. */
  33462. get collisionMask(): number;
  33463. set collisionMask(mask: number);
  33464. /**
  33465. * Gets or sets a collision response flag (default is true).
  33466. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33467. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33468. * to respond to the collision.
  33469. */
  33470. get collisionResponse(): boolean;
  33471. set collisionResponse(response: boolean);
  33472. /**
  33473. * Gets or sets the current collision group mask (-1 by default).
  33474. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33475. */
  33476. get collisionGroup(): number;
  33477. set collisionGroup(mask: number);
  33478. /**
  33479. * Gets or sets current surrounding meshes (null by default).
  33480. *
  33481. * By default collision detection is tested against every mesh in the scene.
  33482. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33483. * meshes will be tested for the collision.
  33484. *
  33485. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33486. */
  33487. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33488. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33489. /**
  33490. * Defines edge width used when edgesRenderer is enabled
  33491. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33492. */
  33493. edgesWidth: number;
  33494. /**
  33495. * Defines edge color used when edgesRenderer is enabled
  33496. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33497. */
  33498. edgesColor: Color4;
  33499. /** @hidden */
  33500. _edgesRenderer: Nullable<IEdgesRenderer>;
  33501. /** @hidden */
  33502. _masterMesh: Nullable<AbstractMesh>;
  33503. /** @hidden */
  33504. _boundingInfo: Nullable<BoundingInfo>;
  33505. /** @hidden */
  33506. _renderId: number;
  33507. /**
  33508. * Gets or sets the list of subMeshes
  33509. * @see https://doc.babylonjs.com/how_to/multi_materials
  33510. */
  33511. subMeshes: SubMesh[];
  33512. /** @hidden */
  33513. _intersectionsInProgress: AbstractMesh[];
  33514. /** @hidden */
  33515. _unIndexed: boolean;
  33516. /** @hidden */
  33517. _lightSources: Light[];
  33518. /** Gets the list of lights affecting that mesh */
  33519. get lightSources(): Light[];
  33520. /** @hidden */
  33521. get _positions(): Nullable<Vector3[]>;
  33522. /** @hidden */
  33523. _waitingData: {
  33524. lods: Nullable<any>;
  33525. actions: Nullable<any>;
  33526. freezeWorldMatrix: Nullable<boolean>;
  33527. };
  33528. /** @hidden */
  33529. _bonesTransformMatrices: Nullable<Float32Array>;
  33530. /** @hidden */
  33531. _transformMatrixTexture: Nullable<RawTexture>;
  33532. /**
  33533. * Gets or sets a skeleton to apply skining transformations
  33534. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33535. */
  33536. set skeleton(value: Nullable<Skeleton>);
  33537. get skeleton(): Nullable<Skeleton>;
  33538. /**
  33539. * An event triggered when the mesh is rebuilt.
  33540. */
  33541. onRebuildObservable: Observable<AbstractMesh>;
  33542. /**
  33543. * Creates a new AbstractMesh
  33544. * @param name defines the name of the mesh
  33545. * @param scene defines the hosting scene
  33546. */
  33547. constructor(name: string, scene?: Nullable<Scene>);
  33548. /**
  33549. * Returns the string "AbstractMesh"
  33550. * @returns "AbstractMesh"
  33551. */
  33552. getClassName(): string;
  33553. /**
  33554. * Gets a string representation of the current mesh
  33555. * @param fullDetails defines a boolean indicating if full details must be included
  33556. * @returns a string representation of the current mesh
  33557. */
  33558. toString(fullDetails?: boolean): string;
  33559. /**
  33560. * @hidden
  33561. */
  33562. protected _getEffectiveParent(): Nullable<Node>;
  33563. /** @hidden */
  33564. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33565. /** @hidden */
  33566. _rebuild(): void;
  33567. /** @hidden */
  33568. _resyncLightSources(): void;
  33569. /** @hidden */
  33570. _resyncLightSource(light: Light): void;
  33571. /** @hidden */
  33572. _unBindEffect(): void;
  33573. /** @hidden */
  33574. _removeLightSource(light: Light, dispose: boolean): void;
  33575. private _markSubMeshesAsDirty;
  33576. /** @hidden */
  33577. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33578. /** @hidden */
  33579. _markSubMeshesAsAttributesDirty(): void;
  33580. /** @hidden */
  33581. _markSubMeshesAsMiscDirty(): void;
  33582. /**
  33583. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33584. */
  33585. get scaling(): Vector3;
  33586. set scaling(newScaling: Vector3);
  33587. /**
  33588. * Returns true if the mesh is blocked. Implemented by child classes
  33589. */
  33590. get isBlocked(): boolean;
  33591. /**
  33592. * Returns the mesh itself by default. Implemented by child classes
  33593. * @param camera defines the camera to use to pick the right LOD level
  33594. * @returns the currentAbstractMesh
  33595. */
  33596. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33597. /**
  33598. * Returns 0 by default. Implemented by child classes
  33599. * @returns an integer
  33600. */
  33601. getTotalVertices(): number;
  33602. /**
  33603. * Returns a positive integer : the total number of indices in this mesh geometry.
  33604. * @returns the numner of indices or zero if the mesh has no geometry.
  33605. */
  33606. getTotalIndices(): number;
  33607. /**
  33608. * Returns null by default. Implemented by child classes
  33609. * @returns null
  33610. */
  33611. getIndices(): Nullable<IndicesArray>;
  33612. /**
  33613. * Returns the array of the requested vertex data kind. Implemented by child classes
  33614. * @param kind defines the vertex data kind to use
  33615. * @returns null
  33616. */
  33617. getVerticesData(kind: string): Nullable<FloatArray>;
  33618. /**
  33619. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33620. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33621. * Note that a new underlying VertexBuffer object is created each call.
  33622. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33623. * @param kind defines vertex data kind:
  33624. * * VertexBuffer.PositionKind
  33625. * * VertexBuffer.UVKind
  33626. * * VertexBuffer.UV2Kind
  33627. * * VertexBuffer.UV3Kind
  33628. * * VertexBuffer.UV4Kind
  33629. * * VertexBuffer.UV5Kind
  33630. * * VertexBuffer.UV6Kind
  33631. * * VertexBuffer.ColorKind
  33632. * * VertexBuffer.MatricesIndicesKind
  33633. * * VertexBuffer.MatricesIndicesExtraKind
  33634. * * VertexBuffer.MatricesWeightsKind
  33635. * * VertexBuffer.MatricesWeightsExtraKind
  33636. * @param data defines the data source
  33637. * @param updatable defines if the data must be flagged as updatable (or static)
  33638. * @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
  33639. * @returns the current mesh
  33640. */
  33641. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33642. /**
  33643. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33644. * If the mesh has no geometry, it is simply returned as it is.
  33645. * @param kind defines vertex data kind:
  33646. * * VertexBuffer.PositionKind
  33647. * * VertexBuffer.UVKind
  33648. * * VertexBuffer.UV2Kind
  33649. * * VertexBuffer.UV3Kind
  33650. * * VertexBuffer.UV4Kind
  33651. * * VertexBuffer.UV5Kind
  33652. * * VertexBuffer.UV6Kind
  33653. * * VertexBuffer.ColorKind
  33654. * * VertexBuffer.MatricesIndicesKind
  33655. * * VertexBuffer.MatricesIndicesExtraKind
  33656. * * VertexBuffer.MatricesWeightsKind
  33657. * * VertexBuffer.MatricesWeightsExtraKind
  33658. * @param data defines the data source
  33659. * @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
  33660. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33661. * @returns the current mesh
  33662. */
  33663. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33664. /**
  33665. * Sets the mesh indices,
  33666. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33667. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33668. * @param totalVertices Defines the total number of vertices
  33669. * @returns the current mesh
  33670. */
  33671. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33672. /**
  33673. * Gets a boolean indicating if specific vertex data is present
  33674. * @param kind defines the vertex data kind to use
  33675. * @returns true is data kind is present
  33676. */
  33677. isVerticesDataPresent(kind: string): boolean;
  33678. /**
  33679. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33680. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33681. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33682. * @returns a BoundingInfo
  33683. */
  33684. getBoundingInfo(): BoundingInfo;
  33685. /**
  33686. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33687. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33688. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33689. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33690. * @returns the current mesh
  33691. */
  33692. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33693. /**
  33694. * Overwrite the current bounding info
  33695. * @param boundingInfo defines the new bounding info
  33696. * @returns the current mesh
  33697. */
  33698. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33699. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33700. get useBones(): boolean;
  33701. /** @hidden */
  33702. _preActivate(): void;
  33703. /** @hidden */
  33704. _preActivateForIntermediateRendering(renderId: number): void;
  33705. /** @hidden */
  33706. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33707. /** @hidden */
  33708. _postActivate(): void;
  33709. /** @hidden */
  33710. _freeze(): void;
  33711. /** @hidden */
  33712. _unFreeze(): void;
  33713. /**
  33714. * Gets the current world matrix
  33715. * @returns a Matrix
  33716. */
  33717. getWorldMatrix(): Matrix;
  33718. /** @hidden */
  33719. _getWorldMatrixDeterminant(): number;
  33720. /**
  33721. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33722. */
  33723. get isAnInstance(): boolean;
  33724. /**
  33725. * Gets a boolean indicating if this mesh has instances
  33726. */
  33727. get hasInstances(): boolean;
  33728. /**
  33729. * Gets a boolean indicating if this mesh has thin instances
  33730. */
  33731. get hasThinInstances(): boolean;
  33732. /**
  33733. * Perform relative position change from the point of view of behind the front of the mesh.
  33734. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33735. * Supports definition of mesh facing forward or backward
  33736. * @param amountRight defines the distance on the right axis
  33737. * @param amountUp defines the distance on the up axis
  33738. * @param amountForward defines the distance on the forward axis
  33739. * @returns the current mesh
  33740. */
  33741. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33742. /**
  33743. * Calculate relative position change from the point of view of behind the front of the mesh.
  33744. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33745. * Supports definition of mesh facing forward or backward
  33746. * @param amountRight defines the distance on the right axis
  33747. * @param amountUp defines the distance on the up axis
  33748. * @param amountForward defines the distance on the forward axis
  33749. * @returns the new displacement vector
  33750. */
  33751. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33752. /**
  33753. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33754. * Supports definition of mesh facing forward or backward
  33755. * @param flipBack defines the flip
  33756. * @param twirlClockwise defines the twirl
  33757. * @param tiltRight defines the tilt
  33758. * @returns the current mesh
  33759. */
  33760. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33761. /**
  33762. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33763. * Supports definition of mesh facing forward or backward.
  33764. * @param flipBack defines the flip
  33765. * @param twirlClockwise defines the twirl
  33766. * @param tiltRight defines the tilt
  33767. * @returns the new rotation vector
  33768. */
  33769. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33770. /**
  33771. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33772. * This means the mesh underlying bounding box and sphere are recomputed.
  33773. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33774. * @returns the current mesh
  33775. */
  33776. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33777. /** @hidden */
  33778. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33779. /** @hidden */
  33780. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33781. /** @hidden */
  33782. _updateBoundingInfo(): AbstractMesh;
  33783. /** @hidden */
  33784. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33785. /** @hidden */
  33786. protected _afterComputeWorldMatrix(): void;
  33787. /** @hidden */
  33788. get _effectiveMesh(): AbstractMesh;
  33789. /**
  33790. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33791. * A mesh is in the frustum if its bounding box intersects the frustum
  33792. * @param frustumPlanes defines the frustum to test
  33793. * @returns true if the mesh is in the frustum planes
  33794. */
  33795. isInFrustum(frustumPlanes: Plane[]): boolean;
  33796. /**
  33797. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33798. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33799. * @param frustumPlanes defines the frustum to test
  33800. * @returns true if the mesh is completely in the frustum planes
  33801. */
  33802. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33803. /**
  33804. * True if the mesh intersects another mesh or a SolidParticle object
  33805. * @param mesh defines a target mesh or SolidParticle to test
  33806. * @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)
  33807. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33808. * @returns true if there is an intersection
  33809. */
  33810. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33811. /**
  33812. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33813. * @param point defines the point to test
  33814. * @returns true if there is an intersection
  33815. */
  33816. intersectsPoint(point: Vector3): boolean;
  33817. /**
  33818. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33819. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33820. */
  33821. get checkCollisions(): boolean;
  33822. set checkCollisions(collisionEnabled: boolean);
  33823. /**
  33824. * Gets Collider object used to compute collisions (not physics)
  33825. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33826. */
  33827. get collider(): Nullable<Collider>;
  33828. /**
  33829. * Move the mesh using collision engine
  33830. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33831. * @param displacement defines the requested displacement vector
  33832. * @returns the current mesh
  33833. */
  33834. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33835. private _onCollisionPositionChange;
  33836. /** @hidden */
  33837. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33838. /** @hidden */
  33839. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33840. /** @hidden */
  33841. _checkCollision(collider: Collider): AbstractMesh;
  33842. /** @hidden */
  33843. _generatePointsArray(): boolean;
  33844. /**
  33845. * Checks if the passed Ray intersects with the mesh
  33846. * @param ray defines the ray to use
  33847. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33848. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33849. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33850. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33851. * @returns the picking info
  33852. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33853. */
  33854. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33855. /**
  33856. * Clones the current mesh
  33857. * @param name defines the mesh name
  33858. * @param newParent defines the new mesh parent
  33859. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33860. * @returns the new mesh
  33861. */
  33862. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33863. /**
  33864. * Disposes all the submeshes of the current meshnp
  33865. * @returns the current mesh
  33866. */
  33867. releaseSubMeshes(): AbstractMesh;
  33868. /**
  33869. * Releases resources associated with this abstract mesh.
  33870. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33871. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33872. */
  33873. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33874. /**
  33875. * Adds the passed mesh as a child to the current mesh
  33876. * @param mesh defines the child mesh
  33877. * @returns the current mesh
  33878. */
  33879. addChild(mesh: AbstractMesh): AbstractMesh;
  33880. /**
  33881. * Removes the passed mesh from the current mesh children list
  33882. * @param mesh defines the child mesh
  33883. * @returns the current mesh
  33884. */
  33885. removeChild(mesh: AbstractMesh): AbstractMesh;
  33886. /** @hidden */
  33887. private _initFacetData;
  33888. /**
  33889. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33890. * This method can be called within the render loop.
  33891. * 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
  33892. * @returns the current mesh
  33893. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33894. */
  33895. updateFacetData(): AbstractMesh;
  33896. /**
  33897. * Returns the facetLocalNormals array.
  33898. * The normals are expressed in the mesh local spac
  33899. * @returns an array of Vector3
  33900. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33901. */
  33902. getFacetLocalNormals(): Vector3[];
  33903. /**
  33904. * Returns the facetLocalPositions array.
  33905. * The facet positions are expressed in the mesh local space
  33906. * @returns an array of Vector3
  33907. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33908. */
  33909. getFacetLocalPositions(): Vector3[];
  33910. /**
  33911. * Returns the facetLocalPartioning array
  33912. * @returns an array of array of numbers
  33913. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33914. */
  33915. getFacetLocalPartitioning(): number[][];
  33916. /**
  33917. * Returns the i-th facet position in the world system.
  33918. * This method allocates a new Vector3 per call
  33919. * @param i defines the facet index
  33920. * @returns a new Vector3
  33921. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33922. */
  33923. getFacetPosition(i: number): Vector3;
  33924. /**
  33925. * Sets the reference Vector3 with the i-th facet position in the world system
  33926. * @param i defines the facet index
  33927. * @param ref defines the target vector
  33928. * @returns the current mesh
  33929. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33930. */
  33931. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33932. /**
  33933. * Returns the i-th facet normal in the world system.
  33934. * This method allocates a new Vector3 per call
  33935. * @param i defines the facet index
  33936. * @returns a new Vector3
  33937. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33938. */
  33939. getFacetNormal(i: number): Vector3;
  33940. /**
  33941. * Sets the reference Vector3 with the i-th facet normal in the world system
  33942. * @param i defines the facet index
  33943. * @param ref defines the target vector
  33944. * @returns the current mesh
  33945. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33946. */
  33947. getFacetNormalToRef(i: number, ref: Vector3): this;
  33948. /**
  33949. * 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)
  33950. * @param x defines x coordinate
  33951. * @param y defines y coordinate
  33952. * @param z defines z coordinate
  33953. * @returns the array of facet indexes
  33954. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33955. */
  33956. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33957. /**
  33958. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33959. * @param projected sets as the (x,y,z) world projection on the facet
  33960. * @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
  33961. * @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
  33962. * @param x defines x coordinate
  33963. * @param y defines y coordinate
  33964. * @param z defines z coordinate
  33965. * @returns the face index if found (or null instead)
  33966. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33967. */
  33968. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33969. /**
  33970. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33971. * @param projected sets as the (x,y,z) local projection on the facet
  33972. * @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
  33973. * @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
  33974. * @param x defines x coordinate
  33975. * @param y defines y coordinate
  33976. * @param z defines z coordinate
  33977. * @returns the face index if found (or null instead)
  33978. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33979. */
  33980. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33981. /**
  33982. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33983. * @returns the parameters
  33984. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33985. */
  33986. getFacetDataParameters(): any;
  33987. /**
  33988. * Disables the feature FacetData and frees the related memory
  33989. * @returns the current mesh
  33990. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33991. */
  33992. disableFacetData(): AbstractMesh;
  33993. /**
  33994. * Updates the AbstractMesh indices array
  33995. * @param indices defines the data source
  33996. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33997. * @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)
  33998. * @returns the current mesh
  33999. */
  34000. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34001. /**
  34002. * Creates new normals data for the mesh
  34003. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  34004. * @returns the current mesh
  34005. */
  34006. createNormals(updatable: boolean): AbstractMesh;
  34007. /**
  34008. * Align the mesh with a normal
  34009. * @param normal defines the normal to use
  34010. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  34011. * @returns the current mesh
  34012. */
  34013. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  34014. /** @hidden */
  34015. _checkOcclusionQuery(): boolean;
  34016. /**
  34017. * Disables the mesh edge rendering mode
  34018. * @returns the currentAbstractMesh
  34019. */
  34020. disableEdgesRendering(): AbstractMesh;
  34021. /**
  34022. * Enables the edge rendering mode on the mesh.
  34023. * This mode makes the mesh edges visible
  34024. * @param epsilon defines the maximal distance between two angles to detect a face
  34025. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34026. * @returns the currentAbstractMesh
  34027. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34028. */
  34029. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34030. /**
  34031. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  34032. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34033. */
  34034. getConnectedParticleSystems(): IParticleSystem[];
  34035. }
  34036. }
  34037. declare module "babylonjs/Actions/actionEvent" {
  34038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34039. import { Nullable } from "babylonjs/types";
  34040. import { Sprite } from "babylonjs/Sprites/sprite";
  34041. import { Scene } from "babylonjs/scene";
  34042. import { Vector2 } from "babylonjs/Maths/math.vector";
  34043. /**
  34044. * Interface used to define ActionEvent
  34045. */
  34046. export interface IActionEvent {
  34047. /** The mesh or sprite that triggered the action */
  34048. source: any;
  34049. /** The X mouse cursor position at the time of the event */
  34050. pointerX: number;
  34051. /** The Y mouse cursor position at the time of the event */
  34052. pointerY: number;
  34053. /** The mesh that is currently pointed at (can be null) */
  34054. meshUnderPointer: Nullable<AbstractMesh>;
  34055. /** the original (browser) event that triggered the ActionEvent */
  34056. sourceEvent?: any;
  34057. /** additional data for the event */
  34058. additionalData?: any;
  34059. }
  34060. /**
  34061. * ActionEvent is the event being sent when an action is triggered.
  34062. */
  34063. export class ActionEvent implements IActionEvent {
  34064. /** The mesh or sprite that triggered the action */
  34065. source: any;
  34066. /** The X mouse cursor position at the time of the event */
  34067. pointerX: number;
  34068. /** The Y mouse cursor position at the time of the event */
  34069. pointerY: number;
  34070. /** The mesh that is currently pointed at (can be null) */
  34071. meshUnderPointer: Nullable<AbstractMesh>;
  34072. /** the original (browser) event that triggered the ActionEvent */
  34073. sourceEvent?: any;
  34074. /** additional data for the event */
  34075. additionalData?: any;
  34076. /**
  34077. * Creates a new ActionEvent
  34078. * @param source The mesh or sprite that triggered the action
  34079. * @param pointerX The X mouse cursor position at the time of the event
  34080. * @param pointerY The Y mouse cursor position at the time of the event
  34081. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34082. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34083. * @param additionalData additional data for the event
  34084. */
  34085. constructor(
  34086. /** The mesh or sprite that triggered the action */
  34087. source: any,
  34088. /** The X mouse cursor position at the time of the event */
  34089. pointerX: number,
  34090. /** The Y mouse cursor position at the time of the event */
  34091. pointerY: number,
  34092. /** The mesh that is currently pointed at (can be null) */
  34093. meshUnderPointer: Nullable<AbstractMesh>,
  34094. /** the original (browser) event that triggered the ActionEvent */
  34095. sourceEvent?: any,
  34096. /** additional data for the event */
  34097. additionalData?: any);
  34098. /**
  34099. * Helper function to auto-create an ActionEvent from a source mesh.
  34100. * @param source The source mesh that triggered the event
  34101. * @param evt The original (browser) event
  34102. * @param additionalData additional data for the event
  34103. * @returns the new ActionEvent
  34104. */
  34105. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34106. /**
  34107. * Helper function to auto-create an ActionEvent from a source sprite
  34108. * @param source The source sprite that triggered the event
  34109. * @param scene Scene associated with the sprite
  34110. * @param evt The original (browser) event
  34111. * @param additionalData additional data for the event
  34112. * @returns the new ActionEvent
  34113. */
  34114. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34115. /**
  34116. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34117. * @param scene the scene where the event occurred
  34118. * @param evt The original (browser) event
  34119. * @returns the new ActionEvent
  34120. */
  34121. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34122. /**
  34123. * Helper function to auto-create an ActionEvent from a primitive
  34124. * @param prim defines the target primitive
  34125. * @param pointerPos defines the pointer position
  34126. * @param evt The original (browser) event
  34127. * @param additionalData additional data for the event
  34128. * @returns the new ActionEvent
  34129. */
  34130. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34131. }
  34132. }
  34133. declare module "babylonjs/Actions/abstractActionManager" {
  34134. import { IDisposable } from "babylonjs/scene";
  34135. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34136. import { IAction } from "babylonjs/Actions/action";
  34137. import { Nullable } from "babylonjs/types";
  34138. /**
  34139. * Abstract class used to decouple action Manager from scene and meshes.
  34140. * Do not instantiate.
  34141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34142. */
  34143. export abstract class AbstractActionManager implements IDisposable {
  34144. /** Gets the list of active triggers */
  34145. static Triggers: {
  34146. [key: string]: number;
  34147. };
  34148. /** Gets the cursor to use when hovering items */
  34149. hoverCursor: string;
  34150. /** Gets the list of actions */
  34151. actions: IAction[];
  34152. /**
  34153. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34154. */
  34155. isRecursive: boolean;
  34156. /**
  34157. * Releases all associated resources
  34158. */
  34159. abstract dispose(): void;
  34160. /**
  34161. * Does this action manager has pointer triggers
  34162. */
  34163. abstract get hasPointerTriggers(): boolean;
  34164. /**
  34165. * Does this action manager has pick triggers
  34166. */
  34167. abstract get hasPickTriggers(): boolean;
  34168. /**
  34169. * Process a specific trigger
  34170. * @param trigger defines the trigger to process
  34171. * @param evt defines the event details to be processed
  34172. */
  34173. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34174. /**
  34175. * Does this action manager handles actions of any of the given triggers
  34176. * @param triggers defines the triggers to be tested
  34177. * @return a boolean indicating whether one (or more) of the triggers is handled
  34178. */
  34179. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34180. /**
  34181. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34182. * speed.
  34183. * @param triggerA defines the trigger to be tested
  34184. * @param triggerB defines the trigger to be tested
  34185. * @return a boolean indicating whether one (or more) of the triggers is handled
  34186. */
  34187. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34188. /**
  34189. * Does this action manager handles actions of a given trigger
  34190. * @param trigger defines the trigger to be tested
  34191. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34192. * @return whether the trigger is handled
  34193. */
  34194. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34195. /**
  34196. * Serialize this manager to a JSON object
  34197. * @param name defines the property name to store this manager
  34198. * @returns a JSON representation of this manager
  34199. */
  34200. abstract serialize(name: string): any;
  34201. /**
  34202. * Registers an action to this action manager
  34203. * @param action defines the action to be registered
  34204. * @return the action amended (prepared) after registration
  34205. */
  34206. abstract registerAction(action: IAction): Nullable<IAction>;
  34207. /**
  34208. * Unregisters an action to this action manager
  34209. * @param action defines the action to be unregistered
  34210. * @return a boolean indicating whether the action has been unregistered
  34211. */
  34212. abstract unregisterAction(action: IAction): Boolean;
  34213. /**
  34214. * Does exist one action manager with at least one trigger
  34215. **/
  34216. static get HasTriggers(): boolean;
  34217. /**
  34218. * Does exist one action manager with at least one pick trigger
  34219. **/
  34220. static get HasPickTriggers(): boolean;
  34221. /**
  34222. * Does exist one action manager that handles actions of a given trigger
  34223. * @param trigger defines the trigger to be tested
  34224. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34225. **/
  34226. static HasSpecificTrigger(trigger: number): boolean;
  34227. }
  34228. }
  34229. declare module "babylonjs/node" {
  34230. import { Scene } from "babylonjs/scene";
  34231. import { Nullable } from "babylonjs/types";
  34232. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34233. import { Engine } from "babylonjs/Engines/engine";
  34234. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34235. import { Observable } from "babylonjs/Misc/observable";
  34236. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34237. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34238. import { Animatable } from "babylonjs/Animations/animatable";
  34239. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34240. import { Animation } from "babylonjs/Animations/animation";
  34241. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34243. /**
  34244. * Defines how a node can be built from a string name.
  34245. */
  34246. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34247. /**
  34248. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34249. */
  34250. export class Node implements IBehaviorAware<Node> {
  34251. /** @hidden */
  34252. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34253. private static _NodeConstructors;
  34254. /**
  34255. * Add a new node constructor
  34256. * @param type defines the type name of the node to construct
  34257. * @param constructorFunc defines the constructor function
  34258. */
  34259. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34260. /**
  34261. * Returns a node constructor based on type name
  34262. * @param type defines the type name
  34263. * @param name defines the new node name
  34264. * @param scene defines the hosting scene
  34265. * @param options defines optional options to transmit to constructors
  34266. * @returns the new constructor or null
  34267. */
  34268. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34269. /**
  34270. * Gets or sets the name of the node
  34271. */
  34272. name: string;
  34273. /**
  34274. * Gets or sets the id of the node
  34275. */
  34276. id: string;
  34277. /**
  34278. * Gets or sets the unique id of the node
  34279. */
  34280. uniqueId: number;
  34281. /**
  34282. * Gets or sets a string used to store user defined state for the node
  34283. */
  34284. state: string;
  34285. /**
  34286. * Gets or sets an object used to store user defined information for the node
  34287. */
  34288. metadata: any;
  34289. /**
  34290. * For internal use only. Please do not use.
  34291. */
  34292. reservedDataStore: any;
  34293. /**
  34294. * List of inspectable custom properties (used by the Inspector)
  34295. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34296. */
  34297. inspectableCustomProperties: IInspectable[];
  34298. private _doNotSerialize;
  34299. /**
  34300. * Gets or sets a boolean used to define if the node must be serialized
  34301. */
  34302. get doNotSerialize(): boolean;
  34303. set doNotSerialize(value: boolean);
  34304. /** @hidden */
  34305. _isDisposed: boolean;
  34306. /**
  34307. * Gets a list of Animations associated with the node
  34308. */
  34309. animations: import("babylonjs/Animations/animation").Animation[];
  34310. protected _ranges: {
  34311. [name: string]: Nullable<AnimationRange>;
  34312. };
  34313. /**
  34314. * Callback raised when the node is ready to be used
  34315. */
  34316. onReady: Nullable<(node: Node) => void>;
  34317. private _isEnabled;
  34318. private _isParentEnabled;
  34319. private _isReady;
  34320. /** @hidden */
  34321. _currentRenderId: number;
  34322. private _parentUpdateId;
  34323. /** @hidden */
  34324. _childUpdateId: number;
  34325. /** @hidden */
  34326. _waitingParentId: Nullable<string>;
  34327. /** @hidden */
  34328. _scene: Scene;
  34329. /** @hidden */
  34330. _cache: any;
  34331. private _parentNode;
  34332. private _children;
  34333. /** @hidden */
  34334. _worldMatrix: Matrix;
  34335. /** @hidden */
  34336. _worldMatrixDeterminant: number;
  34337. /** @hidden */
  34338. _worldMatrixDeterminantIsDirty: boolean;
  34339. /** @hidden */
  34340. private _sceneRootNodesIndex;
  34341. /**
  34342. * Gets a boolean indicating if the node has been disposed
  34343. * @returns true if the node was disposed
  34344. */
  34345. isDisposed(): boolean;
  34346. /**
  34347. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34348. * @see https://doc.babylonjs.com/how_to/parenting
  34349. */
  34350. set parent(parent: Nullable<Node>);
  34351. get parent(): Nullable<Node>;
  34352. /** @hidden */
  34353. _addToSceneRootNodes(): void;
  34354. /** @hidden */
  34355. _removeFromSceneRootNodes(): void;
  34356. private _animationPropertiesOverride;
  34357. /**
  34358. * Gets or sets the animation properties override
  34359. */
  34360. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34361. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34362. /**
  34363. * Gets a string identifying the name of the class
  34364. * @returns "Node" string
  34365. */
  34366. getClassName(): string;
  34367. /** @hidden */
  34368. readonly _isNode: boolean;
  34369. /**
  34370. * An event triggered when the mesh is disposed
  34371. */
  34372. onDisposeObservable: Observable<Node>;
  34373. private _onDisposeObserver;
  34374. /**
  34375. * Sets a callback that will be raised when the node will be disposed
  34376. */
  34377. set onDispose(callback: () => void);
  34378. /**
  34379. * Creates a new Node
  34380. * @param name the name and id to be given to this node
  34381. * @param scene the scene this node will be added to
  34382. */
  34383. constructor(name: string, scene?: Nullable<Scene>);
  34384. /**
  34385. * Gets the scene of the node
  34386. * @returns a scene
  34387. */
  34388. getScene(): Scene;
  34389. /**
  34390. * Gets the engine of the node
  34391. * @returns a Engine
  34392. */
  34393. getEngine(): Engine;
  34394. private _behaviors;
  34395. /**
  34396. * Attach a behavior to the node
  34397. * @see https://doc.babylonjs.com/features/behaviour
  34398. * @param behavior defines the behavior to attach
  34399. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34400. * @returns the current Node
  34401. */
  34402. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34403. /**
  34404. * Remove an attached behavior
  34405. * @see https://doc.babylonjs.com/features/behaviour
  34406. * @param behavior defines the behavior to attach
  34407. * @returns the current Node
  34408. */
  34409. removeBehavior(behavior: Behavior<Node>): Node;
  34410. /**
  34411. * Gets the list of attached behaviors
  34412. * @see https://doc.babylonjs.com/features/behaviour
  34413. */
  34414. get behaviors(): Behavior<Node>[];
  34415. /**
  34416. * Gets an attached behavior by name
  34417. * @param name defines the name of the behavior to look for
  34418. * @see https://doc.babylonjs.com/features/behaviour
  34419. * @returns null if behavior was not found else the requested behavior
  34420. */
  34421. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34422. /**
  34423. * Returns the latest update of the World matrix
  34424. * @returns a Matrix
  34425. */
  34426. getWorldMatrix(): Matrix;
  34427. /** @hidden */
  34428. _getWorldMatrixDeterminant(): number;
  34429. /**
  34430. * Returns directly the latest state of the mesh World matrix.
  34431. * A Matrix is returned.
  34432. */
  34433. get worldMatrixFromCache(): Matrix;
  34434. /** @hidden */
  34435. _initCache(): void;
  34436. /** @hidden */
  34437. updateCache(force?: boolean): void;
  34438. /** @hidden */
  34439. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34440. /** @hidden */
  34441. _updateCache(ignoreParentClass?: boolean): void;
  34442. /** @hidden */
  34443. _isSynchronized(): boolean;
  34444. /** @hidden */
  34445. _markSyncedWithParent(): void;
  34446. /** @hidden */
  34447. isSynchronizedWithParent(): boolean;
  34448. /** @hidden */
  34449. isSynchronized(): boolean;
  34450. /**
  34451. * Is this node ready to be used/rendered
  34452. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34453. * @return true if the node is ready
  34454. */
  34455. isReady(completeCheck?: boolean): boolean;
  34456. /**
  34457. * Is this node enabled?
  34458. * 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
  34459. * @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
  34460. * @return whether this node (and its parent) is enabled
  34461. */
  34462. isEnabled(checkAncestors?: boolean): boolean;
  34463. /** @hidden */
  34464. protected _syncParentEnabledState(): void;
  34465. /**
  34466. * Set the enabled state of this node
  34467. * @param value defines the new enabled state
  34468. */
  34469. setEnabled(value: boolean): void;
  34470. /**
  34471. * Is this node a descendant of the given node?
  34472. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34473. * @param ancestor defines the parent node to inspect
  34474. * @returns a boolean indicating if this node is a descendant of the given node
  34475. */
  34476. isDescendantOf(ancestor: Node): boolean;
  34477. /** @hidden */
  34478. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34479. /**
  34480. * Will return all nodes that have this node as ascendant
  34481. * @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
  34482. * @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
  34483. * @return all children nodes of all types
  34484. */
  34485. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34486. /**
  34487. * Get all child-meshes of this node
  34488. * @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)
  34489. * @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
  34490. * @returns an array of AbstractMesh
  34491. */
  34492. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34493. /**
  34494. * Get all direct children of this node
  34495. * @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
  34496. * @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)
  34497. * @returns an array of Node
  34498. */
  34499. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34500. /** @hidden */
  34501. _setReady(state: boolean): void;
  34502. /**
  34503. * Get an animation by name
  34504. * @param name defines the name of the animation to look for
  34505. * @returns null if not found else the requested animation
  34506. */
  34507. getAnimationByName(name: string): Nullable<Animation>;
  34508. /**
  34509. * Creates an animation range for this node
  34510. * @param name defines the name of the range
  34511. * @param from defines the starting key
  34512. * @param to defines the end key
  34513. */
  34514. createAnimationRange(name: string, from: number, to: number): void;
  34515. /**
  34516. * Delete a specific animation range
  34517. * @param name defines the name of the range to delete
  34518. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34519. */
  34520. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34521. /**
  34522. * Get an animation range by name
  34523. * @param name defines the name of the animation range to look for
  34524. * @returns null if not found else the requested animation range
  34525. */
  34526. getAnimationRange(name: string): Nullable<AnimationRange>;
  34527. /**
  34528. * Gets the list of all animation ranges defined on this node
  34529. * @returns an array
  34530. */
  34531. getAnimationRanges(): Nullable<AnimationRange>[];
  34532. /**
  34533. * Will start the animation sequence
  34534. * @param name defines the range frames for animation sequence
  34535. * @param loop defines if the animation should loop (false by default)
  34536. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34537. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34538. * @returns the object created for this animation. If range does not exist, it will return null
  34539. */
  34540. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34541. /**
  34542. * Serialize animation ranges into a JSON compatible object
  34543. * @returns serialization object
  34544. */
  34545. serializeAnimationRanges(): any;
  34546. /**
  34547. * Computes the world matrix of the node
  34548. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34549. * @returns the world matrix
  34550. */
  34551. computeWorldMatrix(force?: boolean): Matrix;
  34552. /**
  34553. * Releases resources associated with this node.
  34554. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34555. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34556. */
  34557. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34558. /**
  34559. * Parse animation range data from a serialization object and store them into a given node
  34560. * @param node defines where to store the animation ranges
  34561. * @param parsedNode defines the serialization object to read data from
  34562. * @param scene defines the hosting scene
  34563. */
  34564. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34565. /**
  34566. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34567. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34568. * @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
  34569. * @returns the new bounding vectors
  34570. */
  34571. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34572. min: Vector3;
  34573. max: Vector3;
  34574. };
  34575. }
  34576. }
  34577. declare module "babylonjs/Animations/animation" {
  34578. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34579. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34580. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34581. import { Nullable } from "babylonjs/types";
  34582. import { Scene } from "babylonjs/scene";
  34583. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34584. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34585. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34586. import { Node } from "babylonjs/node";
  34587. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34588. import { Size } from "babylonjs/Maths/math.size";
  34589. import { Animatable } from "babylonjs/Animations/animatable";
  34590. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34591. /**
  34592. * @hidden
  34593. */
  34594. export class _IAnimationState {
  34595. key: number;
  34596. repeatCount: number;
  34597. workValue?: any;
  34598. loopMode?: number;
  34599. offsetValue?: any;
  34600. highLimitValue?: any;
  34601. }
  34602. /**
  34603. * Class used to store any kind of animation
  34604. */
  34605. export class Animation {
  34606. /**Name of the animation */
  34607. name: string;
  34608. /**Property to animate */
  34609. targetProperty: string;
  34610. /**The frames per second of the animation */
  34611. framePerSecond: number;
  34612. /**The data type of the animation */
  34613. dataType: number;
  34614. /**The loop mode of the animation */
  34615. loopMode?: number | undefined;
  34616. /**Specifies if blending should be enabled */
  34617. enableBlending?: boolean | undefined;
  34618. /**
  34619. * Use matrix interpolation instead of using direct key value when animating matrices
  34620. */
  34621. static AllowMatricesInterpolation: boolean;
  34622. /**
  34623. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34624. */
  34625. static AllowMatrixDecomposeForInterpolation: boolean;
  34626. /** Define the Url to load snippets */
  34627. static SnippetUrl: string;
  34628. /** Snippet ID if the animation was created from the snippet server */
  34629. snippetId: string;
  34630. /**
  34631. * Stores the key frames of the animation
  34632. */
  34633. private _keys;
  34634. /**
  34635. * Stores the easing function of the animation
  34636. */
  34637. private _easingFunction;
  34638. /**
  34639. * @hidden Internal use only
  34640. */
  34641. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34642. /**
  34643. * The set of event that will be linked to this animation
  34644. */
  34645. private _events;
  34646. /**
  34647. * Stores an array of target property paths
  34648. */
  34649. targetPropertyPath: string[];
  34650. /**
  34651. * Stores the blending speed of the animation
  34652. */
  34653. blendingSpeed: number;
  34654. /**
  34655. * Stores the animation ranges for the animation
  34656. */
  34657. private _ranges;
  34658. /**
  34659. * @hidden Internal use
  34660. */
  34661. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34662. /**
  34663. * Sets up an animation
  34664. * @param property The property to animate
  34665. * @param animationType The animation type to apply
  34666. * @param framePerSecond The frames per second of the animation
  34667. * @param easingFunction The easing function used in the animation
  34668. * @returns The created animation
  34669. */
  34670. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34671. /**
  34672. * Create and start an animation on a node
  34673. * @param name defines the name of the global animation that will be run on all nodes
  34674. * @param node defines the root node where the animation will take place
  34675. * @param targetProperty defines property to animate
  34676. * @param framePerSecond defines the number of frame per second yo use
  34677. * @param totalFrame defines the number of frames in total
  34678. * @param from defines the initial value
  34679. * @param to defines the final value
  34680. * @param loopMode defines which loop mode you want to use (off by default)
  34681. * @param easingFunction defines the easing function to use (linear by default)
  34682. * @param onAnimationEnd defines the callback to call when animation end
  34683. * @returns the animatable created for this animation
  34684. */
  34685. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34686. /**
  34687. * Create and start an animation on a node and its descendants
  34688. * @param name defines the name of the global animation that will be run on all nodes
  34689. * @param node defines the root node where the animation will take place
  34690. * @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
  34691. * @param targetProperty defines property to animate
  34692. * @param framePerSecond defines the number of frame per second to use
  34693. * @param totalFrame defines the number of frames in total
  34694. * @param from defines the initial value
  34695. * @param to defines the final value
  34696. * @param loopMode defines which loop mode you want to use (off by default)
  34697. * @param easingFunction defines the easing function to use (linear by default)
  34698. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34699. * @returns the list of animatables created for all nodes
  34700. * @example https://www.babylonjs-playground.com/#MH0VLI
  34701. */
  34702. 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[]>;
  34703. /**
  34704. * Creates a new animation, merges it with the existing animations and starts it
  34705. * @param name Name of the animation
  34706. * @param node Node which contains the scene that begins the animations
  34707. * @param targetProperty Specifies which property to animate
  34708. * @param framePerSecond The frames per second of the animation
  34709. * @param totalFrame The total number of frames
  34710. * @param from The frame at the beginning of the animation
  34711. * @param to The frame at the end of the animation
  34712. * @param loopMode Specifies the loop mode of the animation
  34713. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34714. * @param onAnimationEnd Callback to run once the animation is complete
  34715. * @returns Nullable animation
  34716. */
  34717. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34718. /**
  34719. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34720. * @param sourceAnimation defines the Animation containing keyframes to convert
  34721. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34722. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34723. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34724. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34725. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34726. */
  34727. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34728. /**
  34729. * Transition property of an host to the target Value
  34730. * @param property The property to transition
  34731. * @param targetValue The target Value of the property
  34732. * @param host The object where the property to animate belongs
  34733. * @param scene Scene used to run the animation
  34734. * @param frameRate Framerate (in frame/s) to use
  34735. * @param transition The transition type we want to use
  34736. * @param duration The duration of the animation, in milliseconds
  34737. * @param onAnimationEnd Callback trigger at the end of the animation
  34738. * @returns Nullable animation
  34739. */
  34740. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34741. /**
  34742. * Return the array of runtime animations currently using this animation
  34743. */
  34744. get runtimeAnimations(): RuntimeAnimation[];
  34745. /**
  34746. * Specifies if any of the runtime animations are currently running
  34747. */
  34748. get hasRunningRuntimeAnimations(): boolean;
  34749. /**
  34750. * Initializes the animation
  34751. * @param name Name of the animation
  34752. * @param targetProperty Property to animate
  34753. * @param framePerSecond The frames per second of the animation
  34754. * @param dataType The data type of the animation
  34755. * @param loopMode The loop mode of the animation
  34756. * @param enableBlending Specifies if blending should be enabled
  34757. */
  34758. constructor(
  34759. /**Name of the animation */
  34760. name: string,
  34761. /**Property to animate */
  34762. targetProperty: string,
  34763. /**The frames per second of the animation */
  34764. framePerSecond: number,
  34765. /**The data type of the animation */
  34766. dataType: number,
  34767. /**The loop mode of the animation */
  34768. loopMode?: number | undefined,
  34769. /**Specifies if blending should be enabled */
  34770. enableBlending?: boolean | undefined);
  34771. /**
  34772. * Converts the animation to a string
  34773. * @param fullDetails support for multiple levels of logging within scene loading
  34774. * @returns String form of the animation
  34775. */
  34776. toString(fullDetails?: boolean): string;
  34777. /**
  34778. * Add an event to this animation
  34779. * @param event Event to add
  34780. */
  34781. addEvent(event: AnimationEvent): void;
  34782. /**
  34783. * Remove all events found at the given frame
  34784. * @param frame The frame to remove events from
  34785. */
  34786. removeEvents(frame: number): void;
  34787. /**
  34788. * Retrieves all the events from the animation
  34789. * @returns Events from the animation
  34790. */
  34791. getEvents(): AnimationEvent[];
  34792. /**
  34793. * Creates an animation range
  34794. * @param name Name of the animation range
  34795. * @param from Starting frame of the animation range
  34796. * @param to Ending frame of the animation
  34797. */
  34798. createRange(name: string, from: number, to: number): void;
  34799. /**
  34800. * Deletes an animation range by name
  34801. * @param name Name of the animation range to delete
  34802. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34803. */
  34804. deleteRange(name: string, deleteFrames?: boolean): void;
  34805. /**
  34806. * Gets the animation range by name, or null if not defined
  34807. * @param name Name of the animation range
  34808. * @returns Nullable animation range
  34809. */
  34810. getRange(name: string): Nullable<AnimationRange>;
  34811. /**
  34812. * Gets the key frames from the animation
  34813. * @returns The key frames of the animation
  34814. */
  34815. getKeys(): Array<IAnimationKey>;
  34816. /**
  34817. * Gets the highest frame rate of the animation
  34818. * @returns Highest frame rate of the animation
  34819. */
  34820. getHighestFrame(): number;
  34821. /**
  34822. * Gets the easing function of the animation
  34823. * @returns Easing function of the animation
  34824. */
  34825. getEasingFunction(): IEasingFunction;
  34826. /**
  34827. * Sets the easing function of the animation
  34828. * @param easingFunction A custom mathematical formula for animation
  34829. */
  34830. setEasingFunction(easingFunction: EasingFunction): void;
  34831. /**
  34832. * Interpolates a scalar linearly
  34833. * @param startValue Start value of the animation curve
  34834. * @param endValue End value of the animation curve
  34835. * @param gradient Scalar amount to interpolate
  34836. * @returns Interpolated scalar value
  34837. */
  34838. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34839. /**
  34840. * Interpolates a scalar cubically
  34841. * @param startValue Start value of the animation curve
  34842. * @param outTangent End tangent of the animation
  34843. * @param endValue End value of the animation curve
  34844. * @param inTangent Start tangent of the animation curve
  34845. * @param gradient Scalar amount to interpolate
  34846. * @returns Interpolated scalar value
  34847. */
  34848. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34849. /**
  34850. * Interpolates a quaternion using a spherical linear interpolation
  34851. * @param startValue Start value of the animation curve
  34852. * @param endValue End value of the animation curve
  34853. * @param gradient Scalar amount to interpolate
  34854. * @returns Interpolated quaternion value
  34855. */
  34856. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34857. /**
  34858. * Interpolates a quaternion cubically
  34859. * @param startValue Start value of the animation curve
  34860. * @param outTangent End tangent of the animation curve
  34861. * @param endValue End value of the animation curve
  34862. * @param inTangent Start tangent of the animation curve
  34863. * @param gradient Scalar amount to interpolate
  34864. * @returns Interpolated quaternion value
  34865. */
  34866. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34867. /**
  34868. * Interpolates a Vector3 linearl
  34869. * @param startValue Start value of the animation curve
  34870. * @param endValue End value of the animation curve
  34871. * @param gradient Scalar amount to interpolate
  34872. * @returns Interpolated scalar value
  34873. */
  34874. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34875. /**
  34876. * Interpolates a Vector3 cubically
  34877. * @param startValue Start value of the animation curve
  34878. * @param outTangent End tangent of the animation
  34879. * @param endValue End value of the animation curve
  34880. * @param inTangent Start tangent of the animation curve
  34881. * @param gradient Scalar amount to interpolate
  34882. * @returns InterpolatedVector3 value
  34883. */
  34884. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34885. /**
  34886. * Interpolates a Vector2 linearly
  34887. * @param startValue Start value of the animation curve
  34888. * @param endValue End value of the animation curve
  34889. * @param gradient Scalar amount to interpolate
  34890. * @returns Interpolated Vector2 value
  34891. */
  34892. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34893. /**
  34894. * Interpolates a Vector2 cubically
  34895. * @param startValue Start value of the animation curve
  34896. * @param outTangent End tangent of the animation
  34897. * @param endValue End value of the animation curve
  34898. * @param inTangent Start tangent of the animation curve
  34899. * @param gradient Scalar amount to interpolate
  34900. * @returns Interpolated Vector2 value
  34901. */
  34902. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34903. /**
  34904. * Interpolates a size linearly
  34905. * @param startValue Start value of the animation curve
  34906. * @param endValue End value of the animation curve
  34907. * @param gradient Scalar amount to interpolate
  34908. * @returns Interpolated Size value
  34909. */
  34910. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34911. /**
  34912. * Interpolates a Color3 linearly
  34913. * @param startValue Start value of the animation curve
  34914. * @param endValue End value of the animation curve
  34915. * @param gradient Scalar amount to interpolate
  34916. * @returns Interpolated Color3 value
  34917. */
  34918. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34919. /**
  34920. * Interpolates a Color4 linearly
  34921. * @param startValue Start value of the animation curve
  34922. * @param endValue End value of the animation curve
  34923. * @param gradient Scalar amount to interpolate
  34924. * @returns Interpolated Color3 value
  34925. */
  34926. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34927. /**
  34928. * @hidden Internal use only
  34929. */
  34930. _getKeyValue(value: any): any;
  34931. /**
  34932. * @hidden Internal use only
  34933. */
  34934. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34935. /**
  34936. * Defines the function to use to interpolate matrices
  34937. * @param startValue defines the start matrix
  34938. * @param endValue defines the end matrix
  34939. * @param gradient defines the gradient between both matrices
  34940. * @param result defines an optional target matrix where to store the interpolation
  34941. * @returns the interpolated matrix
  34942. */
  34943. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34944. /**
  34945. * Makes a copy of the animation
  34946. * @returns Cloned animation
  34947. */
  34948. clone(): Animation;
  34949. /**
  34950. * Sets the key frames of the animation
  34951. * @param values The animation key frames to set
  34952. */
  34953. setKeys(values: Array<IAnimationKey>): void;
  34954. /**
  34955. * Serializes the animation to an object
  34956. * @returns Serialized object
  34957. */
  34958. serialize(): any;
  34959. /**
  34960. * Float animation type
  34961. */
  34962. static readonly ANIMATIONTYPE_FLOAT: number;
  34963. /**
  34964. * Vector3 animation type
  34965. */
  34966. static readonly ANIMATIONTYPE_VECTOR3: number;
  34967. /**
  34968. * Quaternion animation type
  34969. */
  34970. static readonly ANIMATIONTYPE_QUATERNION: number;
  34971. /**
  34972. * Matrix animation type
  34973. */
  34974. static readonly ANIMATIONTYPE_MATRIX: number;
  34975. /**
  34976. * Color3 animation type
  34977. */
  34978. static readonly ANIMATIONTYPE_COLOR3: number;
  34979. /**
  34980. * Color3 animation type
  34981. */
  34982. static readonly ANIMATIONTYPE_COLOR4: number;
  34983. /**
  34984. * Vector2 animation type
  34985. */
  34986. static readonly ANIMATIONTYPE_VECTOR2: number;
  34987. /**
  34988. * Size animation type
  34989. */
  34990. static readonly ANIMATIONTYPE_SIZE: number;
  34991. /**
  34992. * Relative Loop Mode
  34993. */
  34994. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34995. /**
  34996. * Cycle Loop Mode
  34997. */
  34998. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34999. /**
  35000. * Constant Loop Mode
  35001. */
  35002. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  35003. /** @hidden */
  35004. static _UniversalLerp(left: any, right: any, amount: number): any;
  35005. /**
  35006. * Parses an animation object and creates an animation
  35007. * @param parsedAnimation Parsed animation object
  35008. * @returns Animation object
  35009. */
  35010. static Parse(parsedAnimation: any): Animation;
  35011. /**
  35012. * Appends the serialized animations from the source animations
  35013. * @param source Source containing the animations
  35014. * @param destination Target to store the animations
  35015. */
  35016. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35017. /**
  35018. * Creates a new animation or an array of animations from a snippet saved in a remote file
  35019. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  35020. * @param url defines the url to load from
  35021. * @returns a promise that will resolve to the new animation or an array of animations
  35022. */
  35023. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  35024. /**
  35025. * Creates an animation or an array of animations from a snippet saved by the Inspector
  35026. * @param snippetId defines the snippet to load
  35027. * @returns a promise that will resolve to the new animation or a new array of animations
  35028. */
  35029. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  35030. }
  35031. }
  35032. declare module "babylonjs/Animations/animatable.interface" {
  35033. import { Nullable } from "babylonjs/types";
  35034. import { Animation } from "babylonjs/Animations/animation";
  35035. /**
  35036. * Interface containing an array of animations
  35037. */
  35038. export interface IAnimatable {
  35039. /**
  35040. * Array of animations
  35041. */
  35042. animations: Nullable<Array<Animation>>;
  35043. }
  35044. }
  35045. declare module "babylonjs/Misc/decorators" {
  35046. import { Nullable } from "babylonjs/types";
  35047. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35048. import { Scene } from "babylonjs/scene";
  35049. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35050. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35051. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35052. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35053. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35054. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35055. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35056. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35057. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35058. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35059. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35060. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35061. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35062. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35063. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35064. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35065. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35066. /**
  35067. * Decorator used to define property that can be serialized as reference to a camera
  35068. * @param sourceName defines the name of the property to decorate
  35069. */
  35070. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35071. /**
  35072. * Class used to help serialization objects
  35073. */
  35074. export class SerializationHelper {
  35075. /** @hidden */
  35076. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35077. /** @hidden */
  35078. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35079. /** @hidden */
  35080. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35081. /** @hidden */
  35082. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35083. /**
  35084. * Appends the serialized animations from the source animations
  35085. * @param source Source containing the animations
  35086. * @param destination Target to store the animations
  35087. */
  35088. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35089. /**
  35090. * Static function used to serialized a specific entity
  35091. * @param entity defines the entity to serialize
  35092. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35093. * @returns a JSON compatible object representing the serialization of the entity
  35094. */
  35095. static Serialize<T>(entity: T, serializationObject?: any): any;
  35096. /**
  35097. * Creates a new entity from a serialization data object
  35098. * @param creationFunction defines a function used to instanciated the new entity
  35099. * @param source defines the source serialization data
  35100. * @param scene defines the hosting scene
  35101. * @param rootUrl defines the root url for resources
  35102. * @returns a new entity
  35103. */
  35104. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35105. /**
  35106. * Clones an object
  35107. * @param creationFunction defines the function used to instanciate the new object
  35108. * @param source defines the source object
  35109. * @returns the cloned object
  35110. */
  35111. static Clone<T>(creationFunction: () => T, source: T): T;
  35112. /**
  35113. * Instanciates a new object based on a source one (some data will be shared between both object)
  35114. * @param creationFunction defines the function used to instanciate the new object
  35115. * @param source defines the source object
  35116. * @returns the new object
  35117. */
  35118. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35119. }
  35120. }
  35121. declare module "babylonjs/Materials/Textures/baseTexture" {
  35122. import { Observable } from "babylonjs/Misc/observable";
  35123. import { Nullable } from "babylonjs/types";
  35124. import { Scene } from "babylonjs/scene";
  35125. import { Matrix } from "babylonjs/Maths/math.vector";
  35126. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35127. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35128. import { ISize } from "babylonjs/Maths/math.size";
  35129. import "babylonjs/Misc/fileTools";
  35130. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35131. /**
  35132. * Base class of all the textures in babylon.
  35133. * It groups all the common properties the materials, post process, lights... might need
  35134. * in order to make a correct use of the texture.
  35135. */
  35136. export class BaseTexture implements IAnimatable {
  35137. /**
  35138. * Default anisotropic filtering level for the application.
  35139. * It is set to 4 as a good tradeoff between perf and quality.
  35140. */
  35141. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35142. /**
  35143. * Gets or sets the unique id of the texture
  35144. */
  35145. uniqueId: number;
  35146. /**
  35147. * Define the name of the texture.
  35148. */
  35149. name: string;
  35150. /**
  35151. * Gets or sets an object used to store user defined information.
  35152. */
  35153. metadata: any;
  35154. /**
  35155. * For internal use only. Please do not use.
  35156. */
  35157. reservedDataStore: any;
  35158. private _hasAlpha;
  35159. /**
  35160. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35161. */
  35162. set hasAlpha(value: boolean);
  35163. get hasAlpha(): boolean;
  35164. /**
  35165. * Defines if the alpha value should be determined via the rgb values.
  35166. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35167. */
  35168. getAlphaFromRGB: boolean;
  35169. /**
  35170. * Intensity or strength of the texture.
  35171. * It is commonly used by materials to fine tune the intensity of the texture
  35172. */
  35173. level: number;
  35174. /**
  35175. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35176. * This is part of the texture as textures usually maps to one uv set.
  35177. */
  35178. coordinatesIndex: number;
  35179. protected _coordinatesMode: number;
  35180. /**
  35181. * How a texture is mapped.
  35182. *
  35183. * | Value | Type | Description |
  35184. * | ----- | ----------------------------------- | ----------- |
  35185. * | 0 | EXPLICIT_MODE | |
  35186. * | 1 | SPHERICAL_MODE | |
  35187. * | 2 | PLANAR_MODE | |
  35188. * | 3 | CUBIC_MODE | |
  35189. * | 4 | PROJECTION_MODE | |
  35190. * | 5 | SKYBOX_MODE | |
  35191. * | 6 | INVCUBIC_MODE | |
  35192. * | 7 | EQUIRECTANGULAR_MODE | |
  35193. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35194. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35195. */
  35196. set coordinatesMode(value: number);
  35197. get coordinatesMode(): number;
  35198. private _wrapU;
  35199. /**
  35200. * | Value | Type | Description |
  35201. * | ----- | ------------------ | ----------- |
  35202. * | 0 | CLAMP_ADDRESSMODE | |
  35203. * | 1 | WRAP_ADDRESSMODE | |
  35204. * | 2 | MIRROR_ADDRESSMODE | |
  35205. */
  35206. get wrapU(): number;
  35207. set wrapU(value: number);
  35208. private _wrapV;
  35209. /**
  35210. * | Value | Type | Description |
  35211. * | ----- | ------------------ | ----------- |
  35212. * | 0 | CLAMP_ADDRESSMODE | |
  35213. * | 1 | WRAP_ADDRESSMODE | |
  35214. * | 2 | MIRROR_ADDRESSMODE | |
  35215. */
  35216. get wrapV(): number;
  35217. set wrapV(value: number);
  35218. /**
  35219. * | Value | Type | Description |
  35220. * | ----- | ------------------ | ----------- |
  35221. * | 0 | CLAMP_ADDRESSMODE | |
  35222. * | 1 | WRAP_ADDRESSMODE | |
  35223. * | 2 | MIRROR_ADDRESSMODE | |
  35224. */
  35225. wrapR: number;
  35226. /**
  35227. * With compliant hardware and browser (supporting anisotropic filtering)
  35228. * this defines the level of anisotropic filtering in the texture.
  35229. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35230. */
  35231. anisotropicFilteringLevel: number;
  35232. /**
  35233. * Define if the texture is a cube texture or if false a 2d texture.
  35234. */
  35235. get isCube(): boolean;
  35236. set isCube(value: boolean);
  35237. /**
  35238. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35239. */
  35240. get is3D(): boolean;
  35241. set is3D(value: boolean);
  35242. /**
  35243. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35244. */
  35245. get is2DArray(): boolean;
  35246. set is2DArray(value: boolean);
  35247. private _gammaSpace;
  35248. /**
  35249. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35250. * HDR texture are usually stored in linear space.
  35251. * This only impacts the PBR and Background materials
  35252. */
  35253. get gammaSpace(): boolean;
  35254. set gammaSpace(gamma: boolean);
  35255. /**
  35256. * Gets or sets whether or not the texture contains RGBD data.
  35257. */
  35258. get isRGBD(): boolean;
  35259. set isRGBD(value: boolean);
  35260. /**
  35261. * Is Z inverted in the texture (useful in a cube texture).
  35262. */
  35263. invertZ: boolean;
  35264. /**
  35265. * Are mip maps generated for this texture or not.
  35266. */
  35267. get noMipmap(): boolean;
  35268. /**
  35269. * @hidden
  35270. */
  35271. lodLevelInAlpha: boolean;
  35272. /**
  35273. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35274. */
  35275. get lodGenerationOffset(): number;
  35276. set lodGenerationOffset(value: number);
  35277. /**
  35278. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35279. */
  35280. get lodGenerationScale(): number;
  35281. set lodGenerationScale(value: number);
  35282. /**
  35283. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35284. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35285. * average roughness values.
  35286. */
  35287. get linearSpecularLOD(): boolean;
  35288. set linearSpecularLOD(value: boolean);
  35289. /**
  35290. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35291. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35292. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35293. */
  35294. get irradianceTexture(): Nullable<BaseTexture>;
  35295. set irradianceTexture(value: Nullable<BaseTexture>);
  35296. /**
  35297. * Define if the texture is a render target.
  35298. */
  35299. isRenderTarget: boolean;
  35300. /**
  35301. * Define the unique id of the texture in the scene.
  35302. */
  35303. get uid(): string;
  35304. /** @hidden */
  35305. _prefiltered: boolean;
  35306. /**
  35307. * Return a string representation of the texture.
  35308. * @returns the texture as a string
  35309. */
  35310. toString(): string;
  35311. /**
  35312. * Get the class name of the texture.
  35313. * @returns "BaseTexture"
  35314. */
  35315. getClassName(): string;
  35316. /**
  35317. * Define the list of animation attached to the texture.
  35318. */
  35319. animations: import("babylonjs/Animations/animation").Animation[];
  35320. /**
  35321. * An event triggered when the texture is disposed.
  35322. */
  35323. onDisposeObservable: Observable<BaseTexture>;
  35324. private _onDisposeObserver;
  35325. /**
  35326. * Callback triggered when the texture has been disposed.
  35327. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35328. */
  35329. set onDispose(callback: () => void);
  35330. /**
  35331. * Define the current state of the loading sequence when in delayed load mode.
  35332. */
  35333. delayLoadState: number;
  35334. protected _scene: Nullable<Scene>;
  35335. protected _engine: Nullable<ThinEngine>;
  35336. /** @hidden */
  35337. _texture: Nullable<InternalTexture>;
  35338. private _uid;
  35339. /**
  35340. * Define if the texture is preventinga material to render or not.
  35341. * If not and the texture is not ready, the engine will use a default black texture instead.
  35342. */
  35343. get isBlocking(): boolean;
  35344. /**
  35345. * Instantiates a new BaseTexture.
  35346. * Base class of all the textures in babylon.
  35347. * It groups all the common properties the materials, post process, lights... might need
  35348. * in order to make a correct use of the texture.
  35349. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35350. */
  35351. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35352. /**
  35353. * Get the scene the texture belongs to.
  35354. * @returns the scene or null if undefined
  35355. */
  35356. getScene(): Nullable<Scene>;
  35357. /** @hidden */
  35358. protected _getEngine(): Nullable<ThinEngine>;
  35359. /**
  35360. * Get the texture transform matrix used to offset tile the texture for istance.
  35361. * @returns the transformation matrix
  35362. */
  35363. getTextureMatrix(): Matrix;
  35364. /**
  35365. * Get the texture reflection matrix used to rotate/transform the reflection.
  35366. * @returns the reflection matrix
  35367. */
  35368. getReflectionTextureMatrix(): Matrix;
  35369. /**
  35370. * Get the underlying lower level texture from Babylon.
  35371. * @returns the insternal texture
  35372. */
  35373. getInternalTexture(): Nullable<InternalTexture>;
  35374. /**
  35375. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35376. * @returns true if ready or not blocking
  35377. */
  35378. isReadyOrNotBlocking(): boolean;
  35379. /**
  35380. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35381. * @returns true if fully ready
  35382. */
  35383. isReady(): boolean;
  35384. private _cachedSize;
  35385. /**
  35386. * Get the size of the texture.
  35387. * @returns the texture size.
  35388. */
  35389. getSize(): ISize;
  35390. /**
  35391. * Get the base size of the texture.
  35392. * It can be different from the size if the texture has been resized for POT for instance
  35393. * @returns the base size
  35394. */
  35395. getBaseSize(): ISize;
  35396. /**
  35397. * Update the sampling mode of the texture.
  35398. * Default is Trilinear mode.
  35399. *
  35400. * | Value | Type | Description |
  35401. * | ----- | ------------------ | ----------- |
  35402. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35403. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35404. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35405. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35406. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35407. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35408. * | 7 | NEAREST_LINEAR | |
  35409. * | 8 | NEAREST_NEAREST | |
  35410. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35411. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35412. * | 11 | LINEAR_LINEAR | |
  35413. * | 12 | LINEAR_NEAREST | |
  35414. *
  35415. * > _mag_: magnification filter (close to the viewer)
  35416. * > _min_: minification filter (far from the viewer)
  35417. * > _mip_: filter used between mip map levels
  35418. *@param samplingMode Define the new sampling mode of the texture
  35419. */
  35420. updateSamplingMode(samplingMode: number): void;
  35421. /**
  35422. * Scales the texture if is `canRescale()`
  35423. * @param ratio the resize factor we want to use to rescale
  35424. */
  35425. scale(ratio: number): void;
  35426. /**
  35427. * Get if the texture can rescale.
  35428. */
  35429. get canRescale(): boolean;
  35430. /** @hidden */
  35431. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35432. /** @hidden */
  35433. _rebuild(): void;
  35434. /**
  35435. * Triggers the load sequence in delayed load mode.
  35436. */
  35437. delayLoad(): void;
  35438. /**
  35439. * Clones the texture.
  35440. * @returns the cloned texture
  35441. */
  35442. clone(): Nullable<BaseTexture>;
  35443. /**
  35444. * Get the texture underlying type (INT, FLOAT...)
  35445. */
  35446. get textureType(): number;
  35447. /**
  35448. * Get the texture underlying format (RGB, RGBA...)
  35449. */
  35450. get textureFormat(): number;
  35451. /**
  35452. * Indicates that textures need to be re-calculated for all materials
  35453. */
  35454. protected _markAllSubMeshesAsTexturesDirty(): void;
  35455. /**
  35456. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35457. * This will returns an RGBA array buffer containing either in values (0-255) or
  35458. * float values (0-1) depending of the underlying buffer type.
  35459. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35460. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35461. * @param buffer defines a user defined buffer to fill with data (can be null)
  35462. * @returns The Array buffer containing the pixels data.
  35463. */
  35464. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35465. /**
  35466. * Release and destroy the underlying lower level texture aka internalTexture.
  35467. */
  35468. releaseInternalTexture(): void;
  35469. /** @hidden */
  35470. get _lodTextureHigh(): Nullable<BaseTexture>;
  35471. /** @hidden */
  35472. get _lodTextureMid(): Nullable<BaseTexture>;
  35473. /** @hidden */
  35474. get _lodTextureLow(): Nullable<BaseTexture>;
  35475. /**
  35476. * Dispose the texture and release its associated resources.
  35477. */
  35478. dispose(): void;
  35479. /**
  35480. * Serialize the texture into a JSON representation that can be parsed later on.
  35481. * @returns the JSON representation of the texture
  35482. */
  35483. serialize(): any;
  35484. /**
  35485. * Helper function to be called back once a list of texture contains only ready textures.
  35486. * @param textures Define the list of textures to wait for
  35487. * @param callback Define the callback triggered once the entire list will be ready
  35488. */
  35489. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35490. private static _isScene;
  35491. }
  35492. }
  35493. declare module "babylonjs/Materials/effect" {
  35494. import { Observable } from "babylonjs/Misc/observable";
  35495. import { Nullable } from "babylonjs/types";
  35496. import { IDisposable } from "babylonjs/scene";
  35497. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35498. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35499. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35500. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35501. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35502. import { Engine } from "babylonjs/Engines/engine";
  35503. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35506. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35507. /**
  35508. * Options to be used when creating an effect.
  35509. */
  35510. export interface IEffectCreationOptions {
  35511. /**
  35512. * Atrributes that will be used in the shader.
  35513. */
  35514. attributes: string[];
  35515. /**
  35516. * Uniform varible names that will be set in the shader.
  35517. */
  35518. uniformsNames: string[];
  35519. /**
  35520. * Uniform buffer variable names that will be set in the shader.
  35521. */
  35522. uniformBuffersNames: string[];
  35523. /**
  35524. * Sampler texture variable names that will be set in the shader.
  35525. */
  35526. samplers: string[];
  35527. /**
  35528. * Define statements that will be set in the shader.
  35529. */
  35530. defines: any;
  35531. /**
  35532. * Possible fallbacks for this effect to improve performance when needed.
  35533. */
  35534. fallbacks: Nullable<IEffectFallbacks>;
  35535. /**
  35536. * Callback that will be called when the shader is compiled.
  35537. */
  35538. onCompiled: Nullable<(effect: Effect) => void>;
  35539. /**
  35540. * Callback that will be called if an error occurs during shader compilation.
  35541. */
  35542. onError: Nullable<(effect: Effect, errors: string) => void>;
  35543. /**
  35544. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35545. */
  35546. indexParameters?: any;
  35547. /**
  35548. * Max number of lights that can be used in the shader.
  35549. */
  35550. maxSimultaneousLights?: number;
  35551. /**
  35552. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35553. */
  35554. transformFeedbackVaryings?: Nullable<string[]>;
  35555. /**
  35556. * 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
  35557. */
  35558. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35559. /**
  35560. * Is this effect rendering to several color attachments ?
  35561. */
  35562. multiTarget?: boolean;
  35563. }
  35564. /**
  35565. * Effect containing vertex and fragment shader that can be executed on an object.
  35566. */
  35567. export class Effect implements IDisposable {
  35568. /**
  35569. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35570. */
  35571. static ShadersRepository: string;
  35572. /**
  35573. * Enable logging of the shader code when a compilation error occurs
  35574. */
  35575. static LogShaderCodeOnCompilationError: boolean;
  35576. /**
  35577. * Name of the effect.
  35578. */
  35579. name: any;
  35580. /**
  35581. * String container all the define statements that should be set on the shader.
  35582. */
  35583. defines: string;
  35584. /**
  35585. * Callback that will be called when the shader is compiled.
  35586. */
  35587. onCompiled: Nullable<(effect: Effect) => void>;
  35588. /**
  35589. * Callback that will be called if an error occurs during shader compilation.
  35590. */
  35591. onError: Nullable<(effect: Effect, errors: string) => void>;
  35592. /**
  35593. * Callback that will be called when effect is bound.
  35594. */
  35595. onBind: Nullable<(effect: Effect) => void>;
  35596. /**
  35597. * Unique ID of the effect.
  35598. */
  35599. uniqueId: number;
  35600. /**
  35601. * Observable that will be called when the shader is compiled.
  35602. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35603. */
  35604. onCompileObservable: Observable<Effect>;
  35605. /**
  35606. * Observable that will be called if an error occurs during shader compilation.
  35607. */
  35608. onErrorObservable: Observable<Effect>;
  35609. /** @hidden */
  35610. _onBindObservable: Nullable<Observable<Effect>>;
  35611. /**
  35612. * @hidden
  35613. * Specifies if the effect was previously ready
  35614. */
  35615. _wasPreviouslyReady: boolean;
  35616. /**
  35617. * Observable that will be called when effect is bound.
  35618. */
  35619. get onBindObservable(): Observable<Effect>;
  35620. /** @hidden */
  35621. _bonesComputationForcedToCPU: boolean;
  35622. /** @hidden */
  35623. _multiTarget: boolean;
  35624. private static _uniqueIdSeed;
  35625. private _engine;
  35626. private _uniformBuffersNames;
  35627. private _uniformBuffersNamesList;
  35628. private _uniformsNames;
  35629. private _samplerList;
  35630. private _samplers;
  35631. private _isReady;
  35632. private _compilationError;
  35633. private _allFallbacksProcessed;
  35634. private _attributesNames;
  35635. private _attributes;
  35636. private _attributeLocationByName;
  35637. private _uniforms;
  35638. /**
  35639. * Key for the effect.
  35640. * @hidden
  35641. */
  35642. _key: string;
  35643. private _indexParameters;
  35644. private _fallbacks;
  35645. private _vertexSourceCode;
  35646. private _fragmentSourceCode;
  35647. private _vertexSourceCodeOverride;
  35648. private _fragmentSourceCodeOverride;
  35649. private _transformFeedbackVaryings;
  35650. /**
  35651. * Compiled shader to webGL program.
  35652. * @hidden
  35653. */
  35654. _pipelineContext: Nullable<IPipelineContext>;
  35655. private _valueCache;
  35656. private static _baseCache;
  35657. /**
  35658. * Instantiates an effect.
  35659. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35660. * @param baseName Name of the effect.
  35661. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35662. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35663. * @param samplers List of sampler variables that will be passed to the shader.
  35664. * @param engine Engine to be used to render the effect
  35665. * @param defines Define statements to be added to the shader.
  35666. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35667. * @param onCompiled Callback that will be called when the shader is compiled.
  35668. * @param onError Callback that will be called if an error occurs during shader compilation.
  35669. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35670. */
  35671. 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);
  35672. private _useFinalCode;
  35673. /**
  35674. * Unique key for this effect
  35675. */
  35676. get key(): string;
  35677. /**
  35678. * If the effect has been compiled and prepared.
  35679. * @returns if the effect is compiled and prepared.
  35680. */
  35681. isReady(): boolean;
  35682. private _isReadyInternal;
  35683. /**
  35684. * The engine the effect was initialized with.
  35685. * @returns the engine.
  35686. */
  35687. getEngine(): Engine;
  35688. /**
  35689. * The pipeline context for this effect
  35690. * @returns the associated pipeline context
  35691. */
  35692. getPipelineContext(): Nullable<IPipelineContext>;
  35693. /**
  35694. * The set of names of attribute variables for the shader.
  35695. * @returns An array of attribute names.
  35696. */
  35697. getAttributesNames(): string[];
  35698. /**
  35699. * Returns the attribute at the given index.
  35700. * @param index The index of the attribute.
  35701. * @returns The location of the attribute.
  35702. */
  35703. getAttributeLocation(index: number): number;
  35704. /**
  35705. * Returns the attribute based on the name of the variable.
  35706. * @param name of the attribute to look up.
  35707. * @returns the attribute location.
  35708. */
  35709. getAttributeLocationByName(name: string): number;
  35710. /**
  35711. * The number of attributes.
  35712. * @returns the numnber of attributes.
  35713. */
  35714. getAttributesCount(): number;
  35715. /**
  35716. * Gets the index of a uniform variable.
  35717. * @param uniformName of the uniform to look up.
  35718. * @returns the index.
  35719. */
  35720. getUniformIndex(uniformName: string): number;
  35721. /**
  35722. * Returns the attribute based on the name of the variable.
  35723. * @param uniformName of the uniform to look up.
  35724. * @returns the location of the uniform.
  35725. */
  35726. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35727. /**
  35728. * Returns an array of sampler variable names
  35729. * @returns The array of sampler variable names.
  35730. */
  35731. getSamplers(): string[];
  35732. /**
  35733. * Returns an array of uniform variable names
  35734. * @returns The array of uniform variable names.
  35735. */
  35736. getUniformNames(): string[];
  35737. /**
  35738. * Returns an array of uniform buffer variable names
  35739. * @returns The array of uniform buffer variable names.
  35740. */
  35741. getUniformBuffersNames(): string[];
  35742. /**
  35743. * Returns the index parameters used to create the effect
  35744. * @returns The index parameters object
  35745. */
  35746. getIndexParameters(): any;
  35747. /**
  35748. * The error from the last compilation.
  35749. * @returns the error string.
  35750. */
  35751. getCompilationError(): string;
  35752. /**
  35753. * Gets a boolean indicating that all fallbacks were used during compilation
  35754. * @returns true if all fallbacks were used
  35755. */
  35756. allFallbacksProcessed(): boolean;
  35757. /**
  35758. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35759. * @param func The callback to be used.
  35760. */
  35761. executeWhenCompiled(func: (effect: Effect) => void): void;
  35762. private _checkIsReady;
  35763. private _loadShader;
  35764. /**
  35765. * Gets the vertex shader source code of this effect
  35766. */
  35767. get vertexSourceCode(): string;
  35768. /**
  35769. * Gets the fragment shader source code of this effect
  35770. */
  35771. get fragmentSourceCode(): string;
  35772. /**
  35773. * Recompiles the webGL program
  35774. * @param vertexSourceCode The source code for the vertex shader.
  35775. * @param fragmentSourceCode The source code for the fragment shader.
  35776. * @param onCompiled Callback called when completed.
  35777. * @param onError Callback called on error.
  35778. * @hidden
  35779. */
  35780. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35781. /**
  35782. * Prepares the effect
  35783. * @hidden
  35784. */
  35785. _prepareEffect(): void;
  35786. private _getShaderCodeAndErrorLine;
  35787. private _processCompilationErrors;
  35788. /**
  35789. * Checks if the effect is supported. (Must be called after compilation)
  35790. */
  35791. get isSupported(): boolean;
  35792. /**
  35793. * Binds a texture to the engine to be used as output of the shader.
  35794. * @param channel Name of the output variable.
  35795. * @param texture Texture to bind.
  35796. * @hidden
  35797. */
  35798. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35799. /**
  35800. * Sets a texture on the engine to be used in the shader.
  35801. * @param channel Name of the sampler variable.
  35802. * @param texture Texture to set.
  35803. */
  35804. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35805. /**
  35806. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35807. * @param channel Name of the sampler variable.
  35808. * @param texture Texture to set.
  35809. */
  35810. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35811. /**
  35812. * Sets an array of textures on the engine to be used in the shader.
  35813. * @param channel Name of the variable.
  35814. * @param textures Textures to set.
  35815. */
  35816. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35817. /**
  35818. * 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)
  35819. * @param channel Name of the sampler variable.
  35820. * @param postProcess Post process to get the input texture from.
  35821. */
  35822. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35823. /**
  35824. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35825. * 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)
  35826. * @param channel Name of the sampler variable.
  35827. * @param postProcess Post process to get the output texture from.
  35828. */
  35829. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35830. /** @hidden */
  35831. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35832. /** @hidden */
  35833. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35834. /** @hidden */
  35835. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35836. /** @hidden */
  35837. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35838. /**
  35839. * Binds a buffer to a uniform.
  35840. * @param buffer Buffer to bind.
  35841. * @param name Name of the uniform variable to bind to.
  35842. */
  35843. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35844. /**
  35845. * Binds block to a uniform.
  35846. * @param blockName Name of the block to bind.
  35847. * @param index Index to bind.
  35848. */
  35849. bindUniformBlock(blockName: string, index: number): void;
  35850. /**
  35851. * Sets an interger value on a uniform variable.
  35852. * @param uniformName Name of the variable.
  35853. * @param value Value to be set.
  35854. * @returns this effect.
  35855. */
  35856. setInt(uniformName: string, value: number): Effect;
  35857. /**
  35858. * Sets an int array on a uniform variable.
  35859. * @param uniformName Name of the variable.
  35860. * @param array array to be set.
  35861. * @returns this effect.
  35862. */
  35863. setIntArray(uniformName: string, array: Int32Array): Effect;
  35864. /**
  35865. * 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)
  35866. * @param uniformName Name of the variable.
  35867. * @param array array to be set.
  35868. * @returns this effect.
  35869. */
  35870. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35871. /**
  35872. * 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)
  35873. * @param uniformName Name of the variable.
  35874. * @param array array to be set.
  35875. * @returns this effect.
  35876. */
  35877. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35878. /**
  35879. * 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)
  35880. * @param uniformName Name of the variable.
  35881. * @param array array to be set.
  35882. * @returns this effect.
  35883. */
  35884. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35885. /**
  35886. * Sets an float array on a uniform variable.
  35887. * @param uniformName Name of the variable.
  35888. * @param array array to be set.
  35889. * @returns this effect.
  35890. */
  35891. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35892. /**
  35893. * 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)
  35894. * @param uniformName Name of the variable.
  35895. * @param array array to be set.
  35896. * @returns this effect.
  35897. */
  35898. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35899. /**
  35900. * 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)
  35901. * @param uniformName Name of the variable.
  35902. * @param array array to be set.
  35903. * @returns this effect.
  35904. */
  35905. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35906. /**
  35907. * 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)
  35908. * @param uniformName Name of the variable.
  35909. * @param array array to be set.
  35910. * @returns this effect.
  35911. */
  35912. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35913. /**
  35914. * Sets an array on a uniform variable.
  35915. * @param uniformName Name of the variable.
  35916. * @param array array to be set.
  35917. * @returns this effect.
  35918. */
  35919. setArray(uniformName: string, array: number[]): Effect;
  35920. /**
  35921. * 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)
  35922. * @param uniformName Name of the variable.
  35923. * @param array array to be set.
  35924. * @returns this effect.
  35925. */
  35926. setArray2(uniformName: string, array: number[]): Effect;
  35927. /**
  35928. * 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)
  35929. * @param uniformName Name of the variable.
  35930. * @param array array to be set.
  35931. * @returns this effect.
  35932. */
  35933. setArray3(uniformName: string, array: number[]): Effect;
  35934. /**
  35935. * 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)
  35936. * @param uniformName Name of the variable.
  35937. * @param array array to be set.
  35938. * @returns this effect.
  35939. */
  35940. setArray4(uniformName: string, array: number[]): Effect;
  35941. /**
  35942. * Sets matrices on a uniform variable.
  35943. * @param uniformName Name of the variable.
  35944. * @param matrices matrices to be set.
  35945. * @returns this effect.
  35946. */
  35947. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35948. /**
  35949. * Sets matrix on a uniform variable.
  35950. * @param uniformName Name of the variable.
  35951. * @param matrix matrix to be set.
  35952. * @returns this effect.
  35953. */
  35954. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35955. /**
  35956. * 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)
  35957. * @param uniformName Name of the variable.
  35958. * @param matrix matrix to be set.
  35959. * @returns this effect.
  35960. */
  35961. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35962. /**
  35963. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35964. * @param uniformName Name of the variable.
  35965. * @param matrix matrix to be set.
  35966. * @returns this effect.
  35967. */
  35968. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35969. /**
  35970. * Sets a float on a uniform variable.
  35971. * @param uniformName Name of the variable.
  35972. * @param value value to be set.
  35973. * @returns this effect.
  35974. */
  35975. setFloat(uniformName: string, value: number): Effect;
  35976. /**
  35977. * Sets a boolean on a uniform variable.
  35978. * @param uniformName Name of the variable.
  35979. * @param bool value to be set.
  35980. * @returns this effect.
  35981. */
  35982. setBool(uniformName: string, bool: boolean): Effect;
  35983. /**
  35984. * Sets a Vector2 on a uniform variable.
  35985. * @param uniformName Name of the variable.
  35986. * @param vector2 vector2 to be set.
  35987. * @returns this effect.
  35988. */
  35989. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35990. /**
  35991. * Sets a float2 on a uniform variable.
  35992. * @param uniformName Name of the variable.
  35993. * @param x First float in float2.
  35994. * @param y Second float in float2.
  35995. * @returns this effect.
  35996. */
  35997. setFloat2(uniformName: string, x: number, y: number): Effect;
  35998. /**
  35999. * Sets a Vector3 on a uniform variable.
  36000. * @param uniformName Name of the variable.
  36001. * @param vector3 Value to be set.
  36002. * @returns this effect.
  36003. */
  36004. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  36005. /**
  36006. * Sets a float3 on a uniform variable.
  36007. * @param uniformName Name of the variable.
  36008. * @param x First float in float3.
  36009. * @param y Second float in float3.
  36010. * @param z Third float in float3.
  36011. * @returns this effect.
  36012. */
  36013. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  36014. /**
  36015. * Sets a Vector4 on a uniform variable.
  36016. * @param uniformName Name of the variable.
  36017. * @param vector4 Value to be set.
  36018. * @returns this effect.
  36019. */
  36020. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  36021. /**
  36022. * Sets a float4 on a uniform variable.
  36023. * @param uniformName Name of the variable.
  36024. * @param x First float in float4.
  36025. * @param y Second float in float4.
  36026. * @param z Third float in float4.
  36027. * @param w Fourth float in float4.
  36028. * @returns this effect.
  36029. */
  36030. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  36031. /**
  36032. * Sets a Color3 on a uniform variable.
  36033. * @param uniformName Name of the variable.
  36034. * @param color3 Value to be set.
  36035. * @returns this effect.
  36036. */
  36037. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36038. /**
  36039. * Sets a Color4 on a uniform variable.
  36040. * @param uniformName Name of the variable.
  36041. * @param color3 Value to be set.
  36042. * @param alpha Alpha value to be set.
  36043. * @returns this effect.
  36044. */
  36045. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36046. /**
  36047. * Sets a Color4 on a uniform variable
  36048. * @param uniformName defines the name of the variable
  36049. * @param color4 defines the value to be set
  36050. * @returns this effect.
  36051. */
  36052. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36053. /** Release all associated resources */
  36054. dispose(): void;
  36055. /**
  36056. * This function will add a new shader to the shader store
  36057. * @param name the name of the shader
  36058. * @param pixelShader optional pixel shader content
  36059. * @param vertexShader optional vertex shader content
  36060. */
  36061. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36062. /**
  36063. * Store of each shader (The can be looked up using effect.key)
  36064. */
  36065. static ShadersStore: {
  36066. [key: string]: string;
  36067. };
  36068. /**
  36069. * Store of each included file for a shader (The can be looked up using effect.key)
  36070. */
  36071. static IncludesShadersStore: {
  36072. [key: string]: string;
  36073. };
  36074. /**
  36075. * Resets the cache of effects.
  36076. */
  36077. static ResetCache(): void;
  36078. }
  36079. }
  36080. declare module "babylonjs/Engines/engineCapabilities" {
  36081. /**
  36082. * Interface used to describe the capabilities of the engine relatively to the current browser
  36083. */
  36084. export interface EngineCapabilities {
  36085. /** Maximum textures units per fragment shader */
  36086. maxTexturesImageUnits: number;
  36087. /** Maximum texture units per vertex shader */
  36088. maxVertexTextureImageUnits: number;
  36089. /** Maximum textures units in the entire pipeline */
  36090. maxCombinedTexturesImageUnits: number;
  36091. /** Maximum texture size */
  36092. maxTextureSize: number;
  36093. /** Maximum texture samples */
  36094. maxSamples?: number;
  36095. /** Maximum cube texture size */
  36096. maxCubemapTextureSize: number;
  36097. /** Maximum render texture size */
  36098. maxRenderTextureSize: number;
  36099. /** Maximum number of vertex attributes */
  36100. maxVertexAttribs: number;
  36101. /** Maximum number of varyings */
  36102. maxVaryingVectors: number;
  36103. /** Maximum number of uniforms per vertex shader */
  36104. maxVertexUniformVectors: number;
  36105. /** Maximum number of uniforms per fragment shader */
  36106. maxFragmentUniformVectors: number;
  36107. /** Defines if standard derivates (dx/dy) are supported */
  36108. standardDerivatives: boolean;
  36109. /** Defines if s3tc texture compression is supported */
  36110. s3tc?: WEBGL_compressed_texture_s3tc;
  36111. /** Defines if pvrtc texture compression is supported */
  36112. pvrtc: any;
  36113. /** Defines if etc1 texture compression is supported */
  36114. etc1: any;
  36115. /** Defines if etc2 texture compression is supported */
  36116. etc2: any;
  36117. /** Defines if astc texture compression is supported */
  36118. astc: any;
  36119. /** Defines if bptc texture compression is supported */
  36120. bptc: any;
  36121. /** Defines if float textures are supported */
  36122. textureFloat: boolean;
  36123. /** Defines if vertex array objects are supported */
  36124. vertexArrayObject: boolean;
  36125. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36126. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36127. /** Gets the maximum level of anisotropy supported */
  36128. maxAnisotropy: number;
  36129. /** Defines if instancing is supported */
  36130. instancedArrays: boolean;
  36131. /** Defines if 32 bits indices are supported */
  36132. uintIndices: boolean;
  36133. /** Defines if high precision shaders are supported */
  36134. highPrecisionShaderSupported: boolean;
  36135. /** Defines if depth reading in the fragment shader is supported */
  36136. fragmentDepthSupported: boolean;
  36137. /** Defines if float texture linear filtering is supported*/
  36138. textureFloatLinearFiltering: boolean;
  36139. /** Defines if rendering to float textures is supported */
  36140. textureFloatRender: boolean;
  36141. /** Defines if half float textures are supported*/
  36142. textureHalfFloat: boolean;
  36143. /** Defines if half float texture linear filtering is supported*/
  36144. textureHalfFloatLinearFiltering: boolean;
  36145. /** Defines if rendering to half float textures is supported */
  36146. textureHalfFloatRender: boolean;
  36147. /** Defines if textureLOD shader command is supported */
  36148. textureLOD: boolean;
  36149. /** Defines if draw buffers extension is supported */
  36150. drawBuffersExtension: boolean;
  36151. /** Defines if depth textures are supported */
  36152. depthTextureExtension: boolean;
  36153. /** Defines if float color buffer are supported */
  36154. colorBufferFloat: boolean;
  36155. /** Gets disjoint timer query extension (null if not supported) */
  36156. timerQuery?: EXT_disjoint_timer_query;
  36157. /** Defines if timestamp can be used with timer query */
  36158. canUseTimestampForTimerQuery: boolean;
  36159. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36160. multiview?: any;
  36161. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36162. oculusMultiview?: any;
  36163. /** Function used to let the system compiles shaders in background */
  36164. parallelShaderCompile?: {
  36165. COMPLETION_STATUS_KHR: number;
  36166. };
  36167. /** Max number of texture samples for MSAA */
  36168. maxMSAASamples: number;
  36169. /** Defines if the blend min max extension is supported */
  36170. blendMinMax: boolean;
  36171. }
  36172. }
  36173. declare module "babylonjs/States/depthCullingState" {
  36174. import { Nullable } from "babylonjs/types";
  36175. /**
  36176. * @hidden
  36177. **/
  36178. export class DepthCullingState {
  36179. private _isDepthTestDirty;
  36180. private _isDepthMaskDirty;
  36181. private _isDepthFuncDirty;
  36182. private _isCullFaceDirty;
  36183. private _isCullDirty;
  36184. private _isZOffsetDirty;
  36185. private _isFrontFaceDirty;
  36186. private _depthTest;
  36187. private _depthMask;
  36188. private _depthFunc;
  36189. private _cull;
  36190. private _cullFace;
  36191. private _zOffset;
  36192. private _frontFace;
  36193. /**
  36194. * Initializes the state.
  36195. */
  36196. constructor();
  36197. get isDirty(): boolean;
  36198. get zOffset(): number;
  36199. set zOffset(value: number);
  36200. get cullFace(): Nullable<number>;
  36201. set cullFace(value: Nullable<number>);
  36202. get cull(): Nullable<boolean>;
  36203. set cull(value: Nullable<boolean>);
  36204. get depthFunc(): Nullable<number>;
  36205. set depthFunc(value: Nullable<number>);
  36206. get depthMask(): boolean;
  36207. set depthMask(value: boolean);
  36208. get depthTest(): boolean;
  36209. set depthTest(value: boolean);
  36210. get frontFace(): Nullable<number>;
  36211. set frontFace(value: Nullable<number>);
  36212. reset(): void;
  36213. apply(gl: WebGLRenderingContext): void;
  36214. }
  36215. }
  36216. declare module "babylonjs/States/stencilState" {
  36217. /**
  36218. * @hidden
  36219. **/
  36220. export class StencilState {
  36221. /** 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 */
  36222. static readonly ALWAYS: number;
  36223. /** Passed to stencilOperation to specify that stencil value must be kept */
  36224. static readonly KEEP: number;
  36225. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36226. static readonly REPLACE: number;
  36227. private _isStencilTestDirty;
  36228. private _isStencilMaskDirty;
  36229. private _isStencilFuncDirty;
  36230. private _isStencilOpDirty;
  36231. private _stencilTest;
  36232. private _stencilMask;
  36233. private _stencilFunc;
  36234. private _stencilFuncRef;
  36235. private _stencilFuncMask;
  36236. private _stencilOpStencilFail;
  36237. private _stencilOpDepthFail;
  36238. private _stencilOpStencilDepthPass;
  36239. get isDirty(): boolean;
  36240. get stencilFunc(): number;
  36241. set stencilFunc(value: number);
  36242. get stencilFuncRef(): number;
  36243. set stencilFuncRef(value: number);
  36244. get stencilFuncMask(): number;
  36245. set stencilFuncMask(value: number);
  36246. get stencilOpStencilFail(): number;
  36247. set stencilOpStencilFail(value: number);
  36248. get stencilOpDepthFail(): number;
  36249. set stencilOpDepthFail(value: number);
  36250. get stencilOpStencilDepthPass(): number;
  36251. set stencilOpStencilDepthPass(value: number);
  36252. get stencilMask(): number;
  36253. set stencilMask(value: number);
  36254. get stencilTest(): boolean;
  36255. set stencilTest(value: boolean);
  36256. constructor();
  36257. reset(): void;
  36258. apply(gl: WebGLRenderingContext): void;
  36259. }
  36260. }
  36261. declare module "babylonjs/States/alphaCullingState" {
  36262. /**
  36263. * @hidden
  36264. **/
  36265. export class AlphaState {
  36266. private _isAlphaBlendDirty;
  36267. private _isBlendFunctionParametersDirty;
  36268. private _isBlendEquationParametersDirty;
  36269. private _isBlendConstantsDirty;
  36270. private _alphaBlend;
  36271. private _blendFunctionParameters;
  36272. private _blendEquationParameters;
  36273. private _blendConstants;
  36274. /**
  36275. * Initializes the state.
  36276. */
  36277. constructor();
  36278. get isDirty(): boolean;
  36279. get alphaBlend(): boolean;
  36280. set alphaBlend(value: boolean);
  36281. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36282. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36283. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36284. reset(): void;
  36285. apply(gl: WebGLRenderingContext): void;
  36286. }
  36287. }
  36288. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36289. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36290. /** @hidden */
  36291. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36292. attributeProcessor(attribute: string): string;
  36293. varyingProcessor(varying: string, isFragment: boolean): string;
  36294. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36295. }
  36296. }
  36297. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36298. /**
  36299. * Interface for attribute information associated with buffer instanciation
  36300. */
  36301. export interface InstancingAttributeInfo {
  36302. /**
  36303. * Name of the GLSL attribute
  36304. * if attribute index is not specified, this is used to retrieve the index from the effect
  36305. */
  36306. attributeName: string;
  36307. /**
  36308. * Index/offset of the attribute in the vertex shader
  36309. * if not specified, this will be computes from the name.
  36310. */
  36311. index?: number;
  36312. /**
  36313. * size of the attribute, 1, 2, 3 or 4
  36314. */
  36315. attributeSize: number;
  36316. /**
  36317. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36318. */
  36319. offset: number;
  36320. /**
  36321. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36322. * default to 1
  36323. */
  36324. divisor?: number;
  36325. /**
  36326. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36327. * default is FLOAT
  36328. */
  36329. attributeType?: number;
  36330. /**
  36331. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36332. */
  36333. normalized?: boolean;
  36334. }
  36335. }
  36336. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36337. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36338. import { Nullable } from "babylonjs/types";
  36339. module "babylonjs/Engines/thinEngine" {
  36340. interface ThinEngine {
  36341. /**
  36342. * Update a video texture
  36343. * @param texture defines the texture to update
  36344. * @param video defines the video element to use
  36345. * @param invertY defines if data must be stored with Y axis inverted
  36346. */
  36347. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36348. }
  36349. }
  36350. }
  36351. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36353. import { Nullable } from "babylonjs/types";
  36354. module "babylonjs/Engines/thinEngine" {
  36355. interface ThinEngine {
  36356. /**
  36357. * Creates a dynamic texture
  36358. * @param width defines the width of the texture
  36359. * @param height defines the height of the texture
  36360. * @param generateMipMaps defines if the engine should generate the mip levels
  36361. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36362. * @returns the dynamic texture inside an InternalTexture
  36363. */
  36364. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36365. /**
  36366. * Update the content of a dynamic texture
  36367. * @param texture defines the texture to update
  36368. * @param canvas defines the canvas containing the source
  36369. * @param invertY defines if data must be stored with Y axis inverted
  36370. * @param premulAlpha defines if alpha is stored as premultiplied
  36371. * @param format defines the format of the data
  36372. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36373. */
  36374. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36375. }
  36376. }
  36377. }
  36378. declare module "babylonjs/Materials/Textures/videoTexture" {
  36379. import { Observable } from "babylonjs/Misc/observable";
  36380. import { Nullable } from "babylonjs/types";
  36381. import { Scene } from "babylonjs/scene";
  36382. import { Texture } from "babylonjs/Materials/Textures/texture";
  36383. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36384. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36385. /**
  36386. * Settings for finer control over video usage
  36387. */
  36388. export interface VideoTextureSettings {
  36389. /**
  36390. * Applies `autoplay` to video, if specified
  36391. */
  36392. autoPlay?: boolean;
  36393. /**
  36394. * Applies `loop` to video, if specified
  36395. */
  36396. loop?: boolean;
  36397. /**
  36398. * Automatically updates internal texture from video at every frame in the render loop
  36399. */
  36400. autoUpdateTexture: boolean;
  36401. /**
  36402. * Image src displayed during the video loading or until the user interacts with the video.
  36403. */
  36404. poster?: string;
  36405. }
  36406. /**
  36407. * If you want to display a video in your scene, this is the special texture for that.
  36408. * This special texture works similar to other textures, with the exception of a few parameters.
  36409. * @see https://doc.babylonjs.com/how_to/video_texture
  36410. */
  36411. export class VideoTexture extends Texture {
  36412. /**
  36413. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36414. */
  36415. readonly autoUpdateTexture: boolean;
  36416. /**
  36417. * The video instance used by the texture internally
  36418. */
  36419. readonly video: HTMLVideoElement;
  36420. private _onUserActionRequestedObservable;
  36421. /**
  36422. * Event triggerd when a dom action is required by the user to play the video.
  36423. * This happens due to recent changes in browser policies preventing video to auto start.
  36424. */
  36425. get onUserActionRequestedObservable(): Observable<Texture>;
  36426. private _generateMipMaps;
  36427. private _stillImageCaptured;
  36428. private _displayingPosterTexture;
  36429. private _settings;
  36430. private _createInternalTextureOnEvent;
  36431. private _frameId;
  36432. private _currentSrc;
  36433. /**
  36434. * Creates a video texture.
  36435. * If you want to display a video in your scene, this is the special texture for that.
  36436. * This special texture works similar to other textures, with the exception of a few parameters.
  36437. * @see https://doc.babylonjs.com/how_to/video_texture
  36438. * @param name optional name, will detect from video source, if not defined
  36439. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36440. * @param scene is obviously the current scene.
  36441. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36442. * @param invertY is false by default but can be used to invert video on Y axis
  36443. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36444. * @param settings allows finer control over video usage
  36445. */
  36446. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36447. private _getName;
  36448. private _getVideo;
  36449. private _createInternalTexture;
  36450. private reset;
  36451. /**
  36452. * @hidden Internal method to initiate `update`.
  36453. */
  36454. _rebuild(): void;
  36455. /**
  36456. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36457. */
  36458. update(): void;
  36459. /**
  36460. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36461. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36462. */
  36463. updateTexture(isVisible: boolean): void;
  36464. protected _updateInternalTexture: () => void;
  36465. /**
  36466. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36467. * @param url New url.
  36468. */
  36469. updateURL(url: string): void;
  36470. /**
  36471. * Clones the texture.
  36472. * @returns the cloned texture
  36473. */
  36474. clone(): VideoTexture;
  36475. /**
  36476. * Dispose the texture and release its associated resources.
  36477. */
  36478. dispose(): void;
  36479. /**
  36480. * Creates a video texture straight from a stream.
  36481. * @param scene Define the scene the texture should be created in
  36482. * @param stream Define the stream the texture should be created from
  36483. * @returns The created video texture as a promise
  36484. */
  36485. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36486. /**
  36487. * Creates a video texture straight from your WebCam video feed.
  36488. * @param scene Define the scene the texture should be created in
  36489. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36490. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36491. * @returns The created video texture as a promise
  36492. */
  36493. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36494. minWidth: number;
  36495. maxWidth: number;
  36496. minHeight: number;
  36497. maxHeight: number;
  36498. deviceId: string;
  36499. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36500. /**
  36501. * Creates a video texture straight from your WebCam video feed.
  36502. * @param scene Define the scene the texture should be created in
  36503. * @param onReady Define a callback to triggered once the texture will be ready
  36504. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36505. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36506. */
  36507. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36508. minWidth: number;
  36509. maxWidth: number;
  36510. minHeight: number;
  36511. maxHeight: number;
  36512. deviceId: string;
  36513. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36514. }
  36515. }
  36516. declare module "babylonjs/Engines/thinEngine" {
  36517. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36518. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36519. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36520. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36521. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36522. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36523. import { Observable } from "babylonjs/Misc/observable";
  36524. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36525. import { StencilState } from "babylonjs/States/stencilState";
  36526. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36527. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36528. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36529. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36530. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36531. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36532. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36533. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36534. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36535. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36536. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36537. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36538. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36539. import { WebRequest } from "babylonjs/Misc/webRequest";
  36540. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36541. /**
  36542. * Defines the interface used by objects working like Scene
  36543. * @hidden
  36544. */
  36545. export interface ISceneLike {
  36546. _addPendingData(data: any): void;
  36547. _removePendingData(data: any): void;
  36548. offlineProvider: IOfflineProvider;
  36549. }
  36550. /**
  36551. * Information about the current host
  36552. */
  36553. export interface HostInformation {
  36554. /**
  36555. * Defines if the current host is a mobile
  36556. */
  36557. isMobile: boolean;
  36558. }
  36559. /** Interface defining initialization parameters for Engine class */
  36560. export interface EngineOptions extends WebGLContextAttributes {
  36561. /**
  36562. * Defines if the engine should no exceed a specified device ratio
  36563. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36564. */
  36565. limitDeviceRatio?: number;
  36566. /**
  36567. * Defines if webvr should be enabled automatically
  36568. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36569. */
  36570. autoEnableWebVR?: boolean;
  36571. /**
  36572. * Defines if webgl2 should be turned off even if supported
  36573. * @see https://doc.babylonjs.com/features/webgl2
  36574. */
  36575. disableWebGL2Support?: boolean;
  36576. /**
  36577. * Defines if webaudio should be initialized as well
  36578. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36579. */
  36580. audioEngine?: boolean;
  36581. /**
  36582. * Defines if animations should run using a deterministic lock step
  36583. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36584. */
  36585. deterministicLockstep?: boolean;
  36586. /** Defines the maximum steps to use with deterministic lock step mode */
  36587. lockstepMaxSteps?: number;
  36588. /** Defines the seconds between each deterministic lock step */
  36589. timeStep?: number;
  36590. /**
  36591. * Defines that engine should ignore context lost events
  36592. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36593. */
  36594. doNotHandleContextLost?: boolean;
  36595. /**
  36596. * Defines that engine should ignore modifying touch action attribute and style
  36597. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36598. */
  36599. doNotHandleTouchAction?: boolean;
  36600. /**
  36601. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36602. */
  36603. useHighPrecisionFloats?: boolean;
  36604. /**
  36605. * Make the canvas XR Compatible for XR sessions
  36606. */
  36607. xrCompatible?: boolean;
  36608. /**
  36609. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36610. */
  36611. useHighPrecisionMatrix?: boolean;
  36612. }
  36613. /**
  36614. * The base engine class (root of all engines)
  36615. */
  36616. export class ThinEngine {
  36617. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36618. static ExceptionList: ({
  36619. key: string;
  36620. capture: string;
  36621. captureConstraint: number;
  36622. targets: string[];
  36623. } | {
  36624. key: string;
  36625. capture: null;
  36626. captureConstraint: null;
  36627. targets: string[];
  36628. })[];
  36629. /** @hidden */
  36630. static _TextureLoaders: IInternalTextureLoader[];
  36631. /**
  36632. * Returns the current npm package of the sdk
  36633. */
  36634. static get NpmPackage(): string;
  36635. /**
  36636. * Returns the current version of the framework
  36637. */
  36638. static get Version(): string;
  36639. /**
  36640. * Returns a string describing the current engine
  36641. */
  36642. get description(): string;
  36643. /**
  36644. * Gets or sets the epsilon value used by collision engine
  36645. */
  36646. static CollisionsEpsilon: number;
  36647. /**
  36648. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36649. */
  36650. static get ShadersRepository(): string;
  36651. static set ShadersRepository(value: string);
  36652. /** @hidden */
  36653. _shaderProcessor: IShaderProcessor;
  36654. /**
  36655. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36656. */
  36657. forcePOTTextures: boolean;
  36658. /**
  36659. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36660. */
  36661. isFullscreen: boolean;
  36662. /**
  36663. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36664. */
  36665. cullBackFaces: boolean;
  36666. /**
  36667. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36668. */
  36669. renderEvenInBackground: boolean;
  36670. /**
  36671. * Gets or sets a boolean indicating that cache can be kept between frames
  36672. */
  36673. preventCacheWipeBetweenFrames: boolean;
  36674. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36675. validateShaderPrograms: boolean;
  36676. /**
  36677. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36678. * This can provide greater z depth for distant objects.
  36679. */
  36680. useReverseDepthBuffer: boolean;
  36681. /**
  36682. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36683. */
  36684. disableUniformBuffers: boolean;
  36685. /** @hidden */
  36686. _uniformBuffers: UniformBuffer[];
  36687. /**
  36688. * Gets a boolean indicating that the engine supports uniform buffers
  36689. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36690. */
  36691. get supportsUniformBuffers(): boolean;
  36692. /** @hidden */
  36693. _gl: WebGLRenderingContext;
  36694. /** @hidden */
  36695. _webGLVersion: number;
  36696. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36697. protected _windowIsBackground: boolean;
  36698. protected _creationOptions: EngineOptions;
  36699. protected _highPrecisionShadersAllowed: boolean;
  36700. /** @hidden */
  36701. get _shouldUseHighPrecisionShader(): boolean;
  36702. /**
  36703. * Gets a boolean indicating that only power of 2 textures are supported
  36704. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36705. */
  36706. get needPOTTextures(): boolean;
  36707. /** @hidden */
  36708. _badOS: boolean;
  36709. /** @hidden */
  36710. _badDesktopOS: boolean;
  36711. private _hardwareScalingLevel;
  36712. /** @hidden */
  36713. _caps: EngineCapabilities;
  36714. private _isStencilEnable;
  36715. private _glVersion;
  36716. private _glRenderer;
  36717. private _glVendor;
  36718. /** @hidden */
  36719. _videoTextureSupported: boolean;
  36720. protected _renderingQueueLaunched: boolean;
  36721. protected _activeRenderLoops: (() => void)[];
  36722. /**
  36723. * Observable signaled when a context lost event is raised
  36724. */
  36725. onContextLostObservable: Observable<ThinEngine>;
  36726. /**
  36727. * Observable signaled when a context restored event is raised
  36728. */
  36729. onContextRestoredObservable: Observable<ThinEngine>;
  36730. private _onContextLost;
  36731. private _onContextRestored;
  36732. protected _contextWasLost: boolean;
  36733. /** @hidden */
  36734. _doNotHandleContextLost: boolean;
  36735. /**
  36736. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36737. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36738. */
  36739. get doNotHandleContextLost(): boolean;
  36740. set doNotHandleContextLost(value: boolean);
  36741. /**
  36742. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36743. */
  36744. disableVertexArrayObjects: boolean;
  36745. /** @hidden */
  36746. protected _colorWrite: boolean;
  36747. /** @hidden */
  36748. protected _colorWriteChanged: boolean;
  36749. /** @hidden */
  36750. protected _depthCullingState: DepthCullingState;
  36751. /** @hidden */
  36752. protected _stencilState: StencilState;
  36753. /** @hidden */
  36754. _alphaState: AlphaState;
  36755. /** @hidden */
  36756. _alphaMode: number;
  36757. /** @hidden */
  36758. _alphaEquation: number;
  36759. /** @hidden */
  36760. _internalTexturesCache: InternalTexture[];
  36761. /** @hidden */
  36762. protected _activeChannel: number;
  36763. private _currentTextureChannel;
  36764. /** @hidden */
  36765. protected _boundTexturesCache: {
  36766. [key: string]: Nullable<InternalTexture>;
  36767. };
  36768. /** @hidden */
  36769. protected _currentEffect: Nullable<Effect>;
  36770. /** @hidden */
  36771. protected _currentProgram: Nullable<WebGLProgram>;
  36772. private _compiledEffects;
  36773. private _vertexAttribArraysEnabled;
  36774. /** @hidden */
  36775. protected _cachedViewport: Nullable<IViewportLike>;
  36776. private _cachedVertexArrayObject;
  36777. /** @hidden */
  36778. protected _cachedVertexBuffers: any;
  36779. /** @hidden */
  36780. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36781. /** @hidden */
  36782. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36783. /** @hidden */
  36784. _currentRenderTarget: Nullable<InternalTexture>;
  36785. private _uintIndicesCurrentlySet;
  36786. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36787. /** @hidden */
  36788. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36789. /** @hidden */
  36790. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36791. private _currentBufferPointers;
  36792. private _currentInstanceLocations;
  36793. private _currentInstanceBuffers;
  36794. private _textureUnits;
  36795. /** @hidden */
  36796. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36797. /** @hidden */
  36798. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36799. /** @hidden */
  36800. _boundRenderFunction: any;
  36801. private _vaoRecordInProgress;
  36802. private _mustWipeVertexAttributes;
  36803. private _emptyTexture;
  36804. private _emptyCubeTexture;
  36805. private _emptyTexture3D;
  36806. private _emptyTexture2DArray;
  36807. /** @hidden */
  36808. _frameHandler: number;
  36809. private _nextFreeTextureSlots;
  36810. private _maxSimultaneousTextures;
  36811. private _activeRequests;
  36812. /** @hidden */
  36813. _transformTextureUrl: Nullable<(url: string) => string>;
  36814. /**
  36815. * Gets information about the current host
  36816. */
  36817. hostInformation: HostInformation;
  36818. protected get _supportsHardwareTextureRescaling(): boolean;
  36819. private _framebufferDimensionsObject;
  36820. /**
  36821. * sets the object from which width and height will be taken from when getting render width and height
  36822. * Will fallback to the gl object
  36823. * @param dimensions the framebuffer width and height that will be used.
  36824. */
  36825. set framebufferDimensionsObject(dimensions: Nullable<{
  36826. framebufferWidth: number;
  36827. framebufferHeight: number;
  36828. }>);
  36829. /**
  36830. * Gets the current viewport
  36831. */
  36832. get currentViewport(): Nullable<IViewportLike>;
  36833. /**
  36834. * Gets the default empty texture
  36835. */
  36836. get emptyTexture(): InternalTexture;
  36837. /**
  36838. * Gets the default empty 3D texture
  36839. */
  36840. get emptyTexture3D(): InternalTexture;
  36841. /**
  36842. * Gets the default empty 2D array texture
  36843. */
  36844. get emptyTexture2DArray(): InternalTexture;
  36845. /**
  36846. * Gets the default empty cube texture
  36847. */
  36848. get emptyCubeTexture(): InternalTexture;
  36849. /**
  36850. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36851. */
  36852. readonly premultipliedAlpha: boolean;
  36853. /**
  36854. * Observable event triggered before each texture is initialized
  36855. */
  36856. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36857. /**
  36858. * Creates a new engine
  36859. * @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
  36860. * @param antialias defines enable antialiasing (default: false)
  36861. * @param options defines further options to be sent to the getContext() function
  36862. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36863. */
  36864. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36865. private _rebuildInternalTextures;
  36866. private _rebuildEffects;
  36867. /**
  36868. * Gets a boolean indicating if all created effects are ready
  36869. * @returns true if all effects are ready
  36870. */
  36871. areAllEffectsReady(): boolean;
  36872. protected _rebuildBuffers(): void;
  36873. protected _initGLContext(): void;
  36874. /**
  36875. * Gets version of the current webGL context
  36876. */
  36877. get webGLVersion(): number;
  36878. /**
  36879. * Gets a string identifying the name of the class
  36880. * @returns "Engine" string
  36881. */
  36882. getClassName(): string;
  36883. /**
  36884. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36885. */
  36886. get isStencilEnable(): boolean;
  36887. /** @hidden */
  36888. _prepareWorkingCanvas(): void;
  36889. /**
  36890. * Reset the texture cache to empty state
  36891. */
  36892. resetTextureCache(): void;
  36893. /**
  36894. * Gets an object containing information about the current webGL context
  36895. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36896. */
  36897. getGlInfo(): {
  36898. vendor: string;
  36899. renderer: string;
  36900. version: string;
  36901. };
  36902. /**
  36903. * Defines the hardware scaling level.
  36904. * By default the hardware scaling level is computed from the window device ratio.
  36905. * 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.
  36906. * @param level defines the level to use
  36907. */
  36908. setHardwareScalingLevel(level: number): void;
  36909. /**
  36910. * Gets the current hardware scaling level.
  36911. * By default the hardware scaling level is computed from the window device ratio.
  36912. * 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.
  36913. * @returns a number indicating the current hardware scaling level
  36914. */
  36915. getHardwareScalingLevel(): number;
  36916. /**
  36917. * Gets the list of loaded textures
  36918. * @returns an array containing all loaded textures
  36919. */
  36920. getLoadedTexturesCache(): InternalTexture[];
  36921. /**
  36922. * Gets the object containing all engine capabilities
  36923. * @returns the EngineCapabilities object
  36924. */
  36925. getCaps(): EngineCapabilities;
  36926. /**
  36927. * stop executing a render loop function and remove it from the execution array
  36928. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36929. */
  36930. stopRenderLoop(renderFunction?: () => void): void;
  36931. /** @hidden */
  36932. _renderLoop(): void;
  36933. /**
  36934. * Gets the HTML canvas attached with the current webGL context
  36935. * @returns a HTML canvas
  36936. */
  36937. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36938. /**
  36939. * Gets host window
  36940. * @returns the host window object
  36941. */
  36942. getHostWindow(): Nullable<Window>;
  36943. /**
  36944. * Gets the current render width
  36945. * @param useScreen defines if screen size must be used (or the current render target if any)
  36946. * @returns a number defining the current render width
  36947. */
  36948. getRenderWidth(useScreen?: boolean): number;
  36949. /**
  36950. * Gets the current render height
  36951. * @param useScreen defines if screen size must be used (or the current render target if any)
  36952. * @returns a number defining the current render height
  36953. */
  36954. getRenderHeight(useScreen?: boolean): number;
  36955. /**
  36956. * Can be used to override the current requestAnimationFrame requester.
  36957. * @hidden
  36958. */
  36959. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36960. /**
  36961. * Register and execute a render loop. The engine can have more than one render function
  36962. * @param renderFunction defines the function to continuously execute
  36963. */
  36964. runRenderLoop(renderFunction: () => void): void;
  36965. /**
  36966. * Clear the current render buffer or the current render target (if any is set up)
  36967. * @param color defines the color to use
  36968. * @param backBuffer defines if the back buffer must be cleared
  36969. * @param depth defines if the depth buffer must be cleared
  36970. * @param stencil defines if the stencil buffer must be cleared
  36971. */
  36972. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36973. private _viewportCached;
  36974. /** @hidden */
  36975. _viewport(x: number, y: number, width: number, height: number): void;
  36976. /**
  36977. * Set the WebGL's viewport
  36978. * @param viewport defines the viewport element to be used
  36979. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36980. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36981. */
  36982. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36983. /**
  36984. * Begin a new frame
  36985. */
  36986. beginFrame(): void;
  36987. /**
  36988. * Enf the current frame
  36989. */
  36990. endFrame(): void;
  36991. /**
  36992. * Resize the view according to the canvas' size
  36993. */
  36994. resize(): void;
  36995. /**
  36996. * Force a specific size of the canvas
  36997. * @param width defines the new canvas' width
  36998. * @param height defines the new canvas' height
  36999. * @returns true if the size was changed
  37000. */
  37001. setSize(width: number, height: number): boolean;
  37002. /**
  37003. * Binds the frame buffer to the specified texture.
  37004. * @param texture The texture to render to or null for the default canvas
  37005. * @param faceIndex The face of the texture to render to in case of cube texture
  37006. * @param requiredWidth The width of the target to render to
  37007. * @param requiredHeight The height of the target to render to
  37008. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  37009. * @param lodLevel defines the lod level to bind to the frame buffer
  37010. * @param layer defines the 2d array index to bind to frame buffer to
  37011. */
  37012. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  37013. /** @hidden */
  37014. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  37015. /**
  37016. * Unbind the current render target texture from the webGL context
  37017. * @param texture defines the render target texture to unbind
  37018. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  37019. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  37020. */
  37021. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  37022. /**
  37023. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  37024. */
  37025. flushFramebuffer(): void;
  37026. /**
  37027. * Unbind the current render target and bind the default framebuffer
  37028. */
  37029. restoreDefaultFramebuffer(): void;
  37030. /** @hidden */
  37031. protected _resetVertexBufferBinding(): void;
  37032. /**
  37033. * Creates a vertex buffer
  37034. * @param data the data for the vertex buffer
  37035. * @returns the new WebGL static buffer
  37036. */
  37037. createVertexBuffer(data: DataArray): DataBuffer;
  37038. private _createVertexBuffer;
  37039. /**
  37040. * Creates a dynamic vertex buffer
  37041. * @param data the data for the dynamic vertex buffer
  37042. * @returns the new WebGL dynamic buffer
  37043. */
  37044. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37045. protected _resetIndexBufferBinding(): void;
  37046. /**
  37047. * Creates a new index buffer
  37048. * @param indices defines the content of the index buffer
  37049. * @param updatable defines if the index buffer must be updatable
  37050. * @returns a new webGL buffer
  37051. */
  37052. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37053. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37054. /**
  37055. * Bind a webGL buffer to the webGL context
  37056. * @param buffer defines the buffer to bind
  37057. */
  37058. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37059. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37060. private bindBuffer;
  37061. /**
  37062. * update the bound buffer with the given data
  37063. * @param data defines the data to update
  37064. */
  37065. updateArrayBuffer(data: Float32Array): void;
  37066. private _vertexAttribPointer;
  37067. /** @hidden */
  37068. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37069. private _bindVertexBuffersAttributes;
  37070. /**
  37071. * Records a vertex array object
  37072. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37073. * @param vertexBuffers defines the list of vertex buffers to store
  37074. * @param indexBuffer defines the index buffer to store
  37075. * @param effect defines the effect to store
  37076. * @returns the new vertex array object
  37077. */
  37078. recordVertexArrayObject(vertexBuffers: {
  37079. [key: string]: VertexBuffer;
  37080. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37081. /**
  37082. * Bind a specific vertex array object
  37083. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37084. * @param vertexArrayObject defines the vertex array object to bind
  37085. * @param indexBuffer defines the index buffer to bind
  37086. */
  37087. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37088. /**
  37089. * Bind webGl buffers directly to the webGL context
  37090. * @param vertexBuffer defines the vertex buffer to bind
  37091. * @param indexBuffer defines the index buffer to bind
  37092. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37093. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37094. * @param effect defines the effect associated with the vertex buffer
  37095. */
  37096. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37097. private _unbindVertexArrayObject;
  37098. /**
  37099. * Bind a list of vertex buffers to the webGL context
  37100. * @param vertexBuffers defines the list of vertex buffers to bind
  37101. * @param indexBuffer defines the index buffer to bind
  37102. * @param effect defines the effect associated with the vertex buffers
  37103. */
  37104. bindBuffers(vertexBuffers: {
  37105. [key: string]: Nullable<VertexBuffer>;
  37106. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37107. /**
  37108. * Unbind all instance attributes
  37109. */
  37110. unbindInstanceAttributes(): void;
  37111. /**
  37112. * Release and free the memory of a vertex array object
  37113. * @param vao defines the vertex array object to delete
  37114. */
  37115. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37116. /** @hidden */
  37117. _releaseBuffer(buffer: DataBuffer): boolean;
  37118. protected _deleteBuffer(buffer: DataBuffer): void;
  37119. /**
  37120. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37121. * @param instancesBuffer defines the webGL buffer to update and bind
  37122. * @param data defines the data to store in the buffer
  37123. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37124. */
  37125. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37126. /**
  37127. * Bind the content of a webGL buffer used with instantiation
  37128. * @param instancesBuffer defines the webGL buffer to bind
  37129. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37130. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37131. */
  37132. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37133. /**
  37134. * Disable the instance attribute corresponding to the name in parameter
  37135. * @param name defines the name of the attribute to disable
  37136. */
  37137. disableInstanceAttributeByName(name: string): void;
  37138. /**
  37139. * Disable the instance attribute corresponding to the location in parameter
  37140. * @param attributeLocation defines the attribute location of the attribute to disable
  37141. */
  37142. disableInstanceAttribute(attributeLocation: number): void;
  37143. /**
  37144. * Disable the attribute corresponding to the location in parameter
  37145. * @param attributeLocation defines the attribute location of the attribute to disable
  37146. */
  37147. disableAttributeByIndex(attributeLocation: number): void;
  37148. /**
  37149. * Send a draw order
  37150. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37151. * @param indexStart defines the starting index
  37152. * @param indexCount defines the number of index to draw
  37153. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37154. */
  37155. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37156. /**
  37157. * Draw a list of points
  37158. * @param verticesStart defines the index of first vertex to draw
  37159. * @param verticesCount defines the count of vertices to draw
  37160. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37161. */
  37162. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37163. /**
  37164. * Draw a list of unindexed primitives
  37165. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37166. * @param verticesStart defines the index of first vertex to draw
  37167. * @param verticesCount defines the count of vertices to draw
  37168. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37169. */
  37170. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37171. /**
  37172. * Draw a list of indexed primitives
  37173. * @param fillMode defines the primitive to use
  37174. * @param indexStart defines the starting index
  37175. * @param indexCount defines the number of index to draw
  37176. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37177. */
  37178. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37179. /**
  37180. * Draw a list of unindexed primitives
  37181. * @param fillMode defines the primitive to use
  37182. * @param verticesStart defines the index of first vertex to draw
  37183. * @param verticesCount defines the count of vertices to draw
  37184. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37185. */
  37186. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37187. private _drawMode;
  37188. /** @hidden */
  37189. protected _reportDrawCall(): void;
  37190. /** @hidden */
  37191. _releaseEffect(effect: Effect): void;
  37192. /** @hidden */
  37193. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37194. /**
  37195. * Create a new effect (used to store vertex/fragment shaders)
  37196. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37197. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37198. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37199. * @param samplers defines an array of string used to represent textures
  37200. * @param defines defines the string containing the defines to use to compile the shaders
  37201. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37202. * @param onCompiled defines a function to call when the effect creation is successful
  37203. * @param onError defines a function to call when the effect creation has failed
  37204. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37205. * @returns the new Effect
  37206. */
  37207. 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;
  37208. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37209. private _compileShader;
  37210. private _compileRawShader;
  37211. /** @hidden */
  37212. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37213. /**
  37214. * Directly creates a webGL program
  37215. * @param pipelineContext defines the pipeline context to attach to
  37216. * @param vertexCode defines the vertex shader code to use
  37217. * @param fragmentCode defines the fragment shader code to use
  37218. * @param context defines the webGL context to use (if not set, the current one will be used)
  37219. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37220. * @returns the new webGL program
  37221. */
  37222. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37223. /**
  37224. * Creates a webGL program
  37225. * @param pipelineContext defines the pipeline context to attach to
  37226. * @param vertexCode defines the vertex shader code to use
  37227. * @param fragmentCode defines the fragment shader code to use
  37228. * @param defines defines the string containing the defines to use to compile the shaders
  37229. * @param context defines the webGL context to use (if not set, the current one will be used)
  37230. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37231. * @returns the new webGL program
  37232. */
  37233. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37234. /**
  37235. * Creates a new pipeline context
  37236. * @returns the new pipeline
  37237. */
  37238. createPipelineContext(): IPipelineContext;
  37239. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37240. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37241. /** @hidden */
  37242. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37243. /** @hidden */
  37244. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37245. /** @hidden */
  37246. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37247. /**
  37248. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37249. * @param pipelineContext defines the pipeline context to use
  37250. * @param uniformsNames defines the list of uniform names
  37251. * @returns an array of webGL uniform locations
  37252. */
  37253. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37254. /**
  37255. * Gets the lsit of active attributes for a given webGL program
  37256. * @param pipelineContext defines the pipeline context to use
  37257. * @param attributesNames defines the list of attribute names to get
  37258. * @returns an array of indices indicating the offset of each attribute
  37259. */
  37260. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37261. /**
  37262. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37263. * @param effect defines the effect to activate
  37264. */
  37265. enableEffect(effect: Nullable<Effect>): void;
  37266. /**
  37267. * Set the value of an uniform to a number (int)
  37268. * @param uniform defines the webGL uniform location where to store the value
  37269. * @param value defines the int number to store
  37270. * @returns true if the value was set
  37271. */
  37272. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37273. /**
  37274. * Set the value of an uniform to an array of int32
  37275. * @param uniform defines the webGL uniform location where to store the value
  37276. * @param array defines the array of int32 to store
  37277. * @returns true if the value was set
  37278. */
  37279. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37280. /**
  37281. * Set the value of an uniform to an array of int32 (stored as vec2)
  37282. * @param uniform defines the webGL uniform location where to store the value
  37283. * @param array defines the array of int32 to store
  37284. * @returns true if the value was set
  37285. */
  37286. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37287. /**
  37288. * Set the value of an uniform to an array of int32 (stored as vec3)
  37289. * @param uniform defines the webGL uniform location where to store the value
  37290. * @param array defines the array of int32 to store
  37291. * @returns true if the value was set
  37292. */
  37293. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37294. /**
  37295. * Set the value of an uniform to an array of int32 (stored as vec4)
  37296. * @param uniform defines the webGL uniform location where to store the value
  37297. * @param array defines the array of int32 to store
  37298. * @returns true if the value was set
  37299. */
  37300. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37301. /**
  37302. * Set the value of an uniform to an array of number
  37303. * @param uniform defines the webGL uniform location where to store the value
  37304. * @param array defines the array of number to store
  37305. * @returns true if the value was set
  37306. */
  37307. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37308. /**
  37309. * Set the value of an uniform to an array of number (stored as vec2)
  37310. * @param uniform defines the webGL uniform location where to store the value
  37311. * @param array defines the array of number to store
  37312. * @returns true if the value was set
  37313. */
  37314. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37315. /**
  37316. * Set the value of an uniform to an array of number (stored as vec3)
  37317. * @param uniform defines the webGL uniform location where to store the value
  37318. * @param array defines the array of number to store
  37319. * @returns true if the value was set
  37320. */
  37321. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37322. /**
  37323. * Set the value of an uniform to an array of number (stored as vec4)
  37324. * @param uniform defines the webGL uniform location where to store the value
  37325. * @param array defines the array of number to store
  37326. * @returns true if the value was set
  37327. */
  37328. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37329. /**
  37330. * Set the value of an uniform to an array of float32 (stored as matrices)
  37331. * @param uniform defines the webGL uniform location where to store the value
  37332. * @param matrices defines the array of float32 to store
  37333. * @returns true if the value was set
  37334. */
  37335. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  37336. /**
  37337. * Set the value of an uniform to a matrix (3x3)
  37338. * @param uniform defines the webGL uniform location where to store the value
  37339. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37340. * @returns true if the value was set
  37341. */
  37342. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37343. /**
  37344. * Set the value of an uniform to a matrix (2x2)
  37345. * @param uniform defines the webGL uniform location where to store the value
  37346. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37347. * @returns true if the value was set
  37348. */
  37349. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37350. /**
  37351. * Set the value of an uniform to a number (float)
  37352. * @param uniform defines the webGL uniform location where to store the value
  37353. * @param value defines the float number to store
  37354. * @returns true if the value was transfered
  37355. */
  37356. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37357. /**
  37358. * Set the value of an uniform to a vec2
  37359. * @param uniform defines the webGL uniform location where to store the value
  37360. * @param x defines the 1st component of the value
  37361. * @param y defines the 2nd component of the value
  37362. * @returns true if the value was set
  37363. */
  37364. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  37365. /**
  37366. * Set the value of an uniform to a vec3
  37367. * @param uniform defines the webGL uniform location where to store the value
  37368. * @param x defines the 1st component of the value
  37369. * @param y defines the 2nd component of the value
  37370. * @param z defines the 3rd component of the value
  37371. * @returns true if the value was set
  37372. */
  37373. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  37374. /**
  37375. * Set the value of an uniform to a vec4
  37376. * @param uniform defines the webGL uniform location where to store the value
  37377. * @param x defines the 1st component of the value
  37378. * @param y defines the 2nd component of the value
  37379. * @param z defines the 3rd component of the value
  37380. * @param w defines the 4th component of the value
  37381. * @returns true if the value was set
  37382. */
  37383. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  37384. /**
  37385. * Apply all cached states (depth, culling, stencil and alpha)
  37386. */
  37387. applyStates(): void;
  37388. /**
  37389. * Enable or disable color writing
  37390. * @param enable defines the state to set
  37391. */
  37392. setColorWrite(enable: boolean): void;
  37393. /**
  37394. * Gets a boolean indicating if color writing is enabled
  37395. * @returns the current color writing state
  37396. */
  37397. getColorWrite(): boolean;
  37398. /**
  37399. * Gets the depth culling state manager
  37400. */
  37401. get depthCullingState(): DepthCullingState;
  37402. /**
  37403. * Gets the alpha state manager
  37404. */
  37405. get alphaState(): AlphaState;
  37406. /**
  37407. * Gets the stencil state manager
  37408. */
  37409. get stencilState(): StencilState;
  37410. /**
  37411. * Clears the list of texture accessible through engine.
  37412. * This can help preventing texture load conflict due to name collision.
  37413. */
  37414. clearInternalTexturesCache(): void;
  37415. /**
  37416. * Force the entire cache to be cleared
  37417. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37418. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37419. */
  37420. wipeCaches(bruteForce?: boolean): void;
  37421. /** @hidden */
  37422. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37423. min: number;
  37424. mag: number;
  37425. };
  37426. /** @hidden */
  37427. _createTexture(): WebGLTexture;
  37428. /**
  37429. * Usually called from Texture.ts.
  37430. * Passed information to create a WebGLTexture
  37431. * @param url defines a value which contains one of the following:
  37432. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37433. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37434. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37435. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37436. * @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)
  37437. * @param scene needed for loading to the correct scene
  37438. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37439. * @param onLoad optional callback to be called upon successful completion
  37440. * @param onError optional callback to be called upon failure
  37441. * @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
  37442. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37443. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37444. * @param forcedExtension defines the extension to use to pick the right loader
  37445. * @param mimeType defines an optional mime type
  37446. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37447. */
  37448. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  37449. /**
  37450. * Loads an image as an HTMLImageElement.
  37451. * @param input url string, ArrayBuffer, or Blob to load
  37452. * @param onLoad callback called when the image successfully loads
  37453. * @param onError callback called when the image fails to load
  37454. * @param offlineProvider offline provider for caching
  37455. * @param mimeType optional mime type
  37456. * @returns the HTMLImageElement of the loaded image
  37457. * @hidden
  37458. */
  37459. 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>;
  37460. /**
  37461. * @hidden
  37462. */
  37463. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37464. private _unpackFlipYCached;
  37465. /**
  37466. * In case you are sharing the context with other applications, it might
  37467. * be interested to not cache the unpack flip y state to ensure a consistent
  37468. * value would be set.
  37469. */
  37470. enableUnpackFlipYCached: boolean;
  37471. /** @hidden */
  37472. _unpackFlipY(value: boolean): void;
  37473. /** @hidden */
  37474. _getUnpackAlignement(): number;
  37475. private _getTextureTarget;
  37476. /**
  37477. * Update the sampling mode of a given texture
  37478. * @param samplingMode defines the required sampling mode
  37479. * @param texture defines the texture to update
  37480. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37481. */
  37482. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37483. /**
  37484. * Update the sampling mode of a given texture
  37485. * @param texture defines the texture to update
  37486. * @param wrapU defines the texture wrap mode of the u coordinates
  37487. * @param wrapV defines the texture wrap mode of the v coordinates
  37488. * @param wrapR defines the texture wrap mode of the r coordinates
  37489. */
  37490. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37491. /** @hidden */
  37492. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37493. width: number;
  37494. height: number;
  37495. layers?: number;
  37496. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37497. /** @hidden */
  37498. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37499. /** @hidden */
  37500. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37501. /**
  37502. * Update a portion of an internal texture
  37503. * @param texture defines the texture to update
  37504. * @param imageData defines the data to store into the texture
  37505. * @param xOffset defines the x coordinates of the update rectangle
  37506. * @param yOffset defines the y coordinates of the update rectangle
  37507. * @param width defines the width of the update rectangle
  37508. * @param height defines the height of the update rectangle
  37509. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37510. * @param lod defines the lod level to update (0 by default)
  37511. */
  37512. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37513. /** @hidden */
  37514. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37515. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37516. private _prepareWebGLTexture;
  37517. /** @hidden */
  37518. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37519. private _getDepthStencilBuffer;
  37520. /** @hidden */
  37521. _releaseFramebufferObjects(texture: InternalTexture): void;
  37522. /** @hidden */
  37523. _releaseTexture(texture: InternalTexture): void;
  37524. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37525. protected _setProgram(program: WebGLProgram): void;
  37526. protected _boundUniforms: {
  37527. [key: number]: WebGLUniformLocation;
  37528. };
  37529. /**
  37530. * Binds an effect to the webGL context
  37531. * @param effect defines the effect to bind
  37532. */
  37533. bindSamplers(effect: Effect): void;
  37534. private _activateCurrentTexture;
  37535. /** @hidden */
  37536. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37537. /** @hidden */
  37538. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37539. /**
  37540. * Unbind all textures from the webGL context
  37541. */
  37542. unbindAllTextures(): void;
  37543. /**
  37544. * Sets a texture to the according uniform.
  37545. * @param channel The texture channel
  37546. * @param uniform The uniform to set
  37547. * @param texture The texture to apply
  37548. */
  37549. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37550. private _bindSamplerUniformToChannel;
  37551. private _getTextureWrapMode;
  37552. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37553. /**
  37554. * Sets an array of texture to the webGL context
  37555. * @param channel defines the channel where the texture array must be set
  37556. * @param uniform defines the associated uniform location
  37557. * @param textures defines the array of textures to bind
  37558. */
  37559. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37560. /** @hidden */
  37561. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37562. private _setTextureParameterFloat;
  37563. private _setTextureParameterInteger;
  37564. /**
  37565. * Unbind all vertex attributes from the webGL context
  37566. */
  37567. unbindAllAttributes(): void;
  37568. /**
  37569. * 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
  37570. */
  37571. releaseEffects(): void;
  37572. /**
  37573. * Dispose and release all associated resources
  37574. */
  37575. dispose(): void;
  37576. /**
  37577. * Attach a new callback raised when context lost event is fired
  37578. * @param callback defines the callback to call
  37579. */
  37580. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37581. /**
  37582. * Attach a new callback raised when context restored event is fired
  37583. * @param callback defines the callback to call
  37584. */
  37585. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37586. /**
  37587. * Get the current error code of the webGL context
  37588. * @returns the error code
  37589. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37590. */
  37591. getError(): number;
  37592. private _canRenderToFloatFramebuffer;
  37593. private _canRenderToHalfFloatFramebuffer;
  37594. private _canRenderToFramebuffer;
  37595. /** @hidden */
  37596. _getWebGLTextureType(type: number): number;
  37597. /** @hidden */
  37598. _getInternalFormat(format: number): number;
  37599. /** @hidden */
  37600. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37601. /** @hidden */
  37602. _getRGBAMultiSampleBufferFormat(type: number): number;
  37603. /** @hidden */
  37604. _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;
  37605. /**
  37606. * Loads a file from a url
  37607. * @param url url to load
  37608. * @param onSuccess callback called when the file successfully loads
  37609. * @param onProgress callback called while file is loading (if the server supports this mode)
  37610. * @param offlineProvider defines the offline provider for caching
  37611. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37612. * @param onError callback called when the file fails to load
  37613. * @returns a file request object
  37614. * @hidden
  37615. */
  37616. 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;
  37617. /**
  37618. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37619. * @param x defines the x coordinate of the rectangle where pixels must be read
  37620. * @param y defines the y coordinate of the rectangle where pixels must be read
  37621. * @param width defines the width of the rectangle where pixels must be read
  37622. * @param height defines the height of the rectangle where pixels must be read
  37623. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37624. * @returns a Uint8Array containing RGBA colors
  37625. */
  37626. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37627. private static _isSupported;
  37628. /**
  37629. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37630. * @returns true if the engine can be created
  37631. * @ignorenaming
  37632. */
  37633. static isSupported(): boolean;
  37634. /**
  37635. * Find the next highest power of two.
  37636. * @param x Number to start search from.
  37637. * @return Next highest power of two.
  37638. */
  37639. static CeilingPOT(x: number): number;
  37640. /**
  37641. * Find the next lowest power of two.
  37642. * @param x Number to start search from.
  37643. * @return Next lowest power of two.
  37644. */
  37645. static FloorPOT(x: number): number;
  37646. /**
  37647. * Find the nearest power of two.
  37648. * @param x Number to start search from.
  37649. * @return Next nearest power of two.
  37650. */
  37651. static NearestPOT(x: number): number;
  37652. /**
  37653. * Get the closest exponent of two
  37654. * @param value defines the value to approximate
  37655. * @param max defines the maximum value to return
  37656. * @param mode defines how to define the closest value
  37657. * @returns closest exponent of two of the given value
  37658. */
  37659. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37660. /**
  37661. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37662. * @param func - the function to be called
  37663. * @param requester - the object that will request the next frame. Falls back to window.
  37664. * @returns frame number
  37665. */
  37666. static QueueNewFrame(func: () => void, requester?: any): number;
  37667. /**
  37668. * Gets host document
  37669. * @returns the host document object
  37670. */
  37671. getHostDocument(): Nullable<Document>;
  37672. }
  37673. }
  37674. declare module "babylonjs/Maths/sphericalPolynomial" {
  37675. import { Vector3 } from "babylonjs/Maths/math.vector";
  37676. import { Color3 } from "babylonjs/Maths/math.color";
  37677. /**
  37678. * Class representing spherical harmonics coefficients to the 3rd degree
  37679. */
  37680. export class SphericalHarmonics {
  37681. /**
  37682. * Defines whether or not the harmonics have been prescaled for rendering.
  37683. */
  37684. preScaled: boolean;
  37685. /**
  37686. * The l0,0 coefficients of the spherical harmonics
  37687. */
  37688. l00: Vector3;
  37689. /**
  37690. * The l1,-1 coefficients of the spherical harmonics
  37691. */
  37692. l1_1: Vector3;
  37693. /**
  37694. * The l1,0 coefficients of the spherical harmonics
  37695. */
  37696. l10: Vector3;
  37697. /**
  37698. * The l1,1 coefficients of the spherical harmonics
  37699. */
  37700. l11: Vector3;
  37701. /**
  37702. * The l2,-2 coefficients of the spherical harmonics
  37703. */
  37704. l2_2: Vector3;
  37705. /**
  37706. * The l2,-1 coefficients of the spherical harmonics
  37707. */
  37708. l2_1: Vector3;
  37709. /**
  37710. * The l2,0 coefficients of the spherical harmonics
  37711. */
  37712. l20: Vector3;
  37713. /**
  37714. * The l2,1 coefficients of the spherical harmonics
  37715. */
  37716. l21: Vector3;
  37717. /**
  37718. * The l2,2 coefficients of the spherical harmonics
  37719. */
  37720. l22: Vector3;
  37721. /**
  37722. * Adds a light to the spherical harmonics
  37723. * @param direction the direction of the light
  37724. * @param color the color of the light
  37725. * @param deltaSolidAngle the delta solid angle of the light
  37726. */
  37727. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37728. /**
  37729. * Scales the spherical harmonics by the given amount
  37730. * @param scale the amount to scale
  37731. */
  37732. scaleInPlace(scale: number): void;
  37733. /**
  37734. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37735. *
  37736. * ```
  37737. * E_lm = A_l * L_lm
  37738. * ```
  37739. *
  37740. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37741. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37742. * the scaling factors are given in equation 9.
  37743. */
  37744. convertIncidentRadianceToIrradiance(): void;
  37745. /**
  37746. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37747. *
  37748. * ```
  37749. * L = (1/pi) * E * rho
  37750. * ```
  37751. *
  37752. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37753. */
  37754. convertIrradianceToLambertianRadiance(): void;
  37755. /**
  37756. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37757. * required operations at run time.
  37758. *
  37759. * This is simply done by scaling back the SH with Ylm constants parameter.
  37760. * The trigonometric part being applied by the shader at run time.
  37761. */
  37762. preScaleForRendering(): void;
  37763. /**
  37764. * Constructs a spherical harmonics from an array.
  37765. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37766. * @returns the spherical harmonics
  37767. */
  37768. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37769. /**
  37770. * Gets the spherical harmonics from polynomial
  37771. * @param polynomial the spherical polynomial
  37772. * @returns the spherical harmonics
  37773. */
  37774. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37775. }
  37776. /**
  37777. * Class representing spherical polynomial coefficients to the 3rd degree
  37778. */
  37779. export class SphericalPolynomial {
  37780. private _harmonics;
  37781. /**
  37782. * The spherical harmonics used to create the polynomials.
  37783. */
  37784. get preScaledHarmonics(): SphericalHarmonics;
  37785. /**
  37786. * The x coefficients of the spherical polynomial
  37787. */
  37788. x: Vector3;
  37789. /**
  37790. * The y coefficients of the spherical polynomial
  37791. */
  37792. y: Vector3;
  37793. /**
  37794. * The z coefficients of the spherical polynomial
  37795. */
  37796. z: Vector3;
  37797. /**
  37798. * The xx coefficients of the spherical polynomial
  37799. */
  37800. xx: Vector3;
  37801. /**
  37802. * The yy coefficients of the spherical polynomial
  37803. */
  37804. yy: Vector3;
  37805. /**
  37806. * The zz coefficients of the spherical polynomial
  37807. */
  37808. zz: Vector3;
  37809. /**
  37810. * The xy coefficients of the spherical polynomial
  37811. */
  37812. xy: Vector3;
  37813. /**
  37814. * The yz coefficients of the spherical polynomial
  37815. */
  37816. yz: Vector3;
  37817. /**
  37818. * The zx coefficients of the spherical polynomial
  37819. */
  37820. zx: Vector3;
  37821. /**
  37822. * Adds an ambient color to the spherical polynomial
  37823. * @param color the color to add
  37824. */
  37825. addAmbient(color: Color3): void;
  37826. /**
  37827. * Scales the spherical polynomial by the given amount
  37828. * @param scale the amount to scale
  37829. */
  37830. scaleInPlace(scale: number): void;
  37831. /**
  37832. * Gets the spherical polynomial from harmonics
  37833. * @param harmonics the spherical harmonics
  37834. * @returns the spherical polynomial
  37835. */
  37836. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37837. /**
  37838. * Constructs a spherical polynomial from an array.
  37839. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37840. * @returns the spherical polynomial
  37841. */
  37842. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37843. }
  37844. }
  37845. declare module "babylonjs/Materials/Textures/internalTexture" {
  37846. import { Observable } from "babylonjs/Misc/observable";
  37847. import { Nullable, int } from "babylonjs/types";
  37848. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37850. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37851. /**
  37852. * Defines the source of the internal texture
  37853. */
  37854. export enum InternalTextureSource {
  37855. /**
  37856. * The source of the texture data is unknown
  37857. */
  37858. Unknown = 0,
  37859. /**
  37860. * Texture data comes from an URL
  37861. */
  37862. Url = 1,
  37863. /**
  37864. * Texture data is only used for temporary storage
  37865. */
  37866. Temp = 2,
  37867. /**
  37868. * Texture data comes from raw data (ArrayBuffer)
  37869. */
  37870. Raw = 3,
  37871. /**
  37872. * Texture content is dynamic (video or dynamic texture)
  37873. */
  37874. Dynamic = 4,
  37875. /**
  37876. * Texture content is generated by rendering to it
  37877. */
  37878. RenderTarget = 5,
  37879. /**
  37880. * Texture content is part of a multi render target process
  37881. */
  37882. MultiRenderTarget = 6,
  37883. /**
  37884. * Texture data comes from a cube data file
  37885. */
  37886. Cube = 7,
  37887. /**
  37888. * Texture data comes from a raw cube data
  37889. */
  37890. CubeRaw = 8,
  37891. /**
  37892. * Texture data come from a prefiltered cube data file
  37893. */
  37894. CubePrefiltered = 9,
  37895. /**
  37896. * Texture content is raw 3D data
  37897. */
  37898. Raw3D = 10,
  37899. /**
  37900. * Texture content is raw 2D array data
  37901. */
  37902. Raw2DArray = 11,
  37903. /**
  37904. * Texture content is a depth texture
  37905. */
  37906. Depth = 12,
  37907. /**
  37908. * Texture data comes from a raw cube data encoded with RGBD
  37909. */
  37910. CubeRawRGBD = 13
  37911. }
  37912. /**
  37913. * Class used to store data associated with WebGL texture data for the engine
  37914. * This class should not be used directly
  37915. */
  37916. export class InternalTexture {
  37917. /** @hidden */
  37918. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37919. /**
  37920. * Defines if the texture is ready
  37921. */
  37922. isReady: boolean;
  37923. /**
  37924. * Defines if the texture is a cube texture
  37925. */
  37926. isCube: boolean;
  37927. /**
  37928. * Defines if the texture contains 3D data
  37929. */
  37930. is3D: boolean;
  37931. /**
  37932. * Defines if the texture contains 2D array data
  37933. */
  37934. is2DArray: boolean;
  37935. /**
  37936. * Defines if the texture contains multiview data
  37937. */
  37938. isMultiview: boolean;
  37939. /**
  37940. * Gets the URL used to load this texture
  37941. */
  37942. url: string;
  37943. /**
  37944. * Gets the sampling mode of the texture
  37945. */
  37946. samplingMode: number;
  37947. /**
  37948. * Gets a boolean indicating if the texture needs mipmaps generation
  37949. */
  37950. generateMipMaps: boolean;
  37951. /**
  37952. * Gets the number of samples used by the texture (WebGL2+ only)
  37953. */
  37954. samples: number;
  37955. /**
  37956. * Gets the type of the texture (int, float...)
  37957. */
  37958. type: number;
  37959. /**
  37960. * Gets the format of the texture (RGB, RGBA...)
  37961. */
  37962. format: number;
  37963. /**
  37964. * Observable called when the texture is loaded
  37965. */
  37966. onLoadedObservable: Observable<InternalTexture>;
  37967. /**
  37968. * Gets the width of the texture
  37969. */
  37970. width: number;
  37971. /**
  37972. * Gets the height of the texture
  37973. */
  37974. height: number;
  37975. /**
  37976. * Gets the depth of the texture
  37977. */
  37978. depth: number;
  37979. /**
  37980. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37981. */
  37982. baseWidth: number;
  37983. /**
  37984. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37985. */
  37986. baseHeight: number;
  37987. /**
  37988. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37989. */
  37990. baseDepth: number;
  37991. /**
  37992. * Gets a boolean indicating if the texture is inverted on Y axis
  37993. */
  37994. invertY: boolean;
  37995. /** @hidden */
  37996. _invertVScale: boolean;
  37997. /** @hidden */
  37998. _associatedChannel: number;
  37999. /** @hidden */
  38000. _source: InternalTextureSource;
  38001. /** @hidden */
  38002. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  38003. /** @hidden */
  38004. _bufferView: Nullable<ArrayBufferView>;
  38005. /** @hidden */
  38006. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38007. /** @hidden */
  38008. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38009. /** @hidden */
  38010. _size: number;
  38011. /** @hidden */
  38012. _extension: string;
  38013. /** @hidden */
  38014. _files: Nullable<string[]>;
  38015. /** @hidden */
  38016. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38017. /** @hidden */
  38018. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38019. /** @hidden */
  38020. _framebuffer: Nullable<WebGLFramebuffer>;
  38021. /** @hidden */
  38022. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38023. /** @hidden */
  38024. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38025. /** @hidden */
  38026. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38027. /** @hidden */
  38028. _attachments: Nullable<number[]>;
  38029. /** @hidden */
  38030. _textureArray: Nullable<InternalTexture[]>;
  38031. /** @hidden */
  38032. _cachedCoordinatesMode: Nullable<number>;
  38033. /** @hidden */
  38034. _cachedWrapU: Nullable<number>;
  38035. /** @hidden */
  38036. _cachedWrapV: Nullable<number>;
  38037. /** @hidden */
  38038. _cachedWrapR: Nullable<number>;
  38039. /** @hidden */
  38040. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38041. /** @hidden */
  38042. _isDisabled: boolean;
  38043. /** @hidden */
  38044. _compression: Nullable<string>;
  38045. /** @hidden */
  38046. _generateStencilBuffer: boolean;
  38047. /** @hidden */
  38048. _generateDepthBuffer: boolean;
  38049. /** @hidden */
  38050. _comparisonFunction: number;
  38051. /** @hidden */
  38052. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38053. /** @hidden */
  38054. _lodGenerationScale: number;
  38055. /** @hidden */
  38056. _lodGenerationOffset: number;
  38057. /** @hidden */
  38058. _depthStencilTexture: Nullable<InternalTexture>;
  38059. /** @hidden */
  38060. _colorTextureArray: Nullable<WebGLTexture>;
  38061. /** @hidden */
  38062. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38063. /** @hidden */
  38064. _lodTextureHigh: Nullable<BaseTexture>;
  38065. /** @hidden */
  38066. _lodTextureMid: Nullable<BaseTexture>;
  38067. /** @hidden */
  38068. _lodTextureLow: Nullable<BaseTexture>;
  38069. /** @hidden */
  38070. _isRGBD: boolean;
  38071. /** @hidden */
  38072. _linearSpecularLOD: boolean;
  38073. /** @hidden */
  38074. _irradianceTexture: Nullable<BaseTexture>;
  38075. /** @hidden */
  38076. _webGLTexture: Nullable<WebGLTexture>;
  38077. /** @hidden */
  38078. _references: number;
  38079. /** @hidden */
  38080. _gammaSpace: Nullable<boolean>;
  38081. private _engine;
  38082. /**
  38083. * Gets the Engine the texture belongs to.
  38084. * @returns The babylon engine
  38085. */
  38086. getEngine(): ThinEngine;
  38087. /**
  38088. * Gets the data source type of the texture
  38089. */
  38090. get source(): InternalTextureSource;
  38091. /**
  38092. * Creates a new InternalTexture
  38093. * @param engine defines the engine to use
  38094. * @param source defines the type of data that will be used
  38095. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38096. */
  38097. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38098. /**
  38099. * Increments the number of references (ie. the number of Texture that point to it)
  38100. */
  38101. incrementReferences(): void;
  38102. /**
  38103. * Change the size of the texture (not the size of the content)
  38104. * @param width defines the new width
  38105. * @param height defines the new height
  38106. * @param depth defines the new depth (1 by default)
  38107. */
  38108. updateSize(width: int, height: int, depth?: int): void;
  38109. /** @hidden */
  38110. _rebuild(): void;
  38111. /** @hidden */
  38112. _swapAndDie(target: InternalTexture): void;
  38113. /**
  38114. * Dispose the current allocated resources
  38115. */
  38116. dispose(): void;
  38117. }
  38118. }
  38119. declare module "babylonjs/Audio/analyser" {
  38120. import { Scene } from "babylonjs/scene";
  38121. /**
  38122. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38123. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38124. */
  38125. export class Analyser {
  38126. /**
  38127. * Gets or sets the smoothing
  38128. * @ignorenaming
  38129. */
  38130. SMOOTHING: number;
  38131. /**
  38132. * Gets or sets the FFT table size
  38133. * @ignorenaming
  38134. */
  38135. FFT_SIZE: number;
  38136. /**
  38137. * Gets or sets the bar graph amplitude
  38138. * @ignorenaming
  38139. */
  38140. BARGRAPHAMPLITUDE: number;
  38141. /**
  38142. * Gets or sets the position of the debug canvas
  38143. * @ignorenaming
  38144. */
  38145. DEBUGCANVASPOS: {
  38146. x: number;
  38147. y: number;
  38148. };
  38149. /**
  38150. * Gets or sets the debug canvas size
  38151. * @ignorenaming
  38152. */
  38153. DEBUGCANVASSIZE: {
  38154. width: number;
  38155. height: number;
  38156. };
  38157. private _byteFreqs;
  38158. private _byteTime;
  38159. private _floatFreqs;
  38160. private _webAudioAnalyser;
  38161. private _debugCanvas;
  38162. private _debugCanvasContext;
  38163. private _scene;
  38164. private _registerFunc;
  38165. private _audioEngine;
  38166. /**
  38167. * Creates a new analyser
  38168. * @param scene defines hosting scene
  38169. */
  38170. constructor(scene: Scene);
  38171. /**
  38172. * Get the number of data values you will have to play with for the visualization
  38173. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38174. * @returns a number
  38175. */
  38176. getFrequencyBinCount(): number;
  38177. /**
  38178. * Gets the current frequency data as a byte array
  38179. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38180. * @returns a Uint8Array
  38181. */
  38182. getByteFrequencyData(): Uint8Array;
  38183. /**
  38184. * Gets the current waveform as a byte array
  38185. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38186. * @returns a Uint8Array
  38187. */
  38188. getByteTimeDomainData(): Uint8Array;
  38189. /**
  38190. * Gets the current frequency data as a float array
  38191. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38192. * @returns a Float32Array
  38193. */
  38194. getFloatFrequencyData(): Float32Array;
  38195. /**
  38196. * Renders the debug canvas
  38197. */
  38198. drawDebugCanvas(): void;
  38199. /**
  38200. * Stops rendering the debug canvas and removes it
  38201. */
  38202. stopDebugCanvas(): void;
  38203. /**
  38204. * Connects two audio nodes
  38205. * @param inputAudioNode defines first node to connect
  38206. * @param outputAudioNode defines second node to connect
  38207. */
  38208. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38209. /**
  38210. * Releases all associated resources
  38211. */
  38212. dispose(): void;
  38213. }
  38214. }
  38215. declare module "babylonjs/Audio/audioEngine" {
  38216. import { IDisposable } from "babylonjs/scene";
  38217. import { Analyser } from "babylonjs/Audio/analyser";
  38218. import { Nullable } from "babylonjs/types";
  38219. import { Observable } from "babylonjs/Misc/observable";
  38220. /**
  38221. * This represents an audio engine and it is responsible
  38222. * to play, synchronize and analyse sounds throughout the application.
  38223. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38224. */
  38225. export interface IAudioEngine extends IDisposable {
  38226. /**
  38227. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38228. */
  38229. readonly canUseWebAudio: boolean;
  38230. /**
  38231. * Gets the current AudioContext if available.
  38232. */
  38233. readonly audioContext: Nullable<AudioContext>;
  38234. /**
  38235. * The master gain node defines the global audio volume of your audio engine.
  38236. */
  38237. readonly masterGain: GainNode;
  38238. /**
  38239. * Gets whether or not mp3 are supported by your browser.
  38240. */
  38241. readonly isMP3supported: boolean;
  38242. /**
  38243. * Gets whether or not ogg are supported by your browser.
  38244. */
  38245. readonly isOGGsupported: boolean;
  38246. /**
  38247. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38248. * @ignoreNaming
  38249. */
  38250. WarnedWebAudioUnsupported: boolean;
  38251. /**
  38252. * Defines if the audio engine relies on a custom unlocked button.
  38253. * In this case, the embedded button will not be displayed.
  38254. */
  38255. useCustomUnlockedButton: boolean;
  38256. /**
  38257. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38258. */
  38259. readonly unlocked: boolean;
  38260. /**
  38261. * Event raised when audio has been unlocked on the browser.
  38262. */
  38263. onAudioUnlockedObservable: Observable<AudioEngine>;
  38264. /**
  38265. * Event raised when audio has been locked on the browser.
  38266. */
  38267. onAudioLockedObservable: Observable<AudioEngine>;
  38268. /**
  38269. * Flags the audio engine in Locked state.
  38270. * This happens due to new browser policies preventing audio to autoplay.
  38271. */
  38272. lock(): void;
  38273. /**
  38274. * Unlocks the audio engine once a user action has been done on the dom.
  38275. * This is helpful to resume play once browser policies have been satisfied.
  38276. */
  38277. unlock(): void;
  38278. /**
  38279. * Gets the global volume sets on the master gain.
  38280. * @returns the global volume if set or -1 otherwise
  38281. */
  38282. getGlobalVolume(): number;
  38283. /**
  38284. * Sets the global volume of your experience (sets on the master gain).
  38285. * @param newVolume Defines the new global volume of the application
  38286. */
  38287. setGlobalVolume(newVolume: number): void;
  38288. /**
  38289. * Connect the audio engine to an audio analyser allowing some amazing
  38290. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38291. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38292. * @param analyser The analyser to connect to the engine
  38293. */
  38294. connectToAnalyser(analyser: Analyser): void;
  38295. }
  38296. /**
  38297. * This represents the default audio engine used in babylon.
  38298. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38299. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38300. */
  38301. export class AudioEngine implements IAudioEngine {
  38302. private _audioContext;
  38303. private _audioContextInitialized;
  38304. private _muteButton;
  38305. private _hostElement;
  38306. /**
  38307. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38308. */
  38309. canUseWebAudio: boolean;
  38310. /**
  38311. * The master gain node defines the global audio volume of your audio engine.
  38312. */
  38313. masterGain: GainNode;
  38314. /**
  38315. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38316. * @ignoreNaming
  38317. */
  38318. WarnedWebAudioUnsupported: boolean;
  38319. /**
  38320. * Gets whether or not mp3 are supported by your browser.
  38321. */
  38322. isMP3supported: boolean;
  38323. /**
  38324. * Gets whether or not ogg are supported by your browser.
  38325. */
  38326. isOGGsupported: boolean;
  38327. /**
  38328. * Gets whether audio has been unlocked on the device.
  38329. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38330. * a user interaction has happened.
  38331. */
  38332. unlocked: boolean;
  38333. /**
  38334. * Defines if the audio engine relies on a custom unlocked button.
  38335. * In this case, the embedded button will not be displayed.
  38336. */
  38337. useCustomUnlockedButton: boolean;
  38338. /**
  38339. * Event raised when audio has been unlocked on the browser.
  38340. */
  38341. onAudioUnlockedObservable: Observable<AudioEngine>;
  38342. /**
  38343. * Event raised when audio has been locked on the browser.
  38344. */
  38345. onAudioLockedObservable: Observable<AudioEngine>;
  38346. /**
  38347. * Gets the current AudioContext if available.
  38348. */
  38349. get audioContext(): Nullable<AudioContext>;
  38350. private _connectedAnalyser;
  38351. /**
  38352. * Instantiates a new audio engine.
  38353. *
  38354. * There should be only one per page as some browsers restrict the number
  38355. * of audio contexts you can create.
  38356. * @param hostElement defines the host element where to display the mute icon if necessary
  38357. */
  38358. constructor(hostElement?: Nullable<HTMLElement>);
  38359. /**
  38360. * Flags the audio engine in Locked state.
  38361. * This happens due to new browser policies preventing audio to autoplay.
  38362. */
  38363. lock(): void;
  38364. /**
  38365. * Unlocks the audio engine once a user action has been done on the dom.
  38366. * This is helpful to resume play once browser policies have been satisfied.
  38367. */
  38368. unlock(): void;
  38369. private _resumeAudioContext;
  38370. private _initializeAudioContext;
  38371. private _tryToRun;
  38372. private _triggerRunningState;
  38373. private _triggerSuspendedState;
  38374. private _displayMuteButton;
  38375. private _moveButtonToTopLeft;
  38376. private _onResize;
  38377. private _hideMuteButton;
  38378. /**
  38379. * Destroy and release the resources associated with the audio ccontext.
  38380. */
  38381. dispose(): void;
  38382. /**
  38383. * Gets the global volume sets on the master gain.
  38384. * @returns the global volume if set or -1 otherwise
  38385. */
  38386. getGlobalVolume(): number;
  38387. /**
  38388. * Sets the global volume of your experience (sets on the master gain).
  38389. * @param newVolume Defines the new global volume of the application
  38390. */
  38391. setGlobalVolume(newVolume: number): void;
  38392. /**
  38393. * Connect the audio engine to an audio analyser allowing some amazing
  38394. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38395. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38396. * @param analyser The analyser to connect to the engine
  38397. */
  38398. connectToAnalyser(analyser: Analyser): void;
  38399. }
  38400. }
  38401. declare module "babylonjs/Loading/loadingScreen" {
  38402. /**
  38403. * Interface used to present a loading screen while loading a scene
  38404. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38405. */
  38406. export interface ILoadingScreen {
  38407. /**
  38408. * Function called to display the loading screen
  38409. */
  38410. displayLoadingUI: () => void;
  38411. /**
  38412. * Function called to hide the loading screen
  38413. */
  38414. hideLoadingUI: () => void;
  38415. /**
  38416. * Gets or sets the color to use for the background
  38417. */
  38418. loadingUIBackgroundColor: string;
  38419. /**
  38420. * Gets or sets the text to display while loading
  38421. */
  38422. loadingUIText: string;
  38423. }
  38424. /**
  38425. * Class used for the default loading screen
  38426. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38427. */
  38428. export class DefaultLoadingScreen implements ILoadingScreen {
  38429. private _renderingCanvas;
  38430. private _loadingText;
  38431. private _loadingDivBackgroundColor;
  38432. private _loadingDiv;
  38433. private _loadingTextDiv;
  38434. /** Gets or sets the logo url to use for the default loading screen */
  38435. static DefaultLogoUrl: string;
  38436. /** Gets or sets the spinner url to use for the default loading screen */
  38437. static DefaultSpinnerUrl: string;
  38438. /**
  38439. * Creates a new default loading screen
  38440. * @param _renderingCanvas defines the canvas used to render the scene
  38441. * @param _loadingText defines the default text to display
  38442. * @param _loadingDivBackgroundColor defines the default background color
  38443. */
  38444. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38445. /**
  38446. * Function called to display the loading screen
  38447. */
  38448. displayLoadingUI(): void;
  38449. /**
  38450. * Function called to hide the loading screen
  38451. */
  38452. hideLoadingUI(): void;
  38453. /**
  38454. * Gets or sets the text to display while loading
  38455. */
  38456. set loadingUIText(text: string);
  38457. get loadingUIText(): string;
  38458. /**
  38459. * Gets or sets the color to use for the background
  38460. */
  38461. get loadingUIBackgroundColor(): string;
  38462. set loadingUIBackgroundColor(color: string);
  38463. private _resizeLoadingUI;
  38464. }
  38465. }
  38466. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38467. /**
  38468. * Interface for any object that can request an animation frame
  38469. */
  38470. export interface ICustomAnimationFrameRequester {
  38471. /**
  38472. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38473. */
  38474. renderFunction?: Function;
  38475. /**
  38476. * Called to request the next frame to render to
  38477. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38478. */
  38479. requestAnimationFrame: Function;
  38480. /**
  38481. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38482. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38483. */
  38484. requestID?: number;
  38485. }
  38486. }
  38487. declare module "babylonjs/Misc/performanceMonitor" {
  38488. /**
  38489. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38490. */
  38491. export class PerformanceMonitor {
  38492. private _enabled;
  38493. private _rollingFrameTime;
  38494. private _lastFrameTimeMs;
  38495. /**
  38496. * constructor
  38497. * @param frameSampleSize The number of samples required to saturate the sliding window
  38498. */
  38499. constructor(frameSampleSize?: number);
  38500. /**
  38501. * Samples current frame
  38502. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38503. */
  38504. sampleFrame(timeMs?: number): void;
  38505. /**
  38506. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38507. */
  38508. get averageFrameTime(): number;
  38509. /**
  38510. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38511. */
  38512. get averageFrameTimeVariance(): number;
  38513. /**
  38514. * Returns the frame time of the most recent frame
  38515. */
  38516. get instantaneousFrameTime(): number;
  38517. /**
  38518. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38519. */
  38520. get averageFPS(): number;
  38521. /**
  38522. * Returns the average framerate in frames per second using the most recent frame time
  38523. */
  38524. get instantaneousFPS(): number;
  38525. /**
  38526. * Returns true if enough samples have been taken to completely fill the sliding window
  38527. */
  38528. get isSaturated(): boolean;
  38529. /**
  38530. * Enables contributions to the sliding window sample set
  38531. */
  38532. enable(): void;
  38533. /**
  38534. * Disables contributions to the sliding window sample set
  38535. * Samples will not be interpolated over the disabled period
  38536. */
  38537. disable(): void;
  38538. /**
  38539. * Returns true if sampling is enabled
  38540. */
  38541. get isEnabled(): boolean;
  38542. /**
  38543. * Resets performance monitor
  38544. */
  38545. reset(): void;
  38546. }
  38547. /**
  38548. * RollingAverage
  38549. *
  38550. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38551. */
  38552. export class RollingAverage {
  38553. /**
  38554. * Current average
  38555. */
  38556. average: number;
  38557. /**
  38558. * Current variance
  38559. */
  38560. variance: number;
  38561. protected _samples: Array<number>;
  38562. protected _sampleCount: number;
  38563. protected _pos: number;
  38564. protected _m2: number;
  38565. /**
  38566. * constructor
  38567. * @param length The number of samples required to saturate the sliding window
  38568. */
  38569. constructor(length: number);
  38570. /**
  38571. * Adds a sample to the sample set
  38572. * @param v The sample value
  38573. */
  38574. add(v: number): void;
  38575. /**
  38576. * Returns previously added values or null if outside of history or outside the sliding window domain
  38577. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38578. * @return Value previously recorded with add() or null if outside of range
  38579. */
  38580. history(i: number): number;
  38581. /**
  38582. * Returns true if enough samples have been taken to completely fill the sliding window
  38583. * @return true if sample-set saturated
  38584. */
  38585. isSaturated(): boolean;
  38586. /**
  38587. * Resets the rolling average (equivalent to 0 samples taken so far)
  38588. */
  38589. reset(): void;
  38590. /**
  38591. * Wraps a value around the sample range boundaries
  38592. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38593. * @return Wrapped position in sample range
  38594. */
  38595. protected _wrapPosition(i: number): number;
  38596. }
  38597. }
  38598. declare module "babylonjs/Misc/perfCounter" {
  38599. /**
  38600. * This class is used to track a performance counter which is number based.
  38601. * The user has access to many properties which give statistics of different nature.
  38602. *
  38603. * The implementer can track two kinds of Performance Counter: time and count.
  38604. * 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.
  38605. * 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.
  38606. */
  38607. export class PerfCounter {
  38608. /**
  38609. * Gets or sets a global boolean to turn on and off all the counters
  38610. */
  38611. static Enabled: boolean;
  38612. /**
  38613. * Returns the smallest value ever
  38614. */
  38615. get min(): number;
  38616. /**
  38617. * Returns the biggest value ever
  38618. */
  38619. get max(): number;
  38620. /**
  38621. * Returns the average value since the performance counter is running
  38622. */
  38623. get average(): number;
  38624. /**
  38625. * Returns the average value of the last second the counter was monitored
  38626. */
  38627. get lastSecAverage(): number;
  38628. /**
  38629. * Returns the current value
  38630. */
  38631. get current(): number;
  38632. /**
  38633. * Gets the accumulated total
  38634. */
  38635. get total(): number;
  38636. /**
  38637. * Gets the total value count
  38638. */
  38639. get count(): number;
  38640. /**
  38641. * Creates a new counter
  38642. */
  38643. constructor();
  38644. /**
  38645. * Call this method to start monitoring a new frame.
  38646. * 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.
  38647. */
  38648. fetchNewFrame(): void;
  38649. /**
  38650. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38651. * @param newCount the count value to add to the monitored count
  38652. * @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.
  38653. */
  38654. addCount(newCount: number, fetchResult: boolean): void;
  38655. /**
  38656. * Start monitoring this performance counter
  38657. */
  38658. beginMonitoring(): void;
  38659. /**
  38660. * Compute the time lapsed since the previous beginMonitoring() call.
  38661. * @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
  38662. */
  38663. endMonitoring(newFrame?: boolean): void;
  38664. private _fetchResult;
  38665. private _startMonitoringTime;
  38666. private _min;
  38667. private _max;
  38668. private _average;
  38669. private _current;
  38670. private _totalValueCount;
  38671. private _totalAccumulated;
  38672. private _lastSecAverage;
  38673. private _lastSecAccumulated;
  38674. private _lastSecTime;
  38675. private _lastSecValueCount;
  38676. }
  38677. }
  38678. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38679. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38680. import { Nullable } from "babylonjs/types";
  38681. module "babylonjs/Engines/thinEngine" {
  38682. interface ThinEngine {
  38683. /** @hidden */
  38684. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38685. }
  38686. }
  38687. }
  38688. declare module "babylonjs/Engines/engine" {
  38689. import { Observable } from "babylonjs/Misc/observable";
  38690. import { Nullable } from "babylonjs/types";
  38691. import { Scene } from "babylonjs/scene";
  38692. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38693. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38694. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38695. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38696. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38697. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38698. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38699. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38700. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38701. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38702. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38703. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38704. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38705. import "babylonjs/Engines/Extensions/engine.alpha";
  38706. import "babylonjs/Engines/Extensions/engine.readTexture";
  38707. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38708. import { Material } from "babylonjs/Materials/material";
  38709. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38710. /**
  38711. * Defines the interface used by display changed events
  38712. */
  38713. export interface IDisplayChangedEventArgs {
  38714. /** Gets the vrDisplay object (if any) */
  38715. vrDisplay: Nullable<any>;
  38716. /** Gets a boolean indicating if webVR is supported */
  38717. vrSupported: boolean;
  38718. }
  38719. /**
  38720. * Defines the interface used by objects containing a viewport (like a camera)
  38721. */
  38722. interface IViewportOwnerLike {
  38723. /**
  38724. * Gets or sets the viewport
  38725. */
  38726. viewport: IViewportLike;
  38727. }
  38728. /**
  38729. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38730. */
  38731. export class Engine extends ThinEngine {
  38732. /** Defines that alpha blending is disabled */
  38733. static readonly ALPHA_DISABLE: number;
  38734. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38735. static readonly ALPHA_ADD: number;
  38736. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38737. static readonly ALPHA_COMBINE: number;
  38738. /** Defines that alpha blending to DEST - SRC * DEST */
  38739. static readonly ALPHA_SUBTRACT: number;
  38740. /** Defines that alpha blending to SRC * DEST */
  38741. static readonly ALPHA_MULTIPLY: number;
  38742. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38743. static readonly ALPHA_MAXIMIZED: number;
  38744. /** Defines that alpha blending to SRC + DEST */
  38745. static readonly ALPHA_ONEONE: number;
  38746. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38747. static readonly ALPHA_PREMULTIPLIED: number;
  38748. /**
  38749. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38750. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38751. */
  38752. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38753. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38754. static readonly ALPHA_INTERPOLATE: number;
  38755. /**
  38756. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38757. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38758. */
  38759. static readonly ALPHA_SCREENMODE: number;
  38760. /** Defines that the ressource is not delayed*/
  38761. static readonly DELAYLOADSTATE_NONE: number;
  38762. /** Defines that the ressource was successfully delay loaded */
  38763. static readonly DELAYLOADSTATE_LOADED: number;
  38764. /** Defines that the ressource is currently delay loading */
  38765. static readonly DELAYLOADSTATE_LOADING: number;
  38766. /** Defines that the ressource is delayed and has not started loading */
  38767. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38768. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38769. static readonly NEVER: number;
  38770. /** 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 */
  38771. static readonly ALWAYS: number;
  38772. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38773. static readonly LESS: number;
  38774. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38775. static readonly EQUAL: number;
  38776. /** 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 */
  38777. static readonly LEQUAL: number;
  38778. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38779. static readonly GREATER: number;
  38780. /** 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 */
  38781. static readonly GEQUAL: number;
  38782. /** 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 */
  38783. static readonly NOTEQUAL: number;
  38784. /** Passed to stencilOperation to specify that stencil value must be kept */
  38785. static readonly KEEP: number;
  38786. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38787. static readonly REPLACE: number;
  38788. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38789. static readonly INCR: number;
  38790. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38791. static readonly DECR: number;
  38792. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38793. static readonly INVERT: number;
  38794. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38795. static readonly INCR_WRAP: number;
  38796. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38797. static readonly DECR_WRAP: number;
  38798. /** Texture is not repeating outside of 0..1 UVs */
  38799. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38800. /** Texture is repeating outside of 0..1 UVs */
  38801. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38802. /** Texture is repeating and mirrored */
  38803. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38804. /** ALPHA */
  38805. static readonly TEXTUREFORMAT_ALPHA: number;
  38806. /** LUMINANCE */
  38807. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38808. /** LUMINANCE_ALPHA */
  38809. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38810. /** RGB */
  38811. static readonly TEXTUREFORMAT_RGB: number;
  38812. /** RGBA */
  38813. static readonly TEXTUREFORMAT_RGBA: number;
  38814. /** RED */
  38815. static readonly TEXTUREFORMAT_RED: number;
  38816. /** RED (2nd reference) */
  38817. static readonly TEXTUREFORMAT_R: number;
  38818. /** RG */
  38819. static readonly TEXTUREFORMAT_RG: number;
  38820. /** RED_INTEGER */
  38821. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38822. /** RED_INTEGER (2nd reference) */
  38823. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38824. /** RG_INTEGER */
  38825. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38826. /** RGB_INTEGER */
  38827. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38828. /** RGBA_INTEGER */
  38829. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38830. /** UNSIGNED_BYTE */
  38831. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38832. /** UNSIGNED_BYTE (2nd reference) */
  38833. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38834. /** FLOAT */
  38835. static readonly TEXTURETYPE_FLOAT: number;
  38836. /** HALF_FLOAT */
  38837. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38838. /** BYTE */
  38839. static readonly TEXTURETYPE_BYTE: number;
  38840. /** SHORT */
  38841. static readonly TEXTURETYPE_SHORT: number;
  38842. /** UNSIGNED_SHORT */
  38843. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38844. /** INT */
  38845. static readonly TEXTURETYPE_INT: number;
  38846. /** UNSIGNED_INT */
  38847. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38848. /** UNSIGNED_SHORT_4_4_4_4 */
  38849. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38850. /** UNSIGNED_SHORT_5_5_5_1 */
  38851. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38852. /** UNSIGNED_SHORT_5_6_5 */
  38853. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38854. /** UNSIGNED_INT_2_10_10_10_REV */
  38855. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38856. /** UNSIGNED_INT_24_8 */
  38857. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38858. /** UNSIGNED_INT_10F_11F_11F_REV */
  38859. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38860. /** UNSIGNED_INT_5_9_9_9_REV */
  38861. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38862. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38863. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38864. /** nearest is mag = nearest and min = nearest and mip = linear */
  38865. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38866. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38867. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38868. /** Trilinear is mag = linear and min = linear and mip = linear */
  38869. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38870. /** nearest is mag = nearest and min = nearest and mip = linear */
  38871. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38872. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38873. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38874. /** Trilinear is mag = linear and min = linear and mip = linear */
  38875. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38876. /** mag = nearest and min = nearest and mip = nearest */
  38877. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38878. /** mag = nearest and min = linear and mip = nearest */
  38879. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38880. /** mag = nearest and min = linear and mip = linear */
  38881. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38882. /** mag = nearest and min = linear and mip = none */
  38883. static readonly TEXTURE_NEAREST_LINEAR: number;
  38884. /** mag = nearest and min = nearest and mip = none */
  38885. static readonly TEXTURE_NEAREST_NEAREST: number;
  38886. /** mag = linear and min = nearest and mip = nearest */
  38887. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38888. /** mag = linear and min = nearest and mip = linear */
  38889. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38890. /** mag = linear and min = linear and mip = none */
  38891. static readonly TEXTURE_LINEAR_LINEAR: number;
  38892. /** mag = linear and min = nearest and mip = none */
  38893. static readonly TEXTURE_LINEAR_NEAREST: number;
  38894. /** Explicit coordinates mode */
  38895. static readonly TEXTURE_EXPLICIT_MODE: number;
  38896. /** Spherical coordinates mode */
  38897. static readonly TEXTURE_SPHERICAL_MODE: number;
  38898. /** Planar coordinates mode */
  38899. static readonly TEXTURE_PLANAR_MODE: number;
  38900. /** Cubic coordinates mode */
  38901. static readonly TEXTURE_CUBIC_MODE: number;
  38902. /** Projection coordinates mode */
  38903. static readonly TEXTURE_PROJECTION_MODE: number;
  38904. /** Skybox coordinates mode */
  38905. static readonly TEXTURE_SKYBOX_MODE: number;
  38906. /** Inverse Cubic coordinates mode */
  38907. static readonly TEXTURE_INVCUBIC_MODE: number;
  38908. /** Equirectangular coordinates mode */
  38909. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38910. /** Equirectangular Fixed coordinates mode */
  38911. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38912. /** Equirectangular Fixed Mirrored coordinates mode */
  38913. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38914. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38915. static readonly SCALEMODE_FLOOR: number;
  38916. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38917. static readonly SCALEMODE_NEAREST: number;
  38918. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38919. static readonly SCALEMODE_CEILING: number;
  38920. /**
  38921. * Returns the current npm package of the sdk
  38922. */
  38923. static get NpmPackage(): string;
  38924. /**
  38925. * Returns the current version of the framework
  38926. */
  38927. static get Version(): string;
  38928. /** Gets the list of created engines */
  38929. static get Instances(): Engine[];
  38930. /**
  38931. * Gets the latest created engine
  38932. */
  38933. static get LastCreatedEngine(): Nullable<Engine>;
  38934. /**
  38935. * Gets the latest created scene
  38936. */
  38937. static get LastCreatedScene(): Nullable<Scene>;
  38938. /**
  38939. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38940. * @param flag defines which part of the materials must be marked as dirty
  38941. * @param predicate defines a predicate used to filter which materials should be affected
  38942. */
  38943. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38944. /**
  38945. * Method called to create the default loading screen.
  38946. * This can be overriden in your own app.
  38947. * @param canvas The rendering canvas element
  38948. * @returns The loading screen
  38949. */
  38950. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38951. /**
  38952. * Method called to create the default rescale post process on each engine.
  38953. */
  38954. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38955. /**
  38956. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38957. **/
  38958. enableOfflineSupport: boolean;
  38959. /**
  38960. * 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)
  38961. **/
  38962. disableManifestCheck: boolean;
  38963. /**
  38964. * Gets the list of created scenes
  38965. */
  38966. scenes: Scene[];
  38967. /**
  38968. * Event raised when a new scene is created
  38969. */
  38970. onNewSceneAddedObservable: Observable<Scene>;
  38971. /**
  38972. * Gets the list of created postprocesses
  38973. */
  38974. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38975. /**
  38976. * Gets a boolean indicating if the pointer is currently locked
  38977. */
  38978. isPointerLock: boolean;
  38979. /**
  38980. * Observable event triggered each time the rendering canvas is resized
  38981. */
  38982. onResizeObservable: Observable<Engine>;
  38983. /**
  38984. * Observable event triggered each time the canvas loses focus
  38985. */
  38986. onCanvasBlurObservable: Observable<Engine>;
  38987. /**
  38988. * Observable event triggered each time the canvas gains focus
  38989. */
  38990. onCanvasFocusObservable: Observable<Engine>;
  38991. /**
  38992. * Observable event triggered each time the canvas receives pointerout event
  38993. */
  38994. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38995. /**
  38996. * Observable raised when the engine begins a new frame
  38997. */
  38998. onBeginFrameObservable: Observable<Engine>;
  38999. /**
  39000. * If set, will be used to request the next animation frame for the render loop
  39001. */
  39002. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  39003. /**
  39004. * Observable raised when the engine ends the current frame
  39005. */
  39006. onEndFrameObservable: Observable<Engine>;
  39007. /**
  39008. * Observable raised when the engine is about to compile a shader
  39009. */
  39010. onBeforeShaderCompilationObservable: Observable<Engine>;
  39011. /**
  39012. * Observable raised when the engine has jsut compiled a shader
  39013. */
  39014. onAfterShaderCompilationObservable: Observable<Engine>;
  39015. /**
  39016. * Gets the audio engine
  39017. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39018. * @ignorenaming
  39019. */
  39020. static audioEngine: IAudioEngine;
  39021. /**
  39022. * Default AudioEngine factory responsible of creating the Audio Engine.
  39023. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  39024. */
  39025. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  39026. /**
  39027. * Default offline support factory responsible of creating a tool used to store data locally.
  39028. * By default, this will create a Database object if the workload has been embedded.
  39029. */
  39030. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  39031. private _loadingScreen;
  39032. private _pointerLockRequested;
  39033. private _rescalePostProcess;
  39034. private _deterministicLockstep;
  39035. private _lockstepMaxSteps;
  39036. private _timeStep;
  39037. protected get _supportsHardwareTextureRescaling(): boolean;
  39038. private _fps;
  39039. private _deltaTime;
  39040. /** @hidden */
  39041. _drawCalls: PerfCounter;
  39042. /** 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 */
  39043. canvasTabIndex: number;
  39044. /**
  39045. * Turn this value on if you want to pause FPS computation when in background
  39046. */
  39047. disablePerformanceMonitorInBackground: boolean;
  39048. private _performanceMonitor;
  39049. /**
  39050. * Gets the performance monitor attached to this engine
  39051. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39052. */
  39053. get performanceMonitor(): PerformanceMonitor;
  39054. private _onFocus;
  39055. private _onBlur;
  39056. private _onCanvasPointerOut;
  39057. private _onCanvasBlur;
  39058. private _onCanvasFocus;
  39059. private _onFullscreenChange;
  39060. private _onPointerLockChange;
  39061. /**
  39062. * Gets the HTML element used to attach event listeners
  39063. * @returns a HTML element
  39064. */
  39065. getInputElement(): Nullable<HTMLElement>;
  39066. /**
  39067. * Creates a new engine
  39068. * @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
  39069. * @param antialias defines enable antialiasing (default: false)
  39070. * @param options defines further options to be sent to the getContext() function
  39071. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39072. */
  39073. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39074. /**
  39075. * Gets current aspect ratio
  39076. * @param viewportOwner defines the camera to use to get the aspect ratio
  39077. * @param useScreen defines if screen size must be used (or the current render target if any)
  39078. * @returns a number defining the aspect ratio
  39079. */
  39080. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39081. /**
  39082. * Gets current screen aspect ratio
  39083. * @returns a number defining the aspect ratio
  39084. */
  39085. getScreenAspectRatio(): number;
  39086. /**
  39087. * Gets the client rect of the HTML canvas attached with the current webGL context
  39088. * @returns a client rectanglee
  39089. */
  39090. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39091. /**
  39092. * Gets the client rect of the HTML element used for events
  39093. * @returns a client rectanglee
  39094. */
  39095. getInputElementClientRect(): Nullable<ClientRect>;
  39096. /**
  39097. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39098. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39099. * @returns true if engine is in deterministic lock step mode
  39100. */
  39101. isDeterministicLockStep(): boolean;
  39102. /**
  39103. * Gets the max steps when engine is running in deterministic lock step
  39104. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39105. * @returns the max steps
  39106. */
  39107. getLockstepMaxSteps(): number;
  39108. /**
  39109. * Returns the time in ms between steps when using deterministic lock step.
  39110. * @returns time step in (ms)
  39111. */
  39112. getTimeStep(): number;
  39113. /**
  39114. * Force the mipmap generation for the given render target texture
  39115. * @param texture defines the render target texture to use
  39116. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39117. */
  39118. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39119. /** States */
  39120. /**
  39121. * Set various states to the webGL context
  39122. * @param culling defines backface culling state
  39123. * @param zOffset defines the value to apply to zOffset (0 by default)
  39124. * @param force defines if states must be applied even if cache is up to date
  39125. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39126. */
  39127. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39128. /**
  39129. * Set the z offset to apply to current rendering
  39130. * @param value defines the offset to apply
  39131. */
  39132. setZOffset(value: number): void;
  39133. /**
  39134. * Gets the current value of the zOffset
  39135. * @returns the current zOffset state
  39136. */
  39137. getZOffset(): number;
  39138. /**
  39139. * Enable or disable depth buffering
  39140. * @param enable defines the state to set
  39141. */
  39142. setDepthBuffer(enable: boolean): void;
  39143. /**
  39144. * Gets a boolean indicating if depth writing is enabled
  39145. * @returns the current depth writing state
  39146. */
  39147. getDepthWrite(): boolean;
  39148. /**
  39149. * Enable or disable depth writing
  39150. * @param enable defines the state to set
  39151. */
  39152. setDepthWrite(enable: boolean): void;
  39153. /**
  39154. * Gets a boolean indicating if stencil buffer is enabled
  39155. * @returns the current stencil buffer state
  39156. */
  39157. getStencilBuffer(): boolean;
  39158. /**
  39159. * Enable or disable the stencil buffer
  39160. * @param enable defines if the stencil buffer must be enabled or disabled
  39161. */
  39162. setStencilBuffer(enable: boolean): void;
  39163. /**
  39164. * Gets the current stencil mask
  39165. * @returns a number defining the new stencil mask to use
  39166. */
  39167. getStencilMask(): number;
  39168. /**
  39169. * Sets the current stencil mask
  39170. * @param mask defines the new stencil mask to use
  39171. */
  39172. setStencilMask(mask: number): void;
  39173. /**
  39174. * Gets the current stencil function
  39175. * @returns a number defining the stencil function to use
  39176. */
  39177. getStencilFunction(): number;
  39178. /**
  39179. * Gets the current stencil reference value
  39180. * @returns a number defining the stencil reference value to use
  39181. */
  39182. getStencilFunctionReference(): number;
  39183. /**
  39184. * Gets the current stencil mask
  39185. * @returns a number defining the stencil mask to use
  39186. */
  39187. getStencilFunctionMask(): number;
  39188. /**
  39189. * Sets the current stencil function
  39190. * @param stencilFunc defines the new stencil function to use
  39191. */
  39192. setStencilFunction(stencilFunc: number): void;
  39193. /**
  39194. * Sets the current stencil reference
  39195. * @param reference defines the new stencil reference to use
  39196. */
  39197. setStencilFunctionReference(reference: number): void;
  39198. /**
  39199. * Sets the current stencil mask
  39200. * @param mask defines the new stencil mask to use
  39201. */
  39202. setStencilFunctionMask(mask: number): void;
  39203. /**
  39204. * Gets the current stencil operation when stencil fails
  39205. * @returns a number defining stencil operation to use when stencil fails
  39206. */
  39207. getStencilOperationFail(): number;
  39208. /**
  39209. * Gets the current stencil operation when depth fails
  39210. * @returns a number defining stencil operation to use when depth fails
  39211. */
  39212. getStencilOperationDepthFail(): number;
  39213. /**
  39214. * Gets the current stencil operation when stencil passes
  39215. * @returns a number defining stencil operation to use when stencil passes
  39216. */
  39217. getStencilOperationPass(): number;
  39218. /**
  39219. * Sets the stencil operation to use when stencil fails
  39220. * @param operation defines the stencil operation to use when stencil fails
  39221. */
  39222. setStencilOperationFail(operation: number): void;
  39223. /**
  39224. * Sets the stencil operation to use when depth fails
  39225. * @param operation defines the stencil operation to use when depth fails
  39226. */
  39227. setStencilOperationDepthFail(operation: number): void;
  39228. /**
  39229. * Sets the stencil operation to use when stencil passes
  39230. * @param operation defines the stencil operation to use when stencil passes
  39231. */
  39232. setStencilOperationPass(operation: number): void;
  39233. /**
  39234. * Sets a boolean indicating if the dithering state is enabled or disabled
  39235. * @param value defines the dithering state
  39236. */
  39237. setDitheringState(value: boolean): void;
  39238. /**
  39239. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39240. * @param value defines the rasterizer state
  39241. */
  39242. setRasterizerState(value: boolean): void;
  39243. /**
  39244. * Gets the current depth function
  39245. * @returns a number defining the depth function
  39246. */
  39247. getDepthFunction(): Nullable<number>;
  39248. /**
  39249. * Sets the current depth function
  39250. * @param depthFunc defines the function to use
  39251. */
  39252. setDepthFunction(depthFunc: number): void;
  39253. /**
  39254. * Sets the current depth function to GREATER
  39255. */
  39256. setDepthFunctionToGreater(): void;
  39257. /**
  39258. * Sets the current depth function to GEQUAL
  39259. */
  39260. setDepthFunctionToGreaterOrEqual(): void;
  39261. /**
  39262. * Sets the current depth function to LESS
  39263. */
  39264. setDepthFunctionToLess(): void;
  39265. /**
  39266. * Sets the current depth function to LEQUAL
  39267. */
  39268. setDepthFunctionToLessOrEqual(): void;
  39269. private _cachedStencilBuffer;
  39270. private _cachedStencilFunction;
  39271. private _cachedStencilMask;
  39272. private _cachedStencilOperationPass;
  39273. private _cachedStencilOperationFail;
  39274. private _cachedStencilOperationDepthFail;
  39275. private _cachedStencilReference;
  39276. /**
  39277. * Caches the the state of the stencil buffer
  39278. */
  39279. cacheStencilState(): void;
  39280. /**
  39281. * Restores the state of the stencil buffer
  39282. */
  39283. restoreStencilState(): void;
  39284. /**
  39285. * Directly set the WebGL Viewport
  39286. * @param x defines the x coordinate of the viewport (in screen space)
  39287. * @param y defines the y coordinate of the viewport (in screen space)
  39288. * @param width defines the width of the viewport (in screen space)
  39289. * @param height defines the height of the viewport (in screen space)
  39290. * @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
  39291. */
  39292. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39293. /**
  39294. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39295. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39296. * @param y defines the y-coordinate of the corner of the clear rectangle
  39297. * @param width defines the width of the clear rectangle
  39298. * @param height defines the height of the clear rectangle
  39299. * @param clearColor defines the clear color
  39300. */
  39301. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39302. /**
  39303. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39304. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39305. * @param y defines the y-coordinate of the corner of the clear rectangle
  39306. * @param width defines the width of the clear rectangle
  39307. * @param height defines the height of the clear rectangle
  39308. */
  39309. enableScissor(x: number, y: number, width: number, height: number): void;
  39310. /**
  39311. * Disable previously set scissor test rectangle
  39312. */
  39313. disableScissor(): void;
  39314. protected _reportDrawCall(): void;
  39315. /**
  39316. * Initializes a webVR display and starts listening to display change events
  39317. * The onVRDisplayChangedObservable will be notified upon these changes
  39318. * @returns The onVRDisplayChangedObservable
  39319. */
  39320. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39321. /** @hidden */
  39322. _prepareVRComponent(): void;
  39323. /** @hidden */
  39324. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39325. /** @hidden */
  39326. _submitVRFrame(): void;
  39327. /**
  39328. * Call this function to leave webVR mode
  39329. * Will do nothing if webVR is not supported or if there is no webVR device
  39330. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39331. */
  39332. disableVR(): void;
  39333. /**
  39334. * Gets a boolean indicating that the system is in VR mode and is presenting
  39335. * @returns true if VR mode is engaged
  39336. */
  39337. isVRPresenting(): boolean;
  39338. /** @hidden */
  39339. _requestVRFrame(): void;
  39340. /** @hidden */
  39341. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39342. /**
  39343. * Gets the source code of the vertex shader associated with a specific webGL program
  39344. * @param program defines the program to use
  39345. * @returns a string containing the source code of the vertex shader associated with the program
  39346. */
  39347. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39348. /**
  39349. * Gets the source code of the fragment shader associated with a specific webGL program
  39350. * @param program defines the program to use
  39351. * @returns a string containing the source code of the fragment shader associated with the program
  39352. */
  39353. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39354. /**
  39355. * Sets a depth stencil texture from a render target to the according uniform.
  39356. * @param channel The texture channel
  39357. * @param uniform The uniform to set
  39358. * @param texture The render target texture containing the depth stencil texture to apply
  39359. */
  39360. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39361. /**
  39362. * Sets a texture to the webGL context from a postprocess
  39363. * @param channel defines the channel to use
  39364. * @param postProcess defines the source postprocess
  39365. */
  39366. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39367. /**
  39368. * Binds the output of the passed in post process to the texture channel specified
  39369. * @param channel The channel the texture should be bound to
  39370. * @param postProcess The post process which's output should be bound
  39371. */
  39372. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39373. protected _rebuildBuffers(): void;
  39374. /** @hidden */
  39375. _renderFrame(): void;
  39376. _renderLoop(): void;
  39377. /** @hidden */
  39378. _renderViews(): boolean;
  39379. /**
  39380. * Toggle full screen mode
  39381. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39382. */
  39383. switchFullscreen(requestPointerLock: boolean): void;
  39384. /**
  39385. * Enters full screen mode
  39386. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39387. */
  39388. enterFullscreen(requestPointerLock: boolean): void;
  39389. /**
  39390. * Exits full screen mode
  39391. */
  39392. exitFullscreen(): void;
  39393. /**
  39394. * Enters Pointerlock mode
  39395. */
  39396. enterPointerlock(): void;
  39397. /**
  39398. * Exits Pointerlock mode
  39399. */
  39400. exitPointerlock(): void;
  39401. /**
  39402. * Begin a new frame
  39403. */
  39404. beginFrame(): void;
  39405. /**
  39406. * Enf the current frame
  39407. */
  39408. endFrame(): void;
  39409. resize(): void;
  39410. /**
  39411. * Force a specific size of the canvas
  39412. * @param width defines the new canvas' width
  39413. * @param height defines the new canvas' height
  39414. * @returns true if the size was changed
  39415. */
  39416. setSize(width: number, height: number): boolean;
  39417. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39418. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39419. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39420. _releaseTexture(texture: InternalTexture): void;
  39421. /**
  39422. * @hidden
  39423. * Rescales a texture
  39424. * @param source input texutre
  39425. * @param destination destination texture
  39426. * @param scene scene to use to render the resize
  39427. * @param internalFormat format to use when resizing
  39428. * @param onComplete callback to be called when resize has completed
  39429. */
  39430. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39431. /**
  39432. * Gets the current framerate
  39433. * @returns a number representing the framerate
  39434. */
  39435. getFps(): number;
  39436. /**
  39437. * Gets the time spent between current and previous frame
  39438. * @returns a number representing the delta time in ms
  39439. */
  39440. getDeltaTime(): number;
  39441. private _measureFps;
  39442. /** @hidden */
  39443. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39444. /**
  39445. * Updates the sample count of a render target texture
  39446. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39447. * @param texture defines the texture to update
  39448. * @param samples defines the sample count to set
  39449. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39450. */
  39451. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39452. /**
  39453. * Updates a depth texture Comparison Mode and Function.
  39454. * If the comparison Function is equal to 0, the mode will be set to none.
  39455. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39456. * @param texture The texture to set the comparison function for
  39457. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39458. */
  39459. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39460. /**
  39461. * Creates a webGL buffer to use with instanciation
  39462. * @param capacity defines the size of the buffer
  39463. * @returns the webGL buffer
  39464. */
  39465. createInstancesBuffer(capacity: number): DataBuffer;
  39466. /**
  39467. * Delete a webGL buffer used with instanciation
  39468. * @param buffer defines the webGL buffer to delete
  39469. */
  39470. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39471. private _clientWaitAsync;
  39472. /** @hidden */
  39473. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39474. dispose(): void;
  39475. private _disableTouchAction;
  39476. /**
  39477. * Display the loading screen
  39478. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39479. */
  39480. displayLoadingUI(): void;
  39481. /**
  39482. * Hide the loading screen
  39483. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39484. */
  39485. hideLoadingUI(): void;
  39486. /**
  39487. * Gets the current loading screen object
  39488. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39489. */
  39490. get loadingScreen(): ILoadingScreen;
  39491. /**
  39492. * Sets the current loading screen object
  39493. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39494. */
  39495. set loadingScreen(loadingScreen: ILoadingScreen);
  39496. /**
  39497. * Sets the current loading screen text
  39498. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39499. */
  39500. set loadingUIText(text: string);
  39501. /**
  39502. * Sets the current loading screen background color
  39503. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39504. */
  39505. set loadingUIBackgroundColor(color: string);
  39506. /** Pointerlock and fullscreen */
  39507. /**
  39508. * Ask the browser to promote the current element to pointerlock mode
  39509. * @param element defines the DOM element to promote
  39510. */
  39511. static _RequestPointerlock(element: HTMLElement): void;
  39512. /**
  39513. * Asks the browser to exit pointerlock mode
  39514. */
  39515. static _ExitPointerlock(): void;
  39516. /**
  39517. * Ask the browser to promote the current element to fullscreen rendering mode
  39518. * @param element defines the DOM element to promote
  39519. */
  39520. static _RequestFullscreen(element: HTMLElement): void;
  39521. /**
  39522. * Asks the browser to exit fullscreen mode
  39523. */
  39524. static _ExitFullscreen(): void;
  39525. }
  39526. }
  39527. declare module "babylonjs/Engines/engineStore" {
  39528. import { Nullable } from "babylonjs/types";
  39529. import { Engine } from "babylonjs/Engines/engine";
  39530. import { Scene } from "babylonjs/scene";
  39531. /**
  39532. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39533. * during the life time of the application.
  39534. */
  39535. export class EngineStore {
  39536. /** Gets the list of created engines */
  39537. static Instances: import("babylonjs/Engines/engine").Engine[];
  39538. /** @hidden */
  39539. static _LastCreatedScene: Nullable<Scene>;
  39540. /**
  39541. * Gets the latest created engine
  39542. */
  39543. static get LastCreatedEngine(): Nullable<Engine>;
  39544. /**
  39545. * Gets the latest created scene
  39546. */
  39547. static get LastCreatedScene(): Nullable<Scene>;
  39548. /**
  39549. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39550. * @ignorenaming
  39551. */
  39552. static UseFallbackTexture: boolean;
  39553. /**
  39554. * Texture content used if a texture cannot loaded
  39555. * @ignorenaming
  39556. */
  39557. static FallbackTexture: string;
  39558. }
  39559. }
  39560. declare module "babylonjs/Misc/promise" {
  39561. /**
  39562. * Helper class that provides a small promise polyfill
  39563. */
  39564. export class PromisePolyfill {
  39565. /**
  39566. * Static function used to check if the polyfill is required
  39567. * If this is the case then the function will inject the polyfill to window.Promise
  39568. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39569. */
  39570. static Apply(force?: boolean): void;
  39571. }
  39572. }
  39573. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39574. /**
  39575. * Interface for screenshot methods with describe argument called `size` as object with options
  39576. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39577. */
  39578. export interface IScreenshotSize {
  39579. /**
  39580. * number in pixels for canvas height
  39581. */
  39582. height?: number;
  39583. /**
  39584. * multiplier allowing render at a higher or lower resolution
  39585. * If value is defined then height and width will be ignored and taken from camera
  39586. */
  39587. precision?: number;
  39588. /**
  39589. * number in pixels for canvas width
  39590. */
  39591. width?: number;
  39592. }
  39593. }
  39594. declare module "babylonjs/Misc/tools" {
  39595. import { Nullable, float } from "babylonjs/types";
  39596. import { DomManagement } from "babylonjs/Misc/domManagement";
  39597. import { WebRequest } from "babylonjs/Misc/webRequest";
  39598. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39599. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39600. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39601. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39602. import { Camera } from "babylonjs/Cameras/camera";
  39603. import { Engine } from "babylonjs/Engines/engine";
  39604. interface IColor4Like {
  39605. r: float;
  39606. g: float;
  39607. b: float;
  39608. a: float;
  39609. }
  39610. /**
  39611. * Class containing a set of static utilities functions
  39612. */
  39613. export class Tools {
  39614. /**
  39615. * Gets or sets the base URL to use to load assets
  39616. */
  39617. static get BaseUrl(): string;
  39618. static set BaseUrl(value: string);
  39619. /**
  39620. * Enable/Disable Custom HTTP Request Headers globally.
  39621. * default = false
  39622. * @see CustomRequestHeaders
  39623. */
  39624. static UseCustomRequestHeaders: boolean;
  39625. /**
  39626. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39627. * i.e. when loading files, where the server/service expects an Authorization header
  39628. */
  39629. static CustomRequestHeaders: {
  39630. [key: string]: string;
  39631. };
  39632. /**
  39633. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39634. */
  39635. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39636. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39637. /**
  39638. * Default behaviour for cors in the application.
  39639. * It can be a string if the expected behavior is identical in the entire app.
  39640. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39641. */
  39642. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39643. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39644. /**
  39645. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39646. * @ignorenaming
  39647. */
  39648. static get UseFallbackTexture(): boolean;
  39649. static set UseFallbackTexture(value: boolean);
  39650. /**
  39651. * Use this object to register external classes like custom textures or material
  39652. * to allow the laoders to instantiate them
  39653. */
  39654. static get RegisteredExternalClasses(): {
  39655. [key: string]: Object;
  39656. };
  39657. static set RegisteredExternalClasses(classes: {
  39658. [key: string]: Object;
  39659. });
  39660. /**
  39661. * Texture content used if a texture cannot loaded
  39662. * @ignorenaming
  39663. */
  39664. static get fallbackTexture(): string;
  39665. static set fallbackTexture(value: string);
  39666. /**
  39667. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39668. * @param u defines the coordinate on X axis
  39669. * @param v defines the coordinate on Y axis
  39670. * @param width defines the width of the source data
  39671. * @param height defines the height of the source data
  39672. * @param pixels defines the source byte array
  39673. * @param color defines the output color
  39674. */
  39675. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39676. /**
  39677. * Interpolates between a and b via alpha
  39678. * @param a The lower value (returned when alpha = 0)
  39679. * @param b The upper value (returned when alpha = 1)
  39680. * @param alpha The interpolation-factor
  39681. * @return The mixed value
  39682. */
  39683. static Mix(a: number, b: number, alpha: number): number;
  39684. /**
  39685. * Tries to instantiate a new object from a given class name
  39686. * @param className defines the class name to instantiate
  39687. * @returns the new object or null if the system was not able to do the instantiation
  39688. */
  39689. static Instantiate(className: string): any;
  39690. /**
  39691. * Provides a slice function that will work even on IE
  39692. * @param data defines the array to slice
  39693. * @param start defines the start of the data (optional)
  39694. * @param end defines the end of the data (optional)
  39695. * @returns the new sliced array
  39696. */
  39697. static Slice<T>(data: T, start?: number, end?: number): T;
  39698. /**
  39699. * Polyfill for setImmediate
  39700. * @param action defines the action to execute after the current execution block
  39701. */
  39702. static SetImmediate(action: () => void): void;
  39703. /**
  39704. * Function indicating if a number is an exponent of 2
  39705. * @param value defines the value to test
  39706. * @returns true if the value is an exponent of 2
  39707. */
  39708. static IsExponentOfTwo(value: number): boolean;
  39709. private static _tmpFloatArray;
  39710. /**
  39711. * Returns the nearest 32-bit single precision float representation of a Number
  39712. * @param value A Number. If the parameter is of a different type, it will get converted
  39713. * to a number or to NaN if it cannot be converted
  39714. * @returns number
  39715. */
  39716. static FloatRound(value: number): number;
  39717. /**
  39718. * Extracts the filename from a path
  39719. * @param path defines the path to use
  39720. * @returns the filename
  39721. */
  39722. static GetFilename(path: string): string;
  39723. /**
  39724. * Extracts the "folder" part of a path (everything before the filename).
  39725. * @param uri The URI to extract the info from
  39726. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39727. * @returns The "folder" part of the path
  39728. */
  39729. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39730. /**
  39731. * Extracts text content from a DOM element hierarchy
  39732. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39733. */
  39734. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39735. /**
  39736. * Convert an angle in radians to degrees
  39737. * @param angle defines the angle to convert
  39738. * @returns the angle in degrees
  39739. */
  39740. static ToDegrees(angle: number): number;
  39741. /**
  39742. * Convert an angle in degrees to radians
  39743. * @param angle defines the angle to convert
  39744. * @returns the angle in radians
  39745. */
  39746. static ToRadians(angle: number): number;
  39747. /**
  39748. * Returns an array if obj is not an array
  39749. * @param obj defines the object to evaluate as an array
  39750. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39751. * @returns either obj directly if obj is an array or a new array containing obj
  39752. */
  39753. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39754. /**
  39755. * Gets the pointer prefix to use
  39756. * @param engine defines the engine we are finding the prefix for
  39757. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39758. */
  39759. static GetPointerPrefix(engine: Engine): string;
  39760. /**
  39761. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39762. * @param url define the url we are trying
  39763. * @param element define the dom element where to configure the cors policy
  39764. */
  39765. static SetCorsBehavior(url: string | string[], element: {
  39766. crossOrigin: string | null;
  39767. }): void;
  39768. /**
  39769. * Removes unwanted characters from an url
  39770. * @param url defines the url to clean
  39771. * @returns the cleaned url
  39772. */
  39773. static CleanUrl(url: string): string;
  39774. /**
  39775. * Gets or sets a function used to pre-process url before using them to load assets
  39776. */
  39777. static get PreprocessUrl(): (url: string) => string;
  39778. static set PreprocessUrl(processor: (url: string) => string);
  39779. /**
  39780. * Loads an image as an HTMLImageElement.
  39781. * @param input url string, ArrayBuffer, or Blob to load
  39782. * @param onLoad callback called when the image successfully loads
  39783. * @param onError callback called when the image fails to load
  39784. * @param offlineProvider offline provider for caching
  39785. * @param mimeType optional mime type
  39786. * @returns the HTMLImageElement of the loaded image
  39787. */
  39788. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39789. /**
  39790. * Loads a file from a url
  39791. * @param url url string, ArrayBuffer, or Blob to load
  39792. * @param onSuccess callback called when the file successfully loads
  39793. * @param onProgress callback called while file is loading (if the server supports this mode)
  39794. * @param offlineProvider defines the offline provider for caching
  39795. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39796. * @param onError callback called when the file fails to load
  39797. * @returns a file request object
  39798. */
  39799. 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;
  39800. /**
  39801. * Loads a file from a url
  39802. * @param url the file url to load
  39803. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39804. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39805. */
  39806. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39807. /**
  39808. * Load a script (identified by an url). When the url returns, the
  39809. * content of this file is added into a new script element, attached to the DOM (body element)
  39810. * @param scriptUrl defines the url of the script to laod
  39811. * @param onSuccess defines the callback called when the script is loaded
  39812. * @param onError defines the callback to call if an error occurs
  39813. * @param scriptId defines the id of the script element
  39814. */
  39815. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39816. /**
  39817. * Load an asynchronous script (identified by an url). When the url returns, the
  39818. * content of this file is added into a new script element, attached to the DOM (body element)
  39819. * @param scriptUrl defines the url of the script to laod
  39820. * @param scriptId defines the id of the script element
  39821. * @returns a promise request object
  39822. */
  39823. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39824. /**
  39825. * Loads a file from a blob
  39826. * @param fileToLoad defines the blob to use
  39827. * @param callback defines the callback to call when data is loaded
  39828. * @param progressCallback defines the callback to call during loading process
  39829. * @returns a file request object
  39830. */
  39831. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39832. /**
  39833. * Reads a file from a File object
  39834. * @param file defines the file to load
  39835. * @param onSuccess defines the callback to call when data is loaded
  39836. * @param onProgress defines the callback to call during loading process
  39837. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39838. * @param onError defines the callback to call when an error occurs
  39839. * @returns a file request object
  39840. */
  39841. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39842. /**
  39843. * Creates a data url from a given string content
  39844. * @param content defines the content to convert
  39845. * @returns the new data url link
  39846. */
  39847. static FileAsURL(content: string): string;
  39848. /**
  39849. * Format the given number to a specific decimal format
  39850. * @param value defines the number to format
  39851. * @param decimals defines the number of decimals to use
  39852. * @returns the formatted string
  39853. */
  39854. static Format(value: number, decimals?: number): string;
  39855. /**
  39856. * Tries to copy an object by duplicating every property
  39857. * @param source defines the source object
  39858. * @param destination defines the target object
  39859. * @param doNotCopyList defines a list of properties to avoid
  39860. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39861. */
  39862. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39863. /**
  39864. * Gets a boolean indicating if the given object has no own property
  39865. * @param obj defines the object to test
  39866. * @returns true if object has no own property
  39867. */
  39868. static IsEmpty(obj: any): boolean;
  39869. /**
  39870. * Function used to register events at window level
  39871. * @param windowElement defines the Window object to use
  39872. * @param events defines the events to register
  39873. */
  39874. static RegisterTopRootEvents(windowElement: Window, events: {
  39875. name: string;
  39876. handler: Nullable<(e: FocusEvent) => any>;
  39877. }[]): void;
  39878. /**
  39879. * Function used to unregister events from window level
  39880. * @param windowElement defines the Window object to use
  39881. * @param events defines the events to unregister
  39882. */
  39883. static UnregisterTopRootEvents(windowElement: Window, events: {
  39884. name: string;
  39885. handler: Nullable<(e: FocusEvent) => any>;
  39886. }[]): void;
  39887. /**
  39888. * @ignore
  39889. */
  39890. static _ScreenshotCanvas: HTMLCanvasElement;
  39891. /**
  39892. * Dumps the current bound framebuffer
  39893. * @param width defines the rendering width
  39894. * @param height defines the rendering height
  39895. * @param engine defines the hosting engine
  39896. * @param successCallback defines the callback triggered once the data are available
  39897. * @param mimeType defines the mime type of the result
  39898. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39899. */
  39900. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39901. /**
  39902. * Converts the canvas data to blob.
  39903. * This acts as a polyfill for browsers not supporting the to blob function.
  39904. * @param canvas Defines the canvas to extract the data from
  39905. * @param successCallback Defines the callback triggered once the data are available
  39906. * @param mimeType Defines the mime type of the result
  39907. */
  39908. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39909. /**
  39910. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39911. * @param successCallback defines the callback triggered once the data are available
  39912. * @param mimeType defines the mime type of the result
  39913. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39914. */
  39915. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39916. /**
  39917. * Downloads a blob in the browser
  39918. * @param blob defines the blob to download
  39919. * @param fileName defines the name of the downloaded file
  39920. */
  39921. static Download(blob: Blob, fileName: string): void;
  39922. /**
  39923. * Captures a screenshot of the current rendering
  39924. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39925. * @param engine defines the rendering engine
  39926. * @param camera defines the source camera
  39927. * @param size This parameter can be set to a single number or to an object with the
  39928. * following (optional) properties: precision, width, height. If a single number is passed,
  39929. * it will be used for both width and height. If an object is passed, the screenshot size
  39930. * will be derived from the parameters. The precision property is a multiplier allowing
  39931. * rendering at a higher or lower resolution
  39932. * @param successCallback defines the callback receives a single parameter which contains the
  39933. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39934. * src parameter of an <img> to display it
  39935. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39936. * Check your browser for supported MIME types
  39937. */
  39938. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39939. /**
  39940. * Captures a screenshot of the current rendering
  39941. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39942. * @param engine defines the rendering engine
  39943. * @param camera defines the source camera
  39944. * @param size This parameter can be set to a single number or to an object with the
  39945. * following (optional) properties: precision, width, height. If a single number is passed,
  39946. * it will be used for both width and height. If an object is passed, the screenshot size
  39947. * will be derived from the parameters. The precision property is a multiplier allowing
  39948. * rendering at a higher or lower resolution
  39949. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39950. * Check your browser for supported MIME types
  39951. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39952. * to the src parameter of an <img> to display it
  39953. */
  39954. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39955. /**
  39956. * Generates an image screenshot from the specified camera.
  39957. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39958. * @param engine The engine to use for rendering
  39959. * @param camera The camera to use for rendering
  39960. * @param size This parameter can be set to a single number or to an object with the
  39961. * following (optional) properties: precision, width, height. If a single number is passed,
  39962. * it will be used for both width and height. If an object is passed, the screenshot size
  39963. * will be derived from the parameters. The precision property is a multiplier allowing
  39964. * rendering at a higher or lower resolution
  39965. * @param successCallback The callback receives a single parameter which contains the
  39966. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39967. * src parameter of an <img> to display it
  39968. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39969. * Check your browser for supported MIME types
  39970. * @param samples Texture samples (default: 1)
  39971. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39972. * @param fileName A name for for the downloaded file.
  39973. */
  39974. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39975. /**
  39976. * Generates an image screenshot from the specified camera.
  39977. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39978. * @param engine The engine to use for rendering
  39979. * @param camera The camera to use for rendering
  39980. * @param size This parameter can be set to a single number or to an object with the
  39981. * following (optional) properties: precision, width, height. If a single number is passed,
  39982. * it will be used for both width and height. If an object is passed, the screenshot size
  39983. * will be derived from the parameters. The precision property is a multiplier allowing
  39984. * rendering at a higher or lower resolution
  39985. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39986. * Check your browser for supported MIME types
  39987. * @param samples Texture samples (default: 1)
  39988. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39989. * @param fileName A name for for the downloaded file.
  39990. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39991. * to the src parameter of an <img> to display it
  39992. */
  39993. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39994. /**
  39995. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39996. * Be aware Math.random() could cause collisions, but:
  39997. * "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"
  39998. * @returns a pseudo random id
  39999. */
  40000. static RandomId(): string;
  40001. /**
  40002. * Test if the given uri is a base64 string
  40003. * @param uri The uri to test
  40004. * @return True if the uri is a base64 string or false otherwise
  40005. */
  40006. static IsBase64(uri: string): boolean;
  40007. /**
  40008. * Decode the given base64 uri.
  40009. * @param uri The uri to decode
  40010. * @return The decoded base64 data.
  40011. */
  40012. static DecodeBase64(uri: string): ArrayBuffer;
  40013. /**
  40014. * Gets the absolute url.
  40015. * @param url the input url
  40016. * @return the absolute url
  40017. */
  40018. static GetAbsoluteUrl(url: string): string;
  40019. /**
  40020. * No log
  40021. */
  40022. static readonly NoneLogLevel: number;
  40023. /**
  40024. * Only message logs
  40025. */
  40026. static readonly MessageLogLevel: number;
  40027. /**
  40028. * Only warning logs
  40029. */
  40030. static readonly WarningLogLevel: number;
  40031. /**
  40032. * Only error logs
  40033. */
  40034. static readonly ErrorLogLevel: number;
  40035. /**
  40036. * All logs
  40037. */
  40038. static readonly AllLogLevel: number;
  40039. /**
  40040. * Gets a value indicating the number of loading errors
  40041. * @ignorenaming
  40042. */
  40043. static get errorsCount(): number;
  40044. /**
  40045. * Callback called when a new log is added
  40046. */
  40047. static OnNewCacheEntry: (entry: string) => void;
  40048. /**
  40049. * Log a message to the console
  40050. * @param message defines the message to log
  40051. */
  40052. static Log(message: string): void;
  40053. /**
  40054. * Write a warning message to the console
  40055. * @param message defines the message to log
  40056. */
  40057. static Warn(message: string): void;
  40058. /**
  40059. * Write an error message to the console
  40060. * @param message defines the message to log
  40061. */
  40062. static Error(message: string): void;
  40063. /**
  40064. * Gets current log cache (list of logs)
  40065. */
  40066. static get LogCache(): string;
  40067. /**
  40068. * Clears the log cache
  40069. */
  40070. static ClearLogCache(): void;
  40071. /**
  40072. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40073. */
  40074. static set LogLevels(level: number);
  40075. /**
  40076. * Checks if the window object exists
  40077. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40078. */
  40079. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40080. /**
  40081. * No performance log
  40082. */
  40083. static readonly PerformanceNoneLogLevel: number;
  40084. /**
  40085. * Use user marks to log performance
  40086. */
  40087. static readonly PerformanceUserMarkLogLevel: number;
  40088. /**
  40089. * Log performance to the console
  40090. */
  40091. static readonly PerformanceConsoleLogLevel: number;
  40092. private static _performance;
  40093. /**
  40094. * Sets the current performance log level
  40095. */
  40096. static set PerformanceLogLevel(level: number);
  40097. private static _StartPerformanceCounterDisabled;
  40098. private static _EndPerformanceCounterDisabled;
  40099. private static _StartUserMark;
  40100. private static _EndUserMark;
  40101. private static _StartPerformanceConsole;
  40102. private static _EndPerformanceConsole;
  40103. /**
  40104. * Starts a performance counter
  40105. */
  40106. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40107. /**
  40108. * Ends a specific performance coutner
  40109. */
  40110. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40111. /**
  40112. * Gets either window.performance.now() if supported or Date.now() else
  40113. */
  40114. static get Now(): number;
  40115. /**
  40116. * This method will return the name of the class used to create the instance of the given object.
  40117. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40118. * @param object the object to get the class name from
  40119. * @param isType defines if the object is actually a type
  40120. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40121. */
  40122. static GetClassName(object: any, isType?: boolean): string;
  40123. /**
  40124. * Gets the first element of an array satisfying a given predicate
  40125. * @param array defines the array to browse
  40126. * @param predicate defines the predicate to use
  40127. * @returns null if not found or the element
  40128. */
  40129. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40130. /**
  40131. * This method will return the name of the full name of the class, including its owning module (if any).
  40132. * 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).
  40133. * @param object the object to get the class name from
  40134. * @param isType defines if the object is actually a type
  40135. * @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.
  40136. * @ignorenaming
  40137. */
  40138. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40139. /**
  40140. * Returns a promise that resolves after the given amount of time.
  40141. * @param delay Number of milliseconds to delay
  40142. * @returns Promise that resolves after the given amount of time
  40143. */
  40144. static DelayAsync(delay: number): Promise<void>;
  40145. /**
  40146. * Utility function to detect if the current user agent is Safari
  40147. * @returns whether or not the current user agent is safari
  40148. */
  40149. static IsSafari(): boolean;
  40150. }
  40151. /**
  40152. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40153. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40154. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40155. * @param name The name of the class, case should be preserved
  40156. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40157. */
  40158. export function className(name: string, module?: string): (target: Object) => void;
  40159. /**
  40160. * An implementation of a loop for asynchronous functions.
  40161. */
  40162. export class AsyncLoop {
  40163. /**
  40164. * Defines the number of iterations for the loop
  40165. */
  40166. iterations: number;
  40167. /**
  40168. * Defines the current index of the loop.
  40169. */
  40170. index: number;
  40171. private _done;
  40172. private _fn;
  40173. private _successCallback;
  40174. /**
  40175. * Constructor.
  40176. * @param iterations the number of iterations.
  40177. * @param func the function to run each iteration
  40178. * @param successCallback the callback that will be called upon succesful execution
  40179. * @param offset starting offset.
  40180. */
  40181. constructor(
  40182. /**
  40183. * Defines the number of iterations for the loop
  40184. */
  40185. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40186. /**
  40187. * Execute the next iteration. Must be called after the last iteration was finished.
  40188. */
  40189. executeNext(): void;
  40190. /**
  40191. * Break the loop and run the success callback.
  40192. */
  40193. breakLoop(): void;
  40194. /**
  40195. * Create and run an async loop.
  40196. * @param iterations the number of iterations.
  40197. * @param fn the function to run each iteration
  40198. * @param successCallback the callback that will be called upon succesful execution
  40199. * @param offset starting offset.
  40200. * @returns the created async loop object
  40201. */
  40202. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40203. /**
  40204. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40205. * @param iterations total number of iterations
  40206. * @param syncedIterations number of synchronous iterations in each async iteration.
  40207. * @param fn the function to call each iteration.
  40208. * @param callback a success call back that will be called when iterating stops.
  40209. * @param breakFunction a break condition (optional)
  40210. * @param timeout timeout settings for the setTimeout function. default - 0.
  40211. * @returns the created async loop object
  40212. */
  40213. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40214. }
  40215. }
  40216. declare module "babylonjs/Misc/stringDictionary" {
  40217. import { Nullable } from "babylonjs/types";
  40218. /**
  40219. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40220. * The underlying implementation relies on an associative array to ensure the best performances.
  40221. * The value can be anything including 'null' but except 'undefined'
  40222. */
  40223. export class StringDictionary<T> {
  40224. /**
  40225. * This will clear this dictionary and copy the content from the 'source' one.
  40226. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40227. * @param source the dictionary to take the content from and copy to this dictionary
  40228. */
  40229. copyFrom(source: StringDictionary<T>): void;
  40230. /**
  40231. * Get a value based from its key
  40232. * @param key the given key to get the matching value from
  40233. * @return the value if found, otherwise undefined is returned
  40234. */
  40235. get(key: string): T | undefined;
  40236. /**
  40237. * Get a value from its key or add it if it doesn't exist.
  40238. * This method will ensure you that a given key/data will be present in the dictionary.
  40239. * @param key the given key to get the matching value from
  40240. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40241. * The factory will only be invoked if there's no data for the given key.
  40242. * @return the value corresponding to the key.
  40243. */
  40244. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40245. /**
  40246. * Get a value from its key if present in the dictionary otherwise add it
  40247. * @param key the key to get the value from
  40248. * @param val if there's no such key/value pair in the dictionary add it with this value
  40249. * @return the value corresponding to the key
  40250. */
  40251. getOrAdd(key: string, val: T): T;
  40252. /**
  40253. * Check if there's a given key in the dictionary
  40254. * @param key the key to check for
  40255. * @return true if the key is present, false otherwise
  40256. */
  40257. contains(key: string): boolean;
  40258. /**
  40259. * Add a new key and its corresponding value
  40260. * @param key the key to add
  40261. * @param value the value corresponding to the key
  40262. * @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
  40263. */
  40264. add(key: string, value: T): boolean;
  40265. /**
  40266. * Update a specific value associated to a key
  40267. * @param key defines the key to use
  40268. * @param value defines the value to store
  40269. * @returns true if the value was updated (or false if the key was not found)
  40270. */
  40271. set(key: string, value: T): boolean;
  40272. /**
  40273. * Get the element of the given key and remove it from the dictionary
  40274. * @param key defines the key to search
  40275. * @returns the value associated with the key or null if not found
  40276. */
  40277. getAndRemove(key: string): Nullable<T>;
  40278. /**
  40279. * Remove a key/value from the dictionary.
  40280. * @param key the key to remove
  40281. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40282. */
  40283. remove(key: string): boolean;
  40284. /**
  40285. * Clear the whole content of the dictionary
  40286. */
  40287. clear(): void;
  40288. /**
  40289. * Gets the current count
  40290. */
  40291. get count(): number;
  40292. /**
  40293. * Execute a callback on each key/val of the dictionary.
  40294. * Note that you can remove any element in this dictionary in the callback implementation
  40295. * @param callback the callback to execute on a given key/value pair
  40296. */
  40297. forEach(callback: (key: string, val: T) => void): void;
  40298. /**
  40299. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40300. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40301. * Note that you can remove any element in this dictionary in the callback implementation
  40302. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40303. * @returns the first item
  40304. */
  40305. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40306. private _count;
  40307. private _data;
  40308. }
  40309. }
  40310. declare module "babylonjs/Collisions/collisionCoordinator" {
  40311. import { Nullable } from "babylonjs/types";
  40312. import { Scene } from "babylonjs/scene";
  40313. import { Vector3 } from "babylonjs/Maths/math.vector";
  40314. import { Collider } from "babylonjs/Collisions/collider";
  40315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40316. /** @hidden */
  40317. export interface ICollisionCoordinator {
  40318. createCollider(): Collider;
  40319. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40320. init(scene: Scene): void;
  40321. }
  40322. /** @hidden */
  40323. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40324. private _scene;
  40325. private _scaledPosition;
  40326. private _scaledVelocity;
  40327. private _finalPosition;
  40328. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40329. createCollider(): Collider;
  40330. init(scene: Scene): void;
  40331. private _collideWithWorld;
  40332. }
  40333. }
  40334. declare module "babylonjs/Inputs/scene.inputManager" {
  40335. import { Nullable } from "babylonjs/types";
  40336. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40337. import { Vector2 } from "babylonjs/Maths/math.vector";
  40338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40339. import { Scene } from "babylonjs/scene";
  40340. /**
  40341. * Class used to manage all inputs for the scene.
  40342. */
  40343. export class InputManager {
  40344. /** The distance in pixel that you have to move to prevent some events */
  40345. static DragMovementThreshold: number;
  40346. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40347. static LongPressDelay: number;
  40348. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40349. static DoubleClickDelay: number;
  40350. /** If you need to check double click without raising a single click at first click, enable this flag */
  40351. static ExclusiveDoubleClickMode: boolean;
  40352. /** 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. */
  40353. private _alreadyAttached;
  40354. private _wheelEventName;
  40355. private _onPointerMove;
  40356. private _onPointerDown;
  40357. private _onPointerUp;
  40358. private _initClickEvent;
  40359. private _initActionManager;
  40360. private _delayedSimpleClick;
  40361. private _delayedSimpleClickTimeout;
  40362. private _previousDelayedSimpleClickTimeout;
  40363. private _meshPickProceed;
  40364. private _previousButtonPressed;
  40365. private _currentPickResult;
  40366. private _previousPickResult;
  40367. private _totalPointersPressed;
  40368. private _doubleClickOccured;
  40369. private _pointerOverMesh;
  40370. private _pickedDownMesh;
  40371. private _pickedUpMesh;
  40372. private _pointerX;
  40373. private _pointerY;
  40374. private _unTranslatedPointerX;
  40375. private _unTranslatedPointerY;
  40376. private _startingPointerPosition;
  40377. private _previousStartingPointerPosition;
  40378. private _startingPointerTime;
  40379. private _previousStartingPointerTime;
  40380. private _pointerCaptures;
  40381. private _meshUnderPointerId;
  40382. private _onKeyDown;
  40383. private _onKeyUp;
  40384. private _onCanvasFocusObserver;
  40385. private _onCanvasBlurObserver;
  40386. private _scene;
  40387. /**
  40388. * Creates a new InputManager
  40389. * @param scene defines the hosting scene
  40390. */
  40391. constructor(scene: Scene);
  40392. /**
  40393. * Gets the mesh that is currently under the pointer
  40394. */
  40395. get meshUnderPointer(): Nullable<AbstractMesh>;
  40396. /**
  40397. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40398. * @param pointerId the pointer id to use
  40399. * @returns The mesh under this pointer id or null if not found
  40400. */
  40401. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40402. /**
  40403. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40404. */
  40405. get unTranslatedPointer(): Vector2;
  40406. /**
  40407. * Gets or sets the current on-screen X position of the pointer
  40408. */
  40409. get pointerX(): number;
  40410. set pointerX(value: number);
  40411. /**
  40412. * Gets or sets the current on-screen Y position of the pointer
  40413. */
  40414. get pointerY(): number;
  40415. set pointerY(value: number);
  40416. private _updatePointerPosition;
  40417. private _processPointerMove;
  40418. private _setRayOnPointerInfo;
  40419. private _checkPrePointerObservable;
  40420. /**
  40421. * Use this method to simulate a pointer move on a mesh
  40422. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40423. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40424. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40425. */
  40426. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40427. /**
  40428. * Use this method to simulate a pointer down on a mesh
  40429. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40430. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40431. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40432. */
  40433. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40434. private _processPointerDown;
  40435. /** @hidden */
  40436. _isPointerSwiping(): boolean;
  40437. /**
  40438. * Use this method to simulate a pointer up on a mesh
  40439. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40440. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40441. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40442. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40443. */
  40444. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40445. private _processPointerUp;
  40446. /**
  40447. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40448. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40449. * @returns true if the pointer was captured
  40450. */
  40451. isPointerCaptured(pointerId?: number): boolean;
  40452. /**
  40453. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40454. * @param attachUp defines if you want to attach events to pointerup
  40455. * @param attachDown defines if you want to attach events to pointerdown
  40456. * @param attachMove defines if you want to attach events to pointermove
  40457. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40458. */
  40459. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40460. /**
  40461. * Detaches all event handlers
  40462. */
  40463. detachControl(): void;
  40464. /**
  40465. * Force the value of meshUnderPointer
  40466. * @param mesh defines the mesh to use
  40467. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40468. */
  40469. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40470. /**
  40471. * Gets the mesh under the pointer
  40472. * @returns a Mesh or null if no mesh is under the pointer
  40473. */
  40474. getPointerOverMesh(): Nullable<AbstractMesh>;
  40475. }
  40476. }
  40477. declare module "babylonjs/Animations/animationGroup" {
  40478. import { Animatable } from "babylonjs/Animations/animatable";
  40479. import { Animation } from "babylonjs/Animations/animation";
  40480. import { Scene, IDisposable } from "babylonjs/scene";
  40481. import { Observable } from "babylonjs/Misc/observable";
  40482. import { Nullable } from "babylonjs/types";
  40483. import "babylonjs/Animations/animatable";
  40484. /**
  40485. * This class defines the direct association between an animation and a target
  40486. */
  40487. export class TargetedAnimation {
  40488. /**
  40489. * Animation to perform
  40490. */
  40491. animation: Animation;
  40492. /**
  40493. * Target to animate
  40494. */
  40495. target: any;
  40496. /**
  40497. * Returns the string "TargetedAnimation"
  40498. * @returns "TargetedAnimation"
  40499. */
  40500. getClassName(): string;
  40501. /**
  40502. * Serialize the object
  40503. * @returns the JSON object representing the current entity
  40504. */
  40505. serialize(): any;
  40506. }
  40507. /**
  40508. * Use this class to create coordinated animations on multiple targets
  40509. */
  40510. export class AnimationGroup implements IDisposable {
  40511. /** The name of the animation group */
  40512. name: string;
  40513. private _scene;
  40514. private _targetedAnimations;
  40515. private _animatables;
  40516. private _from;
  40517. private _to;
  40518. private _isStarted;
  40519. private _isPaused;
  40520. private _speedRatio;
  40521. private _loopAnimation;
  40522. private _isAdditive;
  40523. /**
  40524. * Gets or sets the unique id of the node
  40525. */
  40526. uniqueId: number;
  40527. /**
  40528. * This observable will notify when one animation have ended
  40529. */
  40530. onAnimationEndObservable: Observable<TargetedAnimation>;
  40531. /**
  40532. * Observer raised when one animation loops
  40533. */
  40534. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40535. /**
  40536. * Observer raised when all animations have looped
  40537. */
  40538. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40539. /**
  40540. * This observable will notify when all animations have ended.
  40541. */
  40542. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40543. /**
  40544. * This observable will notify when all animations have paused.
  40545. */
  40546. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40547. /**
  40548. * This observable will notify when all animations are playing.
  40549. */
  40550. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40551. /**
  40552. * Gets the first frame
  40553. */
  40554. get from(): number;
  40555. /**
  40556. * Gets the last frame
  40557. */
  40558. get to(): number;
  40559. /**
  40560. * Define if the animations are started
  40561. */
  40562. get isStarted(): boolean;
  40563. /**
  40564. * Gets a value indicating that the current group is playing
  40565. */
  40566. get isPlaying(): boolean;
  40567. /**
  40568. * Gets or sets the speed ratio to use for all animations
  40569. */
  40570. get speedRatio(): number;
  40571. /**
  40572. * Gets or sets the speed ratio to use for all animations
  40573. */
  40574. set speedRatio(value: number);
  40575. /**
  40576. * Gets or sets if all animations should loop or not
  40577. */
  40578. get loopAnimation(): boolean;
  40579. set loopAnimation(value: boolean);
  40580. /**
  40581. * Gets or sets if all animations should be evaluated additively
  40582. */
  40583. get isAdditive(): boolean;
  40584. set isAdditive(value: boolean);
  40585. /**
  40586. * Gets the targeted animations for this animation group
  40587. */
  40588. get targetedAnimations(): Array<TargetedAnimation>;
  40589. /**
  40590. * returning the list of animatables controlled by this animation group.
  40591. */
  40592. get animatables(): Array<Animatable>;
  40593. /**
  40594. * Gets the list of target animations
  40595. */
  40596. get children(): TargetedAnimation[];
  40597. /**
  40598. * Instantiates a new Animation Group.
  40599. * This helps managing several animations at once.
  40600. * @see https://doc.babylonjs.com/how_to/group
  40601. * @param name Defines the name of the group
  40602. * @param scene Defines the scene the group belongs to
  40603. */
  40604. constructor(
  40605. /** The name of the animation group */
  40606. name: string, scene?: Nullable<Scene>);
  40607. /**
  40608. * Add an animation (with its target) in the group
  40609. * @param animation defines the animation we want to add
  40610. * @param target defines the target of the animation
  40611. * @returns the TargetedAnimation object
  40612. */
  40613. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40614. /**
  40615. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40616. * It can add constant keys at begin or end
  40617. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40618. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40619. * @returns the animation group
  40620. */
  40621. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40622. private _animationLoopCount;
  40623. private _animationLoopFlags;
  40624. private _processLoop;
  40625. /**
  40626. * Start all animations on given targets
  40627. * @param loop defines if animations must loop
  40628. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40629. * @param from defines the from key (optional)
  40630. * @param to defines the to key (optional)
  40631. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40632. * @returns the current animation group
  40633. */
  40634. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40635. /**
  40636. * Pause all animations
  40637. * @returns the animation group
  40638. */
  40639. pause(): AnimationGroup;
  40640. /**
  40641. * Play all animations to initial state
  40642. * This function will start() the animations if they were not started or will restart() them if they were paused
  40643. * @param loop defines if animations must loop
  40644. * @returns the animation group
  40645. */
  40646. play(loop?: boolean): AnimationGroup;
  40647. /**
  40648. * Reset all animations to initial state
  40649. * @returns the animation group
  40650. */
  40651. reset(): AnimationGroup;
  40652. /**
  40653. * Restart animations from key 0
  40654. * @returns the animation group
  40655. */
  40656. restart(): AnimationGroup;
  40657. /**
  40658. * Stop all animations
  40659. * @returns the animation group
  40660. */
  40661. stop(): AnimationGroup;
  40662. /**
  40663. * Set animation weight for all animatables
  40664. * @param weight defines the weight to use
  40665. * @return the animationGroup
  40666. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40667. */
  40668. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40669. /**
  40670. * Synchronize and normalize all animatables with a source animatable
  40671. * @param root defines the root animatable to synchronize with
  40672. * @return the animationGroup
  40673. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40674. */
  40675. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40676. /**
  40677. * Goes to a specific frame in this animation group
  40678. * @param frame the frame number to go to
  40679. * @return the animationGroup
  40680. */
  40681. goToFrame(frame: number): AnimationGroup;
  40682. /**
  40683. * Dispose all associated resources
  40684. */
  40685. dispose(): void;
  40686. private _checkAnimationGroupEnded;
  40687. /**
  40688. * Clone the current animation group and returns a copy
  40689. * @param newName defines the name of the new group
  40690. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40691. * @returns the new aniamtion group
  40692. */
  40693. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40694. /**
  40695. * Serializes the animationGroup to an object
  40696. * @returns Serialized object
  40697. */
  40698. serialize(): any;
  40699. /**
  40700. * Returns a new AnimationGroup object parsed from the source provided.
  40701. * @param parsedAnimationGroup defines the source
  40702. * @param scene defines the scene that will receive the animationGroup
  40703. * @returns a new AnimationGroup
  40704. */
  40705. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40706. /**
  40707. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40708. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40709. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40710. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40711. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40712. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40713. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40714. */
  40715. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40716. /**
  40717. * Returns the string "AnimationGroup"
  40718. * @returns "AnimationGroup"
  40719. */
  40720. getClassName(): string;
  40721. /**
  40722. * Creates a detailled string about the object
  40723. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40724. * @returns a string representing the object
  40725. */
  40726. toString(fullDetails?: boolean): string;
  40727. }
  40728. }
  40729. declare module "babylonjs/scene" {
  40730. import { Nullable } from "babylonjs/types";
  40731. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40732. import { Observable } from "babylonjs/Misc/observable";
  40733. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40734. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40735. import { Geometry } from "babylonjs/Meshes/geometry";
  40736. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40737. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40739. import { Mesh } from "babylonjs/Meshes/mesh";
  40740. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40741. import { Bone } from "babylonjs/Bones/bone";
  40742. import { Skeleton } from "babylonjs/Bones/skeleton";
  40743. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40744. import { Camera } from "babylonjs/Cameras/camera";
  40745. import { AbstractScene } from "babylonjs/abstractScene";
  40746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40748. import { Material } from "babylonjs/Materials/material";
  40749. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40750. import { Effect } from "babylonjs/Materials/effect";
  40751. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40752. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40753. import { Light } from "babylonjs/Lights/light";
  40754. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40755. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40756. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40757. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40758. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40759. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40760. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40761. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40762. import { Engine } from "babylonjs/Engines/engine";
  40763. import { Node } from "babylonjs/node";
  40764. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40765. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40766. import { WebRequest } from "babylonjs/Misc/webRequest";
  40767. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40768. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40769. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40770. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40771. import { Plane } from "babylonjs/Maths/math.plane";
  40772. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40773. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40774. import { Ray } from "babylonjs/Culling/ray";
  40775. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40776. import { Animation } from "babylonjs/Animations/animation";
  40777. import { Animatable } from "babylonjs/Animations/animatable";
  40778. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40779. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40780. import { Collider } from "babylonjs/Collisions/collider";
  40781. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40782. /**
  40783. * Define an interface for all classes that will hold resources
  40784. */
  40785. export interface IDisposable {
  40786. /**
  40787. * Releases all held resources
  40788. */
  40789. dispose(): void;
  40790. }
  40791. /** Interface defining initialization parameters for Scene class */
  40792. export interface SceneOptions {
  40793. /**
  40794. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40795. * It will improve performance when the number of geometries becomes important.
  40796. */
  40797. useGeometryUniqueIdsMap?: boolean;
  40798. /**
  40799. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40800. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40801. */
  40802. useMaterialMeshMap?: boolean;
  40803. /**
  40804. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40805. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40806. */
  40807. useClonedMeshMap?: boolean;
  40808. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40809. virtual?: boolean;
  40810. }
  40811. /**
  40812. * Represents a scene to be rendered by the engine.
  40813. * @see https://doc.babylonjs.com/features/scene
  40814. */
  40815. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40816. /** The fog is deactivated */
  40817. static readonly FOGMODE_NONE: number;
  40818. /** The fog density is following an exponential function */
  40819. static readonly FOGMODE_EXP: number;
  40820. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40821. static readonly FOGMODE_EXP2: number;
  40822. /** The fog density is following a linear function. */
  40823. static readonly FOGMODE_LINEAR: number;
  40824. /**
  40825. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40826. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40827. */
  40828. static MinDeltaTime: number;
  40829. /**
  40830. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40831. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40832. */
  40833. static MaxDeltaTime: number;
  40834. /**
  40835. * Factory used to create the default material.
  40836. * @param name The name of the material to create
  40837. * @param scene The scene to create the material for
  40838. * @returns The default material
  40839. */
  40840. static DefaultMaterialFactory(scene: Scene): Material;
  40841. /**
  40842. * Factory used to create the a collision coordinator.
  40843. * @returns The collision coordinator
  40844. */
  40845. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40846. /** @hidden */
  40847. _inputManager: InputManager;
  40848. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40849. cameraToUseForPointers: Nullable<Camera>;
  40850. /** @hidden */
  40851. readonly _isScene: boolean;
  40852. /** @hidden */
  40853. _blockEntityCollection: boolean;
  40854. /**
  40855. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40856. */
  40857. autoClear: boolean;
  40858. /**
  40859. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40860. */
  40861. autoClearDepthAndStencil: boolean;
  40862. /**
  40863. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40864. */
  40865. clearColor: Color4;
  40866. /**
  40867. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40868. */
  40869. ambientColor: Color3;
  40870. /**
  40871. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40872. * It should only be one of the following (if not the default embedded one):
  40873. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40874. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40875. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40876. * The material properties need to be setup according to the type of texture in use.
  40877. */
  40878. environmentBRDFTexture: BaseTexture;
  40879. /**
  40880. * Texture used in all pbr material as the reflection texture.
  40881. * As in the majority of the scene they are the same (exception for multi room and so on),
  40882. * this is easier to reference from here than from all the materials.
  40883. */
  40884. get environmentTexture(): Nullable<BaseTexture>;
  40885. /**
  40886. * Texture used in all pbr material as the reflection texture.
  40887. * As in the majority of the scene they are the same (exception for multi room and so on),
  40888. * this is easier to set here than in all the materials.
  40889. */
  40890. set environmentTexture(value: Nullable<BaseTexture>);
  40891. /** @hidden */
  40892. protected _environmentIntensity: number;
  40893. /**
  40894. * Intensity of the environment in all pbr material.
  40895. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40896. * As in the majority of the scene they are the same (exception for multi room and so on),
  40897. * this is easier to reference from here than from all the materials.
  40898. */
  40899. get environmentIntensity(): number;
  40900. /**
  40901. * Intensity of the environment in all pbr material.
  40902. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40903. * As in the majority of the scene they are the same (exception for multi room and so on),
  40904. * this is easier to set here than in all the materials.
  40905. */
  40906. set environmentIntensity(value: number);
  40907. /** @hidden */
  40908. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40909. /**
  40910. * Default image processing configuration used either in the rendering
  40911. * Forward main pass or through the imageProcessingPostProcess if present.
  40912. * As in the majority of the scene they are the same (exception for multi camera),
  40913. * this is easier to reference from here than from all the materials and post process.
  40914. *
  40915. * No setter as we it is a shared configuration, you can set the values instead.
  40916. */
  40917. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40918. private _forceWireframe;
  40919. /**
  40920. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40921. */
  40922. set forceWireframe(value: boolean);
  40923. get forceWireframe(): boolean;
  40924. private _skipFrustumClipping;
  40925. /**
  40926. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40927. */
  40928. set skipFrustumClipping(value: boolean);
  40929. get skipFrustumClipping(): boolean;
  40930. private _forcePointsCloud;
  40931. /**
  40932. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40933. */
  40934. set forcePointsCloud(value: boolean);
  40935. get forcePointsCloud(): boolean;
  40936. /**
  40937. * Gets or sets the active clipplane 1
  40938. */
  40939. clipPlane: Nullable<Plane>;
  40940. /**
  40941. * Gets or sets the active clipplane 2
  40942. */
  40943. clipPlane2: Nullable<Plane>;
  40944. /**
  40945. * Gets or sets the active clipplane 3
  40946. */
  40947. clipPlane3: Nullable<Plane>;
  40948. /**
  40949. * Gets or sets the active clipplane 4
  40950. */
  40951. clipPlane4: Nullable<Plane>;
  40952. /**
  40953. * Gets or sets the active clipplane 5
  40954. */
  40955. clipPlane5: Nullable<Plane>;
  40956. /**
  40957. * Gets or sets the active clipplane 6
  40958. */
  40959. clipPlane6: Nullable<Plane>;
  40960. /**
  40961. * Gets or sets a boolean indicating if animations are enabled
  40962. */
  40963. animationsEnabled: boolean;
  40964. private _animationPropertiesOverride;
  40965. /**
  40966. * Gets or sets the animation properties override
  40967. */
  40968. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40969. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40970. /**
  40971. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40972. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40973. */
  40974. useConstantAnimationDeltaTime: boolean;
  40975. /**
  40976. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40977. * Please note that it requires to run a ray cast through the scene on every frame
  40978. */
  40979. constantlyUpdateMeshUnderPointer: boolean;
  40980. /**
  40981. * Defines the HTML cursor to use when hovering over interactive elements
  40982. */
  40983. hoverCursor: string;
  40984. /**
  40985. * Defines the HTML default cursor to use (empty by default)
  40986. */
  40987. defaultCursor: string;
  40988. /**
  40989. * Defines whether cursors are handled by the scene.
  40990. */
  40991. doNotHandleCursors: boolean;
  40992. /**
  40993. * This is used to call preventDefault() on pointer down
  40994. * in order to block unwanted artifacts like system double clicks
  40995. */
  40996. preventDefaultOnPointerDown: boolean;
  40997. /**
  40998. * This is used to call preventDefault() on pointer up
  40999. * in order to block unwanted artifacts like system double clicks
  41000. */
  41001. preventDefaultOnPointerUp: boolean;
  41002. /**
  41003. * Gets or sets user defined metadata
  41004. */
  41005. metadata: any;
  41006. /**
  41007. * For internal use only. Please do not use.
  41008. */
  41009. reservedDataStore: any;
  41010. /**
  41011. * Gets the name of the plugin used to load this scene (null by default)
  41012. */
  41013. loadingPluginName: string;
  41014. /**
  41015. * Use this array to add regular expressions used to disable offline support for specific urls
  41016. */
  41017. disableOfflineSupportExceptionRules: RegExp[];
  41018. /**
  41019. * An event triggered when the scene is disposed.
  41020. */
  41021. onDisposeObservable: Observable<Scene>;
  41022. private _onDisposeObserver;
  41023. /** Sets a function to be executed when this scene is disposed. */
  41024. set onDispose(callback: () => void);
  41025. /**
  41026. * An event triggered before rendering the scene (right after animations and physics)
  41027. */
  41028. onBeforeRenderObservable: Observable<Scene>;
  41029. private _onBeforeRenderObserver;
  41030. /** Sets a function to be executed before rendering this scene */
  41031. set beforeRender(callback: Nullable<() => void>);
  41032. /**
  41033. * An event triggered after rendering the scene
  41034. */
  41035. onAfterRenderObservable: Observable<Scene>;
  41036. /**
  41037. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  41038. */
  41039. onAfterRenderCameraObservable: Observable<Camera>;
  41040. private _onAfterRenderObserver;
  41041. /** Sets a function to be executed after rendering this scene */
  41042. set afterRender(callback: Nullable<() => void>);
  41043. /**
  41044. * An event triggered before animating the scene
  41045. */
  41046. onBeforeAnimationsObservable: Observable<Scene>;
  41047. /**
  41048. * An event triggered after animations processing
  41049. */
  41050. onAfterAnimationsObservable: Observable<Scene>;
  41051. /**
  41052. * An event triggered before draw calls are ready to be sent
  41053. */
  41054. onBeforeDrawPhaseObservable: Observable<Scene>;
  41055. /**
  41056. * An event triggered after draw calls have been sent
  41057. */
  41058. onAfterDrawPhaseObservable: Observable<Scene>;
  41059. /**
  41060. * An event triggered when the scene is ready
  41061. */
  41062. onReadyObservable: Observable<Scene>;
  41063. /**
  41064. * An event triggered before rendering a camera
  41065. */
  41066. onBeforeCameraRenderObservable: Observable<Camera>;
  41067. private _onBeforeCameraRenderObserver;
  41068. /** Sets a function to be executed before rendering a camera*/
  41069. set beforeCameraRender(callback: () => void);
  41070. /**
  41071. * An event triggered after rendering a camera
  41072. */
  41073. onAfterCameraRenderObservable: Observable<Camera>;
  41074. private _onAfterCameraRenderObserver;
  41075. /** Sets a function to be executed after rendering a camera*/
  41076. set afterCameraRender(callback: () => void);
  41077. /**
  41078. * An event triggered when active meshes evaluation is about to start
  41079. */
  41080. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41081. /**
  41082. * An event triggered when active meshes evaluation is done
  41083. */
  41084. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41085. /**
  41086. * An event triggered when particles rendering is about to start
  41087. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41088. */
  41089. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41090. /**
  41091. * An event triggered when particles rendering is done
  41092. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41093. */
  41094. onAfterParticlesRenderingObservable: Observable<Scene>;
  41095. /**
  41096. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41097. */
  41098. onDataLoadedObservable: Observable<Scene>;
  41099. /**
  41100. * An event triggered when a camera is created
  41101. */
  41102. onNewCameraAddedObservable: Observable<Camera>;
  41103. /**
  41104. * An event triggered when a camera is removed
  41105. */
  41106. onCameraRemovedObservable: Observable<Camera>;
  41107. /**
  41108. * An event triggered when a light is created
  41109. */
  41110. onNewLightAddedObservable: Observable<Light>;
  41111. /**
  41112. * An event triggered when a light is removed
  41113. */
  41114. onLightRemovedObservable: Observable<Light>;
  41115. /**
  41116. * An event triggered when a geometry is created
  41117. */
  41118. onNewGeometryAddedObservable: Observable<Geometry>;
  41119. /**
  41120. * An event triggered when a geometry is removed
  41121. */
  41122. onGeometryRemovedObservable: Observable<Geometry>;
  41123. /**
  41124. * An event triggered when a transform node is created
  41125. */
  41126. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41127. /**
  41128. * An event triggered when a transform node is removed
  41129. */
  41130. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41131. /**
  41132. * An event triggered when a mesh is created
  41133. */
  41134. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41135. /**
  41136. * An event triggered when a mesh is removed
  41137. */
  41138. onMeshRemovedObservable: Observable<AbstractMesh>;
  41139. /**
  41140. * An event triggered when a skeleton is created
  41141. */
  41142. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41143. /**
  41144. * An event triggered when a skeleton is removed
  41145. */
  41146. onSkeletonRemovedObservable: Observable<Skeleton>;
  41147. /**
  41148. * An event triggered when a material is created
  41149. */
  41150. onNewMaterialAddedObservable: Observable<Material>;
  41151. /**
  41152. * An event triggered when a material is removed
  41153. */
  41154. onMaterialRemovedObservable: Observable<Material>;
  41155. /**
  41156. * An event triggered when a texture is created
  41157. */
  41158. onNewTextureAddedObservable: Observable<BaseTexture>;
  41159. /**
  41160. * An event triggered when a texture is removed
  41161. */
  41162. onTextureRemovedObservable: Observable<BaseTexture>;
  41163. /**
  41164. * An event triggered when render targets are about to be rendered
  41165. * Can happen multiple times per frame.
  41166. */
  41167. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41168. /**
  41169. * An event triggered when render targets were rendered.
  41170. * Can happen multiple times per frame.
  41171. */
  41172. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41173. /**
  41174. * An event triggered before calculating deterministic simulation step
  41175. */
  41176. onBeforeStepObservable: Observable<Scene>;
  41177. /**
  41178. * An event triggered after calculating deterministic simulation step
  41179. */
  41180. onAfterStepObservable: Observable<Scene>;
  41181. /**
  41182. * An event triggered when the activeCamera property is updated
  41183. */
  41184. onActiveCameraChanged: Observable<Scene>;
  41185. /**
  41186. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41187. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41188. * 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)
  41189. */
  41190. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41191. /**
  41192. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41193. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41194. * 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)
  41195. */
  41196. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41197. /**
  41198. * This Observable will when a mesh has been imported into the scene.
  41199. */
  41200. onMeshImportedObservable: Observable<AbstractMesh>;
  41201. /**
  41202. * This Observable will when an animation file has been imported into the scene.
  41203. */
  41204. onAnimationFileImportedObservable: Observable<Scene>;
  41205. /**
  41206. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41207. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41208. */
  41209. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41210. /** @hidden */
  41211. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41212. /**
  41213. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41214. */
  41215. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41216. /**
  41217. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41218. */
  41219. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41220. /**
  41221. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41222. */
  41223. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41224. /** Callback called when a pointer move is detected */
  41225. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41226. /** Callback called when a pointer down is detected */
  41227. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41228. /** Callback called when a pointer up is detected */
  41229. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41230. /** Callback called when a pointer pick is detected */
  41231. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41232. /**
  41233. * 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).
  41234. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41235. */
  41236. onPrePointerObservable: Observable<PointerInfoPre>;
  41237. /**
  41238. * Observable event triggered each time an input event is received from the rendering canvas
  41239. */
  41240. onPointerObservable: Observable<PointerInfo>;
  41241. /**
  41242. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41243. */
  41244. get unTranslatedPointer(): Vector2;
  41245. /**
  41246. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41247. */
  41248. static get DragMovementThreshold(): number;
  41249. static set DragMovementThreshold(value: number);
  41250. /**
  41251. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41252. */
  41253. static get LongPressDelay(): number;
  41254. static set LongPressDelay(value: number);
  41255. /**
  41256. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41257. */
  41258. static get DoubleClickDelay(): number;
  41259. static set DoubleClickDelay(value: number);
  41260. /** If you need to check double click without raising a single click at first click, enable this flag */
  41261. static get ExclusiveDoubleClickMode(): boolean;
  41262. static set ExclusiveDoubleClickMode(value: boolean);
  41263. /** @hidden */
  41264. _mirroredCameraPosition: Nullable<Vector3>;
  41265. /**
  41266. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41267. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41268. */
  41269. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41270. /**
  41271. * Observable event triggered each time an keyboard event is received from the hosting window
  41272. */
  41273. onKeyboardObservable: Observable<KeyboardInfo>;
  41274. private _useRightHandedSystem;
  41275. /**
  41276. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41277. */
  41278. set useRightHandedSystem(value: boolean);
  41279. get useRightHandedSystem(): boolean;
  41280. private _timeAccumulator;
  41281. private _currentStepId;
  41282. private _currentInternalStep;
  41283. /**
  41284. * Sets the step Id used by deterministic lock step
  41285. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41286. * @param newStepId defines the step Id
  41287. */
  41288. setStepId(newStepId: number): void;
  41289. /**
  41290. * Gets the step Id used by deterministic lock step
  41291. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41292. * @returns the step Id
  41293. */
  41294. getStepId(): number;
  41295. /**
  41296. * Gets the internal step used by deterministic lock step
  41297. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41298. * @returns the internal step
  41299. */
  41300. getInternalStep(): number;
  41301. private _fogEnabled;
  41302. /**
  41303. * Gets or sets a boolean indicating if fog is enabled on this scene
  41304. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41305. * (Default is true)
  41306. */
  41307. set fogEnabled(value: boolean);
  41308. get fogEnabled(): boolean;
  41309. private _fogMode;
  41310. /**
  41311. * Gets or sets the fog mode to use
  41312. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41313. * | mode | value |
  41314. * | --- | --- |
  41315. * | FOGMODE_NONE | 0 |
  41316. * | FOGMODE_EXP | 1 |
  41317. * | FOGMODE_EXP2 | 2 |
  41318. * | FOGMODE_LINEAR | 3 |
  41319. */
  41320. set fogMode(value: number);
  41321. get fogMode(): number;
  41322. /**
  41323. * Gets or sets the fog color to use
  41324. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41325. * (Default is Color3(0.2, 0.2, 0.3))
  41326. */
  41327. fogColor: Color3;
  41328. /**
  41329. * Gets or sets the fog density to use
  41330. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41331. * (Default is 0.1)
  41332. */
  41333. fogDensity: number;
  41334. /**
  41335. * Gets or sets the fog start distance to use
  41336. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41337. * (Default is 0)
  41338. */
  41339. fogStart: number;
  41340. /**
  41341. * Gets or sets the fog end distance to use
  41342. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41343. * (Default is 1000)
  41344. */
  41345. fogEnd: number;
  41346. /**
  41347. * Flag indicating that the frame buffer binding is handled by another component
  41348. */
  41349. prePass: boolean;
  41350. private _shadowsEnabled;
  41351. /**
  41352. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41353. */
  41354. set shadowsEnabled(value: boolean);
  41355. get shadowsEnabled(): boolean;
  41356. private _lightsEnabled;
  41357. /**
  41358. * Gets or sets a boolean indicating if lights are enabled on this scene
  41359. */
  41360. set lightsEnabled(value: boolean);
  41361. get lightsEnabled(): boolean;
  41362. /** All of the active cameras added to this scene. */
  41363. activeCameras: Camera[];
  41364. /** @hidden */
  41365. _activeCamera: Nullable<Camera>;
  41366. /** Gets or sets the current active camera */
  41367. get activeCamera(): Nullable<Camera>;
  41368. set activeCamera(value: Nullable<Camera>);
  41369. private _defaultMaterial;
  41370. /** The default material used on meshes when no material is affected */
  41371. get defaultMaterial(): Material;
  41372. /** The default material used on meshes when no material is affected */
  41373. set defaultMaterial(value: Material);
  41374. private _texturesEnabled;
  41375. /**
  41376. * Gets or sets a boolean indicating if textures are enabled on this scene
  41377. */
  41378. set texturesEnabled(value: boolean);
  41379. get texturesEnabled(): boolean;
  41380. /**
  41381. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41382. */
  41383. physicsEnabled: boolean;
  41384. /**
  41385. * Gets or sets a boolean indicating if particles are enabled on this scene
  41386. */
  41387. particlesEnabled: boolean;
  41388. /**
  41389. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41390. */
  41391. spritesEnabled: boolean;
  41392. private _skeletonsEnabled;
  41393. /**
  41394. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41395. */
  41396. set skeletonsEnabled(value: boolean);
  41397. get skeletonsEnabled(): boolean;
  41398. /**
  41399. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41400. */
  41401. lensFlaresEnabled: boolean;
  41402. /**
  41403. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41404. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41405. */
  41406. collisionsEnabled: boolean;
  41407. private _collisionCoordinator;
  41408. /** @hidden */
  41409. get collisionCoordinator(): ICollisionCoordinator;
  41410. /**
  41411. * Defines the gravity applied to this scene (used only for collisions)
  41412. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41413. */
  41414. gravity: Vector3;
  41415. /**
  41416. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41417. */
  41418. postProcessesEnabled: boolean;
  41419. /**
  41420. * Gets the current postprocess manager
  41421. */
  41422. postProcessManager: PostProcessManager;
  41423. /**
  41424. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41425. */
  41426. renderTargetsEnabled: boolean;
  41427. /**
  41428. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41429. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41430. */
  41431. dumpNextRenderTargets: boolean;
  41432. /**
  41433. * The list of user defined render targets added to the scene
  41434. */
  41435. customRenderTargets: RenderTargetTexture[];
  41436. /**
  41437. * Defines if texture loading must be delayed
  41438. * If true, textures will only be loaded when they need to be rendered
  41439. */
  41440. useDelayedTextureLoading: boolean;
  41441. /**
  41442. * Gets the list of meshes imported to the scene through SceneLoader
  41443. */
  41444. importedMeshesFiles: String[];
  41445. /**
  41446. * Gets or sets a boolean indicating if probes are enabled on this scene
  41447. */
  41448. probesEnabled: boolean;
  41449. /**
  41450. * Gets or sets the current offline provider to use to store scene data
  41451. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41452. */
  41453. offlineProvider: IOfflineProvider;
  41454. /**
  41455. * Gets or sets the action manager associated with the scene
  41456. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41457. */
  41458. actionManager: AbstractActionManager;
  41459. private _meshesForIntersections;
  41460. /**
  41461. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41462. */
  41463. proceduralTexturesEnabled: boolean;
  41464. private _engine;
  41465. private _totalVertices;
  41466. /** @hidden */
  41467. _activeIndices: PerfCounter;
  41468. /** @hidden */
  41469. _activeParticles: PerfCounter;
  41470. /** @hidden */
  41471. _activeBones: PerfCounter;
  41472. private _animationRatio;
  41473. /** @hidden */
  41474. _animationTimeLast: number;
  41475. /** @hidden */
  41476. _animationTime: number;
  41477. /**
  41478. * Gets or sets a general scale for animation speed
  41479. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41480. */
  41481. animationTimeScale: number;
  41482. /** @hidden */
  41483. _cachedMaterial: Nullable<Material>;
  41484. /** @hidden */
  41485. _cachedEffect: Nullable<Effect>;
  41486. /** @hidden */
  41487. _cachedVisibility: Nullable<number>;
  41488. private _renderId;
  41489. private _frameId;
  41490. private _executeWhenReadyTimeoutId;
  41491. private _intermediateRendering;
  41492. private _viewUpdateFlag;
  41493. private _projectionUpdateFlag;
  41494. /** @hidden */
  41495. _toBeDisposed: Nullable<IDisposable>[];
  41496. private _activeRequests;
  41497. /** @hidden */
  41498. _pendingData: any[];
  41499. private _isDisposed;
  41500. /**
  41501. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41502. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41503. */
  41504. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41505. private _activeMeshes;
  41506. private _processedMaterials;
  41507. private _renderTargets;
  41508. /** @hidden */
  41509. _activeParticleSystems: SmartArray<IParticleSystem>;
  41510. private _activeSkeletons;
  41511. private _softwareSkinnedMeshes;
  41512. private _renderingManager;
  41513. /** @hidden */
  41514. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41515. private _transformMatrix;
  41516. private _sceneUbo;
  41517. /** @hidden */
  41518. _viewMatrix: Matrix;
  41519. private _projectionMatrix;
  41520. /** @hidden */
  41521. _forcedViewPosition: Nullable<Vector3>;
  41522. /** @hidden */
  41523. _frustumPlanes: Plane[];
  41524. /**
  41525. * Gets the list of frustum planes (built from the active camera)
  41526. */
  41527. get frustumPlanes(): Plane[];
  41528. /**
  41529. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41530. * This is useful if there are more lights that the maximum simulteanous authorized
  41531. */
  41532. requireLightSorting: boolean;
  41533. /** @hidden */
  41534. readonly useMaterialMeshMap: boolean;
  41535. /** @hidden */
  41536. readonly useClonedMeshMap: boolean;
  41537. private _externalData;
  41538. private _uid;
  41539. /**
  41540. * @hidden
  41541. * Backing store of defined scene components.
  41542. */
  41543. _components: ISceneComponent[];
  41544. /**
  41545. * @hidden
  41546. * Backing store of defined scene components.
  41547. */
  41548. _serializableComponents: ISceneSerializableComponent[];
  41549. /**
  41550. * List of components to register on the next registration step.
  41551. */
  41552. private _transientComponents;
  41553. /**
  41554. * Registers the transient components if needed.
  41555. */
  41556. private _registerTransientComponents;
  41557. /**
  41558. * @hidden
  41559. * Add a component to the scene.
  41560. * Note that the ccomponent could be registered on th next frame if this is called after
  41561. * the register component stage.
  41562. * @param component Defines the component to add to the scene
  41563. */
  41564. _addComponent(component: ISceneComponent): void;
  41565. /**
  41566. * @hidden
  41567. * Gets a component from the scene.
  41568. * @param name defines the name of the component to retrieve
  41569. * @returns the component or null if not present
  41570. */
  41571. _getComponent(name: string): Nullable<ISceneComponent>;
  41572. /**
  41573. * @hidden
  41574. * Defines the actions happening before camera updates.
  41575. */
  41576. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41577. /**
  41578. * @hidden
  41579. * Defines the actions happening before clear the canvas.
  41580. */
  41581. _beforeClearStage: Stage<SimpleStageAction>;
  41582. /**
  41583. * @hidden
  41584. * Defines the actions when collecting render targets for the frame.
  41585. */
  41586. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41587. /**
  41588. * @hidden
  41589. * Defines the actions happening for one camera in the frame.
  41590. */
  41591. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41592. /**
  41593. * @hidden
  41594. * Defines the actions happening during the per mesh ready checks.
  41595. */
  41596. _isReadyForMeshStage: Stage<MeshStageAction>;
  41597. /**
  41598. * @hidden
  41599. * Defines the actions happening before evaluate active mesh checks.
  41600. */
  41601. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41602. /**
  41603. * @hidden
  41604. * Defines the actions happening during the evaluate sub mesh checks.
  41605. */
  41606. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41607. /**
  41608. * @hidden
  41609. * Defines the actions happening during the active mesh stage.
  41610. */
  41611. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41612. /**
  41613. * @hidden
  41614. * Defines the actions happening during the per camera render target step.
  41615. */
  41616. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41617. /**
  41618. * @hidden
  41619. * Defines the actions happening just before the active camera is drawing.
  41620. */
  41621. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41622. /**
  41623. * @hidden
  41624. * Defines the actions happening just before a render target is drawing.
  41625. */
  41626. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41627. /**
  41628. * @hidden
  41629. * Defines the actions happening just before a rendering group is drawing.
  41630. */
  41631. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41632. /**
  41633. * @hidden
  41634. * Defines the actions happening just before a mesh is drawing.
  41635. */
  41636. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41637. /**
  41638. * @hidden
  41639. * Defines the actions happening just after a mesh has been drawn.
  41640. */
  41641. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41642. /**
  41643. * @hidden
  41644. * Defines the actions happening just after a rendering group has been drawn.
  41645. */
  41646. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41647. /**
  41648. * @hidden
  41649. * Defines the actions happening just after the active camera has been drawn.
  41650. */
  41651. _afterCameraDrawStage: Stage<CameraStageAction>;
  41652. /**
  41653. * @hidden
  41654. * Defines the actions happening just after a render target has been drawn.
  41655. */
  41656. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41657. /**
  41658. * @hidden
  41659. * Defines the actions happening just after rendering all cameras and computing intersections.
  41660. */
  41661. _afterRenderStage: Stage<SimpleStageAction>;
  41662. /**
  41663. * @hidden
  41664. * Defines the actions happening when a pointer move event happens.
  41665. */
  41666. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41667. /**
  41668. * @hidden
  41669. * Defines the actions happening when a pointer down event happens.
  41670. */
  41671. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41672. /**
  41673. * @hidden
  41674. * Defines the actions happening when a pointer up event happens.
  41675. */
  41676. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41677. /**
  41678. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41679. */
  41680. private geometriesByUniqueId;
  41681. /**
  41682. * Creates a new Scene
  41683. * @param engine defines the engine to use to render this scene
  41684. * @param options defines the scene options
  41685. */
  41686. constructor(engine: Engine, options?: SceneOptions);
  41687. /**
  41688. * Gets a string identifying the name of the class
  41689. * @returns "Scene" string
  41690. */
  41691. getClassName(): string;
  41692. private _defaultMeshCandidates;
  41693. /**
  41694. * @hidden
  41695. */
  41696. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41697. private _defaultSubMeshCandidates;
  41698. /**
  41699. * @hidden
  41700. */
  41701. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41702. /**
  41703. * Sets the default candidate providers for the scene.
  41704. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41705. * and getCollidingSubMeshCandidates to their default function
  41706. */
  41707. setDefaultCandidateProviders(): void;
  41708. /**
  41709. * Gets the mesh that is currently under the pointer
  41710. */
  41711. get meshUnderPointer(): Nullable<AbstractMesh>;
  41712. /**
  41713. * Gets or sets the current on-screen X position of the pointer
  41714. */
  41715. get pointerX(): number;
  41716. set pointerX(value: number);
  41717. /**
  41718. * Gets or sets the current on-screen Y position of the pointer
  41719. */
  41720. get pointerY(): number;
  41721. set pointerY(value: number);
  41722. /**
  41723. * Gets the cached material (ie. the latest rendered one)
  41724. * @returns the cached material
  41725. */
  41726. getCachedMaterial(): Nullable<Material>;
  41727. /**
  41728. * Gets the cached effect (ie. the latest rendered one)
  41729. * @returns the cached effect
  41730. */
  41731. getCachedEffect(): Nullable<Effect>;
  41732. /**
  41733. * Gets the cached visibility state (ie. the latest rendered one)
  41734. * @returns the cached visibility state
  41735. */
  41736. getCachedVisibility(): Nullable<number>;
  41737. /**
  41738. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41739. * @param material defines the current material
  41740. * @param effect defines the current effect
  41741. * @param visibility defines the current visibility state
  41742. * @returns true if one parameter is not cached
  41743. */
  41744. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41745. /**
  41746. * Gets the engine associated with the scene
  41747. * @returns an Engine
  41748. */
  41749. getEngine(): Engine;
  41750. /**
  41751. * Gets the total number of vertices rendered per frame
  41752. * @returns the total number of vertices rendered per frame
  41753. */
  41754. getTotalVertices(): number;
  41755. /**
  41756. * Gets the performance counter for total vertices
  41757. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41758. */
  41759. get totalVerticesPerfCounter(): PerfCounter;
  41760. /**
  41761. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41762. * @returns the total number of active indices rendered per frame
  41763. */
  41764. getActiveIndices(): number;
  41765. /**
  41766. * Gets the performance counter for active indices
  41767. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41768. */
  41769. get totalActiveIndicesPerfCounter(): PerfCounter;
  41770. /**
  41771. * Gets the total number of active particles rendered per frame
  41772. * @returns the total number of active particles rendered per frame
  41773. */
  41774. getActiveParticles(): number;
  41775. /**
  41776. * Gets the performance counter for active particles
  41777. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41778. */
  41779. get activeParticlesPerfCounter(): PerfCounter;
  41780. /**
  41781. * Gets the total number of active bones rendered per frame
  41782. * @returns the total number of active bones rendered per frame
  41783. */
  41784. getActiveBones(): number;
  41785. /**
  41786. * Gets the performance counter for active bones
  41787. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41788. */
  41789. get activeBonesPerfCounter(): PerfCounter;
  41790. /**
  41791. * Gets the array of active meshes
  41792. * @returns an array of AbstractMesh
  41793. */
  41794. getActiveMeshes(): SmartArray<AbstractMesh>;
  41795. /**
  41796. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41797. * @returns a number
  41798. */
  41799. getAnimationRatio(): number;
  41800. /**
  41801. * Gets an unique Id for the current render phase
  41802. * @returns a number
  41803. */
  41804. getRenderId(): number;
  41805. /**
  41806. * Gets an unique Id for the current frame
  41807. * @returns a number
  41808. */
  41809. getFrameId(): number;
  41810. /** Call this function if you want to manually increment the render Id*/
  41811. incrementRenderId(): void;
  41812. private _createUbo;
  41813. /**
  41814. * Use this method to simulate a pointer move on a mesh
  41815. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41816. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41817. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41818. * @returns the current scene
  41819. */
  41820. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41821. /**
  41822. * Use this method to simulate a pointer down on a mesh
  41823. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41824. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41825. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41826. * @returns the current scene
  41827. */
  41828. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41829. /**
  41830. * Use this method to simulate a pointer up on a mesh
  41831. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41832. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41833. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41834. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41835. * @returns the current scene
  41836. */
  41837. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41838. /**
  41839. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41840. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41841. * @returns true if the pointer was captured
  41842. */
  41843. isPointerCaptured(pointerId?: number): boolean;
  41844. /**
  41845. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41846. * @param attachUp defines if you want to attach events to pointerup
  41847. * @param attachDown defines if you want to attach events to pointerdown
  41848. * @param attachMove defines if you want to attach events to pointermove
  41849. */
  41850. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41851. /** Detaches all event handlers*/
  41852. detachControl(): void;
  41853. /**
  41854. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41855. * Delay loaded resources are not taking in account
  41856. * @return true if all required resources are ready
  41857. */
  41858. isReady(): boolean;
  41859. /** Resets all cached information relative to material (including effect and visibility) */
  41860. resetCachedMaterial(): void;
  41861. /**
  41862. * Registers a function to be called before every frame render
  41863. * @param func defines the function to register
  41864. */
  41865. registerBeforeRender(func: () => void): void;
  41866. /**
  41867. * Unregisters a function called before every frame render
  41868. * @param func defines the function to unregister
  41869. */
  41870. unregisterBeforeRender(func: () => void): void;
  41871. /**
  41872. * Registers a function to be called after every frame render
  41873. * @param func defines the function to register
  41874. */
  41875. registerAfterRender(func: () => void): void;
  41876. /**
  41877. * Unregisters a function called after every frame render
  41878. * @param func defines the function to unregister
  41879. */
  41880. unregisterAfterRender(func: () => void): void;
  41881. private _executeOnceBeforeRender;
  41882. /**
  41883. * The provided function will run before render once and will be disposed afterwards.
  41884. * A timeout delay can be provided so that the function will be executed in N ms.
  41885. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41886. * @param func The function to be executed.
  41887. * @param timeout optional delay in ms
  41888. */
  41889. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41890. /** @hidden */
  41891. _addPendingData(data: any): void;
  41892. /** @hidden */
  41893. _removePendingData(data: any): void;
  41894. /**
  41895. * Returns the number of items waiting to be loaded
  41896. * @returns the number of items waiting to be loaded
  41897. */
  41898. getWaitingItemsCount(): number;
  41899. /**
  41900. * Returns a boolean indicating if the scene is still loading data
  41901. */
  41902. get isLoading(): boolean;
  41903. /**
  41904. * Registers a function to be executed when the scene is ready
  41905. * @param {Function} func - the function to be executed
  41906. */
  41907. executeWhenReady(func: () => void): void;
  41908. /**
  41909. * Returns a promise that resolves when the scene is ready
  41910. * @returns A promise that resolves when the scene is ready
  41911. */
  41912. whenReadyAsync(): Promise<void>;
  41913. /** @hidden */
  41914. _checkIsReady(): void;
  41915. /**
  41916. * Gets all animatable attached to the scene
  41917. */
  41918. get animatables(): Animatable[];
  41919. /**
  41920. * Resets the last animation time frame.
  41921. * Useful to override when animations start running when loading a scene for the first time.
  41922. */
  41923. resetLastAnimationTimeFrame(): void;
  41924. /**
  41925. * Gets the current view matrix
  41926. * @returns a Matrix
  41927. */
  41928. getViewMatrix(): Matrix;
  41929. /**
  41930. * Gets the current projection matrix
  41931. * @returns a Matrix
  41932. */
  41933. getProjectionMatrix(): Matrix;
  41934. /**
  41935. * Gets the current transform matrix
  41936. * @returns a Matrix made of View * Projection
  41937. */
  41938. getTransformMatrix(): Matrix;
  41939. /**
  41940. * Sets the current transform matrix
  41941. * @param viewL defines the View matrix to use
  41942. * @param projectionL defines the Projection matrix to use
  41943. * @param viewR defines the right View matrix to use (if provided)
  41944. * @param projectionR defines the right Projection matrix to use (if provided)
  41945. */
  41946. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41947. /**
  41948. * Gets the uniform buffer used to store scene data
  41949. * @returns a UniformBuffer
  41950. */
  41951. getSceneUniformBuffer(): UniformBuffer;
  41952. /**
  41953. * Gets an unique (relatively to the current scene) Id
  41954. * @returns an unique number for the scene
  41955. */
  41956. getUniqueId(): number;
  41957. /**
  41958. * Add a mesh to the list of scene's meshes
  41959. * @param newMesh defines the mesh to add
  41960. * @param recursive if all child meshes should also be added to the scene
  41961. */
  41962. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41963. /**
  41964. * Remove a mesh for the list of scene's meshes
  41965. * @param toRemove defines the mesh to remove
  41966. * @param recursive if all child meshes should also be removed from the scene
  41967. * @returns the index where the mesh was in the mesh list
  41968. */
  41969. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41970. /**
  41971. * Add a transform node to the list of scene's transform nodes
  41972. * @param newTransformNode defines the transform node to add
  41973. */
  41974. addTransformNode(newTransformNode: TransformNode): void;
  41975. /**
  41976. * Remove a transform node for the list of scene's transform nodes
  41977. * @param toRemove defines the transform node to remove
  41978. * @returns the index where the transform node was in the transform node list
  41979. */
  41980. removeTransformNode(toRemove: TransformNode): number;
  41981. /**
  41982. * Remove a skeleton for the list of scene's skeletons
  41983. * @param toRemove defines the skeleton to remove
  41984. * @returns the index where the skeleton was in the skeleton list
  41985. */
  41986. removeSkeleton(toRemove: Skeleton): number;
  41987. /**
  41988. * Remove a morph target for the list of scene's morph targets
  41989. * @param toRemove defines the morph target to remove
  41990. * @returns the index where the morph target was in the morph target list
  41991. */
  41992. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41993. /**
  41994. * Remove a light for the list of scene's lights
  41995. * @param toRemove defines the light to remove
  41996. * @returns the index where the light was in the light list
  41997. */
  41998. removeLight(toRemove: Light): number;
  41999. /**
  42000. * Remove a camera for the list of scene's cameras
  42001. * @param toRemove defines the camera to remove
  42002. * @returns the index where the camera was in the camera list
  42003. */
  42004. removeCamera(toRemove: Camera): number;
  42005. /**
  42006. * Remove a particle system for the list of scene's particle systems
  42007. * @param toRemove defines the particle system to remove
  42008. * @returns the index where the particle system was in the particle system list
  42009. */
  42010. removeParticleSystem(toRemove: IParticleSystem): number;
  42011. /**
  42012. * Remove a animation for the list of scene's animations
  42013. * @param toRemove defines the animation to remove
  42014. * @returns the index where the animation was in the animation list
  42015. */
  42016. removeAnimation(toRemove: Animation): number;
  42017. /**
  42018. * Will stop the animation of the given target
  42019. * @param target - the target
  42020. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  42021. * @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)
  42022. */
  42023. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  42024. /**
  42025. * Removes the given animation group from this scene.
  42026. * @param toRemove The animation group to remove
  42027. * @returns The index of the removed animation group
  42028. */
  42029. removeAnimationGroup(toRemove: AnimationGroup): number;
  42030. /**
  42031. * Removes the given multi-material from this scene.
  42032. * @param toRemove The multi-material to remove
  42033. * @returns The index of the removed multi-material
  42034. */
  42035. removeMultiMaterial(toRemove: MultiMaterial): number;
  42036. /**
  42037. * Removes the given material from this scene.
  42038. * @param toRemove The material to remove
  42039. * @returns The index of the removed material
  42040. */
  42041. removeMaterial(toRemove: Material): number;
  42042. /**
  42043. * Removes the given action manager from this scene.
  42044. * @param toRemove The action manager to remove
  42045. * @returns The index of the removed action manager
  42046. */
  42047. removeActionManager(toRemove: AbstractActionManager): number;
  42048. /**
  42049. * Removes the given texture from this scene.
  42050. * @param toRemove The texture to remove
  42051. * @returns The index of the removed texture
  42052. */
  42053. removeTexture(toRemove: BaseTexture): number;
  42054. /**
  42055. * Adds the given light to this scene
  42056. * @param newLight The light to add
  42057. */
  42058. addLight(newLight: Light): void;
  42059. /**
  42060. * Sorts the list list based on light priorities
  42061. */
  42062. sortLightsByPriority(): void;
  42063. /**
  42064. * Adds the given camera to this scene
  42065. * @param newCamera The camera to add
  42066. */
  42067. addCamera(newCamera: Camera): void;
  42068. /**
  42069. * Adds the given skeleton to this scene
  42070. * @param newSkeleton The skeleton to add
  42071. */
  42072. addSkeleton(newSkeleton: Skeleton): void;
  42073. /**
  42074. * Adds the given particle system to this scene
  42075. * @param newParticleSystem The particle system to add
  42076. */
  42077. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42078. /**
  42079. * Adds the given animation to this scene
  42080. * @param newAnimation The animation to add
  42081. */
  42082. addAnimation(newAnimation: Animation): void;
  42083. /**
  42084. * Adds the given animation group to this scene.
  42085. * @param newAnimationGroup The animation group to add
  42086. */
  42087. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42088. /**
  42089. * Adds the given multi-material to this scene
  42090. * @param newMultiMaterial The multi-material to add
  42091. */
  42092. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42093. /**
  42094. * Adds the given material to this scene
  42095. * @param newMaterial The material to add
  42096. */
  42097. addMaterial(newMaterial: Material): void;
  42098. /**
  42099. * Adds the given morph target to this scene
  42100. * @param newMorphTargetManager The morph target to add
  42101. */
  42102. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42103. /**
  42104. * Adds the given geometry to this scene
  42105. * @param newGeometry The geometry to add
  42106. */
  42107. addGeometry(newGeometry: Geometry): void;
  42108. /**
  42109. * Adds the given action manager to this scene
  42110. * @param newActionManager The action manager to add
  42111. */
  42112. addActionManager(newActionManager: AbstractActionManager): void;
  42113. /**
  42114. * Adds the given texture to this scene.
  42115. * @param newTexture The texture to add
  42116. */
  42117. addTexture(newTexture: BaseTexture): void;
  42118. /**
  42119. * Switch active camera
  42120. * @param newCamera defines the new active camera
  42121. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42122. */
  42123. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42124. /**
  42125. * sets the active camera of the scene using its ID
  42126. * @param id defines the camera's ID
  42127. * @return the new active camera or null if none found.
  42128. */
  42129. setActiveCameraByID(id: string): Nullable<Camera>;
  42130. /**
  42131. * sets the active camera of the scene using its name
  42132. * @param name defines the camera's name
  42133. * @returns the new active camera or null if none found.
  42134. */
  42135. setActiveCameraByName(name: string): Nullable<Camera>;
  42136. /**
  42137. * get an animation group using its name
  42138. * @param name defines the material's name
  42139. * @return the animation group or null if none found.
  42140. */
  42141. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42142. /**
  42143. * Get a material using its unique id
  42144. * @param uniqueId defines the material's unique id
  42145. * @return the material or null if none found.
  42146. */
  42147. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42148. /**
  42149. * get a material using its id
  42150. * @param id defines the material's ID
  42151. * @return the material or null if none found.
  42152. */
  42153. getMaterialByID(id: string): Nullable<Material>;
  42154. /**
  42155. * Gets a the last added material using a given id
  42156. * @param id defines the material's ID
  42157. * @return the last material with the given id or null if none found.
  42158. */
  42159. getLastMaterialByID(id: string): Nullable<Material>;
  42160. /**
  42161. * Gets a material using its name
  42162. * @param name defines the material's name
  42163. * @return the material or null if none found.
  42164. */
  42165. getMaterialByName(name: string): Nullable<Material>;
  42166. /**
  42167. * Get a texture using its unique id
  42168. * @param uniqueId defines the texture's unique id
  42169. * @return the texture or null if none found.
  42170. */
  42171. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42172. /**
  42173. * Gets a camera using its id
  42174. * @param id defines the id to look for
  42175. * @returns the camera or null if not found
  42176. */
  42177. getCameraByID(id: string): Nullable<Camera>;
  42178. /**
  42179. * Gets a camera using its unique id
  42180. * @param uniqueId defines the unique id to look for
  42181. * @returns the camera or null if not found
  42182. */
  42183. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42184. /**
  42185. * Gets a camera using its name
  42186. * @param name defines the camera's name
  42187. * @return the camera or null if none found.
  42188. */
  42189. getCameraByName(name: string): Nullable<Camera>;
  42190. /**
  42191. * Gets a bone using its id
  42192. * @param id defines the bone's id
  42193. * @return the bone or null if not found
  42194. */
  42195. getBoneByID(id: string): Nullable<Bone>;
  42196. /**
  42197. * Gets a bone using its id
  42198. * @param name defines the bone's name
  42199. * @return the bone or null if not found
  42200. */
  42201. getBoneByName(name: string): Nullable<Bone>;
  42202. /**
  42203. * Gets a light node using its name
  42204. * @param name defines the the light's name
  42205. * @return the light or null if none found.
  42206. */
  42207. getLightByName(name: string): Nullable<Light>;
  42208. /**
  42209. * Gets a light node using its id
  42210. * @param id defines the light's id
  42211. * @return the light or null if none found.
  42212. */
  42213. getLightByID(id: string): Nullable<Light>;
  42214. /**
  42215. * Gets a light node using its scene-generated unique ID
  42216. * @param uniqueId defines the light's unique id
  42217. * @return the light or null if none found.
  42218. */
  42219. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42220. /**
  42221. * Gets a particle system by id
  42222. * @param id defines the particle system id
  42223. * @return the corresponding system or null if none found
  42224. */
  42225. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42226. /**
  42227. * Gets a geometry using its ID
  42228. * @param id defines the geometry's id
  42229. * @return the geometry or null if none found.
  42230. */
  42231. getGeometryByID(id: string): Nullable<Geometry>;
  42232. private _getGeometryByUniqueID;
  42233. /**
  42234. * Add a new geometry to this scene
  42235. * @param geometry defines the geometry to be added to the scene.
  42236. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42237. * @return a boolean defining if the geometry was added or not
  42238. */
  42239. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42240. /**
  42241. * Removes an existing geometry
  42242. * @param geometry defines the geometry to be removed from the scene
  42243. * @return a boolean defining if the geometry was removed or not
  42244. */
  42245. removeGeometry(geometry: Geometry): boolean;
  42246. /**
  42247. * Gets the list of geometries attached to the scene
  42248. * @returns an array of Geometry
  42249. */
  42250. getGeometries(): Geometry[];
  42251. /**
  42252. * Gets the first added mesh found of a given ID
  42253. * @param id defines the id to search for
  42254. * @return the mesh found or null if not found at all
  42255. */
  42256. getMeshByID(id: string): Nullable<AbstractMesh>;
  42257. /**
  42258. * Gets a list of meshes using their id
  42259. * @param id defines the id to search for
  42260. * @returns a list of meshes
  42261. */
  42262. getMeshesByID(id: string): Array<AbstractMesh>;
  42263. /**
  42264. * Gets the first added transform node found of a given ID
  42265. * @param id defines the id to search for
  42266. * @return the found transform node or null if not found at all.
  42267. */
  42268. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42269. /**
  42270. * Gets a transform node with its auto-generated unique id
  42271. * @param uniqueId efines the unique id to search for
  42272. * @return the found transform node or null if not found at all.
  42273. */
  42274. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42275. /**
  42276. * Gets a list of transform nodes using their id
  42277. * @param id defines the id to search for
  42278. * @returns a list of transform nodes
  42279. */
  42280. getTransformNodesByID(id: string): Array<TransformNode>;
  42281. /**
  42282. * Gets a mesh with its auto-generated unique id
  42283. * @param uniqueId defines the unique id to search for
  42284. * @return the found mesh or null if not found at all.
  42285. */
  42286. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42287. /**
  42288. * Gets a the last added mesh using a given id
  42289. * @param id defines the id to search for
  42290. * @return the found mesh or null if not found at all.
  42291. */
  42292. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42293. /**
  42294. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42295. * @param id defines the id to search for
  42296. * @return the found node or null if not found at all
  42297. */
  42298. getLastEntryByID(id: string): Nullable<Node>;
  42299. /**
  42300. * Gets a node (Mesh, Camera, Light) using a given id
  42301. * @param id defines the id to search for
  42302. * @return the found node or null if not found at all
  42303. */
  42304. getNodeByID(id: string): Nullable<Node>;
  42305. /**
  42306. * Gets a node (Mesh, Camera, Light) using a given name
  42307. * @param name defines the name to search for
  42308. * @return the found node or null if not found at all.
  42309. */
  42310. getNodeByName(name: string): Nullable<Node>;
  42311. /**
  42312. * Gets a mesh using a given name
  42313. * @param name defines the name to search for
  42314. * @return the found mesh or null if not found at all.
  42315. */
  42316. getMeshByName(name: string): Nullable<AbstractMesh>;
  42317. /**
  42318. * Gets a transform node using a given name
  42319. * @param name defines the name to search for
  42320. * @return the found transform node or null if not found at all.
  42321. */
  42322. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42323. /**
  42324. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42325. * @param id defines the id to search for
  42326. * @return the found skeleton or null if not found at all.
  42327. */
  42328. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42329. /**
  42330. * Gets a skeleton using a given auto generated unique id
  42331. * @param uniqueId defines the unique id to search for
  42332. * @return the found skeleton or null if not found at all.
  42333. */
  42334. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42335. /**
  42336. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42337. * @param id defines the id to search for
  42338. * @return the found skeleton or null if not found at all.
  42339. */
  42340. getSkeletonById(id: string): Nullable<Skeleton>;
  42341. /**
  42342. * Gets a skeleton using a given name
  42343. * @param name defines the name to search for
  42344. * @return the found skeleton or null if not found at all.
  42345. */
  42346. getSkeletonByName(name: string): Nullable<Skeleton>;
  42347. /**
  42348. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42349. * @param id defines the id to search for
  42350. * @return the found morph target manager or null if not found at all.
  42351. */
  42352. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42353. /**
  42354. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42355. * @param id defines the id to search for
  42356. * @return the found morph target or null if not found at all.
  42357. */
  42358. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42359. /**
  42360. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42361. * @param name defines the name to search for
  42362. * @return the found morph target or null if not found at all.
  42363. */
  42364. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42365. /**
  42366. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42367. * @param name defines the name to search for
  42368. * @return the found post process or null if not found at all.
  42369. */
  42370. getPostProcessByName(name: string): Nullable<PostProcess>;
  42371. /**
  42372. * Gets a boolean indicating if the given mesh is active
  42373. * @param mesh defines the mesh to look for
  42374. * @returns true if the mesh is in the active list
  42375. */
  42376. isActiveMesh(mesh: AbstractMesh): boolean;
  42377. /**
  42378. * Return a unique id as a string which can serve as an identifier for the scene
  42379. */
  42380. get uid(): string;
  42381. /**
  42382. * Add an externaly attached data from its key.
  42383. * This method call will fail and return false, if such key already exists.
  42384. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42385. * @param key the unique key that identifies the data
  42386. * @param data the data object to associate to the key for this Engine instance
  42387. * @return true if no such key were already present and the data was added successfully, false otherwise
  42388. */
  42389. addExternalData<T>(key: string, data: T): boolean;
  42390. /**
  42391. * Get an externaly attached data from its key
  42392. * @param key the unique key that identifies the data
  42393. * @return the associated data, if present (can be null), or undefined if not present
  42394. */
  42395. getExternalData<T>(key: string): Nullable<T>;
  42396. /**
  42397. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42398. * @param key the unique key that identifies the data
  42399. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42400. * @return the associated data, can be null if the factory returned null.
  42401. */
  42402. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42403. /**
  42404. * Remove an externaly attached data from the Engine instance
  42405. * @param key the unique key that identifies the data
  42406. * @return true if the data was successfully removed, false if it doesn't exist
  42407. */
  42408. removeExternalData(key: string): boolean;
  42409. private _evaluateSubMesh;
  42410. /**
  42411. * Clear the processed materials smart array preventing retention point in material dispose.
  42412. */
  42413. freeProcessedMaterials(): void;
  42414. private _preventFreeActiveMeshesAndRenderingGroups;
  42415. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42416. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42417. * when disposing several meshes in a row or a hierarchy of meshes.
  42418. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42419. */
  42420. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42421. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42422. /**
  42423. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42424. */
  42425. freeActiveMeshes(): void;
  42426. /**
  42427. * Clear the info related to rendering groups preventing retention points during dispose.
  42428. */
  42429. freeRenderingGroups(): void;
  42430. /** @hidden */
  42431. _isInIntermediateRendering(): boolean;
  42432. /**
  42433. * Lambda returning the list of potentially active meshes.
  42434. */
  42435. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42436. /**
  42437. * Lambda returning the list of potentially active sub meshes.
  42438. */
  42439. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42440. /**
  42441. * Lambda returning the list of potentially intersecting sub meshes.
  42442. */
  42443. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42444. /**
  42445. * Lambda returning the list of potentially colliding sub meshes.
  42446. */
  42447. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42448. private _activeMeshesFrozen;
  42449. private _skipEvaluateActiveMeshesCompletely;
  42450. /**
  42451. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42452. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42453. * @returns the current scene
  42454. */
  42455. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42456. /**
  42457. * Use this function to restart evaluating active meshes on every frame
  42458. * @returns the current scene
  42459. */
  42460. unfreezeActiveMeshes(): Scene;
  42461. private _evaluateActiveMeshes;
  42462. private _activeMesh;
  42463. /**
  42464. * Update the transform matrix to update from the current active camera
  42465. * @param force defines a boolean used to force the update even if cache is up to date
  42466. */
  42467. updateTransformMatrix(force?: boolean): void;
  42468. private _bindFrameBuffer;
  42469. /** @hidden */
  42470. _allowPostProcessClearColor: boolean;
  42471. /** @hidden */
  42472. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42473. private _processSubCameras;
  42474. private _checkIntersections;
  42475. /** @hidden */
  42476. _advancePhysicsEngineStep(step: number): void;
  42477. /**
  42478. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42479. */
  42480. getDeterministicFrameTime: () => number;
  42481. /** @hidden */
  42482. _animate(): void;
  42483. /** Execute all animations (for a frame) */
  42484. animate(): void;
  42485. /**
  42486. * Render the scene
  42487. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42488. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42489. */
  42490. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42491. /**
  42492. * Freeze all materials
  42493. * A frozen material will not be updatable but should be faster to render
  42494. */
  42495. freezeMaterials(): void;
  42496. /**
  42497. * Unfreeze all materials
  42498. * A frozen material will not be updatable but should be faster to render
  42499. */
  42500. unfreezeMaterials(): void;
  42501. /**
  42502. * Releases all held ressources
  42503. */
  42504. dispose(): void;
  42505. /**
  42506. * Gets if the scene is already disposed
  42507. */
  42508. get isDisposed(): boolean;
  42509. /**
  42510. * Call this function to reduce memory footprint of the scene.
  42511. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42512. */
  42513. clearCachedVertexData(): void;
  42514. /**
  42515. * This function will remove the local cached buffer data from texture.
  42516. * It will save memory but will prevent the texture from being rebuilt
  42517. */
  42518. cleanCachedTextureBuffer(): void;
  42519. /**
  42520. * Get the world extend vectors with an optional filter
  42521. *
  42522. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42523. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42524. */
  42525. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42526. min: Vector3;
  42527. max: Vector3;
  42528. };
  42529. /**
  42530. * Creates a ray that can be used to pick in the scene
  42531. * @param x defines the x coordinate of the origin (on-screen)
  42532. * @param y defines the y coordinate of the origin (on-screen)
  42533. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42534. * @param camera defines the camera to use for the picking
  42535. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42536. * @returns a Ray
  42537. */
  42538. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42539. /**
  42540. * Creates a ray that can be used to pick in the scene
  42541. * @param x defines the x coordinate of the origin (on-screen)
  42542. * @param y defines the y coordinate of the origin (on-screen)
  42543. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42544. * @param result defines the ray where to store the picking ray
  42545. * @param camera defines the camera to use for the picking
  42546. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42547. * @returns the current scene
  42548. */
  42549. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42550. /**
  42551. * Creates a ray that can be used to pick in the scene
  42552. * @param x defines the x coordinate of the origin (on-screen)
  42553. * @param y defines the y coordinate of the origin (on-screen)
  42554. * @param camera defines the camera to use for the picking
  42555. * @returns a Ray
  42556. */
  42557. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42558. /**
  42559. * Creates a ray that can be used to pick in the scene
  42560. * @param x defines the x coordinate of the origin (on-screen)
  42561. * @param y defines the y coordinate of the origin (on-screen)
  42562. * @param result defines the ray where to store the picking ray
  42563. * @param camera defines the camera to use for the picking
  42564. * @returns the current scene
  42565. */
  42566. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42567. /** Launch a ray to try to pick a mesh in the scene
  42568. * @param x position on screen
  42569. * @param y position on screen
  42570. * @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
  42571. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42572. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42573. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42574. * @returns a PickingInfo
  42575. */
  42576. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42577. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42578. * @param x position on screen
  42579. * @param y position on screen
  42580. * @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
  42581. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42582. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42583. * @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)
  42584. */
  42585. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42586. /** Use the given ray to pick a mesh in the scene
  42587. * @param ray The ray to use to pick meshes
  42588. * @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
  42589. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42590. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42591. * @returns a PickingInfo
  42592. */
  42593. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42594. /**
  42595. * Launch a ray to try to pick a mesh in the scene
  42596. * @param x X position on screen
  42597. * @param y Y position on screen
  42598. * @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
  42599. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42600. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42601. * @returns an array of PickingInfo
  42602. */
  42603. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42604. /**
  42605. * Launch a ray to try to pick a mesh in the scene
  42606. * @param ray Ray to use
  42607. * @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
  42608. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42609. * @returns an array of PickingInfo
  42610. */
  42611. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42612. /**
  42613. * Force the value of meshUnderPointer
  42614. * @param mesh defines the mesh to use
  42615. * @param pointerId optional pointer id when using more than one pointer
  42616. */
  42617. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42618. /**
  42619. * Gets the mesh under the pointer
  42620. * @returns a Mesh or null if no mesh is under the pointer
  42621. */
  42622. getPointerOverMesh(): Nullable<AbstractMesh>;
  42623. /** @hidden */
  42624. _rebuildGeometries(): void;
  42625. /** @hidden */
  42626. _rebuildTextures(): void;
  42627. private _getByTags;
  42628. /**
  42629. * Get a list of meshes by tags
  42630. * @param tagsQuery defines the tags query to use
  42631. * @param forEach defines a predicate used to filter results
  42632. * @returns an array of Mesh
  42633. */
  42634. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42635. /**
  42636. * Get a list of cameras by tags
  42637. * @param tagsQuery defines the tags query to use
  42638. * @param forEach defines a predicate used to filter results
  42639. * @returns an array of Camera
  42640. */
  42641. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42642. /**
  42643. * Get a list of lights by tags
  42644. * @param tagsQuery defines the tags query to use
  42645. * @param forEach defines a predicate used to filter results
  42646. * @returns an array of Light
  42647. */
  42648. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42649. /**
  42650. * Get a list of materials by tags
  42651. * @param tagsQuery defines the tags query to use
  42652. * @param forEach defines a predicate used to filter results
  42653. * @returns an array of Material
  42654. */
  42655. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42656. /**
  42657. * Get a list of transform nodes by tags
  42658. * @param tagsQuery defines the tags query to use
  42659. * @param forEach defines a predicate used to filter results
  42660. * @returns an array of TransformNode
  42661. */
  42662. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42663. /**
  42664. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42665. * This allowed control for front to back rendering or reversly depending of the special needs.
  42666. *
  42667. * @param renderingGroupId The rendering group id corresponding to its index
  42668. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42669. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42670. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42671. */
  42672. 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;
  42673. /**
  42674. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42675. *
  42676. * @param renderingGroupId The rendering group id corresponding to its index
  42677. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42678. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42679. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42680. */
  42681. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42682. /**
  42683. * Gets the current auto clear configuration for one rendering group of the rendering
  42684. * manager.
  42685. * @param index the rendering group index to get the information for
  42686. * @returns The auto clear setup for the requested rendering group
  42687. */
  42688. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42689. private _blockMaterialDirtyMechanism;
  42690. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42691. get blockMaterialDirtyMechanism(): boolean;
  42692. set blockMaterialDirtyMechanism(value: boolean);
  42693. /**
  42694. * Will flag all materials as dirty to trigger new shader compilation
  42695. * @param flag defines the flag used to specify which material part must be marked as dirty
  42696. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42697. */
  42698. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42699. /** @hidden */
  42700. _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;
  42701. /** @hidden */
  42702. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42703. /** @hidden */
  42704. _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;
  42705. /** @hidden */
  42706. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42707. /** @hidden */
  42708. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42709. /** @hidden */
  42710. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42711. }
  42712. }
  42713. declare module "babylonjs/assetContainer" {
  42714. import { AbstractScene } from "babylonjs/abstractScene";
  42715. import { Scene } from "babylonjs/scene";
  42716. import { Mesh } from "babylonjs/Meshes/mesh";
  42717. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42718. import { Skeleton } from "babylonjs/Bones/skeleton";
  42719. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42720. import { Animatable } from "babylonjs/Animations/animatable";
  42721. import { Nullable } from "babylonjs/types";
  42722. import { Node } from "babylonjs/node";
  42723. /**
  42724. * Set of assets to keep when moving a scene into an asset container.
  42725. */
  42726. export class KeepAssets extends AbstractScene {
  42727. }
  42728. /**
  42729. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42730. */
  42731. export class InstantiatedEntries {
  42732. /**
  42733. * List of new root nodes (eg. nodes with no parent)
  42734. */
  42735. rootNodes: TransformNode[];
  42736. /**
  42737. * List of new skeletons
  42738. */
  42739. skeletons: Skeleton[];
  42740. /**
  42741. * List of new animation groups
  42742. */
  42743. animationGroups: AnimationGroup[];
  42744. }
  42745. /**
  42746. * Container with a set of assets that can be added or removed from a scene.
  42747. */
  42748. export class AssetContainer extends AbstractScene {
  42749. private _wasAddedToScene;
  42750. /**
  42751. * The scene the AssetContainer belongs to.
  42752. */
  42753. scene: Scene;
  42754. /**
  42755. * Instantiates an AssetContainer.
  42756. * @param scene The scene the AssetContainer belongs to.
  42757. */
  42758. constructor(scene: Scene);
  42759. /**
  42760. * Instantiate or clone all meshes and add the new ones to the scene.
  42761. * Skeletons and animation groups will all be cloned
  42762. * @param nameFunction defines an optional function used to get new names for clones
  42763. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42764. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42765. */
  42766. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42767. /**
  42768. * Adds all the assets from the container to the scene.
  42769. */
  42770. addAllToScene(): void;
  42771. /**
  42772. * Removes all the assets in the container from the scene
  42773. */
  42774. removeAllFromScene(): void;
  42775. /**
  42776. * Disposes all the assets in the container
  42777. */
  42778. dispose(): void;
  42779. private _moveAssets;
  42780. /**
  42781. * Removes all the assets contained in the scene and adds them to the container.
  42782. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42783. */
  42784. moveAllFromScene(keepAssets?: KeepAssets): void;
  42785. /**
  42786. * 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.
  42787. * @returns the root mesh
  42788. */
  42789. createRootMesh(): Mesh;
  42790. /**
  42791. * Merge animations (direct and animation groups) from this asset container into a scene
  42792. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42793. * @param animatables set of animatables to retarget to a node from the scene
  42794. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42795. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42796. */
  42797. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42798. }
  42799. }
  42800. declare module "babylonjs/abstractScene" {
  42801. import { Scene } from "babylonjs/scene";
  42802. import { Nullable } from "babylonjs/types";
  42803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42804. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42805. import { Geometry } from "babylonjs/Meshes/geometry";
  42806. import { Skeleton } from "babylonjs/Bones/skeleton";
  42807. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42808. import { AssetContainer } from "babylonjs/assetContainer";
  42809. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42810. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42811. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42812. import { Material } from "babylonjs/Materials/material";
  42813. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42814. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42815. import { Camera } from "babylonjs/Cameras/camera";
  42816. import { Light } from "babylonjs/Lights/light";
  42817. import { Node } from "babylonjs/node";
  42818. import { Animation } from "babylonjs/Animations/animation";
  42819. /**
  42820. * Defines how the parser contract is defined.
  42821. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42822. */
  42823. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42824. /**
  42825. * Defines how the individual parser contract is defined.
  42826. * These parser can parse an individual asset
  42827. */
  42828. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42829. /**
  42830. * Base class of the scene acting as a container for the different elements composing a scene.
  42831. * This class is dynamically extended by the different components of the scene increasing
  42832. * flexibility and reducing coupling
  42833. */
  42834. export abstract class AbstractScene {
  42835. /**
  42836. * Stores the list of available parsers in the application.
  42837. */
  42838. private static _BabylonFileParsers;
  42839. /**
  42840. * Stores the list of available individual parsers in the application.
  42841. */
  42842. private static _IndividualBabylonFileParsers;
  42843. /**
  42844. * Adds a parser in the list of available ones
  42845. * @param name Defines the name of the parser
  42846. * @param parser Defines the parser to add
  42847. */
  42848. static AddParser(name: string, parser: BabylonFileParser): void;
  42849. /**
  42850. * Gets a general parser from the list of avaialble ones
  42851. * @param name Defines the name of the parser
  42852. * @returns the requested parser or null
  42853. */
  42854. static GetParser(name: string): Nullable<BabylonFileParser>;
  42855. /**
  42856. * Adds n individual parser in the list of available ones
  42857. * @param name Defines the name of the parser
  42858. * @param parser Defines the parser to add
  42859. */
  42860. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42861. /**
  42862. * Gets an individual parser from the list of avaialble ones
  42863. * @param name Defines the name of the parser
  42864. * @returns the requested parser or null
  42865. */
  42866. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42867. /**
  42868. * Parser json data and populate both a scene and its associated container object
  42869. * @param jsonData Defines the data to parse
  42870. * @param scene Defines the scene to parse the data for
  42871. * @param container Defines the container attached to the parsing sequence
  42872. * @param rootUrl Defines the root url of the data
  42873. */
  42874. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42875. /**
  42876. * Gets the list of root nodes (ie. nodes with no parent)
  42877. */
  42878. rootNodes: Node[];
  42879. /** All of the cameras added to this scene
  42880. * @see https://doc.babylonjs.com/babylon101/cameras
  42881. */
  42882. cameras: Camera[];
  42883. /**
  42884. * All of the lights added to this scene
  42885. * @see https://doc.babylonjs.com/babylon101/lights
  42886. */
  42887. lights: Light[];
  42888. /**
  42889. * All of the (abstract) meshes added to this scene
  42890. */
  42891. meshes: AbstractMesh[];
  42892. /**
  42893. * The list of skeletons added to the scene
  42894. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42895. */
  42896. skeletons: Skeleton[];
  42897. /**
  42898. * All of the particle systems added to this scene
  42899. * @see https://doc.babylonjs.com/babylon101/particles
  42900. */
  42901. particleSystems: IParticleSystem[];
  42902. /**
  42903. * Gets a list of Animations associated with the scene
  42904. */
  42905. animations: Animation[];
  42906. /**
  42907. * All of the animation groups added to this scene
  42908. * @see https://doc.babylonjs.com/how_to/group
  42909. */
  42910. animationGroups: AnimationGroup[];
  42911. /**
  42912. * All of the multi-materials added to this scene
  42913. * @see https://doc.babylonjs.com/how_to/multi_materials
  42914. */
  42915. multiMaterials: MultiMaterial[];
  42916. /**
  42917. * All of the materials added to this scene
  42918. * In the context of a Scene, it is not supposed to be modified manually.
  42919. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42920. * Note also that the order of the Material within the array is not significant and might change.
  42921. * @see https://doc.babylonjs.com/babylon101/materials
  42922. */
  42923. materials: Material[];
  42924. /**
  42925. * The list of morph target managers added to the scene
  42926. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42927. */
  42928. morphTargetManagers: MorphTargetManager[];
  42929. /**
  42930. * The list of geometries used in the scene.
  42931. */
  42932. geometries: Geometry[];
  42933. /**
  42934. * All of the tranform nodes added to this scene
  42935. * In the context of a Scene, it is not supposed to be modified manually.
  42936. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42937. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42938. * @see https://doc.babylonjs.com/how_to/transformnode
  42939. */
  42940. transformNodes: TransformNode[];
  42941. /**
  42942. * ActionManagers available on the scene.
  42943. */
  42944. actionManagers: AbstractActionManager[];
  42945. /**
  42946. * Textures to keep.
  42947. */
  42948. textures: BaseTexture[];
  42949. /** @hidden */
  42950. protected _environmentTexture: Nullable<BaseTexture>;
  42951. /**
  42952. * Texture used in all pbr material as the reflection texture.
  42953. * As in the majority of the scene they are the same (exception for multi room and so on),
  42954. * this is easier to reference from here than from all the materials.
  42955. */
  42956. get environmentTexture(): Nullable<BaseTexture>;
  42957. set environmentTexture(value: Nullable<BaseTexture>);
  42958. /**
  42959. * The list of postprocesses added to the scene
  42960. */
  42961. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42962. /**
  42963. * @returns all meshes, lights, cameras, transformNodes and bones
  42964. */
  42965. getNodes(): Array<Node>;
  42966. }
  42967. }
  42968. declare module "babylonjs/Audio/sound" {
  42969. import { Observable } from "babylonjs/Misc/observable";
  42970. import { Vector3 } from "babylonjs/Maths/math.vector";
  42971. import { Nullable } from "babylonjs/types";
  42972. import { Scene } from "babylonjs/scene";
  42973. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42974. /**
  42975. * Interface used to define options for Sound class
  42976. */
  42977. export interface ISoundOptions {
  42978. /**
  42979. * Does the sound autoplay once loaded.
  42980. */
  42981. autoplay?: boolean;
  42982. /**
  42983. * Does the sound loop after it finishes playing once.
  42984. */
  42985. loop?: boolean;
  42986. /**
  42987. * Sound's volume
  42988. */
  42989. volume?: number;
  42990. /**
  42991. * Is it a spatial sound?
  42992. */
  42993. spatialSound?: boolean;
  42994. /**
  42995. * Maximum distance to hear that sound
  42996. */
  42997. maxDistance?: number;
  42998. /**
  42999. * Uses user defined attenuation function
  43000. */
  43001. useCustomAttenuation?: boolean;
  43002. /**
  43003. * Define the roll off factor of spatial sounds.
  43004. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43005. */
  43006. rolloffFactor?: number;
  43007. /**
  43008. * Define the reference distance the sound should be heard perfectly.
  43009. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43010. */
  43011. refDistance?: number;
  43012. /**
  43013. * Define the distance attenuation model the sound will follow.
  43014. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43015. */
  43016. distanceModel?: string;
  43017. /**
  43018. * Defines the playback speed (1 by default)
  43019. */
  43020. playbackRate?: number;
  43021. /**
  43022. * Defines if the sound is from a streaming source
  43023. */
  43024. streaming?: boolean;
  43025. /**
  43026. * Defines an optional length (in seconds) inside the sound file
  43027. */
  43028. length?: number;
  43029. /**
  43030. * Defines an optional offset (in seconds) inside the sound file
  43031. */
  43032. offset?: number;
  43033. /**
  43034. * If true, URLs will not be required to state the audio file codec to use.
  43035. */
  43036. skipCodecCheck?: boolean;
  43037. }
  43038. /**
  43039. * Defines a sound that can be played in the application.
  43040. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  43041. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43042. */
  43043. export class Sound {
  43044. /**
  43045. * The name of the sound in the scene.
  43046. */
  43047. name: string;
  43048. /**
  43049. * Does the sound autoplay once loaded.
  43050. */
  43051. autoplay: boolean;
  43052. /**
  43053. * Does the sound loop after it finishes playing once.
  43054. */
  43055. loop: boolean;
  43056. /**
  43057. * Does the sound use a custom attenuation curve to simulate the falloff
  43058. * happening when the source gets further away from the camera.
  43059. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43060. */
  43061. useCustomAttenuation: boolean;
  43062. /**
  43063. * The sound track id this sound belongs to.
  43064. */
  43065. soundTrackId: number;
  43066. /**
  43067. * Is this sound currently played.
  43068. */
  43069. isPlaying: boolean;
  43070. /**
  43071. * Is this sound currently paused.
  43072. */
  43073. isPaused: boolean;
  43074. /**
  43075. * Does this sound enables spatial sound.
  43076. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43077. */
  43078. spatialSound: boolean;
  43079. /**
  43080. * Define the reference distance the sound should be heard perfectly.
  43081. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43082. */
  43083. refDistance: number;
  43084. /**
  43085. * Define the roll off factor of spatial sounds.
  43086. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43087. */
  43088. rolloffFactor: number;
  43089. /**
  43090. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43091. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43092. */
  43093. maxDistance: number;
  43094. /**
  43095. * Define the distance attenuation model the sound will follow.
  43096. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43097. */
  43098. distanceModel: string;
  43099. /**
  43100. * @hidden
  43101. * Back Compat
  43102. **/
  43103. onended: () => any;
  43104. /**
  43105. * Gets or sets an object used to store user defined information for the sound.
  43106. */
  43107. metadata: any;
  43108. /**
  43109. * Observable event when the current playing sound finishes.
  43110. */
  43111. onEndedObservable: Observable<Sound>;
  43112. private _panningModel;
  43113. private _playbackRate;
  43114. private _streaming;
  43115. private _startTime;
  43116. private _startOffset;
  43117. private _position;
  43118. /** @hidden */
  43119. _positionInEmitterSpace: boolean;
  43120. private _localDirection;
  43121. private _volume;
  43122. private _isReadyToPlay;
  43123. private _isDirectional;
  43124. private _readyToPlayCallback;
  43125. private _audioBuffer;
  43126. private _soundSource;
  43127. private _streamingSource;
  43128. private _soundPanner;
  43129. private _soundGain;
  43130. private _inputAudioNode;
  43131. private _outputAudioNode;
  43132. private _coneInnerAngle;
  43133. private _coneOuterAngle;
  43134. private _coneOuterGain;
  43135. private _scene;
  43136. private _connectedTransformNode;
  43137. private _customAttenuationFunction;
  43138. private _registerFunc;
  43139. private _isOutputConnected;
  43140. private _htmlAudioElement;
  43141. private _urlType;
  43142. private _length?;
  43143. private _offset?;
  43144. /** @hidden */
  43145. static _SceneComponentInitialization: (scene: Scene) => void;
  43146. /**
  43147. * Create a sound and attach it to a scene
  43148. * @param name Name of your sound
  43149. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43150. * @param scene defines the scene the sound belongs to
  43151. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43152. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43153. */
  43154. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43155. /**
  43156. * Release the sound and its associated resources
  43157. */
  43158. dispose(): void;
  43159. /**
  43160. * Gets if the sounds is ready to be played or not.
  43161. * @returns true if ready, otherwise false
  43162. */
  43163. isReady(): boolean;
  43164. private _soundLoaded;
  43165. /**
  43166. * Sets the data of the sound from an audiobuffer
  43167. * @param audioBuffer The audioBuffer containing the data
  43168. */
  43169. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43170. /**
  43171. * Updates the current sounds options such as maxdistance, loop...
  43172. * @param options A JSON object containing values named as the object properties
  43173. */
  43174. updateOptions(options: ISoundOptions): void;
  43175. private _createSpatialParameters;
  43176. private _updateSpatialParameters;
  43177. /**
  43178. * Switch the panning model to HRTF:
  43179. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43180. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43181. */
  43182. switchPanningModelToHRTF(): void;
  43183. /**
  43184. * Switch the panning model to Equal Power:
  43185. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43186. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43187. */
  43188. switchPanningModelToEqualPower(): void;
  43189. private _switchPanningModel;
  43190. /**
  43191. * Connect this sound to a sound track audio node like gain...
  43192. * @param soundTrackAudioNode the sound track audio node to connect to
  43193. */
  43194. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43195. /**
  43196. * Transform this sound into a directional source
  43197. * @param coneInnerAngle Size of the inner cone in degree
  43198. * @param coneOuterAngle Size of the outer cone in degree
  43199. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43200. */
  43201. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43202. /**
  43203. * Gets or sets the inner angle for the directional cone.
  43204. */
  43205. get directionalConeInnerAngle(): number;
  43206. /**
  43207. * Gets or sets the inner angle for the directional cone.
  43208. */
  43209. set directionalConeInnerAngle(value: number);
  43210. /**
  43211. * Gets or sets the outer angle for the directional cone.
  43212. */
  43213. get directionalConeOuterAngle(): number;
  43214. /**
  43215. * Gets or sets the outer angle for the directional cone.
  43216. */
  43217. set directionalConeOuterAngle(value: number);
  43218. /**
  43219. * Sets the position of the emitter if spatial sound is enabled
  43220. * @param newPosition Defines the new posisiton
  43221. */
  43222. setPosition(newPosition: Vector3): void;
  43223. /**
  43224. * Sets the local direction of the emitter if spatial sound is enabled
  43225. * @param newLocalDirection Defines the new local direction
  43226. */
  43227. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43228. private _updateDirection;
  43229. /** @hidden */
  43230. updateDistanceFromListener(): void;
  43231. /**
  43232. * Sets a new custom attenuation function for the sound.
  43233. * @param callback Defines the function used for the attenuation
  43234. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43235. */
  43236. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43237. /**
  43238. * Play the sound
  43239. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43240. * @param offset (optional) Start the sound at a specific time in seconds
  43241. * @param length (optional) Sound duration (in seconds)
  43242. */
  43243. play(time?: number, offset?: number, length?: number): void;
  43244. private _onended;
  43245. /**
  43246. * Stop the sound
  43247. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43248. */
  43249. stop(time?: number): void;
  43250. /**
  43251. * Put the sound in pause
  43252. */
  43253. pause(): void;
  43254. /**
  43255. * Sets a dedicated volume for this sounds
  43256. * @param newVolume Define the new volume of the sound
  43257. * @param time Define time for gradual change to new volume
  43258. */
  43259. setVolume(newVolume: number, time?: number): void;
  43260. /**
  43261. * Set the sound play back rate
  43262. * @param newPlaybackRate Define the playback rate the sound should be played at
  43263. */
  43264. setPlaybackRate(newPlaybackRate: number): void;
  43265. /**
  43266. * Gets the volume of the sound.
  43267. * @returns the volume of the sound
  43268. */
  43269. getVolume(): number;
  43270. /**
  43271. * Attach the sound to a dedicated mesh
  43272. * @param transformNode The transform node to connect the sound with
  43273. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43274. */
  43275. attachToMesh(transformNode: TransformNode): void;
  43276. /**
  43277. * Detach the sound from the previously attached mesh
  43278. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43279. */
  43280. detachFromMesh(): void;
  43281. private _onRegisterAfterWorldMatrixUpdate;
  43282. /**
  43283. * Clone the current sound in the scene.
  43284. * @returns the new sound clone
  43285. */
  43286. clone(): Nullable<Sound>;
  43287. /**
  43288. * Gets the current underlying audio buffer containing the data
  43289. * @returns the audio buffer
  43290. */
  43291. getAudioBuffer(): Nullable<AudioBuffer>;
  43292. /**
  43293. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43294. * @returns the source node
  43295. */
  43296. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43297. /**
  43298. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43299. * @returns the gain node
  43300. */
  43301. getSoundGain(): Nullable<GainNode>;
  43302. /**
  43303. * Serializes the Sound in a JSON representation
  43304. * @returns the JSON representation of the sound
  43305. */
  43306. serialize(): any;
  43307. /**
  43308. * Parse a JSON representation of a sound to innstantiate in a given scene
  43309. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43310. * @param scene Define the scene the new parsed sound should be created in
  43311. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43312. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43313. * @returns the newly parsed sound
  43314. */
  43315. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43316. }
  43317. }
  43318. declare module "babylonjs/Actions/directAudioActions" {
  43319. import { Action } from "babylonjs/Actions/action";
  43320. import { Condition } from "babylonjs/Actions/condition";
  43321. import { Sound } from "babylonjs/Audio/sound";
  43322. /**
  43323. * This defines an action helpful to play a defined sound on a triggered action.
  43324. */
  43325. export class PlaySoundAction extends Action {
  43326. private _sound;
  43327. /**
  43328. * Instantiate the action
  43329. * @param triggerOptions defines the trigger options
  43330. * @param sound defines the sound to play
  43331. * @param condition defines the trigger related conditions
  43332. */
  43333. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43334. /** @hidden */
  43335. _prepare(): void;
  43336. /**
  43337. * Execute the action and play the sound.
  43338. */
  43339. execute(): void;
  43340. /**
  43341. * Serializes the actions and its related information.
  43342. * @param parent defines the object to serialize in
  43343. * @returns the serialized object
  43344. */
  43345. serialize(parent: any): any;
  43346. }
  43347. /**
  43348. * This defines an action helpful to stop a defined sound on a triggered action.
  43349. */
  43350. export class StopSoundAction extends Action {
  43351. private _sound;
  43352. /**
  43353. * Instantiate the action
  43354. * @param triggerOptions defines the trigger options
  43355. * @param sound defines the sound to stop
  43356. * @param condition defines the trigger related conditions
  43357. */
  43358. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43359. /** @hidden */
  43360. _prepare(): void;
  43361. /**
  43362. * Execute the action and stop the sound.
  43363. */
  43364. execute(): void;
  43365. /**
  43366. * Serializes the actions and its related information.
  43367. * @param parent defines the object to serialize in
  43368. * @returns the serialized object
  43369. */
  43370. serialize(parent: any): any;
  43371. }
  43372. }
  43373. declare module "babylonjs/Actions/interpolateValueAction" {
  43374. import { Action } from "babylonjs/Actions/action";
  43375. import { Condition } from "babylonjs/Actions/condition";
  43376. import { Observable } from "babylonjs/Misc/observable";
  43377. /**
  43378. * This defines an action responsible to change the value of a property
  43379. * by interpolating between its current value and the newly set one once triggered.
  43380. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43381. */
  43382. export class InterpolateValueAction extends Action {
  43383. /**
  43384. * Defines the path of the property where the value should be interpolated
  43385. */
  43386. propertyPath: string;
  43387. /**
  43388. * Defines the target value at the end of the interpolation.
  43389. */
  43390. value: any;
  43391. /**
  43392. * Defines the time it will take for the property to interpolate to the value.
  43393. */
  43394. duration: number;
  43395. /**
  43396. * Defines if the other scene animations should be stopped when the action has been triggered
  43397. */
  43398. stopOtherAnimations?: boolean;
  43399. /**
  43400. * Defines a callback raised once the interpolation animation has been done.
  43401. */
  43402. onInterpolationDone?: () => void;
  43403. /**
  43404. * Observable triggered once the interpolation animation has been done.
  43405. */
  43406. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43407. private _target;
  43408. private _effectiveTarget;
  43409. private _property;
  43410. /**
  43411. * Instantiate the action
  43412. * @param triggerOptions defines the trigger options
  43413. * @param target defines the object containing the value to interpolate
  43414. * @param propertyPath defines the path to the property in the target object
  43415. * @param value defines the target value at the end of the interpolation
  43416. * @param duration deines the time it will take for the property to interpolate to the value.
  43417. * @param condition defines the trigger related conditions
  43418. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43419. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43420. */
  43421. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43422. /** @hidden */
  43423. _prepare(): void;
  43424. /**
  43425. * Execute the action starts the value interpolation.
  43426. */
  43427. execute(): void;
  43428. /**
  43429. * Serializes the actions and its related information.
  43430. * @param parent defines the object to serialize in
  43431. * @returns the serialized object
  43432. */
  43433. serialize(parent: any): any;
  43434. }
  43435. }
  43436. declare module "babylonjs/Actions/index" {
  43437. export * from "babylonjs/Actions/abstractActionManager";
  43438. export * from "babylonjs/Actions/action";
  43439. export * from "babylonjs/Actions/actionEvent";
  43440. export * from "babylonjs/Actions/actionManager";
  43441. export * from "babylonjs/Actions/condition";
  43442. export * from "babylonjs/Actions/directActions";
  43443. export * from "babylonjs/Actions/directAudioActions";
  43444. export * from "babylonjs/Actions/interpolateValueAction";
  43445. }
  43446. declare module "babylonjs/Animations/index" {
  43447. export * from "babylonjs/Animations/animatable";
  43448. export * from "babylonjs/Animations/animation";
  43449. export * from "babylonjs/Animations/animationGroup";
  43450. export * from "babylonjs/Animations/animationPropertiesOverride";
  43451. export * from "babylonjs/Animations/easing";
  43452. export * from "babylonjs/Animations/runtimeAnimation";
  43453. export * from "babylonjs/Animations/animationEvent";
  43454. export * from "babylonjs/Animations/animationGroup";
  43455. export * from "babylonjs/Animations/animationKey";
  43456. export * from "babylonjs/Animations/animationRange";
  43457. export * from "babylonjs/Animations/animatable.interface";
  43458. }
  43459. declare module "babylonjs/Audio/soundTrack" {
  43460. import { Sound } from "babylonjs/Audio/sound";
  43461. import { Analyser } from "babylonjs/Audio/analyser";
  43462. import { Scene } from "babylonjs/scene";
  43463. /**
  43464. * Options allowed during the creation of a sound track.
  43465. */
  43466. export interface ISoundTrackOptions {
  43467. /**
  43468. * The volume the sound track should take during creation
  43469. */
  43470. volume?: number;
  43471. /**
  43472. * Define if the sound track is the main sound track of the scene
  43473. */
  43474. mainTrack?: boolean;
  43475. }
  43476. /**
  43477. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43478. * It will be also used in a future release to apply effects on a specific track.
  43479. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43480. */
  43481. export class SoundTrack {
  43482. /**
  43483. * The unique identifier of the sound track in the scene.
  43484. */
  43485. id: number;
  43486. /**
  43487. * The list of sounds included in the sound track.
  43488. */
  43489. soundCollection: Array<Sound>;
  43490. private _outputAudioNode;
  43491. private _scene;
  43492. private _connectedAnalyser;
  43493. private _options;
  43494. private _isInitialized;
  43495. /**
  43496. * Creates a new sound track.
  43497. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43498. * @param scene Define the scene the sound track belongs to
  43499. * @param options
  43500. */
  43501. constructor(scene: Scene, options?: ISoundTrackOptions);
  43502. private _initializeSoundTrackAudioGraph;
  43503. /**
  43504. * Release the sound track and its associated resources
  43505. */
  43506. dispose(): void;
  43507. /**
  43508. * Adds a sound to this sound track
  43509. * @param sound define the cound to add
  43510. * @ignoreNaming
  43511. */
  43512. AddSound(sound: Sound): void;
  43513. /**
  43514. * Removes a sound to this sound track
  43515. * @param sound define the cound to remove
  43516. * @ignoreNaming
  43517. */
  43518. RemoveSound(sound: Sound): void;
  43519. /**
  43520. * Set a global volume for the full sound track.
  43521. * @param newVolume Define the new volume of the sound track
  43522. */
  43523. setVolume(newVolume: number): void;
  43524. /**
  43525. * Switch the panning model to HRTF:
  43526. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43527. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43528. */
  43529. switchPanningModelToHRTF(): void;
  43530. /**
  43531. * Switch the panning model to Equal Power:
  43532. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43533. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43534. */
  43535. switchPanningModelToEqualPower(): void;
  43536. /**
  43537. * Connect the sound track to an audio analyser allowing some amazing
  43538. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43539. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43540. * @param analyser The analyser to connect to the engine
  43541. */
  43542. connectToAnalyser(analyser: Analyser): void;
  43543. }
  43544. }
  43545. declare module "babylonjs/Audio/audioSceneComponent" {
  43546. import { Sound } from "babylonjs/Audio/sound";
  43547. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43548. import { Nullable } from "babylonjs/types";
  43549. import { Vector3 } from "babylonjs/Maths/math.vector";
  43550. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43551. import { Scene } from "babylonjs/scene";
  43552. import { AbstractScene } from "babylonjs/abstractScene";
  43553. import "babylonjs/Audio/audioEngine";
  43554. module "babylonjs/abstractScene" {
  43555. interface AbstractScene {
  43556. /**
  43557. * The list of sounds used in the scene.
  43558. */
  43559. sounds: Nullable<Array<Sound>>;
  43560. }
  43561. }
  43562. module "babylonjs/scene" {
  43563. interface Scene {
  43564. /**
  43565. * @hidden
  43566. * Backing field
  43567. */
  43568. _mainSoundTrack: SoundTrack;
  43569. /**
  43570. * The main sound track played by the scene.
  43571. * It cotains your primary collection of sounds.
  43572. */
  43573. mainSoundTrack: SoundTrack;
  43574. /**
  43575. * The list of sound tracks added to the scene
  43576. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43577. */
  43578. soundTracks: Nullable<Array<SoundTrack>>;
  43579. /**
  43580. * Gets a sound using a given name
  43581. * @param name defines the name to search for
  43582. * @return the found sound or null if not found at all.
  43583. */
  43584. getSoundByName(name: string): Nullable<Sound>;
  43585. /**
  43586. * Gets or sets if audio support is enabled
  43587. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43588. */
  43589. audioEnabled: boolean;
  43590. /**
  43591. * Gets or sets if audio will be output to headphones
  43592. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43593. */
  43594. headphone: boolean;
  43595. /**
  43596. * Gets or sets custom audio listener position provider
  43597. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43598. */
  43599. audioListenerPositionProvider: Nullable<() => Vector3>;
  43600. /**
  43601. * Gets or sets a refresh rate when using 3D audio positioning
  43602. */
  43603. audioPositioningRefreshRate: number;
  43604. }
  43605. }
  43606. /**
  43607. * Defines the sound scene component responsible to manage any sounds
  43608. * in a given scene.
  43609. */
  43610. export class AudioSceneComponent implements ISceneSerializableComponent {
  43611. private static _CameraDirectionLH;
  43612. private static _CameraDirectionRH;
  43613. /**
  43614. * The component name helpfull to identify the component in the list of scene components.
  43615. */
  43616. readonly name: string;
  43617. /**
  43618. * The scene the component belongs to.
  43619. */
  43620. scene: Scene;
  43621. private _audioEnabled;
  43622. /**
  43623. * Gets whether audio is enabled or not.
  43624. * Please use related enable/disable method to switch state.
  43625. */
  43626. get audioEnabled(): boolean;
  43627. private _headphone;
  43628. /**
  43629. * Gets whether audio is outputing to headphone or not.
  43630. * Please use the according Switch methods to change output.
  43631. */
  43632. get headphone(): boolean;
  43633. /**
  43634. * Gets or sets a refresh rate when using 3D audio positioning
  43635. */
  43636. audioPositioningRefreshRate: number;
  43637. private _audioListenerPositionProvider;
  43638. /**
  43639. * Gets the current audio listener position provider
  43640. */
  43641. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43642. /**
  43643. * Sets a custom listener position for all sounds in the scene
  43644. * By default, this is the position of the first active camera
  43645. */
  43646. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43647. /**
  43648. * Creates a new instance of the component for the given scene
  43649. * @param scene Defines the scene to register the component in
  43650. */
  43651. constructor(scene: Scene);
  43652. /**
  43653. * Registers the component in a given scene
  43654. */
  43655. register(): void;
  43656. /**
  43657. * Rebuilds the elements related to this component in case of
  43658. * context lost for instance.
  43659. */
  43660. rebuild(): void;
  43661. /**
  43662. * Serializes the component data to the specified json object
  43663. * @param serializationObject The object to serialize to
  43664. */
  43665. serialize(serializationObject: any): void;
  43666. /**
  43667. * Adds all the elements from the container to the scene
  43668. * @param container the container holding the elements
  43669. */
  43670. addFromContainer(container: AbstractScene): void;
  43671. /**
  43672. * Removes all the elements in the container from the scene
  43673. * @param container contains the elements to remove
  43674. * @param dispose if the removed element should be disposed (default: false)
  43675. */
  43676. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43677. /**
  43678. * Disposes the component and the associated ressources.
  43679. */
  43680. dispose(): void;
  43681. /**
  43682. * Disables audio in the associated scene.
  43683. */
  43684. disableAudio(): void;
  43685. /**
  43686. * Enables audio in the associated scene.
  43687. */
  43688. enableAudio(): void;
  43689. /**
  43690. * Switch audio to headphone output.
  43691. */
  43692. switchAudioModeForHeadphones(): void;
  43693. /**
  43694. * Switch audio to normal speakers.
  43695. */
  43696. switchAudioModeForNormalSpeakers(): void;
  43697. private _cachedCameraDirection;
  43698. private _cachedCameraPosition;
  43699. private _lastCheck;
  43700. private _afterRender;
  43701. }
  43702. }
  43703. declare module "babylonjs/Audio/weightedsound" {
  43704. import { Sound } from "babylonjs/Audio/sound";
  43705. /**
  43706. * Wraps one or more Sound objects and selects one with random weight for playback.
  43707. */
  43708. export class WeightedSound {
  43709. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43710. loop: boolean;
  43711. private _coneInnerAngle;
  43712. private _coneOuterAngle;
  43713. private _volume;
  43714. /** A Sound is currently playing. */
  43715. isPlaying: boolean;
  43716. /** A Sound is currently paused. */
  43717. isPaused: boolean;
  43718. private _sounds;
  43719. private _weights;
  43720. private _currentIndex?;
  43721. /**
  43722. * Creates a new WeightedSound from the list of sounds given.
  43723. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43724. * @param sounds Array of Sounds that will be selected from.
  43725. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43726. */
  43727. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43728. /**
  43729. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43730. */
  43731. get directionalConeInnerAngle(): number;
  43732. /**
  43733. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43734. */
  43735. set directionalConeInnerAngle(value: number);
  43736. /**
  43737. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43738. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43739. */
  43740. get directionalConeOuterAngle(): number;
  43741. /**
  43742. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43743. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43744. */
  43745. set directionalConeOuterAngle(value: number);
  43746. /**
  43747. * Playback volume.
  43748. */
  43749. get volume(): number;
  43750. /**
  43751. * Playback volume.
  43752. */
  43753. set volume(value: number);
  43754. private _onended;
  43755. /**
  43756. * Suspend playback
  43757. */
  43758. pause(): void;
  43759. /**
  43760. * Stop playback
  43761. */
  43762. stop(): void;
  43763. /**
  43764. * Start playback.
  43765. * @param startOffset Position the clip head at a specific time in seconds.
  43766. */
  43767. play(startOffset?: number): void;
  43768. }
  43769. }
  43770. declare module "babylonjs/Audio/index" {
  43771. export * from "babylonjs/Audio/analyser";
  43772. export * from "babylonjs/Audio/audioEngine";
  43773. export * from "babylonjs/Audio/audioSceneComponent";
  43774. export * from "babylonjs/Audio/sound";
  43775. export * from "babylonjs/Audio/soundTrack";
  43776. export * from "babylonjs/Audio/weightedsound";
  43777. }
  43778. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43779. import { Behavior } from "babylonjs/Behaviors/behavior";
  43780. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43781. import { BackEase } from "babylonjs/Animations/easing";
  43782. /**
  43783. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43784. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43785. */
  43786. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43787. /**
  43788. * Gets the name of the behavior.
  43789. */
  43790. get name(): string;
  43791. /**
  43792. * The easing function used by animations
  43793. */
  43794. static EasingFunction: BackEase;
  43795. /**
  43796. * The easing mode used by animations
  43797. */
  43798. static EasingMode: number;
  43799. /**
  43800. * The duration of the animation, in milliseconds
  43801. */
  43802. transitionDuration: number;
  43803. /**
  43804. * Length of the distance animated by the transition when lower radius is reached
  43805. */
  43806. lowerRadiusTransitionRange: number;
  43807. /**
  43808. * Length of the distance animated by the transition when upper radius is reached
  43809. */
  43810. upperRadiusTransitionRange: number;
  43811. private _autoTransitionRange;
  43812. /**
  43813. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43814. */
  43815. get autoTransitionRange(): boolean;
  43816. /**
  43817. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43818. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43819. */
  43820. set autoTransitionRange(value: boolean);
  43821. private _attachedCamera;
  43822. private _onAfterCheckInputsObserver;
  43823. private _onMeshTargetChangedObserver;
  43824. /**
  43825. * Initializes the behavior.
  43826. */
  43827. init(): void;
  43828. /**
  43829. * Attaches the behavior to its arc rotate camera.
  43830. * @param camera Defines the camera to attach the behavior to
  43831. */
  43832. attach(camera: ArcRotateCamera): void;
  43833. /**
  43834. * Detaches the behavior from its current arc rotate camera.
  43835. */
  43836. detach(): void;
  43837. private _radiusIsAnimating;
  43838. private _radiusBounceTransition;
  43839. private _animatables;
  43840. private _cachedWheelPrecision;
  43841. /**
  43842. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43843. * @param radiusLimit The limit to check against.
  43844. * @return Bool to indicate if at limit.
  43845. */
  43846. private _isRadiusAtLimit;
  43847. /**
  43848. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43849. * @param radiusDelta The delta by which to animate to. Can be negative.
  43850. */
  43851. private _applyBoundRadiusAnimation;
  43852. /**
  43853. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43854. */
  43855. protected _clearAnimationLocks(): void;
  43856. /**
  43857. * Stops and removes all animations that have been applied to the camera
  43858. */
  43859. stopAllAnimations(): void;
  43860. }
  43861. }
  43862. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43863. import { Behavior } from "babylonjs/Behaviors/behavior";
  43864. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43865. import { ExponentialEase } from "babylonjs/Animations/easing";
  43866. import { Nullable } from "babylonjs/types";
  43867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43868. import { Vector3 } from "babylonjs/Maths/math.vector";
  43869. /**
  43870. * 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.
  43871. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43872. */
  43873. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43874. /**
  43875. * Gets the name of the behavior.
  43876. */
  43877. get name(): string;
  43878. private _mode;
  43879. private _radiusScale;
  43880. private _positionScale;
  43881. private _defaultElevation;
  43882. private _elevationReturnTime;
  43883. private _elevationReturnWaitTime;
  43884. private _zoomStopsAnimation;
  43885. private _framingTime;
  43886. /**
  43887. * The easing function used by animations
  43888. */
  43889. static EasingFunction: ExponentialEase;
  43890. /**
  43891. * The easing mode used by animations
  43892. */
  43893. static EasingMode: number;
  43894. /**
  43895. * Sets the current mode used by the behavior
  43896. */
  43897. set mode(mode: number);
  43898. /**
  43899. * Gets current mode used by the behavior.
  43900. */
  43901. get mode(): number;
  43902. /**
  43903. * Sets the scale applied to the radius (1 by default)
  43904. */
  43905. set radiusScale(radius: number);
  43906. /**
  43907. * Gets the scale applied to the radius
  43908. */
  43909. get radiusScale(): number;
  43910. /**
  43911. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43912. */
  43913. set positionScale(scale: number);
  43914. /**
  43915. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43916. */
  43917. get positionScale(): number;
  43918. /**
  43919. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43920. * behaviour is triggered, in radians.
  43921. */
  43922. set defaultElevation(elevation: number);
  43923. /**
  43924. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43925. * behaviour is triggered, in radians.
  43926. */
  43927. get defaultElevation(): number;
  43928. /**
  43929. * Sets the time (in milliseconds) taken to return to the default beta position.
  43930. * Negative value indicates camera should not return to default.
  43931. */
  43932. set elevationReturnTime(speed: number);
  43933. /**
  43934. * Gets the time (in milliseconds) taken to return to the default beta position.
  43935. * Negative value indicates camera should not return to default.
  43936. */
  43937. get elevationReturnTime(): number;
  43938. /**
  43939. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43940. */
  43941. set elevationReturnWaitTime(time: number);
  43942. /**
  43943. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43944. */
  43945. get elevationReturnWaitTime(): number;
  43946. /**
  43947. * Sets the flag that indicates if user zooming should stop animation.
  43948. */
  43949. set zoomStopsAnimation(flag: boolean);
  43950. /**
  43951. * Gets the flag that indicates if user zooming should stop animation.
  43952. */
  43953. get zoomStopsAnimation(): boolean;
  43954. /**
  43955. * Sets the transition time when framing the mesh, in milliseconds
  43956. */
  43957. set framingTime(time: number);
  43958. /**
  43959. * Gets the transition time when framing the mesh, in milliseconds
  43960. */
  43961. get framingTime(): number;
  43962. /**
  43963. * Define if the behavior should automatically change the configured
  43964. * camera limits and sensibilities.
  43965. */
  43966. autoCorrectCameraLimitsAndSensibility: boolean;
  43967. private _onPrePointerObservableObserver;
  43968. private _onAfterCheckInputsObserver;
  43969. private _onMeshTargetChangedObserver;
  43970. private _attachedCamera;
  43971. private _isPointerDown;
  43972. private _lastInteractionTime;
  43973. /**
  43974. * Initializes the behavior.
  43975. */
  43976. init(): void;
  43977. /**
  43978. * Attaches the behavior to its arc rotate camera.
  43979. * @param camera Defines the camera to attach the behavior to
  43980. */
  43981. attach(camera: ArcRotateCamera): void;
  43982. /**
  43983. * Detaches the behavior from its current arc rotate camera.
  43984. */
  43985. detach(): void;
  43986. private _animatables;
  43987. private _betaIsAnimating;
  43988. private _betaTransition;
  43989. private _radiusTransition;
  43990. private _vectorTransition;
  43991. /**
  43992. * Targets the given mesh and updates zoom level accordingly.
  43993. * @param mesh The mesh to target.
  43994. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43995. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43996. */
  43997. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43998. /**
  43999. * Targets the given mesh with its children and updates zoom level accordingly.
  44000. * @param mesh The mesh to target.
  44001. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44002. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44003. */
  44004. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44005. /**
  44006. * Targets the given meshes with their children and updates zoom level accordingly.
  44007. * @param meshes The mesh to target.
  44008. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44009. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44010. */
  44011. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44012. /**
  44013. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  44014. * @param minimumWorld Determines the smaller position of the bounding box extend
  44015. * @param maximumWorld Determines the bigger position of the bounding box extend
  44016. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44017. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44018. */
  44019. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44020. /**
  44021. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  44022. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  44023. * frustum width.
  44024. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  44025. * to fully enclose the mesh in the viewing frustum.
  44026. */
  44027. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  44028. /**
  44029. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  44030. * is automatically returned to its default position (expected to be above ground plane).
  44031. */
  44032. private _maintainCameraAboveGround;
  44033. /**
  44034. * Returns the frustum slope based on the canvas ratio and camera FOV
  44035. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  44036. */
  44037. private _getFrustumSlope;
  44038. /**
  44039. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  44040. */
  44041. private _clearAnimationLocks;
  44042. /**
  44043. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44044. */
  44045. private _applyUserInteraction;
  44046. /**
  44047. * Stops and removes all animations that have been applied to the camera
  44048. */
  44049. stopAllAnimations(): void;
  44050. /**
  44051. * Gets a value indicating if the user is moving the camera
  44052. */
  44053. get isUserIsMoving(): boolean;
  44054. /**
  44055. * The camera can move all the way towards the mesh.
  44056. */
  44057. static IgnoreBoundsSizeMode: number;
  44058. /**
  44059. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44060. */
  44061. static FitFrustumSidesMode: number;
  44062. }
  44063. }
  44064. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44065. import { Nullable } from "babylonjs/types";
  44066. import { Camera } from "babylonjs/Cameras/camera";
  44067. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44068. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44069. /**
  44070. * Base class for Camera Pointer Inputs.
  44071. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44072. * for example usage.
  44073. */
  44074. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44075. /**
  44076. * Defines the camera the input is attached to.
  44077. */
  44078. abstract camera: Camera;
  44079. /**
  44080. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44081. */
  44082. protected _altKey: boolean;
  44083. protected _ctrlKey: boolean;
  44084. protected _metaKey: boolean;
  44085. protected _shiftKey: boolean;
  44086. /**
  44087. * Which mouse buttons were pressed at time of last mouse event.
  44088. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44089. */
  44090. protected _buttonsPressed: number;
  44091. /**
  44092. * Defines the buttons associated with the input to handle camera move.
  44093. */
  44094. buttons: number[];
  44095. /**
  44096. * Attach the input controls to a specific dom element to get the input from.
  44097. * @param element Defines the element the controls should be listened from
  44098. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44099. */
  44100. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44101. /**
  44102. * Detach the current controls from the specified dom element.
  44103. * @param element Defines the element to stop listening the inputs from
  44104. */
  44105. detachControl(element: Nullable<HTMLElement>): void;
  44106. /**
  44107. * Gets the class name of the current input.
  44108. * @returns the class name
  44109. */
  44110. getClassName(): string;
  44111. /**
  44112. * Get the friendly name associated with the input class.
  44113. * @returns the input friendly name
  44114. */
  44115. getSimpleName(): string;
  44116. /**
  44117. * Called on pointer POINTERDOUBLETAP event.
  44118. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44119. */
  44120. protected onDoubleTap(type: string): void;
  44121. /**
  44122. * Called on pointer POINTERMOVE event if only a single touch is active.
  44123. * Override this method to provide functionality.
  44124. */
  44125. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44126. /**
  44127. * Called on pointer POINTERMOVE event if multiple touches are active.
  44128. * Override this method to provide functionality.
  44129. */
  44130. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44131. /**
  44132. * Called on JS contextmenu event.
  44133. * Override this method to provide functionality.
  44134. */
  44135. protected onContextMenu(evt: PointerEvent): void;
  44136. /**
  44137. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44138. * press.
  44139. * Override this method to provide functionality.
  44140. */
  44141. protected onButtonDown(evt: PointerEvent): void;
  44142. /**
  44143. * Called each time a new POINTERUP event occurs. Ie, for each button
  44144. * release.
  44145. * Override this method to provide functionality.
  44146. */
  44147. protected onButtonUp(evt: PointerEvent): void;
  44148. /**
  44149. * Called when window becomes inactive.
  44150. * Override this method to provide functionality.
  44151. */
  44152. protected onLostFocus(): void;
  44153. private _pointerInput;
  44154. private _observer;
  44155. private _onLostFocus;
  44156. private pointA;
  44157. private pointB;
  44158. }
  44159. }
  44160. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44161. import { Nullable } from "babylonjs/types";
  44162. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44163. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44164. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44165. /**
  44166. * Manage the pointers inputs to control an arc rotate camera.
  44167. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44168. */
  44169. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44170. /**
  44171. * Defines the camera the input is attached to.
  44172. */
  44173. camera: ArcRotateCamera;
  44174. /**
  44175. * Gets the class name of the current input.
  44176. * @returns the class name
  44177. */
  44178. getClassName(): string;
  44179. /**
  44180. * Defines the buttons associated with the input to handle camera move.
  44181. */
  44182. buttons: number[];
  44183. /**
  44184. * Defines the pointer angular sensibility along the X axis or how fast is
  44185. * the camera rotating.
  44186. */
  44187. angularSensibilityX: number;
  44188. /**
  44189. * Defines the pointer angular sensibility along the Y axis or how fast is
  44190. * the camera rotating.
  44191. */
  44192. angularSensibilityY: number;
  44193. /**
  44194. * Defines the pointer pinch precision or how fast is the camera zooming.
  44195. */
  44196. pinchPrecision: number;
  44197. /**
  44198. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44199. * from 0.
  44200. * It defines the percentage of current camera.radius to use as delta when
  44201. * pinch zoom is used.
  44202. */
  44203. pinchDeltaPercentage: number;
  44204. /**
  44205. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44206. * that any object in the plane at the camera's target point will scale
  44207. * perfectly with finger motion.
  44208. * Overrides pinchDeltaPercentage and pinchPrecision.
  44209. */
  44210. useNaturalPinchZoom: boolean;
  44211. /**
  44212. * Defines the pointer panning sensibility or how fast is the camera moving.
  44213. */
  44214. panningSensibility: number;
  44215. /**
  44216. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44217. */
  44218. multiTouchPanning: boolean;
  44219. /**
  44220. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44221. * zoom (pinch) through multitouch.
  44222. */
  44223. multiTouchPanAndZoom: boolean;
  44224. /**
  44225. * Revers pinch action direction.
  44226. */
  44227. pinchInwards: boolean;
  44228. private _isPanClick;
  44229. private _twoFingerActivityCount;
  44230. private _isPinching;
  44231. /**
  44232. * Called on pointer POINTERMOVE event if only a single touch is active.
  44233. */
  44234. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44235. /**
  44236. * Called on pointer POINTERDOUBLETAP event.
  44237. */
  44238. protected onDoubleTap(type: string): void;
  44239. /**
  44240. * Called on pointer POINTERMOVE event if multiple touches are active.
  44241. */
  44242. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44243. /**
  44244. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44245. * press.
  44246. */
  44247. protected onButtonDown(evt: PointerEvent): void;
  44248. /**
  44249. * Called each time a new POINTERUP event occurs. Ie, for each button
  44250. * release.
  44251. */
  44252. protected onButtonUp(evt: PointerEvent): void;
  44253. /**
  44254. * Called when window becomes inactive.
  44255. */
  44256. protected onLostFocus(): void;
  44257. }
  44258. }
  44259. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44260. import { Nullable } from "babylonjs/types";
  44261. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44262. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44263. /**
  44264. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44265. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44266. */
  44267. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44268. /**
  44269. * Defines the camera the input is attached to.
  44270. */
  44271. camera: ArcRotateCamera;
  44272. /**
  44273. * Defines the list of key codes associated with the up action (increase alpha)
  44274. */
  44275. keysUp: number[];
  44276. /**
  44277. * Defines the list of key codes associated with the down action (decrease alpha)
  44278. */
  44279. keysDown: number[];
  44280. /**
  44281. * Defines the list of key codes associated with the left action (increase beta)
  44282. */
  44283. keysLeft: number[];
  44284. /**
  44285. * Defines the list of key codes associated with the right action (decrease beta)
  44286. */
  44287. keysRight: number[];
  44288. /**
  44289. * Defines the list of key codes associated with the reset action.
  44290. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44291. */
  44292. keysReset: number[];
  44293. /**
  44294. * Defines the panning sensibility of the inputs.
  44295. * (How fast is the camera panning)
  44296. */
  44297. panningSensibility: number;
  44298. /**
  44299. * Defines the zooming sensibility of the inputs.
  44300. * (How fast is the camera zooming)
  44301. */
  44302. zoomingSensibility: number;
  44303. /**
  44304. * Defines whether maintaining the alt key down switch the movement mode from
  44305. * orientation to zoom.
  44306. */
  44307. useAltToZoom: boolean;
  44308. /**
  44309. * Rotation speed of the camera
  44310. */
  44311. angularSpeed: number;
  44312. private _keys;
  44313. private _ctrlPressed;
  44314. private _altPressed;
  44315. private _onCanvasBlurObserver;
  44316. private _onKeyboardObserver;
  44317. private _engine;
  44318. private _scene;
  44319. /**
  44320. * Attach the input controls to a specific dom element to get the input from.
  44321. * @param element Defines the element the controls should be listened from
  44322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44323. */
  44324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44325. /**
  44326. * Detach the current controls from the specified dom element.
  44327. * @param element Defines the element to stop listening the inputs from
  44328. */
  44329. detachControl(element: Nullable<HTMLElement>): void;
  44330. /**
  44331. * Update the current camera state depending on the inputs that have been used this frame.
  44332. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44333. */
  44334. checkInputs(): void;
  44335. /**
  44336. * Gets the class name of the current intput.
  44337. * @returns the class name
  44338. */
  44339. getClassName(): string;
  44340. /**
  44341. * Get the friendly name associated with the input class.
  44342. * @returns the input friendly name
  44343. */
  44344. getSimpleName(): string;
  44345. }
  44346. }
  44347. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44348. import { Nullable } from "babylonjs/types";
  44349. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44350. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44351. /**
  44352. * Manage the mouse wheel inputs to control an arc rotate camera.
  44353. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44354. */
  44355. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44356. /**
  44357. * Defines the camera the input is attached to.
  44358. */
  44359. camera: ArcRotateCamera;
  44360. /**
  44361. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44362. */
  44363. wheelPrecision: number;
  44364. /**
  44365. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44366. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44367. */
  44368. wheelDeltaPercentage: number;
  44369. private _wheel;
  44370. private _observer;
  44371. private computeDeltaFromMouseWheelLegacyEvent;
  44372. /**
  44373. * Attach the input controls to a specific dom element to get the input from.
  44374. * @param element Defines the element the controls should be listened from
  44375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44376. */
  44377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44378. /**
  44379. * Detach the current controls from the specified dom element.
  44380. * @param element Defines the element to stop listening the inputs from
  44381. */
  44382. detachControl(element: Nullable<HTMLElement>): void;
  44383. /**
  44384. * Gets the class name of the current intput.
  44385. * @returns the class name
  44386. */
  44387. getClassName(): string;
  44388. /**
  44389. * Get the friendly name associated with the input class.
  44390. * @returns the input friendly name
  44391. */
  44392. getSimpleName(): string;
  44393. }
  44394. }
  44395. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44396. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44397. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44398. /**
  44399. * Default Inputs manager for the ArcRotateCamera.
  44400. * It groups all the default supported inputs for ease of use.
  44401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44402. */
  44403. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44404. /**
  44405. * Instantiates a new ArcRotateCameraInputsManager.
  44406. * @param camera Defines the camera the inputs belong to
  44407. */
  44408. constructor(camera: ArcRotateCamera);
  44409. /**
  44410. * Add mouse wheel input support to the input manager.
  44411. * @returns the current input manager
  44412. */
  44413. addMouseWheel(): ArcRotateCameraInputsManager;
  44414. /**
  44415. * Add pointers input support to the input manager.
  44416. * @returns the current input manager
  44417. */
  44418. addPointers(): ArcRotateCameraInputsManager;
  44419. /**
  44420. * Add keyboard input support to the input manager.
  44421. * @returns the current input manager
  44422. */
  44423. addKeyboard(): ArcRotateCameraInputsManager;
  44424. }
  44425. }
  44426. declare module "babylonjs/Cameras/arcRotateCamera" {
  44427. import { Observable } from "babylonjs/Misc/observable";
  44428. import { Nullable } from "babylonjs/types";
  44429. import { Scene } from "babylonjs/scene";
  44430. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44432. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44433. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44434. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44435. import { Camera } from "babylonjs/Cameras/camera";
  44436. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44437. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44438. import { Collider } from "babylonjs/Collisions/collider";
  44439. /**
  44440. * This represents an orbital type of camera.
  44441. *
  44442. * 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.
  44443. * 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.
  44444. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44445. */
  44446. export class ArcRotateCamera extends TargetCamera {
  44447. /**
  44448. * Defines the rotation angle of the camera along the longitudinal axis.
  44449. */
  44450. alpha: number;
  44451. /**
  44452. * Defines the rotation angle of the camera along the latitudinal axis.
  44453. */
  44454. beta: number;
  44455. /**
  44456. * Defines the radius of the camera from it s target point.
  44457. */
  44458. radius: number;
  44459. protected _target: Vector3;
  44460. protected _targetHost: Nullable<AbstractMesh>;
  44461. /**
  44462. * Defines the target point of the camera.
  44463. * The camera looks towards it form the radius distance.
  44464. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44465. */
  44466. get target(): Vector3;
  44467. set target(value: Vector3);
  44468. /**
  44469. * Define the current local position of the camera in the scene
  44470. */
  44471. get position(): Vector3;
  44472. set position(newPosition: Vector3);
  44473. protected _upToYMatrix: Matrix;
  44474. protected _YToUpMatrix: Matrix;
  44475. /**
  44476. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44477. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44478. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44479. */
  44480. set upVector(vec: Vector3);
  44481. get upVector(): Vector3;
  44482. /**
  44483. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44484. */
  44485. setMatUp(): void;
  44486. /**
  44487. * Current inertia value on the longitudinal axis.
  44488. * The bigger this number the longer it will take for the camera to stop.
  44489. */
  44490. inertialAlphaOffset: number;
  44491. /**
  44492. * Current inertia value on the latitudinal axis.
  44493. * The bigger this number the longer it will take for the camera to stop.
  44494. */
  44495. inertialBetaOffset: number;
  44496. /**
  44497. * Current inertia value on the radius axis.
  44498. * The bigger this number the longer it will take for the camera to stop.
  44499. */
  44500. inertialRadiusOffset: number;
  44501. /**
  44502. * Minimum allowed angle on the longitudinal axis.
  44503. * This can help limiting how the Camera is able to move in the scene.
  44504. */
  44505. lowerAlphaLimit: Nullable<number>;
  44506. /**
  44507. * Maximum allowed angle on the longitudinal axis.
  44508. * This can help limiting how the Camera is able to move in the scene.
  44509. */
  44510. upperAlphaLimit: Nullable<number>;
  44511. /**
  44512. * Minimum allowed angle on the latitudinal axis.
  44513. * This can help limiting how the Camera is able to move in the scene.
  44514. */
  44515. lowerBetaLimit: number;
  44516. /**
  44517. * Maximum allowed angle on the latitudinal axis.
  44518. * This can help limiting how the Camera is able to move in the scene.
  44519. */
  44520. upperBetaLimit: number;
  44521. /**
  44522. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44523. * This can help limiting how the Camera is able to move in the scene.
  44524. */
  44525. lowerRadiusLimit: Nullable<number>;
  44526. /**
  44527. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44528. * This can help limiting how the Camera is able to move in the scene.
  44529. */
  44530. upperRadiusLimit: Nullable<number>;
  44531. /**
  44532. * Defines the current inertia value used during panning of the camera along the X axis.
  44533. */
  44534. inertialPanningX: number;
  44535. /**
  44536. * Defines the current inertia value used during panning of the camera along the Y axis.
  44537. */
  44538. inertialPanningY: number;
  44539. /**
  44540. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44541. * Basically if your fingers moves away from more than this distance you will be considered
  44542. * in pinch mode.
  44543. */
  44544. pinchToPanMaxDistance: number;
  44545. /**
  44546. * Defines the maximum distance the camera can pan.
  44547. * This could help keeping the cammera always in your scene.
  44548. */
  44549. panningDistanceLimit: Nullable<number>;
  44550. /**
  44551. * Defines the target of the camera before paning.
  44552. */
  44553. panningOriginTarget: Vector3;
  44554. /**
  44555. * Defines the value of the inertia used during panning.
  44556. * 0 would mean stop inertia and one would mean no decelleration at all.
  44557. */
  44558. panningInertia: number;
  44559. /**
  44560. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44561. */
  44562. get angularSensibilityX(): number;
  44563. set angularSensibilityX(value: number);
  44564. /**
  44565. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44566. */
  44567. get angularSensibilityY(): number;
  44568. set angularSensibilityY(value: number);
  44569. /**
  44570. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44571. */
  44572. get pinchPrecision(): number;
  44573. set pinchPrecision(value: number);
  44574. /**
  44575. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44576. * It will be used instead of pinchDeltaPrecision if different from 0.
  44577. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44578. */
  44579. get pinchDeltaPercentage(): number;
  44580. set pinchDeltaPercentage(value: number);
  44581. /**
  44582. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44583. * and pinch delta percentage.
  44584. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44585. * that any object in the plane at the camera's target point will scale
  44586. * perfectly with finger motion.
  44587. */
  44588. get useNaturalPinchZoom(): boolean;
  44589. set useNaturalPinchZoom(value: boolean);
  44590. /**
  44591. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44592. */
  44593. get panningSensibility(): number;
  44594. set panningSensibility(value: number);
  44595. /**
  44596. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44597. */
  44598. get keysUp(): number[];
  44599. set keysUp(value: number[]);
  44600. /**
  44601. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44602. */
  44603. get keysDown(): number[];
  44604. set keysDown(value: number[]);
  44605. /**
  44606. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44607. */
  44608. get keysLeft(): number[];
  44609. set keysLeft(value: number[]);
  44610. /**
  44611. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44612. */
  44613. get keysRight(): number[];
  44614. set keysRight(value: number[]);
  44615. /**
  44616. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44617. */
  44618. get wheelPrecision(): number;
  44619. set wheelPrecision(value: number);
  44620. /**
  44621. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44622. * It will be used instead of pinchDeltaPrecision if different from 0.
  44623. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44624. */
  44625. get wheelDeltaPercentage(): number;
  44626. set wheelDeltaPercentage(value: number);
  44627. /**
  44628. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44629. */
  44630. zoomOnFactor: number;
  44631. /**
  44632. * Defines a screen offset for the camera position.
  44633. */
  44634. targetScreenOffset: Vector2;
  44635. /**
  44636. * Allows the camera to be completely reversed.
  44637. * If false the camera can not arrive upside down.
  44638. */
  44639. allowUpsideDown: boolean;
  44640. /**
  44641. * Define if double tap/click is used to restore the previously saved state of the camera.
  44642. */
  44643. useInputToRestoreState: boolean;
  44644. /** @hidden */
  44645. _viewMatrix: Matrix;
  44646. /** @hidden */
  44647. _useCtrlForPanning: boolean;
  44648. /** @hidden */
  44649. _panningMouseButton: number;
  44650. /**
  44651. * Defines the input associated to the camera.
  44652. */
  44653. inputs: ArcRotateCameraInputsManager;
  44654. /** @hidden */
  44655. _reset: () => void;
  44656. /**
  44657. * Defines the allowed panning axis.
  44658. */
  44659. panningAxis: Vector3;
  44660. protected _localDirection: Vector3;
  44661. protected _transformedDirection: Vector3;
  44662. private _bouncingBehavior;
  44663. /**
  44664. * Gets the bouncing behavior of the camera if it has been enabled.
  44665. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44666. */
  44667. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44668. /**
  44669. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44670. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44671. */
  44672. get useBouncingBehavior(): boolean;
  44673. set useBouncingBehavior(value: boolean);
  44674. private _framingBehavior;
  44675. /**
  44676. * Gets the framing behavior of the camera if it has been enabled.
  44677. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44678. */
  44679. get framingBehavior(): Nullable<FramingBehavior>;
  44680. /**
  44681. * Defines if the framing behavior of the camera is enabled on the camera.
  44682. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44683. */
  44684. get useFramingBehavior(): boolean;
  44685. set useFramingBehavior(value: boolean);
  44686. private _autoRotationBehavior;
  44687. /**
  44688. * Gets the auto rotation behavior of the camera if it has been enabled.
  44689. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44690. */
  44691. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44692. /**
  44693. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44694. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44695. */
  44696. get useAutoRotationBehavior(): boolean;
  44697. set useAutoRotationBehavior(value: boolean);
  44698. /**
  44699. * Observable triggered when the mesh target has been changed on the camera.
  44700. */
  44701. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44702. /**
  44703. * Event raised when the camera is colliding with a mesh.
  44704. */
  44705. onCollide: (collidedMesh: AbstractMesh) => void;
  44706. /**
  44707. * Defines whether the camera should check collision with the objects oh the scene.
  44708. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44709. */
  44710. checkCollisions: boolean;
  44711. /**
  44712. * Defines the collision radius of the camera.
  44713. * This simulates a sphere around the camera.
  44714. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44715. */
  44716. collisionRadius: Vector3;
  44717. protected _collider: Collider;
  44718. protected _previousPosition: Vector3;
  44719. protected _collisionVelocity: Vector3;
  44720. protected _newPosition: Vector3;
  44721. protected _previousAlpha: number;
  44722. protected _previousBeta: number;
  44723. protected _previousRadius: number;
  44724. protected _collisionTriggered: boolean;
  44725. protected _targetBoundingCenter: Nullable<Vector3>;
  44726. private _computationVector;
  44727. /**
  44728. * Instantiates a new ArcRotateCamera in a given scene
  44729. * @param name Defines the name of the camera
  44730. * @param alpha Defines the camera rotation along the logitudinal axis
  44731. * @param beta Defines the camera rotation along the latitudinal axis
  44732. * @param radius Defines the camera distance from its target
  44733. * @param target Defines the camera target
  44734. * @param scene Defines the scene the camera belongs to
  44735. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44736. */
  44737. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44738. /** @hidden */
  44739. _initCache(): void;
  44740. /** @hidden */
  44741. _updateCache(ignoreParentClass?: boolean): void;
  44742. protected _getTargetPosition(): Vector3;
  44743. private _storedAlpha;
  44744. private _storedBeta;
  44745. private _storedRadius;
  44746. private _storedTarget;
  44747. private _storedTargetScreenOffset;
  44748. /**
  44749. * Stores the current state of the camera (alpha, beta, radius and target)
  44750. * @returns the camera itself
  44751. */
  44752. storeState(): Camera;
  44753. /**
  44754. * @hidden
  44755. * Restored camera state. You must call storeState() first
  44756. */
  44757. _restoreStateValues(): boolean;
  44758. /** @hidden */
  44759. _isSynchronizedViewMatrix(): boolean;
  44760. /**
  44761. * Attached controls to the current camera.
  44762. * @param element Defines the element the controls should be listened from
  44763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44764. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44765. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44766. */
  44767. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44768. /**
  44769. * Detach the current controls from the camera.
  44770. * The camera will stop reacting to inputs.
  44771. * @param element Defines the element to stop listening the inputs from
  44772. */
  44773. detachControl(element: HTMLElement): void;
  44774. /** @hidden */
  44775. _checkInputs(): void;
  44776. protected _checkLimits(): void;
  44777. /**
  44778. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44779. */
  44780. rebuildAnglesAndRadius(): void;
  44781. /**
  44782. * Use a position to define the current camera related information like alpha, beta and radius
  44783. * @param position Defines the position to set the camera at
  44784. */
  44785. setPosition(position: Vector3): void;
  44786. /**
  44787. * Defines the target the camera should look at.
  44788. * This will automatically adapt alpha beta and radius to fit within the new target.
  44789. * @param target Defines the new target as a Vector or a mesh
  44790. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44791. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44792. */
  44793. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44794. /** @hidden */
  44795. _getViewMatrix(): Matrix;
  44796. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44797. /**
  44798. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44799. * @param meshes Defines the mesh to zoom on
  44800. * @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)
  44801. */
  44802. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44803. /**
  44804. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44805. * The target will be changed but the radius
  44806. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44807. * @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)
  44808. */
  44809. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44810. min: Vector3;
  44811. max: Vector3;
  44812. distance: number;
  44813. }, doNotUpdateMaxZ?: boolean): void;
  44814. /**
  44815. * @override
  44816. * Override Camera.createRigCamera
  44817. */
  44818. createRigCamera(name: string, cameraIndex: number): Camera;
  44819. /**
  44820. * @hidden
  44821. * @override
  44822. * Override Camera._updateRigCameras
  44823. */
  44824. _updateRigCameras(): void;
  44825. /**
  44826. * Destroy the camera and release the current resources hold by it.
  44827. */
  44828. dispose(): void;
  44829. /**
  44830. * Gets the current object class name.
  44831. * @return the class name
  44832. */
  44833. getClassName(): string;
  44834. }
  44835. }
  44836. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44837. import { Behavior } from "babylonjs/Behaviors/behavior";
  44838. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44839. /**
  44840. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44841. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44842. */
  44843. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44844. /**
  44845. * Gets the name of the behavior.
  44846. */
  44847. get name(): string;
  44848. private _zoomStopsAnimation;
  44849. private _idleRotationSpeed;
  44850. private _idleRotationWaitTime;
  44851. private _idleRotationSpinupTime;
  44852. /**
  44853. * Sets the flag that indicates if user zooming should stop animation.
  44854. */
  44855. set zoomStopsAnimation(flag: boolean);
  44856. /**
  44857. * Gets the flag that indicates if user zooming should stop animation.
  44858. */
  44859. get zoomStopsAnimation(): boolean;
  44860. /**
  44861. * Sets the default speed at which the camera rotates around the model.
  44862. */
  44863. set idleRotationSpeed(speed: number);
  44864. /**
  44865. * Gets the default speed at which the camera rotates around the model.
  44866. */
  44867. get idleRotationSpeed(): number;
  44868. /**
  44869. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44870. */
  44871. set idleRotationWaitTime(time: number);
  44872. /**
  44873. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44874. */
  44875. get idleRotationWaitTime(): number;
  44876. /**
  44877. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44878. */
  44879. set idleRotationSpinupTime(time: number);
  44880. /**
  44881. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44882. */
  44883. get idleRotationSpinupTime(): number;
  44884. /**
  44885. * Gets a value indicating if the camera is currently rotating because of this behavior
  44886. */
  44887. get rotationInProgress(): boolean;
  44888. private _onPrePointerObservableObserver;
  44889. private _onAfterCheckInputsObserver;
  44890. private _attachedCamera;
  44891. private _isPointerDown;
  44892. private _lastFrameTime;
  44893. private _lastInteractionTime;
  44894. private _cameraRotationSpeed;
  44895. /**
  44896. * Initializes the behavior.
  44897. */
  44898. init(): void;
  44899. /**
  44900. * Attaches the behavior to its arc rotate camera.
  44901. * @param camera Defines the camera to attach the behavior to
  44902. */
  44903. attach(camera: ArcRotateCamera): void;
  44904. /**
  44905. * Detaches the behavior from its current arc rotate camera.
  44906. */
  44907. detach(): void;
  44908. /**
  44909. * Returns true if user is scrolling.
  44910. * @return true if user is scrolling.
  44911. */
  44912. private _userIsZooming;
  44913. private _lastFrameRadius;
  44914. private _shouldAnimationStopForInteraction;
  44915. /**
  44916. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44917. */
  44918. private _applyUserInteraction;
  44919. private _userIsMoving;
  44920. }
  44921. }
  44922. declare module "babylonjs/Behaviors/Cameras/index" {
  44923. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44924. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44925. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44926. }
  44927. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44928. import { Mesh } from "babylonjs/Meshes/mesh";
  44929. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44930. import { Behavior } from "babylonjs/Behaviors/behavior";
  44931. /**
  44932. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44933. */
  44934. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44935. private ui;
  44936. /**
  44937. * The name of the behavior
  44938. */
  44939. name: string;
  44940. /**
  44941. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44942. */
  44943. distanceAwayFromFace: number;
  44944. /**
  44945. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44946. */
  44947. distanceAwayFromBottomOfFace: number;
  44948. private _faceVectors;
  44949. private _target;
  44950. private _scene;
  44951. private _onRenderObserver;
  44952. private _tmpMatrix;
  44953. private _tmpVector;
  44954. /**
  44955. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44956. * @param ui The transform node that should be attched to the mesh
  44957. */
  44958. constructor(ui: TransformNode);
  44959. /**
  44960. * Initializes the behavior
  44961. */
  44962. init(): void;
  44963. private _closestFace;
  44964. private _zeroVector;
  44965. private _lookAtTmpMatrix;
  44966. private _lookAtToRef;
  44967. /**
  44968. * Attaches the AttachToBoxBehavior to the passed in mesh
  44969. * @param target The mesh that the specified node will be attached to
  44970. */
  44971. attach(target: Mesh): void;
  44972. /**
  44973. * Detaches the behavior from the mesh
  44974. */
  44975. detach(): void;
  44976. }
  44977. }
  44978. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44979. import { Behavior } from "babylonjs/Behaviors/behavior";
  44980. import { Mesh } from "babylonjs/Meshes/mesh";
  44981. /**
  44982. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44983. */
  44984. export class FadeInOutBehavior implements Behavior<Mesh> {
  44985. /**
  44986. * Time in milliseconds to delay before fading in (Default: 0)
  44987. */
  44988. delay: number;
  44989. /**
  44990. * Time in milliseconds for the mesh to fade in (Default: 300)
  44991. */
  44992. fadeInTime: number;
  44993. private _millisecondsPerFrame;
  44994. private _hovered;
  44995. private _hoverValue;
  44996. private _ownerNode;
  44997. /**
  44998. * Instatiates the FadeInOutBehavior
  44999. */
  45000. constructor();
  45001. /**
  45002. * The name of the behavior
  45003. */
  45004. get name(): string;
  45005. /**
  45006. * Initializes the behavior
  45007. */
  45008. init(): void;
  45009. /**
  45010. * Attaches the fade behavior on the passed in mesh
  45011. * @param ownerNode The mesh that will be faded in/out once attached
  45012. */
  45013. attach(ownerNode: Mesh): void;
  45014. /**
  45015. * Detaches the behavior from the mesh
  45016. */
  45017. detach(): void;
  45018. /**
  45019. * Triggers the mesh to begin fading in or out
  45020. * @param value if the object should fade in or out (true to fade in)
  45021. */
  45022. fadeIn(value: boolean): void;
  45023. private _update;
  45024. private _setAllVisibility;
  45025. }
  45026. }
  45027. declare module "babylonjs/Misc/pivotTools" {
  45028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45029. /**
  45030. * Class containing a set of static utilities functions for managing Pivots
  45031. * @hidden
  45032. */
  45033. export class PivotTools {
  45034. private static _PivotCached;
  45035. private static _OldPivotPoint;
  45036. private static _PivotTranslation;
  45037. private static _PivotTmpVector;
  45038. private static _PivotPostMultiplyPivotMatrix;
  45039. /** @hidden */
  45040. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  45041. /** @hidden */
  45042. static _RestorePivotPoint(mesh: AbstractMesh): void;
  45043. }
  45044. }
  45045. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  45046. import { Scene } from "babylonjs/scene";
  45047. import { Vector4 } from "babylonjs/Maths/math.vector";
  45048. import { Mesh } from "babylonjs/Meshes/mesh";
  45049. import { Nullable } from "babylonjs/types";
  45050. import { Plane } from "babylonjs/Maths/math.plane";
  45051. /**
  45052. * Class containing static functions to help procedurally build meshes
  45053. */
  45054. export class PlaneBuilder {
  45055. /**
  45056. * Creates a plane mesh
  45057. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45058. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45059. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45063. * @param name defines the name of the mesh
  45064. * @param options defines the options used to create the mesh
  45065. * @param scene defines the hosting scene
  45066. * @returns the plane mesh
  45067. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45068. */
  45069. static CreatePlane(name: string, options: {
  45070. size?: number;
  45071. width?: number;
  45072. height?: number;
  45073. sideOrientation?: number;
  45074. frontUVs?: Vector4;
  45075. backUVs?: Vector4;
  45076. updatable?: boolean;
  45077. sourcePlane?: Plane;
  45078. }, scene?: Nullable<Scene>): Mesh;
  45079. }
  45080. }
  45081. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45082. import { Behavior } from "babylonjs/Behaviors/behavior";
  45083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45084. import { Observable } from "babylonjs/Misc/observable";
  45085. import { Vector3 } from "babylonjs/Maths/math.vector";
  45086. import { Ray } from "babylonjs/Culling/ray";
  45087. import "babylonjs/Meshes/Builders/planeBuilder";
  45088. /**
  45089. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45090. */
  45091. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45092. private static _AnyMouseID;
  45093. /**
  45094. * Abstract mesh the behavior is set on
  45095. */
  45096. attachedNode: AbstractMesh;
  45097. private _dragPlane;
  45098. private _scene;
  45099. private _pointerObserver;
  45100. private _beforeRenderObserver;
  45101. private static _planeScene;
  45102. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45103. /**
  45104. * 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)
  45105. */
  45106. maxDragAngle: number;
  45107. /**
  45108. * @hidden
  45109. */
  45110. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45111. /**
  45112. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45113. */
  45114. currentDraggingPointerID: number;
  45115. /**
  45116. * The last position where the pointer hit the drag plane in world space
  45117. */
  45118. lastDragPosition: Vector3;
  45119. /**
  45120. * If the behavior is currently in a dragging state
  45121. */
  45122. dragging: boolean;
  45123. /**
  45124. * 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)
  45125. */
  45126. dragDeltaRatio: number;
  45127. /**
  45128. * If the drag plane orientation should be updated during the dragging (Default: true)
  45129. */
  45130. updateDragPlane: boolean;
  45131. private _debugMode;
  45132. private _moving;
  45133. /**
  45134. * Fires each time the attached mesh is dragged with the pointer
  45135. * * delta between last drag position and current drag position in world space
  45136. * * dragDistance along the drag axis
  45137. * * dragPlaneNormal normal of the current drag plane used during the drag
  45138. * * dragPlanePoint in world space where the drag intersects the drag plane
  45139. */
  45140. onDragObservable: Observable<{
  45141. delta: Vector3;
  45142. dragPlanePoint: Vector3;
  45143. dragPlaneNormal: Vector3;
  45144. dragDistance: number;
  45145. pointerId: number;
  45146. }>;
  45147. /**
  45148. * Fires each time a drag begins (eg. mouse down on mesh)
  45149. */
  45150. onDragStartObservable: Observable<{
  45151. dragPlanePoint: Vector3;
  45152. pointerId: number;
  45153. }>;
  45154. /**
  45155. * Fires each time a drag ends (eg. mouse release after drag)
  45156. */
  45157. onDragEndObservable: Observable<{
  45158. dragPlanePoint: Vector3;
  45159. pointerId: number;
  45160. }>;
  45161. /**
  45162. * If the attached mesh should be moved when dragged
  45163. */
  45164. moveAttached: boolean;
  45165. /**
  45166. * If the drag behavior will react to drag events (Default: true)
  45167. */
  45168. enabled: boolean;
  45169. /**
  45170. * If pointer events should start and release the drag (Default: true)
  45171. */
  45172. startAndReleaseDragOnPointerEvents: boolean;
  45173. /**
  45174. * If camera controls should be detached during the drag
  45175. */
  45176. detachCameraControls: boolean;
  45177. /**
  45178. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45179. */
  45180. useObjectOrientationForDragging: boolean;
  45181. private _options;
  45182. /**
  45183. * Gets the options used by the behavior
  45184. */
  45185. get options(): {
  45186. dragAxis?: Vector3;
  45187. dragPlaneNormal?: Vector3;
  45188. };
  45189. /**
  45190. * Sets the options used by the behavior
  45191. */
  45192. set options(options: {
  45193. dragAxis?: Vector3;
  45194. dragPlaneNormal?: Vector3;
  45195. });
  45196. /**
  45197. * Creates a pointer drag behavior that can be attached to a mesh
  45198. * @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)
  45199. */
  45200. constructor(options?: {
  45201. dragAxis?: Vector3;
  45202. dragPlaneNormal?: Vector3;
  45203. });
  45204. /**
  45205. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45206. */
  45207. validateDrag: (targetPosition: Vector3) => boolean;
  45208. /**
  45209. * The name of the behavior
  45210. */
  45211. get name(): string;
  45212. /**
  45213. * Initializes the behavior
  45214. */
  45215. init(): void;
  45216. private _tmpVector;
  45217. private _alternatePickedPoint;
  45218. private _worldDragAxis;
  45219. private _targetPosition;
  45220. private _attachedElement;
  45221. /**
  45222. * Attaches the drag behavior the passed in mesh
  45223. * @param ownerNode The mesh that will be dragged around once attached
  45224. * @param predicate Predicate to use for pick filtering
  45225. */
  45226. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45227. /**
  45228. * Force relase the drag action by code.
  45229. */
  45230. releaseDrag(): void;
  45231. private _startDragRay;
  45232. private _lastPointerRay;
  45233. /**
  45234. * Simulates the start of a pointer drag event on the behavior
  45235. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45236. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45237. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45238. */
  45239. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45240. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45241. private _dragDelta;
  45242. protected _moveDrag(ray: Ray): void;
  45243. private _pickWithRayOnDragPlane;
  45244. private _pointA;
  45245. private _pointC;
  45246. private _localAxis;
  45247. private _lookAt;
  45248. private _updateDragPlanePosition;
  45249. /**
  45250. * Detaches the behavior from the mesh
  45251. */
  45252. detach(): void;
  45253. }
  45254. }
  45255. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45256. import { Mesh } from "babylonjs/Meshes/mesh";
  45257. import { Behavior } from "babylonjs/Behaviors/behavior";
  45258. /**
  45259. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45260. */
  45261. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45262. private _dragBehaviorA;
  45263. private _dragBehaviorB;
  45264. private _startDistance;
  45265. private _initialScale;
  45266. private _targetScale;
  45267. private _ownerNode;
  45268. private _sceneRenderObserver;
  45269. /**
  45270. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45271. */
  45272. constructor();
  45273. /**
  45274. * The name of the behavior
  45275. */
  45276. get name(): string;
  45277. /**
  45278. * Initializes the behavior
  45279. */
  45280. init(): void;
  45281. private _getCurrentDistance;
  45282. /**
  45283. * Attaches the scale behavior the passed in mesh
  45284. * @param ownerNode The mesh that will be scaled around once attached
  45285. */
  45286. attach(ownerNode: Mesh): void;
  45287. /**
  45288. * Detaches the behavior from the mesh
  45289. */
  45290. detach(): void;
  45291. }
  45292. }
  45293. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45294. import { Behavior } from "babylonjs/Behaviors/behavior";
  45295. import { Mesh } from "babylonjs/Meshes/mesh";
  45296. import { Observable } from "babylonjs/Misc/observable";
  45297. /**
  45298. * 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
  45299. */
  45300. export class SixDofDragBehavior implements Behavior<Mesh> {
  45301. private static _virtualScene;
  45302. private _ownerNode;
  45303. private _sceneRenderObserver;
  45304. private _scene;
  45305. private _targetPosition;
  45306. private _virtualOriginMesh;
  45307. private _virtualDragMesh;
  45308. private _pointerObserver;
  45309. private _moving;
  45310. private _startingOrientation;
  45311. private _attachedElement;
  45312. /**
  45313. * 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)
  45314. */
  45315. private zDragFactor;
  45316. /**
  45317. * If the object should rotate to face the drag origin
  45318. */
  45319. rotateDraggedObject: boolean;
  45320. /**
  45321. * If the behavior is currently in a dragging state
  45322. */
  45323. dragging: boolean;
  45324. /**
  45325. * 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)
  45326. */
  45327. dragDeltaRatio: number;
  45328. /**
  45329. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45330. */
  45331. currentDraggingPointerID: number;
  45332. /**
  45333. * If camera controls should be detached during the drag
  45334. */
  45335. detachCameraControls: boolean;
  45336. /**
  45337. * Fires each time a drag starts
  45338. */
  45339. onDragStartObservable: Observable<{}>;
  45340. /**
  45341. * Fires each time a drag ends (eg. mouse release after drag)
  45342. */
  45343. onDragEndObservable: Observable<{}>;
  45344. /**
  45345. * 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
  45346. */
  45347. constructor();
  45348. /**
  45349. * The name of the behavior
  45350. */
  45351. get name(): string;
  45352. /**
  45353. * Initializes the behavior
  45354. */
  45355. init(): void;
  45356. /**
  45357. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45358. */
  45359. private get _pointerCamera();
  45360. /**
  45361. * Attaches the scale behavior the passed in mesh
  45362. * @param ownerNode The mesh that will be scaled around once attached
  45363. */
  45364. attach(ownerNode: Mesh): void;
  45365. /**
  45366. * Detaches the behavior from the mesh
  45367. */
  45368. detach(): void;
  45369. }
  45370. }
  45371. declare module "babylonjs/Behaviors/Meshes/index" {
  45372. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45373. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45374. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45375. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45376. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45377. }
  45378. declare module "babylonjs/Behaviors/index" {
  45379. export * from "babylonjs/Behaviors/behavior";
  45380. export * from "babylonjs/Behaviors/Cameras/index";
  45381. export * from "babylonjs/Behaviors/Meshes/index";
  45382. }
  45383. declare module "babylonjs/Bones/boneIKController" {
  45384. import { Bone } from "babylonjs/Bones/bone";
  45385. import { Vector3 } from "babylonjs/Maths/math.vector";
  45386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45387. import { Nullable } from "babylonjs/types";
  45388. /**
  45389. * Class used to apply inverse kinematics to bones
  45390. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45391. */
  45392. export class BoneIKController {
  45393. private static _tmpVecs;
  45394. private static _tmpQuat;
  45395. private static _tmpMats;
  45396. /**
  45397. * Gets or sets the target mesh
  45398. */
  45399. targetMesh: AbstractMesh;
  45400. /** Gets or sets the mesh used as pole */
  45401. poleTargetMesh: AbstractMesh;
  45402. /**
  45403. * Gets or sets the bone used as pole
  45404. */
  45405. poleTargetBone: Nullable<Bone>;
  45406. /**
  45407. * Gets or sets the target position
  45408. */
  45409. targetPosition: Vector3;
  45410. /**
  45411. * Gets or sets the pole target position
  45412. */
  45413. poleTargetPosition: Vector3;
  45414. /**
  45415. * Gets or sets the pole target local offset
  45416. */
  45417. poleTargetLocalOffset: Vector3;
  45418. /**
  45419. * Gets or sets the pole angle
  45420. */
  45421. poleAngle: number;
  45422. /**
  45423. * Gets or sets the mesh associated with the controller
  45424. */
  45425. mesh: AbstractMesh;
  45426. /**
  45427. * 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)
  45428. */
  45429. slerpAmount: number;
  45430. private _bone1Quat;
  45431. private _bone1Mat;
  45432. private _bone2Ang;
  45433. private _bone1;
  45434. private _bone2;
  45435. private _bone1Length;
  45436. private _bone2Length;
  45437. private _maxAngle;
  45438. private _maxReach;
  45439. private _rightHandedSystem;
  45440. private _bendAxis;
  45441. private _slerping;
  45442. private _adjustRoll;
  45443. /**
  45444. * Gets or sets maximum allowed angle
  45445. */
  45446. get maxAngle(): number;
  45447. set maxAngle(value: number);
  45448. /**
  45449. * Creates a new BoneIKController
  45450. * @param mesh defines the mesh to control
  45451. * @param bone defines the bone to control
  45452. * @param options defines options to set up the controller
  45453. */
  45454. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45455. targetMesh?: AbstractMesh;
  45456. poleTargetMesh?: AbstractMesh;
  45457. poleTargetBone?: Bone;
  45458. poleTargetLocalOffset?: Vector3;
  45459. poleAngle?: number;
  45460. bendAxis?: Vector3;
  45461. maxAngle?: number;
  45462. slerpAmount?: number;
  45463. });
  45464. private _setMaxAngle;
  45465. /**
  45466. * Force the controller to update the bones
  45467. */
  45468. update(): void;
  45469. }
  45470. }
  45471. declare module "babylonjs/Bones/boneLookController" {
  45472. import { Vector3 } from "babylonjs/Maths/math.vector";
  45473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45474. import { Bone } from "babylonjs/Bones/bone";
  45475. import { Space } from "babylonjs/Maths/math.axis";
  45476. /**
  45477. * Class used to make a bone look toward a point in space
  45478. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45479. */
  45480. export class BoneLookController {
  45481. private static _tmpVecs;
  45482. private static _tmpQuat;
  45483. private static _tmpMats;
  45484. /**
  45485. * The target Vector3 that the bone will look at
  45486. */
  45487. target: Vector3;
  45488. /**
  45489. * The mesh that the bone is attached to
  45490. */
  45491. mesh: AbstractMesh;
  45492. /**
  45493. * The bone that will be looking to the target
  45494. */
  45495. bone: Bone;
  45496. /**
  45497. * The up axis of the coordinate system that is used when the bone is rotated
  45498. */
  45499. upAxis: Vector3;
  45500. /**
  45501. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45502. */
  45503. upAxisSpace: Space;
  45504. /**
  45505. * Used to make an adjustment to the yaw of the bone
  45506. */
  45507. adjustYaw: number;
  45508. /**
  45509. * Used to make an adjustment to the pitch of the bone
  45510. */
  45511. adjustPitch: number;
  45512. /**
  45513. * Used to make an adjustment to the roll of the bone
  45514. */
  45515. adjustRoll: number;
  45516. /**
  45517. * 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)
  45518. */
  45519. slerpAmount: number;
  45520. private _minYaw;
  45521. private _maxYaw;
  45522. private _minPitch;
  45523. private _maxPitch;
  45524. private _minYawSin;
  45525. private _minYawCos;
  45526. private _maxYawSin;
  45527. private _maxYawCos;
  45528. private _midYawConstraint;
  45529. private _minPitchTan;
  45530. private _maxPitchTan;
  45531. private _boneQuat;
  45532. private _slerping;
  45533. private _transformYawPitch;
  45534. private _transformYawPitchInv;
  45535. private _firstFrameSkipped;
  45536. private _yawRange;
  45537. private _fowardAxis;
  45538. /**
  45539. * Gets or sets the minimum yaw angle that the bone can look to
  45540. */
  45541. get minYaw(): number;
  45542. set minYaw(value: number);
  45543. /**
  45544. * Gets or sets the maximum yaw angle that the bone can look to
  45545. */
  45546. get maxYaw(): number;
  45547. set maxYaw(value: number);
  45548. /**
  45549. * Gets or sets the minimum pitch angle that the bone can look to
  45550. */
  45551. get minPitch(): number;
  45552. set minPitch(value: number);
  45553. /**
  45554. * Gets or sets the maximum pitch angle that the bone can look to
  45555. */
  45556. get maxPitch(): number;
  45557. set maxPitch(value: number);
  45558. /**
  45559. * Create a BoneLookController
  45560. * @param mesh the mesh that the bone belongs to
  45561. * @param bone the bone that will be looking to the target
  45562. * @param target the target Vector3 to look at
  45563. * @param options optional settings:
  45564. * * maxYaw: the maximum angle the bone will yaw to
  45565. * * minYaw: the minimum angle the bone will yaw to
  45566. * * maxPitch: the maximum angle the bone will pitch to
  45567. * * minPitch: the minimum angle the bone will yaw to
  45568. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45569. * * upAxis: the up axis of the coordinate system
  45570. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45571. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45572. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45573. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45574. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45575. * * adjustRoll: used to make an adjustment to the roll of the bone
  45576. **/
  45577. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45578. maxYaw?: number;
  45579. minYaw?: number;
  45580. maxPitch?: number;
  45581. minPitch?: number;
  45582. slerpAmount?: number;
  45583. upAxis?: Vector3;
  45584. upAxisSpace?: Space;
  45585. yawAxis?: Vector3;
  45586. pitchAxis?: Vector3;
  45587. adjustYaw?: number;
  45588. adjustPitch?: number;
  45589. adjustRoll?: number;
  45590. });
  45591. /**
  45592. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45593. */
  45594. update(): void;
  45595. private _getAngleDiff;
  45596. private _getAngleBetween;
  45597. private _isAngleBetween;
  45598. }
  45599. }
  45600. declare module "babylonjs/Bones/index" {
  45601. export * from "babylonjs/Bones/bone";
  45602. export * from "babylonjs/Bones/boneIKController";
  45603. export * from "babylonjs/Bones/boneLookController";
  45604. export * from "babylonjs/Bones/skeleton";
  45605. }
  45606. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45607. import { Nullable } from "babylonjs/types";
  45608. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45609. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45610. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45611. /**
  45612. * Manage the gamepad inputs to control an arc rotate camera.
  45613. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45614. */
  45615. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45616. /**
  45617. * Defines the camera the input is attached to.
  45618. */
  45619. camera: ArcRotateCamera;
  45620. /**
  45621. * Defines the gamepad the input is gathering event from.
  45622. */
  45623. gamepad: Nullable<Gamepad>;
  45624. /**
  45625. * Defines the gamepad rotation sensiblity.
  45626. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45627. */
  45628. gamepadRotationSensibility: number;
  45629. /**
  45630. * Defines the gamepad move sensiblity.
  45631. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45632. */
  45633. gamepadMoveSensibility: number;
  45634. private _yAxisScale;
  45635. /**
  45636. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45637. */
  45638. get invertYAxis(): boolean;
  45639. set invertYAxis(value: boolean);
  45640. private _onGamepadConnectedObserver;
  45641. private _onGamepadDisconnectedObserver;
  45642. /**
  45643. * Attach the input controls to a specific dom element to get the input from.
  45644. * @param element Defines the element the controls should be listened from
  45645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45646. */
  45647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45648. /**
  45649. * Detach the current controls from the specified dom element.
  45650. * @param element Defines the element to stop listening the inputs from
  45651. */
  45652. detachControl(element: Nullable<HTMLElement>): void;
  45653. /**
  45654. * Update the current camera state depending on the inputs that have been used this frame.
  45655. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45656. */
  45657. checkInputs(): void;
  45658. /**
  45659. * Gets the class name of the current intput.
  45660. * @returns the class name
  45661. */
  45662. getClassName(): string;
  45663. /**
  45664. * Get the friendly name associated with the input class.
  45665. * @returns the input friendly name
  45666. */
  45667. getSimpleName(): string;
  45668. }
  45669. }
  45670. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45671. import { Nullable } from "babylonjs/types";
  45672. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45673. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45674. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45675. interface ArcRotateCameraInputsManager {
  45676. /**
  45677. * Add orientation input support to the input manager.
  45678. * @returns the current input manager
  45679. */
  45680. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45681. }
  45682. }
  45683. /**
  45684. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45685. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45686. */
  45687. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45688. /**
  45689. * Defines the camera the input is attached to.
  45690. */
  45691. camera: ArcRotateCamera;
  45692. /**
  45693. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45694. */
  45695. alphaCorrection: number;
  45696. /**
  45697. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45698. */
  45699. gammaCorrection: number;
  45700. private _alpha;
  45701. private _gamma;
  45702. private _dirty;
  45703. private _deviceOrientationHandler;
  45704. /**
  45705. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45706. */
  45707. constructor();
  45708. /**
  45709. * Attach the input controls to a specific dom element to get the input from.
  45710. * @param element Defines the element the controls should be listened from
  45711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45712. */
  45713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45714. /** @hidden */
  45715. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45716. /**
  45717. * Update the current camera state depending on the inputs that have been used this frame.
  45718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45719. */
  45720. checkInputs(): void;
  45721. /**
  45722. * Detach the current controls from the specified dom element.
  45723. * @param element Defines the element to stop listening the inputs from
  45724. */
  45725. detachControl(element: Nullable<HTMLElement>): void;
  45726. /**
  45727. * Gets the class name of the current intput.
  45728. * @returns the class name
  45729. */
  45730. getClassName(): string;
  45731. /**
  45732. * Get the friendly name associated with the input class.
  45733. * @returns the input friendly name
  45734. */
  45735. getSimpleName(): string;
  45736. }
  45737. }
  45738. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45739. import { Nullable } from "babylonjs/types";
  45740. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45741. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45742. /**
  45743. * Listen to mouse events to control the camera.
  45744. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45745. */
  45746. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45747. /**
  45748. * Defines the camera the input is attached to.
  45749. */
  45750. camera: FlyCamera;
  45751. /**
  45752. * Defines if touch is enabled. (Default is true.)
  45753. */
  45754. touchEnabled: boolean;
  45755. /**
  45756. * Defines the buttons associated with the input to handle camera rotation.
  45757. */
  45758. buttons: number[];
  45759. /**
  45760. * Assign buttons for Yaw control.
  45761. */
  45762. buttonsYaw: number[];
  45763. /**
  45764. * Assign buttons for Pitch control.
  45765. */
  45766. buttonsPitch: number[];
  45767. /**
  45768. * Assign buttons for Roll control.
  45769. */
  45770. buttonsRoll: number[];
  45771. /**
  45772. * Detect if any button is being pressed while mouse is moved.
  45773. * -1 = Mouse locked.
  45774. * 0 = Left button.
  45775. * 1 = Middle Button.
  45776. * 2 = Right Button.
  45777. */
  45778. activeButton: number;
  45779. /**
  45780. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45781. * Higher values reduce its sensitivity.
  45782. */
  45783. angularSensibility: number;
  45784. private _mousemoveCallback;
  45785. private _observer;
  45786. private _rollObserver;
  45787. private previousPosition;
  45788. private noPreventDefault;
  45789. private element;
  45790. /**
  45791. * Listen to mouse events to control the camera.
  45792. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45793. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45794. */
  45795. constructor(touchEnabled?: boolean);
  45796. /**
  45797. * Attach the mouse control to the HTML DOM element.
  45798. * @param element Defines the element that listens to the input events.
  45799. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45800. */
  45801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45802. /**
  45803. * Detach the current controls from the specified dom element.
  45804. * @param element Defines the element to stop listening the inputs from
  45805. */
  45806. detachControl(element: Nullable<HTMLElement>): void;
  45807. /**
  45808. * Gets the class name of the current input.
  45809. * @returns the class name.
  45810. */
  45811. getClassName(): string;
  45812. /**
  45813. * Get the friendly name associated with the input class.
  45814. * @returns the input's friendly name.
  45815. */
  45816. getSimpleName(): string;
  45817. private _pointerInput;
  45818. private _onMouseMove;
  45819. /**
  45820. * Rotate camera by mouse offset.
  45821. */
  45822. private rotateCamera;
  45823. }
  45824. }
  45825. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45826. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45827. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45828. /**
  45829. * Default Inputs manager for the FlyCamera.
  45830. * It groups all the default supported inputs for ease of use.
  45831. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45832. */
  45833. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45834. /**
  45835. * Instantiates a new FlyCameraInputsManager.
  45836. * @param camera Defines the camera the inputs belong to.
  45837. */
  45838. constructor(camera: FlyCamera);
  45839. /**
  45840. * Add keyboard input support to the input manager.
  45841. * @returns the new FlyCameraKeyboardMoveInput().
  45842. */
  45843. addKeyboard(): FlyCameraInputsManager;
  45844. /**
  45845. * Add mouse input support to the input manager.
  45846. * @param touchEnabled Enable touch screen support.
  45847. * @returns the new FlyCameraMouseInput().
  45848. */
  45849. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45850. }
  45851. }
  45852. declare module "babylonjs/Cameras/flyCamera" {
  45853. import { Scene } from "babylonjs/scene";
  45854. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45856. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45857. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45858. /**
  45859. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45860. * such as in a 3D Space Shooter or a Flight Simulator.
  45861. */
  45862. export class FlyCamera extends TargetCamera {
  45863. /**
  45864. * Define the collision ellipsoid of the camera.
  45865. * This is helpful for simulating a camera body, like a player's body.
  45866. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45867. */
  45868. ellipsoid: Vector3;
  45869. /**
  45870. * Define an offset for the position of the ellipsoid around the camera.
  45871. * This can be helpful if the camera is attached away from the player's body center,
  45872. * such as at its head.
  45873. */
  45874. ellipsoidOffset: Vector3;
  45875. /**
  45876. * Enable or disable collisions of the camera with the rest of the scene objects.
  45877. */
  45878. checkCollisions: boolean;
  45879. /**
  45880. * Enable or disable gravity on the camera.
  45881. */
  45882. applyGravity: boolean;
  45883. /**
  45884. * Define the current direction the camera is moving to.
  45885. */
  45886. cameraDirection: Vector3;
  45887. /**
  45888. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45889. * This overrides and empties cameraRotation.
  45890. */
  45891. rotationQuaternion: Quaternion;
  45892. /**
  45893. * Track Roll to maintain the wanted Rolling when looking around.
  45894. */
  45895. _trackRoll: number;
  45896. /**
  45897. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45898. */
  45899. rollCorrect: number;
  45900. /**
  45901. * Mimic a banked turn, Rolling the camera when Yawing.
  45902. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45903. */
  45904. bankedTurn: boolean;
  45905. /**
  45906. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45907. */
  45908. bankedTurnLimit: number;
  45909. /**
  45910. * Value of 0 disables the banked Roll.
  45911. * Value of 1 is equal to the Yaw angle in radians.
  45912. */
  45913. bankedTurnMultiplier: number;
  45914. /**
  45915. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45916. */
  45917. inputs: FlyCameraInputsManager;
  45918. /**
  45919. * Gets the input sensibility for mouse input.
  45920. * Higher values reduce sensitivity.
  45921. */
  45922. get angularSensibility(): number;
  45923. /**
  45924. * Sets the input sensibility for a mouse input.
  45925. * Higher values reduce sensitivity.
  45926. */
  45927. set angularSensibility(value: number);
  45928. /**
  45929. * Get the keys for camera movement forward.
  45930. */
  45931. get keysForward(): number[];
  45932. /**
  45933. * Set the keys for camera movement forward.
  45934. */
  45935. set keysForward(value: number[]);
  45936. /**
  45937. * Get the keys for camera movement backward.
  45938. */
  45939. get keysBackward(): number[];
  45940. set keysBackward(value: number[]);
  45941. /**
  45942. * Get the keys for camera movement up.
  45943. */
  45944. get keysUp(): number[];
  45945. /**
  45946. * Set the keys for camera movement up.
  45947. */
  45948. set keysUp(value: number[]);
  45949. /**
  45950. * Get the keys for camera movement down.
  45951. */
  45952. get keysDown(): number[];
  45953. /**
  45954. * Set the keys for camera movement down.
  45955. */
  45956. set keysDown(value: number[]);
  45957. /**
  45958. * Get the keys for camera movement left.
  45959. */
  45960. get keysLeft(): number[];
  45961. /**
  45962. * Set the keys for camera movement left.
  45963. */
  45964. set keysLeft(value: number[]);
  45965. /**
  45966. * Set the keys for camera movement right.
  45967. */
  45968. get keysRight(): number[];
  45969. /**
  45970. * Set the keys for camera movement right.
  45971. */
  45972. set keysRight(value: number[]);
  45973. /**
  45974. * Event raised when the camera collides with a mesh in the scene.
  45975. */
  45976. onCollide: (collidedMesh: AbstractMesh) => void;
  45977. private _collider;
  45978. private _needMoveForGravity;
  45979. private _oldPosition;
  45980. private _diffPosition;
  45981. private _newPosition;
  45982. /** @hidden */
  45983. _localDirection: Vector3;
  45984. /** @hidden */
  45985. _transformedDirection: Vector3;
  45986. /**
  45987. * Instantiates a FlyCamera.
  45988. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45989. * such as in a 3D Space Shooter or a Flight Simulator.
  45990. * @param name Define the name of the camera in the scene.
  45991. * @param position Define the starting position of the camera in the scene.
  45992. * @param scene Define the scene the camera belongs to.
  45993. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45994. */
  45995. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45996. /**
  45997. * Attach a control to the HTML DOM element.
  45998. * @param element Defines the element that listens to the input events.
  45999. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  46000. */
  46001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46002. /**
  46003. * Detach a control from the HTML DOM element.
  46004. * The camera will stop reacting to that input.
  46005. * @param element Defines the element that listens to the input events.
  46006. */
  46007. detachControl(element: HTMLElement): void;
  46008. private _collisionMask;
  46009. /**
  46010. * Get the mask that the camera ignores in collision events.
  46011. */
  46012. get collisionMask(): number;
  46013. /**
  46014. * Set the mask that the camera ignores in collision events.
  46015. */
  46016. set collisionMask(mask: number);
  46017. /** @hidden */
  46018. _collideWithWorld(displacement: Vector3): void;
  46019. /** @hidden */
  46020. private _onCollisionPositionChange;
  46021. /** @hidden */
  46022. _checkInputs(): void;
  46023. /** @hidden */
  46024. _decideIfNeedsToMove(): boolean;
  46025. /** @hidden */
  46026. _updatePosition(): void;
  46027. /**
  46028. * Restore the Roll to its target value at the rate specified.
  46029. * @param rate - Higher means slower restoring.
  46030. * @hidden
  46031. */
  46032. restoreRoll(rate: number): void;
  46033. /**
  46034. * Destroy the camera and release the current resources held by it.
  46035. */
  46036. dispose(): void;
  46037. /**
  46038. * Get the current object class name.
  46039. * @returns the class name.
  46040. */
  46041. getClassName(): string;
  46042. }
  46043. }
  46044. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  46045. import { Nullable } from "babylonjs/types";
  46046. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46047. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  46048. /**
  46049. * Listen to keyboard events to control the camera.
  46050. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46051. */
  46052. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46053. /**
  46054. * Defines the camera the input is attached to.
  46055. */
  46056. camera: FlyCamera;
  46057. /**
  46058. * The list of keyboard keys used to control the forward move of the camera.
  46059. */
  46060. keysForward: number[];
  46061. /**
  46062. * The list of keyboard keys used to control the backward move of the camera.
  46063. */
  46064. keysBackward: number[];
  46065. /**
  46066. * The list of keyboard keys used to control the forward move of the camera.
  46067. */
  46068. keysUp: number[];
  46069. /**
  46070. * The list of keyboard keys used to control the backward move of the camera.
  46071. */
  46072. keysDown: number[];
  46073. /**
  46074. * The list of keyboard keys used to control the right strafe move of the camera.
  46075. */
  46076. keysRight: number[];
  46077. /**
  46078. * The list of keyboard keys used to control the left strafe move of the camera.
  46079. */
  46080. keysLeft: number[];
  46081. private _keys;
  46082. private _onCanvasBlurObserver;
  46083. private _onKeyboardObserver;
  46084. private _engine;
  46085. private _scene;
  46086. /**
  46087. * Attach the input controls to a specific dom element to get the input from.
  46088. * @param element Defines the element the controls should be listened from
  46089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46090. */
  46091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46092. /**
  46093. * Detach the current controls from the specified dom element.
  46094. * @param element Defines the element to stop listening the inputs from
  46095. */
  46096. detachControl(element: Nullable<HTMLElement>): void;
  46097. /**
  46098. * Gets the class name of the current intput.
  46099. * @returns the class name
  46100. */
  46101. getClassName(): string;
  46102. /** @hidden */
  46103. _onLostFocus(e: FocusEvent): void;
  46104. /**
  46105. * Get the friendly name associated with the input class.
  46106. * @returns the input friendly name
  46107. */
  46108. getSimpleName(): string;
  46109. /**
  46110. * Update the current camera state depending on the inputs that have been used this frame.
  46111. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46112. */
  46113. checkInputs(): void;
  46114. }
  46115. }
  46116. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46117. import { Nullable } from "babylonjs/types";
  46118. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46119. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46120. /**
  46121. * Manage the mouse wheel inputs to control a follow camera.
  46122. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46123. */
  46124. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46125. /**
  46126. * Defines the camera the input is attached to.
  46127. */
  46128. camera: FollowCamera;
  46129. /**
  46130. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46131. */
  46132. axisControlRadius: boolean;
  46133. /**
  46134. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46135. */
  46136. axisControlHeight: boolean;
  46137. /**
  46138. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46139. */
  46140. axisControlRotation: boolean;
  46141. /**
  46142. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46143. * relation to mouseWheel events.
  46144. */
  46145. wheelPrecision: number;
  46146. /**
  46147. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46148. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46149. */
  46150. wheelDeltaPercentage: number;
  46151. private _wheel;
  46152. private _observer;
  46153. /**
  46154. * Attach the input controls to a specific dom element to get the input from.
  46155. * @param element Defines the element the controls should be listened from
  46156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46157. */
  46158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46159. /**
  46160. * Detach the current controls from the specified dom element.
  46161. * @param element Defines the element to stop listening the inputs from
  46162. */
  46163. detachControl(element: Nullable<HTMLElement>): void;
  46164. /**
  46165. * Gets the class name of the current intput.
  46166. * @returns the class name
  46167. */
  46168. getClassName(): string;
  46169. /**
  46170. * Get the friendly name associated with the input class.
  46171. * @returns the input friendly name
  46172. */
  46173. getSimpleName(): string;
  46174. }
  46175. }
  46176. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46177. import { Nullable } from "babylonjs/types";
  46178. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46179. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46180. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46181. /**
  46182. * Manage the pointers inputs to control an follow camera.
  46183. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46184. */
  46185. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46186. /**
  46187. * Defines the camera the input is attached to.
  46188. */
  46189. camera: FollowCamera;
  46190. /**
  46191. * Gets the class name of the current input.
  46192. * @returns the class name
  46193. */
  46194. getClassName(): string;
  46195. /**
  46196. * Defines the pointer angular sensibility along the X axis or how fast is
  46197. * the camera rotating.
  46198. * A negative number will reverse the axis direction.
  46199. */
  46200. angularSensibilityX: number;
  46201. /**
  46202. * Defines the pointer angular sensibility along the Y axis or how fast is
  46203. * the camera rotating.
  46204. * A negative number will reverse the axis direction.
  46205. */
  46206. angularSensibilityY: number;
  46207. /**
  46208. * Defines the pointer pinch precision or how fast is the camera zooming.
  46209. * A negative number will reverse the axis direction.
  46210. */
  46211. pinchPrecision: number;
  46212. /**
  46213. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46214. * from 0.
  46215. * It defines the percentage of current camera.radius to use as delta when
  46216. * pinch zoom is used.
  46217. */
  46218. pinchDeltaPercentage: number;
  46219. /**
  46220. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46221. */
  46222. axisXControlRadius: boolean;
  46223. /**
  46224. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46225. */
  46226. axisXControlHeight: boolean;
  46227. /**
  46228. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46229. */
  46230. axisXControlRotation: boolean;
  46231. /**
  46232. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46233. */
  46234. axisYControlRadius: boolean;
  46235. /**
  46236. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46237. */
  46238. axisYControlHeight: boolean;
  46239. /**
  46240. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46241. */
  46242. axisYControlRotation: boolean;
  46243. /**
  46244. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46245. */
  46246. axisPinchControlRadius: boolean;
  46247. /**
  46248. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46249. */
  46250. axisPinchControlHeight: boolean;
  46251. /**
  46252. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46253. */
  46254. axisPinchControlRotation: boolean;
  46255. /**
  46256. * Log error messages if basic misconfiguration has occurred.
  46257. */
  46258. warningEnable: boolean;
  46259. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46260. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46261. private _warningCounter;
  46262. private _warning;
  46263. }
  46264. }
  46265. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46266. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46267. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46268. /**
  46269. * Default Inputs manager for the FollowCamera.
  46270. * It groups all the default supported inputs for ease of use.
  46271. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46272. */
  46273. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46274. /**
  46275. * Instantiates a new FollowCameraInputsManager.
  46276. * @param camera Defines the camera the inputs belong to
  46277. */
  46278. constructor(camera: FollowCamera);
  46279. /**
  46280. * Add keyboard input support to the input manager.
  46281. * @returns the current input manager
  46282. */
  46283. addKeyboard(): FollowCameraInputsManager;
  46284. /**
  46285. * Add mouse wheel input support to the input manager.
  46286. * @returns the current input manager
  46287. */
  46288. addMouseWheel(): FollowCameraInputsManager;
  46289. /**
  46290. * Add pointers input support to the input manager.
  46291. * @returns the current input manager
  46292. */
  46293. addPointers(): FollowCameraInputsManager;
  46294. /**
  46295. * Add orientation input support to the input manager.
  46296. * @returns the current input manager
  46297. */
  46298. addVRDeviceOrientation(): FollowCameraInputsManager;
  46299. }
  46300. }
  46301. declare module "babylonjs/Cameras/followCamera" {
  46302. import { Nullable } from "babylonjs/types";
  46303. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46304. import { Scene } from "babylonjs/scene";
  46305. import { Vector3 } from "babylonjs/Maths/math.vector";
  46306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46307. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46308. /**
  46309. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46310. * an arc rotate version arcFollowCamera are available.
  46311. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46312. */
  46313. export class FollowCamera extends TargetCamera {
  46314. /**
  46315. * Distance the follow camera should follow an object at
  46316. */
  46317. radius: number;
  46318. /**
  46319. * Minimum allowed distance of the camera to the axis of rotation
  46320. * (The camera can not get closer).
  46321. * This can help limiting how the Camera is able to move in the scene.
  46322. */
  46323. lowerRadiusLimit: Nullable<number>;
  46324. /**
  46325. * Maximum allowed distance of the camera to the axis of rotation
  46326. * (The camera can not get further).
  46327. * This can help limiting how the Camera is able to move in the scene.
  46328. */
  46329. upperRadiusLimit: Nullable<number>;
  46330. /**
  46331. * Define a rotation offset between the camera and the object it follows
  46332. */
  46333. rotationOffset: number;
  46334. /**
  46335. * Minimum allowed angle to camera position relative to target object.
  46336. * This can help limiting how the Camera is able to move in the scene.
  46337. */
  46338. lowerRotationOffsetLimit: Nullable<number>;
  46339. /**
  46340. * Maximum allowed angle to camera position relative to target object.
  46341. * This can help limiting how the Camera is able to move in the scene.
  46342. */
  46343. upperRotationOffsetLimit: Nullable<number>;
  46344. /**
  46345. * Define a height offset between the camera and the object it follows.
  46346. * It can help following an object from the top (like a car chaing a plane)
  46347. */
  46348. heightOffset: number;
  46349. /**
  46350. * Minimum allowed height of camera position relative to target object.
  46351. * This can help limiting how the Camera is able to move in the scene.
  46352. */
  46353. lowerHeightOffsetLimit: Nullable<number>;
  46354. /**
  46355. * Maximum allowed height of camera position relative to target object.
  46356. * This can help limiting how the Camera is able to move in the scene.
  46357. */
  46358. upperHeightOffsetLimit: Nullable<number>;
  46359. /**
  46360. * Define how fast the camera can accelerate to follow it s target.
  46361. */
  46362. cameraAcceleration: number;
  46363. /**
  46364. * Define the speed limit of the camera following an object.
  46365. */
  46366. maxCameraSpeed: number;
  46367. /**
  46368. * Define the target of the camera.
  46369. */
  46370. lockedTarget: Nullable<AbstractMesh>;
  46371. /**
  46372. * Defines the input associated with the camera.
  46373. */
  46374. inputs: FollowCameraInputsManager;
  46375. /**
  46376. * Instantiates the follow camera.
  46377. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46378. * @param name Define the name of the camera in the scene
  46379. * @param position Define the position of the camera
  46380. * @param scene Define the scene the camera belong to
  46381. * @param lockedTarget Define the target of the camera
  46382. */
  46383. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46384. private _follow;
  46385. /**
  46386. * Attached controls to the current camera.
  46387. * @param element Defines the element the controls should be listened from
  46388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46389. */
  46390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46391. /**
  46392. * Detach the current controls from the camera.
  46393. * The camera will stop reacting to inputs.
  46394. * @param element Defines the element to stop listening the inputs from
  46395. */
  46396. detachControl(element: HTMLElement): void;
  46397. /** @hidden */
  46398. _checkInputs(): void;
  46399. private _checkLimits;
  46400. /**
  46401. * Gets the camera class name.
  46402. * @returns the class name
  46403. */
  46404. getClassName(): string;
  46405. }
  46406. /**
  46407. * Arc Rotate version of the follow camera.
  46408. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46409. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46410. */
  46411. export class ArcFollowCamera extends TargetCamera {
  46412. /** The longitudinal angle of the camera */
  46413. alpha: number;
  46414. /** The latitudinal angle of the camera */
  46415. beta: number;
  46416. /** The radius of the camera from its target */
  46417. radius: number;
  46418. private _cartesianCoordinates;
  46419. /** Define the camera target (the mesh it should follow) */
  46420. private _meshTarget;
  46421. /**
  46422. * Instantiates a new ArcFollowCamera
  46423. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46424. * @param name Define the name of the camera
  46425. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46426. * @param beta Define the rotation angle of the camera around the elevation axis
  46427. * @param radius Define the radius of the camera from its target point
  46428. * @param target Define the target of the camera
  46429. * @param scene Define the scene the camera belongs to
  46430. */
  46431. constructor(name: string,
  46432. /** The longitudinal angle of the camera */
  46433. alpha: number,
  46434. /** The latitudinal angle of the camera */
  46435. beta: number,
  46436. /** The radius of the camera from its target */
  46437. radius: number,
  46438. /** Define the camera target (the mesh it should follow) */
  46439. target: Nullable<AbstractMesh>, scene: Scene);
  46440. private _follow;
  46441. /** @hidden */
  46442. _checkInputs(): void;
  46443. /**
  46444. * Returns the class name of the object.
  46445. * It is mostly used internally for serialization purposes.
  46446. */
  46447. getClassName(): string;
  46448. }
  46449. }
  46450. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46451. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46452. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46453. import { Nullable } from "babylonjs/types";
  46454. /**
  46455. * Manage the keyboard inputs to control the movement of a follow camera.
  46456. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46457. */
  46458. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46459. /**
  46460. * Defines the camera the input is attached to.
  46461. */
  46462. camera: FollowCamera;
  46463. /**
  46464. * Defines the list of key codes associated with the up action (increase heightOffset)
  46465. */
  46466. keysHeightOffsetIncr: number[];
  46467. /**
  46468. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46469. */
  46470. keysHeightOffsetDecr: number[];
  46471. /**
  46472. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46473. */
  46474. keysHeightOffsetModifierAlt: boolean;
  46475. /**
  46476. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46477. */
  46478. keysHeightOffsetModifierCtrl: boolean;
  46479. /**
  46480. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46481. */
  46482. keysHeightOffsetModifierShift: boolean;
  46483. /**
  46484. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46485. */
  46486. keysRotationOffsetIncr: number[];
  46487. /**
  46488. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46489. */
  46490. keysRotationOffsetDecr: number[];
  46491. /**
  46492. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46493. */
  46494. keysRotationOffsetModifierAlt: boolean;
  46495. /**
  46496. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46497. */
  46498. keysRotationOffsetModifierCtrl: boolean;
  46499. /**
  46500. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46501. */
  46502. keysRotationOffsetModifierShift: boolean;
  46503. /**
  46504. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46505. */
  46506. keysRadiusIncr: number[];
  46507. /**
  46508. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46509. */
  46510. keysRadiusDecr: number[];
  46511. /**
  46512. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46513. */
  46514. keysRadiusModifierAlt: boolean;
  46515. /**
  46516. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46517. */
  46518. keysRadiusModifierCtrl: boolean;
  46519. /**
  46520. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46521. */
  46522. keysRadiusModifierShift: boolean;
  46523. /**
  46524. * Defines the rate of change of heightOffset.
  46525. */
  46526. heightSensibility: number;
  46527. /**
  46528. * Defines the rate of change of rotationOffset.
  46529. */
  46530. rotationSensibility: number;
  46531. /**
  46532. * Defines the rate of change of radius.
  46533. */
  46534. radiusSensibility: number;
  46535. private _keys;
  46536. private _ctrlPressed;
  46537. private _altPressed;
  46538. private _shiftPressed;
  46539. private _onCanvasBlurObserver;
  46540. private _onKeyboardObserver;
  46541. private _engine;
  46542. private _scene;
  46543. /**
  46544. * Attach the input controls to a specific dom element to get the input from.
  46545. * @param element Defines the element the controls should be listened from
  46546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46547. */
  46548. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46549. /**
  46550. * Detach the current controls from the specified dom element.
  46551. * @param element Defines the element to stop listening the inputs from
  46552. */
  46553. detachControl(element: Nullable<HTMLElement>): void;
  46554. /**
  46555. * Update the current camera state depending on the inputs that have been used this frame.
  46556. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46557. */
  46558. checkInputs(): void;
  46559. /**
  46560. * Gets the class name of the current input.
  46561. * @returns the class name
  46562. */
  46563. getClassName(): string;
  46564. /**
  46565. * Get the friendly name associated with the input class.
  46566. * @returns the input friendly name
  46567. */
  46568. getSimpleName(): string;
  46569. /**
  46570. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46571. * allow modification of the heightOffset value.
  46572. */
  46573. private _modifierHeightOffset;
  46574. /**
  46575. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46576. * allow modification of the rotationOffset value.
  46577. */
  46578. private _modifierRotationOffset;
  46579. /**
  46580. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46581. * allow modification of the radius value.
  46582. */
  46583. private _modifierRadius;
  46584. }
  46585. }
  46586. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46587. import { Nullable } from "babylonjs/types";
  46588. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46589. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46590. import { Observable } from "babylonjs/Misc/observable";
  46591. module "babylonjs/Cameras/freeCameraInputsManager" {
  46592. interface FreeCameraInputsManager {
  46593. /**
  46594. * @hidden
  46595. */
  46596. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46597. /**
  46598. * Add orientation input support to the input manager.
  46599. * @returns the current input manager
  46600. */
  46601. addDeviceOrientation(): FreeCameraInputsManager;
  46602. }
  46603. }
  46604. /**
  46605. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46606. * Screen rotation is taken into account.
  46607. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46608. */
  46609. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46610. private _camera;
  46611. private _screenOrientationAngle;
  46612. private _constantTranform;
  46613. private _screenQuaternion;
  46614. private _alpha;
  46615. private _beta;
  46616. private _gamma;
  46617. /**
  46618. * Can be used to detect if a device orientation sensor is available on a device
  46619. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46620. * @returns a promise that will resolve on orientation change
  46621. */
  46622. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46623. /**
  46624. * @hidden
  46625. */
  46626. _onDeviceOrientationChangedObservable: Observable<void>;
  46627. /**
  46628. * Instantiates a new input
  46629. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46630. */
  46631. constructor();
  46632. /**
  46633. * Define the camera controlled by the input.
  46634. */
  46635. get camera(): FreeCamera;
  46636. set camera(camera: FreeCamera);
  46637. /**
  46638. * Attach the input controls to a specific dom element to get the input from.
  46639. * @param element Defines the element the controls should be listened from
  46640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46641. */
  46642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46643. private _orientationChanged;
  46644. private _deviceOrientation;
  46645. /**
  46646. * Detach the current controls from the specified dom element.
  46647. * @param element Defines the element to stop listening the inputs from
  46648. */
  46649. detachControl(element: Nullable<HTMLElement>): void;
  46650. /**
  46651. * Update the current camera state depending on the inputs that have been used this frame.
  46652. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46653. */
  46654. checkInputs(): void;
  46655. /**
  46656. * Gets the class name of the current intput.
  46657. * @returns the class name
  46658. */
  46659. getClassName(): string;
  46660. /**
  46661. * Get the friendly name associated with the input class.
  46662. * @returns the input friendly name
  46663. */
  46664. getSimpleName(): string;
  46665. }
  46666. }
  46667. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46668. import { Nullable } from "babylonjs/types";
  46669. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46670. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46671. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46672. /**
  46673. * Manage the gamepad inputs to control a free camera.
  46674. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46675. */
  46676. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46677. /**
  46678. * Define the camera the input is attached to.
  46679. */
  46680. camera: FreeCamera;
  46681. /**
  46682. * Define the Gamepad controlling the input
  46683. */
  46684. gamepad: Nullable<Gamepad>;
  46685. /**
  46686. * Defines the gamepad rotation sensiblity.
  46687. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46688. */
  46689. gamepadAngularSensibility: number;
  46690. /**
  46691. * Defines the gamepad move sensiblity.
  46692. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46693. */
  46694. gamepadMoveSensibility: number;
  46695. private _yAxisScale;
  46696. /**
  46697. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46698. */
  46699. get invertYAxis(): boolean;
  46700. set invertYAxis(value: boolean);
  46701. private _onGamepadConnectedObserver;
  46702. private _onGamepadDisconnectedObserver;
  46703. private _cameraTransform;
  46704. private _deltaTransform;
  46705. private _vector3;
  46706. private _vector2;
  46707. /**
  46708. * Attach the input controls to a specific dom element to get the input from.
  46709. * @param element Defines the element the controls should be listened from
  46710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46711. */
  46712. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46713. /**
  46714. * Detach the current controls from the specified dom element.
  46715. * @param element Defines the element to stop listening the inputs from
  46716. */
  46717. detachControl(element: Nullable<HTMLElement>): void;
  46718. /**
  46719. * Update the current camera state depending on the inputs that have been used this frame.
  46720. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46721. */
  46722. checkInputs(): void;
  46723. /**
  46724. * Gets the class name of the current intput.
  46725. * @returns the class name
  46726. */
  46727. getClassName(): string;
  46728. /**
  46729. * Get the friendly name associated with the input class.
  46730. * @returns the input friendly name
  46731. */
  46732. getSimpleName(): string;
  46733. }
  46734. }
  46735. declare module "babylonjs/Misc/virtualJoystick" {
  46736. import { Nullable } from "babylonjs/types";
  46737. import { Vector3 } from "babylonjs/Maths/math.vector";
  46738. /**
  46739. * Defines the potential axis of a Joystick
  46740. */
  46741. export enum JoystickAxis {
  46742. /** X axis */
  46743. X = 0,
  46744. /** Y axis */
  46745. Y = 1,
  46746. /** Z axis */
  46747. Z = 2
  46748. }
  46749. /**
  46750. * Represents the different customization options available
  46751. * for VirtualJoystick
  46752. */
  46753. interface VirtualJoystickCustomizations {
  46754. /**
  46755. * Size of the joystick's puck
  46756. */
  46757. puckSize: number;
  46758. /**
  46759. * Size of the joystick's container
  46760. */
  46761. containerSize: number;
  46762. /**
  46763. * Color of the joystick && puck
  46764. */
  46765. color: string;
  46766. /**
  46767. * Image URL for the joystick's puck
  46768. */
  46769. puckImage?: string;
  46770. /**
  46771. * Image URL for the joystick's container
  46772. */
  46773. containerImage?: string;
  46774. /**
  46775. * Defines the unmoving position of the joystick container
  46776. */
  46777. position?: {
  46778. x: number;
  46779. y: number;
  46780. };
  46781. /**
  46782. * Defines whether or not the joystick container is always visible
  46783. */
  46784. alwaysVisible: boolean;
  46785. /**
  46786. * Defines whether or not to limit the movement of the puck to the joystick's container
  46787. */
  46788. limitToContainer: boolean;
  46789. }
  46790. /**
  46791. * Class used to define virtual joystick (used in touch mode)
  46792. */
  46793. export class VirtualJoystick {
  46794. /**
  46795. * Gets or sets a boolean indicating that left and right values must be inverted
  46796. */
  46797. reverseLeftRight: boolean;
  46798. /**
  46799. * Gets or sets a boolean indicating that up and down values must be inverted
  46800. */
  46801. reverseUpDown: boolean;
  46802. /**
  46803. * Gets the offset value for the position (ie. the change of the position value)
  46804. */
  46805. deltaPosition: Vector3;
  46806. /**
  46807. * Gets a boolean indicating if the virtual joystick was pressed
  46808. */
  46809. pressed: boolean;
  46810. /**
  46811. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46812. */
  46813. static Canvas: Nullable<HTMLCanvasElement>;
  46814. /**
  46815. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46816. */
  46817. limitToContainer: boolean;
  46818. private static _globalJoystickIndex;
  46819. private static _alwaysVisibleSticks;
  46820. private static vjCanvasContext;
  46821. private static vjCanvasWidth;
  46822. private static vjCanvasHeight;
  46823. private static halfWidth;
  46824. private static _GetDefaultOptions;
  46825. private _action;
  46826. private _axisTargetedByLeftAndRight;
  46827. private _axisTargetedByUpAndDown;
  46828. private _joystickSensibility;
  46829. private _inversedSensibility;
  46830. private _joystickPointerID;
  46831. private _joystickColor;
  46832. private _joystickPointerPos;
  46833. private _joystickPreviousPointerPos;
  46834. private _joystickPointerStartPos;
  46835. private _deltaJoystickVector;
  46836. private _leftJoystick;
  46837. private _touches;
  46838. private _joystickPosition;
  46839. private _alwaysVisible;
  46840. private _puckImage;
  46841. private _containerImage;
  46842. private _joystickPuckSize;
  46843. private _joystickContainerSize;
  46844. private _clearPuckSize;
  46845. private _clearContainerSize;
  46846. private _clearPuckSizeOffset;
  46847. private _clearContainerSizeOffset;
  46848. private _onPointerDownHandlerRef;
  46849. private _onPointerMoveHandlerRef;
  46850. private _onPointerUpHandlerRef;
  46851. private _onResize;
  46852. /**
  46853. * Creates a new virtual joystick
  46854. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46855. * @param customizations Defines the options we want to customize the VirtualJoystick
  46856. */
  46857. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46858. /**
  46859. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46860. * @param newJoystickSensibility defines the new sensibility
  46861. */
  46862. setJoystickSensibility(newJoystickSensibility: number): void;
  46863. private _onPointerDown;
  46864. private _onPointerMove;
  46865. private _onPointerUp;
  46866. /**
  46867. * Change the color of the virtual joystick
  46868. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46869. */
  46870. setJoystickColor(newColor: string): void;
  46871. /**
  46872. * Size of the joystick's container
  46873. */
  46874. set containerSize(newSize: number);
  46875. get containerSize(): number;
  46876. /**
  46877. * Size of the joystick's puck
  46878. */
  46879. set puckSize(newSize: number);
  46880. get puckSize(): number;
  46881. /**
  46882. * Clears the set position of the joystick
  46883. */
  46884. clearPosition(): void;
  46885. /**
  46886. * Defines whether or not the joystick container is always visible
  46887. */
  46888. set alwaysVisible(value: boolean);
  46889. get alwaysVisible(): boolean;
  46890. /**
  46891. * Sets the constant position of the Joystick container
  46892. * @param x X axis coordinate
  46893. * @param y Y axis coordinate
  46894. */
  46895. setPosition(x: number, y: number): void;
  46896. /**
  46897. * Defines a callback to call when the joystick is touched
  46898. * @param action defines the callback
  46899. */
  46900. setActionOnTouch(action: () => any): void;
  46901. /**
  46902. * Defines which axis you'd like to control for left & right
  46903. * @param axis defines the axis to use
  46904. */
  46905. setAxisForLeftRight(axis: JoystickAxis): void;
  46906. /**
  46907. * Defines which axis you'd like to control for up & down
  46908. * @param axis defines the axis to use
  46909. */
  46910. setAxisForUpDown(axis: JoystickAxis): void;
  46911. /**
  46912. * Clears the canvas from the previous puck / container draw
  46913. */
  46914. private _clearPreviousDraw;
  46915. /**
  46916. * Loads `urlPath` to be used for the container's image
  46917. * @param urlPath defines the urlPath of an image to use
  46918. */
  46919. setContainerImage(urlPath: string): void;
  46920. /**
  46921. * Loads `urlPath` to be used for the puck's image
  46922. * @param urlPath defines the urlPath of an image to use
  46923. */
  46924. setPuckImage(urlPath: string): void;
  46925. /**
  46926. * Draws the Virtual Joystick's container
  46927. */
  46928. private _drawContainer;
  46929. /**
  46930. * Draws the Virtual Joystick's puck
  46931. */
  46932. private _drawPuck;
  46933. private _drawVirtualJoystick;
  46934. /**
  46935. * Release internal HTML canvas
  46936. */
  46937. releaseCanvas(): void;
  46938. }
  46939. }
  46940. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46941. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46942. import { Nullable } from "babylonjs/types";
  46943. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46944. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46945. module "babylonjs/Cameras/freeCameraInputsManager" {
  46946. interface FreeCameraInputsManager {
  46947. /**
  46948. * Add virtual joystick input support to the input manager.
  46949. * @returns the current input manager
  46950. */
  46951. addVirtualJoystick(): FreeCameraInputsManager;
  46952. }
  46953. }
  46954. /**
  46955. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46956. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46957. */
  46958. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46959. /**
  46960. * Defines the camera the input is attached to.
  46961. */
  46962. camera: FreeCamera;
  46963. private _leftjoystick;
  46964. private _rightjoystick;
  46965. /**
  46966. * Gets the left stick of the virtual joystick.
  46967. * @returns The virtual Joystick
  46968. */
  46969. getLeftJoystick(): VirtualJoystick;
  46970. /**
  46971. * Gets the right stick of the virtual joystick.
  46972. * @returns The virtual Joystick
  46973. */
  46974. getRightJoystick(): VirtualJoystick;
  46975. /**
  46976. * Update the current camera state depending on the inputs that have been used this frame.
  46977. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46978. */
  46979. checkInputs(): void;
  46980. /**
  46981. * Attach the input controls to a specific dom element to get the input from.
  46982. * @param element Defines the element the controls should be listened from
  46983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46984. */
  46985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46986. /**
  46987. * Detach the current controls from the specified dom element.
  46988. * @param element Defines the element to stop listening the inputs from
  46989. */
  46990. detachControl(element: Nullable<HTMLElement>): void;
  46991. /**
  46992. * Gets the class name of the current intput.
  46993. * @returns the class name
  46994. */
  46995. getClassName(): string;
  46996. /**
  46997. * Get the friendly name associated with the input class.
  46998. * @returns the input friendly name
  46999. */
  47000. getSimpleName(): string;
  47001. }
  47002. }
  47003. declare module "babylonjs/Cameras/Inputs/index" {
  47004. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  47005. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  47006. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  47007. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  47008. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47009. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  47010. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  47011. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  47012. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  47013. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  47014. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47015. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  47016. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  47017. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  47018. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  47019. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47020. }
  47021. declare module "babylonjs/Cameras/touchCamera" {
  47022. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47023. import { Scene } from "babylonjs/scene";
  47024. import { Vector3 } from "babylonjs/Maths/math.vector";
  47025. /**
  47026. * This represents a FPS type of camera controlled by touch.
  47027. * This is like a universal camera minus the Gamepad controls.
  47028. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47029. */
  47030. export class TouchCamera extends FreeCamera {
  47031. /**
  47032. * Defines the touch sensibility for rotation.
  47033. * The higher the faster.
  47034. */
  47035. get touchAngularSensibility(): number;
  47036. set touchAngularSensibility(value: number);
  47037. /**
  47038. * Defines the touch sensibility for move.
  47039. * The higher the faster.
  47040. */
  47041. get touchMoveSensibility(): number;
  47042. set touchMoveSensibility(value: number);
  47043. /**
  47044. * Instantiates a new touch camera.
  47045. * This represents a FPS type of camera controlled by touch.
  47046. * This is like a universal camera minus the Gamepad controls.
  47047. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47048. * @param name Define the name of the camera in the scene
  47049. * @param position Define the start position of the camera in the scene
  47050. * @param scene Define the scene the camera belongs to
  47051. */
  47052. constructor(name: string, position: Vector3, scene: Scene);
  47053. /**
  47054. * Gets the current object class name.
  47055. * @return the class name
  47056. */
  47057. getClassName(): string;
  47058. /** @hidden */
  47059. _setupInputs(): void;
  47060. }
  47061. }
  47062. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47063. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47064. import { Scene } from "babylonjs/scene";
  47065. import { Vector3 } from "babylonjs/Maths/math.vector";
  47066. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47067. import { Axis } from "babylonjs/Maths/math.axis";
  47068. /**
  47069. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47070. * being tilted forward or back and left or right.
  47071. */
  47072. export class DeviceOrientationCamera extends FreeCamera {
  47073. private _initialQuaternion;
  47074. private _quaternionCache;
  47075. private _tmpDragQuaternion;
  47076. private _disablePointerInputWhenUsingDeviceOrientation;
  47077. /**
  47078. * Creates a new device orientation camera
  47079. * @param name The name of the camera
  47080. * @param position The start position camera
  47081. * @param scene The scene the camera belongs to
  47082. */
  47083. constructor(name: string, position: Vector3, scene: Scene);
  47084. /**
  47085. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47086. */
  47087. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47088. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47089. private _dragFactor;
  47090. /**
  47091. * Enabled turning on the y axis when the orientation sensor is active
  47092. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47093. */
  47094. enableHorizontalDragging(dragFactor?: number): void;
  47095. /**
  47096. * Gets the current instance class name ("DeviceOrientationCamera").
  47097. * This helps avoiding instanceof at run time.
  47098. * @returns the class name
  47099. */
  47100. getClassName(): string;
  47101. /**
  47102. * @hidden
  47103. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47104. */
  47105. _checkInputs(): void;
  47106. /**
  47107. * Reset the camera to its default orientation on the specified axis only.
  47108. * @param axis The axis to reset
  47109. */
  47110. resetToCurrentRotation(axis?: Axis): void;
  47111. }
  47112. }
  47113. declare module "babylonjs/Gamepads/xboxGamepad" {
  47114. import { Observable } from "babylonjs/Misc/observable";
  47115. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47116. /**
  47117. * Defines supported buttons for XBox360 compatible gamepads
  47118. */
  47119. export enum Xbox360Button {
  47120. /** A */
  47121. A = 0,
  47122. /** B */
  47123. B = 1,
  47124. /** X */
  47125. X = 2,
  47126. /** Y */
  47127. Y = 3,
  47128. /** Left button */
  47129. LB = 4,
  47130. /** Right button */
  47131. RB = 5,
  47132. /** Back */
  47133. Back = 8,
  47134. /** Start */
  47135. Start = 9,
  47136. /** Left stick */
  47137. LeftStick = 10,
  47138. /** Right stick */
  47139. RightStick = 11
  47140. }
  47141. /** Defines values for XBox360 DPad */
  47142. export enum Xbox360Dpad {
  47143. /** Up */
  47144. Up = 12,
  47145. /** Down */
  47146. Down = 13,
  47147. /** Left */
  47148. Left = 14,
  47149. /** Right */
  47150. Right = 15
  47151. }
  47152. /**
  47153. * Defines a XBox360 gamepad
  47154. */
  47155. export class Xbox360Pad extends Gamepad {
  47156. private _leftTrigger;
  47157. private _rightTrigger;
  47158. private _onlefttriggerchanged;
  47159. private _onrighttriggerchanged;
  47160. private _onbuttondown;
  47161. private _onbuttonup;
  47162. private _ondpaddown;
  47163. private _ondpadup;
  47164. /** Observable raised when a button is pressed */
  47165. onButtonDownObservable: Observable<Xbox360Button>;
  47166. /** Observable raised when a button is released */
  47167. onButtonUpObservable: Observable<Xbox360Button>;
  47168. /** Observable raised when a pad is pressed */
  47169. onPadDownObservable: Observable<Xbox360Dpad>;
  47170. /** Observable raised when a pad is released */
  47171. onPadUpObservable: Observable<Xbox360Dpad>;
  47172. private _buttonA;
  47173. private _buttonB;
  47174. private _buttonX;
  47175. private _buttonY;
  47176. private _buttonBack;
  47177. private _buttonStart;
  47178. private _buttonLB;
  47179. private _buttonRB;
  47180. private _buttonLeftStick;
  47181. private _buttonRightStick;
  47182. private _dPadUp;
  47183. private _dPadDown;
  47184. private _dPadLeft;
  47185. private _dPadRight;
  47186. private _isXboxOnePad;
  47187. /**
  47188. * Creates a new XBox360 gamepad object
  47189. * @param id defines the id of this gamepad
  47190. * @param index defines its index
  47191. * @param gamepad defines the internal HTML gamepad object
  47192. * @param xboxOne defines if it is a XBox One gamepad
  47193. */
  47194. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47195. /**
  47196. * Defines the callback to call when left trigger is pressed
  47197. * @param callback defines the callback to use
  47198. */
  47199. onlefttriggerchanged(callback: (value: number) => void): void;
  47200. /**
  47201. * Defines the callback to call when right trigger is pressed
  47202. * @param callback defines the callback to use
  47203. */
  47204. onrighttriggerchanged(callback: (value: number) => void): void;
  47205. /**
  47206. * Gets the left trigger value
  47207. */
  47208. get leftTrigger(): number;
  47209. /**
  47210. * Sets the left trigger value
  47211. */
  47212. set leftTrigger(newValue: number);
  47213. /**
  47214. * Gets the right trigger value
  47215. */
  47216. get rightTrigger(): number;
  47217. /**
  47218. * Sets the right trigger value
  47219. */
  47220. set rightTrigger(newValue: number);
  47221. /**
  47222. * Defines the callback to call when a button is pressed
  47223. * @param callback defines the callback to use
  47224. */
  47225. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47226. /**
  47227. * Defines the callback to call when a button is released
  47228. * @param callback defines the callback to use
  47229. */
  47230. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47231. /**
  47232. * Defines the callback to call when a pad is pressed
  47233. * @param callback defines the callback to use
  47234. */
  47235. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47236. /**
  47237. * Defines the callback to call when a pad is released
  47238. * @param callback defines the callback to use
  47239. */
  47240. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47241. private _setButtonValue;
  47242. private _setDPadValue;
  47243. /**
  47244. * Gets the value of the `A` button
  47245. */
  47246. get buttonA(): number;
  47247. /**
  47248. * Sets the value of the `A` button
  47249. */
  47250. set buttonA(value: number);
  47251. /**
  47252. * Gets the value of the `B` button
  47253. */
  47254. get buttonB(): number;
  47255. /**
  47256. * Sets the value of the `B` button
  47257. */
  47258. set buttonB(value: number);
  47259. /**
  47260. * Gets the value of the `X` button
  47261. */
  47262. get buttonX(): number;
  47263. /**
  47264. * Sets the value of the `X` button
  47265. */
  47266. set buttonX(value: number);
  47267. /**
  47268. * Gets the value of the `Y` button
  47269. */
  47270. get buttonY(): number;
  47271. /**
  47272. * Sets the value of the `Y` button
  47273. */
  47274. set buttonY(value: number);
  47275. /**
  47276. * Gets the value of the `Start` button
  47277. */
  47278. get buttonStart(): number;
  47279. /**
  47280. * Sets the value of the `Start` button
  47281. */
  47282. set buttonStart(value: number);
  47283. /**
  47284. * Gets the value of the `Back` button
  47285. */
  47286. get buttonBack(): number;
  47287. /**
  47288. * Sets the value of the `Back` button
  47289. */
  47290. set buttonBack(value: number);
  47291. /**
  47292. * Gets the value of the `Left` button
  47293. */
  47294. get buttonLB(): number;
  47295. /**
  47296. * Sets the value of the `Left` button
  47297. */
  47298. set buttonLB(value: number);
  47299. /**
  47300. * Gets the value of the `Right` button
  47301. */
  47302. get buttonRB(): number;
  47303. /**
  47304. * Sets the value of the `Right` button
  47305. */
  47306. set buttonRB(value: number);
  47307. /**
  47308. * Gets the value of the Left joystick
  47309. */
  47310. get buttonLeftStick(): number;
  47311. /**
  47312. * Sets the value of the Left joystick
  47313. */
  47314. set buttonLeftStick(value: number);
  47315. /**
  47316. * Gets the value of the Right joystick
  47317. */
  47318. get buttonRightStick(): number;
  47319. /**
  47320. * Sets the value of the Right joystick
  47321. */
  47322. set buttonRightStick(value: number);
  47323. /**
  47324. * Gets the value of D-pad up
  47325. */
  47326. get dPadUp(): number;
  47327. /**
  47328. * Sets the value of D-pad up
  47329. */
  47330. set dPadUp(value: number);
  47331. /**
  47332. * Gets the value of D-pad down
  47333. */
  47334. get dPadDown(): number;
  47335. /**
  47336. * Sets the value of D-pad down
  47337. */
  47338. set dPadDown(value: number);
  47339. /**
  47340. * Gets the value of D-pad left
  47341. */
  47342. get dPadLeft(): number;
  47343. /**
  47344. * Sets the value of D-pad left
  47345. */
  47346. set dPadLeft(value: number);
  47347. /**
  47348. * Gets the value of D-pad right
  47349. */
  47350. get dPadRight(): number;
  47351. /**
  47352. * Sets the value of D-pad right
  47353. */
  47354. set dPadRight(value: number);
  47355. /**
  47356. * Force the gamepad to synchronize with device values
  47357. */
  47358. update(): void;
  47359. /**
  47360. * Disposes the gamepad
  47361. */
  47362. dispose(): void;
  47363. }
  47364. }
  47365. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47366. import { Observable } from "babylonjs/Misc/observable";
  47367. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47368. /**
  47369. * Defines supported buttons for DualShock compatible gamepads
  47370. */
  47371. export enum DualShockButton {
  47372. /** Cross */
  47373. Cross = 0,
  47374. /** Circle */
  47375. Circle = 1,
  47376. /** Square */
  47377. Square = 2,
  47378. /** Triangle */
  47379. Triangle = 3,
  47380. /** L1 */
  47381. L1 = 4,
  47382. /** R1 */
  47383. R1 = 5,
  47384. /** Share */
  47385. Share = 8,
  47386. /** Options */
  47387. Options = 9,
  47388. /** Left stick */
  47389. LeftStick = 10,
  47390. /** Right stick */
  47391. RightStick = 11
  47392. }
  47393. /** Defines values for DualShock DPad */
  47394. export enum DualShockDpad {
  47395. /** Up */
  47396. Up = 12,
  47397. /** Down */
  47398. Down = 13,
  47399. /** Left */
  47400. Left = 14,
  47401. /** Right */
  47402. Right = 15
  47403. }
  47404. /**
  47405. * Defines a DualShock gamepad
  47406. */
  47407. export class DualShockPad extends Gamepad {
  47408. private _leftTrigger;
  47409. private _rightTrigger;
  47410. private _onlefttriggerchanged;
  47411. private _onrighttriggerchanged;
  47412. private _onbuttondown;
  47413. private _onbuttonup;
  47414. private _ondpaddown;
  47415. private _ondpadup;
  47416. /** Observable raised when a button is pressed */
  47417. onButtonDownObservable: Observable<DualShockButton>;
  47418. /** Observable raised when a button is released */
  47419. onButtonUpObservable: Observable<DualShockButton>;
  47420. /** Observable raised when a pad is pressed */
  47421. onPadDownObservable: Observable<DualShockDpad>;
  47422. /** Observable raised when a pad is released */
  47423. onPadUpObservable: Observable<DualShockDpad>;
  47424. private _buttonCross;
  47425. private _buttonCircle;
  47426. private _buttonSquare;
  47427. private _buttonTriangle;
  47428. private _buttonShare;
  47429. private _buttonOptions;
  47430. private _buttonL1;
  47431. private _buttonR1;
  47432. private _buttonLeftStick;
  47433. private _buttonRightStick;
  47434. private _dPadUp;
  47435. private _dPadDown;
  47436. private _dPadLeft;
  47437. private _dPadRight;
  47438. /**
  47439. * Creates a new DualShock gamepad object
  47440. * @param id defines the id of this gamepad
  47441. * @param index defines its index
  47442. * @param gamepad defines the internal HTML gamepad object
  47443. */
  47444. constructor(id: string, index: number, gamepad: any);
  47445. /**
  47446. * Defines the callback to call when left trigger is pressed
  47447. * @param callback defines the callback to use
  47448. */
  47449. onlefttriggerchanged(callback: (value: number) => void): void;
  47450. /**
  47451. * Defines the callback to call when right trigger is pressed
  47452. * @param callback defines the callback to use
  47453. */
  47454. onrighttriggerchanged(callback: (value: number) => void): void;
  47455. /**
  47456. * Gets the left trigger value
  47457. */
  47458. get leftTrigger(): number;
  47459. /**
  47460. * Sets the left trigger value
  47461. */
  47462. set leftTrigger(newValue: number);
  47463. /**
  47464. * Gets the right trigger value
  47465. */
  47466. get rightTrigger(): number;
  47467. /**
  47468. * Sets the right trigger value
  47469. */
  47470. set rightTrigger(newValue: number);
  47471. /**
  47472. * Defines the callback to call when a button is pressed
  47473. * @param callback defines the callback to use
  47474. */
  47475. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47476. /**
  47477. * Defines the callback to call when a button is released
  47478. * @param callback defines the callback to use
  47479. */
  47480. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47481. /**
  47482. * Defines the callback to call when a pad is pressed
  47483. * @param callback defines the callback to use
  47484. */
  47485. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47486. /**
  47487. * Defines the callback to call when a pad is released
  47488. * @param callback defines the callback to use
  47489. */
  47490. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47491. private _setButtonValue;
  47492. private _setDPadValue;
  47493. /**
  47494. * Gets the value of the `Cross` button
  47495. */
  47496. get buttonCross(): number;
  47497. /**
  47498. * Sets the value of the `Cross` button
  47499. */
  47500. set buttonCross(value: number);
  47501. /**
  47502. * Gets the value of the `Circle` button
  47503. */
  47504. get buttonCircle(): number;
  47505. /**
  47506. * Sets the value of the `Circle` button
  47507. */
  47508. set buttonCircle(value: number);
  47509. /**
  47510. * Gets the value of the `Square` button
  47511. */
  47512. get buttonSquare(): number;
  47513. /**
  47514. * Sets the value of the `Square` button
  47515. */
  47516. set buttonSquare(value: number);
  47517. /**
  47518. * Gets the value of the `Triangle` button
  47519. */
  47520. get buttonTriangle(): number;
  47521. /**
  47522. * Sets the value of the `Triangle` button
  47523. */
  47524. set buttonTriangle(value: number);
  47525. /**
  47526. * Gets the value of the `Options` button
  47527. */
  47528. get buttonOptions(): number;
  47529. /**
  47530. * Sets the value of the `Options` button
  47531. */
  47532. set buttonOptions(value: number);
  47533. /**
  47534. * Gets the value of the `Share` button
  47535. */
  47536. get buttonShare(): number;
  47537. /**
  47538. * Sets the value of the `Share` button
  47539. */
  47540. set buttonShare(value: number);
  47541. /**
  47542. * Gets the value of the `L1` button
  47543. */
  47544. get buttonL1(): number;
  47545. /**
  47546. * Sets the value of the `L1` button
  47547. */
  47548. set buttonL1(value: number);
  47549. /**
  47550. * Gets the value of the `R1` button
  47551. */
  47552. get buttonR1(): number;
  47553. /**
  47554. * Sets the value of the `R1` button
  47555. */
  47556. set buttonR1(value: number);
  47557. /**
  47558. * Gets the value of the Left joystick
  47559. */
  47560. get buttonLeftStick(): number;
  47561. /**
  47562. * Sets the value of the Left joystick
  47563. */
  47564. set buttonLeftStick(value: number);
  47565. /**
  47566. * Gets the value of the Right joystick
  47567. */
  47568. get buttonRightStick(): number;
  47569. /**
  47570. * Sets the value of the Right joystick
  47571. */
  47572. set buttonRightStick(value: number);
  47573. /**
  47574. * Gets the value of D-pad up
  47575. */
  47576. get dPadUp(): number;
  47577. /**
  47578. * Sets the value of D-pad up
  47579. */
  47580. set dPadUp(value: number);
  47581. /**
  47582. * Gets the value of D-pad down
  47583. */
  47584. get dPadDown(): number;
  47585. /**
  47586. * Sets the value of D-pad down
  47587. */
  47588. set dPadDown(value: number);
  47589. /**
  47590. * Gets the value of D-pad left
  47591. */
  47592. get dPadLeft(): number;
  47593. /**
  47594. * Sets the value of D-pad left
  47595. */
  47596. set dPadLeft(value: number);
  47597. /**
  47598. * Gets the value of D-pad right
  47599. */
  47600. get dPadRight(): number;
  47601. /**
  47602. * Sets the value of D-pad right
  47603. */
  47604. set dPadRight(value: number);
  47605. /**
  47606. * Force the gamepad to synchronize with device values
  47607. */
  47608. update(): void;
  47609. /**
  47610. * Disposes the gamepad
  47611. */
  47612. dispose(): void;
  47613. }
  47614. }
  47615. declare module "babylonjs/Gamepads/gamepadManager" {
  47616. import { Observable } from "babylonjs/Misc/observable";
  47617. import { Nullable } from "babylonjs/types";
  47618. import { Scene } from "babylonjs/scene";
  47619. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47620. /**
  47621. * Manager for handling gamepads
  47622. */
  47623. export class GamepadManager {
  47624. private _scene?;
  47625. private _babylonGamepads;
  47626. private _oneGamepadConnected;
  47627. /** @hidden */
  47628. _isMonitoring: boolean;
  47629. private _gamepadEventSupported;
  47630. private _gamepadSupport?;
  47631. /**
  47632. * observable to be triggered when the gamepad controller has been connected
  47633. */
  47634. onGamepadConnectedObservable: Observable<Gamepad>;
  47635. /**
  47636. * observable to be triggered when the gamepad controller has been disconnected
  47637. */
  47638. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47639. private _onGamepadConnectedEvent;
  47640. private _onGamepadDisconnectedEvent;
  47641. /**
  47642. * Initializes the gamepad manager
  47643. * @param _scene BabylonJS scene
  47644. */
  47645. constructor(_scene?: Scene | undefined);
  47646. /**
  47647. * The gamepads in the game pad manager
  47648. */
  47649. get gamepads(): Gamepad[];
  47650. /**
  47651. * Get the gamepad controllers based on type
  47652. * @param type The type of gamepad controller
  47653. * @returns Nullable gamepad
  47654. */
  47655. getGamepadByType(type?: number): Nullable<Gamepad>;
  47656. /**
  47657. * Disposes the gamepad manager
  47658. */
  47659. dispose(): void;
  47660. private _addNewGamepad;
  47661. private _startMonitoringGamepads;
  47662. private _stopMonitoringGamepads;
  47663. /** @hidden */
  47664. _checkGamepadsStatus(): void;
  47665. private _updateGamepadObjects;
  47666. }
  47667. }
  47668. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47669. import { Nullable } from "babylonjs/types";
  47670. import { Scene } from "babylonjs/scene";
  47671. import { ISceneComponent } from "babylonjs/sceneComponent";
  47672. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47673. module "babylonjs/scene" {
  47674. interface Scene {
  47675. /** @hidden */
  47676. _gamepadManager: Nullable<GamepadManager>;
  47677. /**
  47678. * Gets the gamepad manager associated with the scene
  47679. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47680. */
  47681. gamepadManager: GamepadManager;
  47682. }
  47683. }
  47684. module "babylonjs/Cameras/freeCameraInputsManager" {
  47685. /**
  47686. * Interface representing a free camera inputs manager
  47687. */
  47688. interface FreeCameraInputsManager {
  47689. /**
  47690. * Adds gamepad input support to the FreeCameraInputsManager.
  47691. * @returns the FreeCameraInputsManager
  47692. */
  47693. addGamepad(): FreeCameraInputsManager;
  47694. }
  47695. }
  47696. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47697. /**
  47698. * Interface representing an arc rotate camera inputs manager
  47699. */
  47700. interface ArcRotateCameraInputsManager {
  47701. /**
  47702. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47703. * @returns the camera inputs manager
  47704. */
  47705. addGamepad(): ArcRotateCameraInputsManager;
  47706. }
  47707. }
  47708. /**
  47709. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47710. */
  47711. export class GamepadSystemSceneComponent implements ISceneComponent {
  47712. /**
  47713. * The component name helpfull to identify the component in the list of scene components.
  47714. */
  47715. readonly name: string;
  47716. /**
  47717. * The scene the component belongs to.
  47718. */
  47719. scene: Scene;
  47720. /**
  47721. * Creates a new instance of the component for the given scene
  47722. * @param scene Defines the scene to register the component in
  47723. */
  47724. constructor(scene: Scene);
  47725. /**
  47726. * Registers the component in a given scene
  47727. */
  47728. register(): void;
  47729. /**
  47730. * Rebuilds the elements related to this component in case of
  47731. * context lost for instance.
  47732. */
  47733. rebuild(): void;
  47734. /**
  47735. * Disposes the component and the associated ressources
  47736. */
  47737. dispose(): void;
  47738. private _beforeCameraUpdate;
  47739. }
  47740. }
  47741. declare module "babylonjs/Cameras/universalCamera" {
  47742. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47743. import { Scene } from "babylonjs/scene";
  47744. import { Vector3 } from "babylonjs/Maths/math.vector";
  47745. import "babylonjs/Gamepads/gamepadSceneComponent";
  47746. /**
  47747. * 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,
  47748. * which still works and will still be found in many Playgrounds.
  47749. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47750. */
  47751. export class UniversalCamera extends TouchCamera {
  47752. /**
  47753. * Defines the gamepad rotation sensiblity.
  47754. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47755. */
  47756. get gamepadAngularSensibility(): number;
  47757. set gamepadAngularSensibility(value: number);
  47758. /**
  47759. * Defines the gamepad move sensiblity.
  47760. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47761. */
  47762. get gamepadMoveSensibility(): number;
  47763. set gamepadMoveSensibility(value: number);
  47764. /**
  47765. * 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,
  47766. * which still works and will still be found in many Playgrounds.
  47767. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47768. * @param name Define the name of the camera in the scene
  47769. * @param position Define the start position of the camera in the scene
  47770. * @param scene Define the scene the camera belongs to
  47771. */
  47772. constructor(name: string, position: Vector3, scene: Scene);
  47773. /**
  47774. * Gets the current object class name.
  47775. * @return the class name
  47776. */
  47777. getClassName(): string;
  47778. }
  47779. }
  47780. declare module "babylonjs/Cameras/gamepadCamera" {
  47781. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47782. import { Scene } from "babylonjs/scene";
  47783. import { Vector3 } from "babylonjs/Maths/math.vector";
  47784. /**
  47785. * This represents a FPS type of camera. This is only here for back compat purpose.
  47786. * Please use the UniversalCamera instead as both are identical.
  47787. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47788. */
  47789. export class GamepadCamera extends UniversalCamera {
  47790. /**
  47791. * Instantiates a new Gamepad Camera
  47792. * This represents a FPS type of camera. This is only here for back compat purpose.
  47793. * Please use the UniversalCamera instead as both are identical.
  47794. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47795. * @param name Define the name of the camera in the scene
  47796. * @param position Define the start position of the camera in the scene
  47797. * @param scene Define the scene the camera belongs to
  47798. */
  47799. constructor(name: string, position: Vector3, scene: Scene);
  47800. /**
  47801. * Gets the current object class name.
  47802. * @return the class name
  47803. */
  47804. getClassName(): string;
  47805. }
  47806. }
  47807. declare module "babylonjs/Shaders/pass.fragment" {
  47808. /** @hidden */
  47809. export var passPixelShader: {
  47810. name: string;
  47811. shader: string;
  47812. };
  47813. }
  47814. declare module "babylonjs/Shaders/passCube.fragment" {
  47815. /** @hidden */
  47816. export var passCubePixelShader: {
  47817. name: string;
  47818. shader: string;
  47819. };
  47820. }
  47821. declare module "babylonjs/PostProcesses/passPostProcess" {
  47822. import { Nullable } from "babylonjs/types";
  47823. import { Camera } from "babylonjs/Cameras/camera";
  47824. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47825. import { Engine } from "babylonjs/Engines/engine";
  47826. import "babylonjs/Shaders/pass.fragment";
  47827. import "babylonjs/Shaders/passCube.fragment";
  47828. import { Scene } from "babylonjs/scene";
  47829. /**
  47830. * PassPostProcess which produces an output the same as it's input
  47831. */
  47832. export class PassPostProcess extends PostProcess {
  47833. /**
  47834. * Gets a string identifying the name of the class
  47835. * @returns "PassPostProcess" string
  47836. */
  47837. getClassName(): string;
  47838. /**
  47839. * Creates the PassPostProcess
  47840. * @param name The name of the effect.
  47841. * @param options The required width/height ratio to downsize to before computing the render pass.
  47842. * @param camera The camera to apply the render pass to.
  47843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47844. * @param engine The engine which the post process will be applied. (default: current engine)
  47845. * @param reusable If the post process can be reused on the same frame. (default: false)
  47846. * @param textureType The type of texture to be used when performing the post processing.
  47847. * @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)
  47848. */
  47849. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47850. /** @hidden */
  47851. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47852. }
  47853. /**
  47854. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47855. */
  47856. export class PassCubePostProcess extends PostProcess {
  47857. private _face;
  47858. /**
  47859. * Gets or sets the cube face to display.
  47860. * * 0 is +X
  47861. * * 1 is -X
  47862. * * 2 is +Y
  47863. * * 3 is -Y
  47864. * * 4 is +Z
  47865. * * 5 is -Z
  47866. */
  47867. get face(): number;
  47868. set face(value: number);
  47869. /**
  47870. * Gets a string identifying the name of the class
  47871. * @returns "PassCubePostProcess" string
  47872. */
  47873. getClassName(): string;
  47874. /**
  47875. * Creates the PassCubePostProcess
  47876. * @param name The name of the effect.
  47877. * @param options The required width/height ratio to downsize to before computing the render pass.
  47878. * @param camera The camera to apply the render pass to.
  47879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47880. * @param engine The engine which the post process will be applied. (default: current engine)
  47881. * @param reusable If the post process can be reused on the same frame. (default: false)
  47882. * @param textureType The type of texture to be used when performing the post processing.
  47883. * @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)
  47884. */
  47885. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47886. /** @hidden */
  47887. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47888. }
  47889. }
  47890. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47891. /** @hidden */
  47892. export var anaglyphPixelShader: {
  47893. name: string;
  47894. shader: string;
  47895. };
  47896. }
  47897. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47898. import { Engine } from "babylonjs/Engines/engine";
  47899. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47900. import { Camera } from "babylonjs/Cameras/camera";
  47901. import "babylonjs/Shaders/anaglyph.fragment";
  47902. /**
  47903. * Postprocess used to generate anaglyphic rendering
  47904. */
  47905. export class AnaglyphPostProcess extends PostProcess {
  47906. private _passedProcess;
  47907. /**
  47908. * Gets a string identifying the name of the class
  47909. * @returns "AnaglyphPostProcess" string
  47910. */
  47911. getClassName(): string;
  47912. /**
  47913. * Creates a new AnaglyphPostProcess
  47914. * @param name defines postprocess name
  47915. * @param options defines creation options or target ratio scale
  47916. * @param rigCameras defines cameras using this postprocess
  47917. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47918. * @param engine defines hosting engine
  47919. * @param reusable defines if the postprocess will be reused multiple times per frame
  47920. */
  47921. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47922. }
  47923. }
  47924. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47925. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47926. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47927. import { Scene } from "babylonjs/scene";
  47928. import { Vector3 } from "babylonjs/Maths/math.vector";
  47929. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47930. /**
  47931. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47932. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47933. */
  47934. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47935. /**
  47936. * Creates a new AnaglyphArcRotateCamera
  47937. * @param name defines camera name
  47938. * @param alpha defines alpha angle (in radians)
  47939. * @param beta defines beta angle (in radians)
  47940. * @param radius defines radius
  47941. * @param target defines camera target
  47942. * @param interaxialDistance defines distance between each color axis
  47943. * @param scene defines the hosting scene
  47944. */
  47945. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47946. /**
  47947. * Gets camera class name
  47948. * @returns AnaglyphArcRotateCamera
  47949. */
  47950. getClassName(): string;
  47951. }
  47952. }
  47953. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47954. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47955. import { Scene } from "babylonjs/scene";
  47956. import { Vector3 } from "babylonjs/Maths/math.vector";
  47957. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47958. /**
  47959. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47960. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47961. */
  47962. export class AnaglyphFreeCamera extends FreeCamera {
  47963. /**
  47964. * Creates a new AnaglyphFreeCamera
  47965. * @param name defines camera name
  47966. * @param position defines initial position
  47967. * @param interaxialDistance defines distance between each color axis
  47968. * @param scene defines the hosting scene
  47969. */
  47970. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47971. /**
  47972. * Gets camera class name
  47973. * @returns AnaglyphFreeCamera
  47974. */
  47975. getClassName(): string;
  47976. }
  47977. }
  47978. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47979. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47980. import { Scene } from "babylonjs/scene";
  47981. import { Vector3 } from "babylonjs/Maths/math.vector";
  47982. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47983. /**
  47984. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47985. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47986. */
  47987. export class AnaglyphGamepadCamera extends GamepadCamera {
  47988. /**
  47989. * Creates a new AnaglyphGamepadCamera
  47990. * @param name defines camera name
  47991. * @param position defines initial position
  47992. * @param interaxialDistance defines distance between each color axis
  47993. * @param scene defines the hosting scene
  47994. */
  47995. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47996. /**
  47997. * Gets camera class name
  47998. * @returns AnaglyphGamepadCamera
  47999. */
  48000. getClassName(): string;
  48001. }
  48002. }
  48003. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  48004. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48005. import { Scene } from "babylonjs/scene";
  48006. import { Vector3 } from "babylonjs/Maths/math.vector";
  48007. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48008. /**
  48009. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  48010. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48011. */
  48012. export class AnaglyphUniversalCamera extends UniversalCamera {
  48013. /**
  48014. * Creates a new AnaglyphUniversalCamera
  48015. * @param name defines camera name
  48016. * @param position defines initial position
  48017. * @param interaxialDistance defines distance between each color axis
  48018. * @param scene defines the hosting scene
  48019. */
  48020. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48021. /**
  48022. * Gets camera class name
  48023. * @returns AnaglyphUniversalCamera
  48024. */
  48025. getClassName(): string;
  48026. }
  48027. }
  48028. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  48029. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  48030. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48031. import { Scene } from "babylonjs/scene";
  48032. import { Vector3 } from "babylonjs/Maths/math.vector";
  48033. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48034. /**
  48035. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  48036. * @see https://doc.babylonjs.com/features/cameras
  48037. */
  48038. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  48039. /**
  48040. * Creates a new StereoscopicArcRotateCamera
  48041. * @param name defines camera name
  48042. * @param alpha defines alpha angle (in radians)
  48043. * @param beta defines beta angle (in radians)
  48044. * @param radius defines radius
  48045. * @param target defines camera target
  48046. * @param interaxialDistance defines distance between each color axis
  48047. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48048. * @param scene defines the hosting scene
  48049. */
  48050. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48051. /**
  48052. * Gets camera class name
  48053. * @returns StereoscopicArcRotateCamera
  48054. */
  48055. getClassName(): string;
  48056. }
  48057. }
  48058. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48059. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48060. import { Scene } from "babylonjs/scene";
  48061. import { Vector3 } from "babylonjs/Maths/math.vector";
  48062. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48063. /**
  48064. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48065. * @see https://doc.babylonjs.com/features/cameras
  48066. */
  48067. export class StereoscopicFreeCamera extends FreeCamera {
  48068. /**
  48069. * Creates a new StereoscopicFreeCamera
  48070. * @param name defines camera name
  48071. * @param position defines initial position
  48072. * @param interaxialDistance defines distance between each color axis
  48073. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48074. * @param scene defines the hosting scene
  48075. */
  48076. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48077. /**
  48078. * Gets camera class name
  48079. * @returns StereoscopicFreeCamera
  48080. */
  48081. getClassName(): string;
  48082. }
  48083. }
  48084. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48085. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48086. import { Scene } from "babylonjs/scene";
  48087. import { Vector3 } from "babylonjs/Maths/math.vector";
  48088. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48089. /**
  48090. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48091. * @see https://doc.babylonjs.com/features/cameras
  48092. */
  48093. export class StereoscopicGamepadCamera extends GamepadCamera {
  48094. /**
  48095. * Creates a new StereoscopicGamepadCamera
  48096. * @param name defines camera name
  48097. * @param position defines initial position
  48098. * @param interaxialDistance defines distance between each color axis
  48099. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48100. * @param scene defines the hosting scene
  48101. */
  48102. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48103. /**
  48104. * Gets camera class name
  48105. * @returns StereoscopicGamepadCamera
  48106. */
  48107. getClassName(): string;
  48108. }
  48109. }
  48110. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48111. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48112. import { Scene } from "babylonjs/scene";
  48113. import { Vector3 } from "babylonjs/Maths/math.vector";
  48114. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48115. /**
  48116. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48117. * @see https://doc.babylonjs.com/features/cameras
  48118. */
  48119. export class StereoscopicUniversalCamera extends UniversalCamera {
  48120. /**
  48121. * Creates a new StereoscopicUniversalCamera
  48122. * @param name defines camera name
  48123. * @param position defines initial position
  48124. * @param interaxialDistance defines distance between each color axis
  48125. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48126. * @param scene defines the hosting scene
  48127. */
  48128. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48129. /**
  48130. * Gets camera class name
  48131. * @returns StereoscopicUniversalCamera
  48132. */
  48133. getClassName(): string;
  48134. }
  48135. }
  48136. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48137. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48138. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48139. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48140. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48141. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48142. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48143. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48144. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48145. }
  48146. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48147. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48148. import { Scene } from "babylonjs/scene";
  48149. import { Vector3 } from "babylonjs/Maths/math.vector";
  48150. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48151. /**
  48152. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48153. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48154. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48155. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48156. */
  48157. export class VirtualJoysticksCamera extends FreeCamera {
  48158. /**
  48159. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48160. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48161. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48162. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48163. * @param name Define the name of the camera in the scene
  48164. * @param position Define the start position of the camera in the scene
  48165. * @param scene Define the scene the camera belongs to
  48166. */
  48167. constructor(name: string, position: Vector3, scene: Scene);
  48168. /**
  48169. * Gets the current object class name.
  48170. * @return the class name
  48171. */
  48172. getClassName(): string;
  48173. }
  48174. }
  48175. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48176. import { Matrix } from "babylonjs/Maths/math.vector";
  48177. /**
  48178. * This represents all the required metrics to create a VR camera.
  48179. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48180. */
  48181. export class VRCameraMetrics {
  48182. /**
  48183. * Define the horizontal resolution off the screen.
  48184. */
  48185. hResolution: number;
  48186. /**
  48187. * Define the vertical resolution off the screen.
  48188. */
  48189. vResolution: number;
  48190. /**
  48191. * Define the horizontal screen size.
  48192. */
  48193. hScreenSize: number;
  48194. /**
  48195. * Define the vertical screen size.
  48196. */
  48197. vScreenSize: number;
  48198. /**
  48199. * Define the vertical screen center position.
  48200. */
  48201. vScreenCenter: number;
  48202. /**
  48203. * Define the distance of the eyes to the screen.
  48204. */
  48205. eyeToScreenDistance: number;
  48206. /**
  48207. * Define the distance between both lenses
  48208. */
  48209. lensSeparationDistance: number;
  48210. /**
  48211. * Define the distance between both viewer's eyes.
  48212. */
  48213. interpupillaryDistance: number;
  48214. /**
  48215. * Define the distortion factor of the VR postprocess.
  48216. * Please, touch with care.
  48217. */
  48218. distortionK: number[];
  48219. /**
  48220. * Define the chromatic aberration correction factors for the VR post process.
  48221. */
  48222. chromaAbCorrection: number[];
  48223. /**
  48224. * Define the scale factor of the post process.
  48225. * The smaller the better but the slower.
  48226. */
  48227. postProcessScaleFactor: number;
  48228. /**
  48229. * Define an offset for the lens center.
  48230. */
  48231. lensCenterOffset: number;
  48232. /**
  48233. * Define if the current vr camera should compensate the distortion of the lense or not.
  48234. */
  48235. compensateDistortion: boolean;
  48236. /**
  48237. * Defines if multiview should be enabled when rendering (Default: false)
  48238. */
  48239. multiviewEnabled: boolean;
  48240. /**
  48241. * Gets the rendering aspect ratio based on the provided resolutions.
  48242. */
  48243. get aspectRatio(): number;
  48244. /**
  48245. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48246. */
  48247. get aspectRatioFov(): number;
  48248. /**
  48249. * @hidden
  48250. */
  48251. get leftHMatrix(): Matrix;
  48252. /**
  48253. * @hidden
  48254. */
  48255. get rightHMatrix(): Matrix;
  48256. /**
  48257. * @hidden
  48258. */
  48259. get leftPreViewMatrix(): Matrix;
  48260. /**
  48261. * @hidden
  48262. */
  48263. get rightPreViewMatrix(): Matrix;
  48264. /**
  48265. * Get the default VRMetrics based on the most generic setup.
  48266. * @returns the default vr metrics
  48267. */
  48268. static GetDefault(): VRCameraMetrics;
  48269. }
  48270. }
  48271. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48272. /** @hidden */
  48273. export var vrDistortionCorrectionPixelShader: {
  48274. name: string;
  48275. shader: string;
  48276. };
  48277. }
  48278. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48279. import { Camera } from "babylonjs/Cameras/camera";
  48280. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48281. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48282. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48283. /**
  48284. * VRDistortionCorrectionPostProcess used for mobile VR
  48285. */
  48286. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48287. private _isRightEye;
  48288. private _distortionFactors;
  48289. private _postProcessScaleFactor;
  48290. private _lensCenterOffset;
  48291. private _scaleIn;
  48292. private _scaleFactor;
  48293. private _lensCenter;
  48294. /**
  48295. * Gets a string identifying the name of the class
  48296. * @returns "VRDistortionCorrectionPostProcess" string
  48297. */
  48298. getClassName(): string;
  48299. /**
  48300. * Initializes the VRDistortionCorrectionPostProcess
  48301. * @param name The name of the effect.
  48302. * @param camera The camera to apply the render pass to.
  48303. * @param isRightEye If this is for the right eye distortion
  48304. * @param vrMetrics All the required metrics for the VR camera
  48305. */
  48306. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48307. }
  48308. }
  48309. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48310. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48311. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48312. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48313. import { Scene } from "babylonjs/scene";
  48314. import { Vector3 } from "babylonjs/Maths/math.vector";
  48315. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48316. import "babylonjs/Cameras/RigModes/vrRigMode";
  48317. /**
  48318. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48319. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48320. */
  48321. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48322. /**
  48323. * Creates a new VRDeviceOrientationArcRotateCamera
  48324. * @param name defines camera name
  48325. * @param alpha defines the camera rotation along the logitudinal axis
  48326. * @param beta defines the camera rotation along the latitudinal axis
  48327. * @param radius defines the camera distance from its target
  48328. * @param target defines the camera target
  48329. * @param scene defines the scene the camera belongs to
  48330. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48331. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48332. */
  48333. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48334. /**
  48335. * Gets camera class name
  48336. * @returns VRDeviceOrientationArcRotateCamera
  48337. */
  48338. getClassName(): string;
  48339. }
  48340. }
  48341. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48342. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48343. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48344. import { Scene } from "babylonjs/scene";
  48345. import { Vector3 } from "babylonjs/Maths/math.vector";
  48346. import "babylonjs/Cameras/RigModes/vrRigMode";
  48347. /**
  48348. * Camera used to simulate VR rendering (based on FreeCamera)
  48349. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48350. */
  48351. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48352. /**
  48353. * Creates a new VRDeviceOrientationFreeCamera
  48354. * @param name defines camera name
  48355. * @param position defines the start position of the camera
  48356. * @param scene defines the scene the camera belongs to
  48357. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48358. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48359. */
  48360. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48361. /**
  48362. * Gets camera class name
  48363. * @returns VRDeviceOrientationFreeCamera
  48364. */
  48365. getClassName(): string;
  48366. }
  48367. }
  48368. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48369. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48370. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48371. import { Scene } from "babylonjs/scene";
  48372. import { Vector3 } from "babylonjs/Maths/math.vector";
  48373. import "babylonjs/Gamepads/gamepadSceneComponent";
  48374. /**
  48375. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48376. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48377. */
  48378. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48379. /**
  48380. * Creates a new VRDeviceOrientationGamepadCamera
  48381. * @param name defines camera name
  48382. * @param position defines the start position of the camera
  48383. * @param scene defines the scene the camera belongs to
  48384. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48385. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48386. */
  48387. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48388. /**
  48389. * Gets camera class name
  48390. * @returns VRDeviceOrientationGamepadCamera
  48391. */
  48392. getClassName(): string;
  48393. }
  48394. }
  48395. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48396. import { Scene } from "babylonjs/scene";
  48397. import { Texture } from "babylonjs/Materials/Textures/texture";
  48398. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48399. /**
  48400. * A class extending Texture allowing drawing on a texture
  48401. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48402. */
  48403. export class DynamicTexture extends Texture {
  48404. private _generateMipMaps;
  48405. private _canvas;
  48406. private _context;
  48407. /**
  48408. * Creates a DynamicTexture
  48409. * @param name defines the name of the texture
  48410. * @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
  48411. * @param scene defines the scene where you want the texture
  48412. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48413. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48414. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48415. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  48416. */
  48417. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  48418. /**
  48419. * Get the current class name of the texture useful for serialization or dynamic coding.
  48420. * @returns "DynamicTexture"
  48421. */
  48422. getClassName(): string;
  48423. /**
  48424. * Gets the current state of canRescale
  48425. */
  48426. get canRescale(): boolean;
  48427. private _recreate;
  48428. /**
  48429. * Scales the texture
  48430. * @param ratio the scale factor to apply to both width and height
  48431. */
  48432. scale(ratio: number): void;
  48433. /**
  48434. * Resizes the texture
  48435. * @param width the new width
  48436. * @param height the new height
  48437. */
  48438. scaleTo(width: number, height: number): void;
  48439. /**
  48440. * Gets the context of the canvas used by the texture
  48441. * @returns the canvas context of the dynamic texture
  48442. */
  48443. getContext(): CanvasRenderingContext2D;
  48444. /**
  48445. * Clears the texture
  48446. */
  48447. clear(): void;
  48448. /**
  48449. * Updates the texture
  48450. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48451. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48452. */
  48453. update(invertY?: boolean, premulAlpha?: boolean): void;
  48454. /**
  48455. * Draws text onto the texture
  48456. * @param text defines the text to be drawn
  48457. * @param x defines the placement of the text from the left
  48458. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48459. * @param font defines the font to be used with font-style, font-size, font-name
  48460. * @param color defines the color used for the text
  48461. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48462. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48463. * @param update defines whether texture is immediately update (default is true)
  48464. */
  48465. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48466. /**
  48467. * Clones the texture
  48468. * @returns the clone of the texture.
  48469. */
  48470. clone(): DynamicTexture;
  48471. /**
  48472. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48473. * @returns a serialized dynamic texture object
  48474. */
  48475. serialize(): any;
  48476. private _IsCanvasElement;
  48477. /** @hidden */
  48478. _rebuild(): void;
  48479. }
  48480. }
  48481. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48482. import { Scene } from "babylonjs/scene";
  48483. import { Color3 } from "babylonjs/Maths/math.color";
  48484. import { Mesh } from "babylonjs/Meshes/mesh";
  48485. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48486. import { Nullable } from "babylonjs/types";
  48487. /**
  48488. * Class containing static functions to help procedurally build meshes
  48489. */
  48490. export class GroundBuilder {
  48491. /**
  48492. * Creates a ground mesh
  48493. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48494. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48496. * @param name defines the name of the mesh
  48497. * @param options defines the options used to create the mesh
  48498. * @param scene defines the hosting scene
  48499. * @returns the ground mesh
  48500. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48501. */
  48502. static CreateGround(name: string, options: {
  48503. width?: number;
  48504. height?: number;
  48505. subdivisions?: number;
  48506. subdivisionsX?: number;
  48507. subdivisionsY?: number;
  48508. updatable?: boolean;
  48509. }, scene: any): Mesh;
  48510. /**
  48511. * Creates a tiled ground mesh
  48512. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48513. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48514. * * 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
  48515. * * 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
  48516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48517. * @param name defines the name of the mesh
  48518. * @param options defines the options used to create the mesh
  48519. * @param scene defines the hosting scene
  48520. * @returns the tiled ground mesh
  48521. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48522. */
  48523. static CreateTiledGround(name: string, options: {
  48524. xmin: number;
  48525. zmin: number;
  48526. xmax: number;
  48527. zmax: number;
  48528. subdivisions?: {
  48529. w: number;
  48530. h: number;
  48531. };
  48532. precision?: {
  48533. w: number;
  48534. h: number;
  48535. };
  48536. updatable?: boolean;
  48537. }, scene?: Nullable<Scene>): Mesh;
  48538. /**
  48539. * Creates a ground mesh from a height map
  48540. * * The parameter `url` sets the URL of the height map image resource.
  48541. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48542. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48543. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48544. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48545. * * 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.
  48546. * * 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).
  48547. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48549. * @param name defines the name of the mesh
  48550. * @param url defines the url to the height map
  48551. * @param options defines the options used to create the mesh
  48552. * @param scene defines the hosting scene
  48553. * @returns the ground mesh
  48554. * @see https://doc.babylonjs.com/babylon101/height_map
  48555. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48556. */
  48557. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48558. width?: number;
  48559. height?: number;
  48560. subdivisions?: number;
  48561. minHeight?: number;
  48562. maxHeight?: number;
  48563. colorFilter?: Color3;
  48564. alphaFilter?: number;
  48565. updatable?: boolean;
  48566. onReady?: (mesh: GroundMesh) => void;
  48567. }, scene?: Nullable<Scene>): GroundMesh;
  48568. }
  48569. }
  48570. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48571. import { Vector4 } from "babylonjs/Maths/math.vector";
  48572. import { Mesh } from "babylonjs/Meshes/mesh";
  48573. /**
  48574. * Class containing static functions to help procedurally build meshes
  48575. */
  48576. export class TorusBuilder {
  48577. /**
  48578. * Creates a torus mesh
  48579. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48580. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48581. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48585. * @param name defines the name of the mesh
  48586. * @param options defines the options used to create the mesh
  48587. * @param scene defines the hosting scene
  48588. * @returns the torus mesh
  48589. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48590. */
  48591. static CreateTorus(name: string, options: {
  48592. diameter?: number;
  48593. thickness?: number;
  48594. tessellation?: number;
  48595. updatable?: boolean;
  48596. sideOrientation?: number;
  48597. frontUVs?: Vector4;
  48598. backUVs?: Vector4;
  48599. }, scene: any): Mesh;
  48600. }
  48601. }
  48602. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48603. import { Vector4 } from "babylonjs/Maths/math.vector";
  48604. import { Color4 } from "babylonjs/Maths/math.color";
  48605. import { Mesh } from "babylonjs/Meshes/mesh";
  48606. /**
  48607. * Class containing static functions to help procedurally build meshes
  48608. */
  48609. export class CylinderBuilder {
  48610. /**
  48611. * Creates a cylinder or a cone mesh
  48612. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48613. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48614. * * 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.
  48615. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48616. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48617. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48618. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48619. * * 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).
  48620. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48621. * * 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).
  48622. * * 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
  48623. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48624. * * 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
  48625. * * 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.
  48626. * * If `enclose` is false, a ring surface is one element.
  48627. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48628. * * 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
  48629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48632. * @param name defines the name of the mesh
  48633. * @param options defines the options used to create the mesh
  48634. * @param scene defines the hosting scene
  48635. * @returns the cylinder mesh
  48636. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48637. */
  48638. static CreateCylinder(name: string, options: {
  48639. height?: number;
  48640. diameterTop?: number;
  48641. diameterBottom?: number;
  48642. diameter?: number;
  48643. tessellation?: number;
  48644. subdivisions?: number;
  48645. arc?: number;
  48646. faceColors?: Color4[];
  48647. faceUV?: Vector4[];
  48648. updatable?: boolean;
  48649. hasRings?: boolean;
  48650. enclose?: boolean;
  48651. cap?: number;
  48652. sideOrientation?: number;
  48653. frontUVs?: Vector4;
  48654. backUVs?: Vector4;
  48655. }, scene: any): Mesh;
  48656. }
  48657. }
  48658. declare module "babylonjs/XR/webXRTypes" {
  48659. import { Nullable } from "babylonjs/types";
  48660. import { IDisposable } from "babylonjs/scene";
  48661. /**
  48662. * States of the webXR experience
  48663. */
  48664. export enum WebXRState {
  48665. /**
  48666. * Transitioning to being in XR mode
  48667. */
  48668. ENTERING_XR = 0,
  48669. /**
  48670. * Transitioning to non XR mode
  48671. */
  48672. EXITING_XR = 1,
  48673. /**
  48674. * In XR mode and presenting
  48675. */
  48676. IN_XR = 2,
  48677. /**
  48678. * Not entered XR mode
  48679. */
  48680. NOT_IN_XR = 3
  48681. }
  48682. /**
  48683. * Abstraction of the XR render target
  48684. */
  48685. export interface WebXRRenderTarget extends IDisposable {
  48686. /**
  48687. * xrpresent context of the canvas which can be used to display/mirror xr content
  48688. */
  48689. canvasContext: WebGLRenderingContext;
  48690. /**
  48691. * xr layer for the canvas
  48692. */
  48693. xrLayer: Nullable<XRWebGLLayer>;
  48694. /**
  48695. * Initializes the xr layer for the session
  48696. * @param xrSession xr session
  48697. * @returns a promise that will resolve once the XR Layer has been created
  48698. */
  48699. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48700. }
  48701. }
  48702. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48703. import { Nullable } from "babylonjs/types";
  48704. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48705. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48706. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48707. import { Observable } from "babylonjs/Misc/observable";
  48708. /**
  48709. * COnfiguration object for WebXR output canvas
  48710. */
  48711. export class WebXRManagedOutputCanvasOptions {
  48712. /**
  48713. * An optional canvas in case you wish to create it yourself and provide it here.
  48714. * If not provided, a new canvas will be created
  48715. */
  48716. canvasElement?: HTMLCanvasElement;
  48717. /**
  48718. * Options for this XR Layer output
  48719. */
  48720. canvasOptions?: XRWebGLLayerOptions;
  48721. /**
  48722. * CSS styling for a newly created canvas (if not provided)
  48723. */
  48724. newCanvasCssStyle?: string;
  48725. /**
  48726. * Get the default values of the configuration object
  48727. * @param engine defines the engine to use (can be null)
  48728. * @returns default values of this configuration object
  48729. */
  48730. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48731. }
  48732. /**
  48733. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48734. */
  48735. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48736. private _options;
  48737. private _canvas;
  48738. private _engine;
  48739. private _originalCanvasSize;
  48740. /**
  48741. * Rendering context of the canvas which can be used to display/mirror xr content
  48742. */
  48743. canvasContext: WebGLRenderingContext;
  48744. /**
  48745. * xr layer for the canvas
  48746. */
  48747. xrLayer: Nullable<XRWebGLLayer>;
  48748. /**
  48749. * Obseervers registered here will be triggered when the xr layer was initialized
  48750. */
  48751. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48752. /**
  48753. * Initializes the canvas to be added/removed upon entering/exiting xr
  48754. * @param _xrSessionManager The XR Session manager
  48755. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48756. */
  48757. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48758. /**
  48759. * Disposes of the object
  48760. */
  48761. dispose(): void;
  48762. /**
  48763. * Initializes the xr layer for the session
  48764. * @param xrSession xr session
  48765. * @returns a promise that will resolve once the XR Layer has been created
  48766. */
  48767. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48768. private _addCanvas;
  48769. private _removeCanvas;
  48770. private _setCanvasSize;
  48771. private _setManagedOutputCanvas;
  48772. }
  48773. }
  48774. declare module "babylonjs/XR/webXRSessionManager" {
  48775. import { Observable } from "babylonjs/Misc/observable";
  48776. import { Nullable } from "babylonjs/types";
  48777. import { IDisposable, Scene } from "babylonjs/scene";
  48778. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48779. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48780. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48781. /**
  48782. * Manages an XRSession to work with Babylon's engine
  48783. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48784. */
  48785. export class WebXRSessionManager implements IDisposable {
  48786. /** The scene which the session should be created for */
  48787. scene: Scene;
  48788. private _referenceSpace;
  48789. private _rttProvider;
  48790. private _sessionEnded;
  48791. private _xrNavigator;
  48792. private baseLayer;
  48793. /**
  48794. * The base reference space from which the session started. good if you want to reset your
  48795. * reference space
  48796. */
  48797. baseReferenceSpace: XRReferenceSpace;
  48798. /**
  48799. * Current XR frame
  48800. */
  48801. currentFrame: Nullable<XRFrame>;
  48802. /** WebXR timestamp updated every frame */
  48803. currentTimestamp: number;
  48804. /**
  48805. * Used just in case of a failure to initialize an immersive session.
  48806. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48807. */
  48808. defaultHeightCompensation: number;
  48809. /**
  48810. * Fires every time a new xrFrame arrives which can be used to update the camera
  48811. */
  48812. onXRFrameObservable: Observable<XRFrame>;
  48813. /**
  48814. * Fires when the reference space changed
  48815. */
  48816. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48817. /**
  48818. * Fires when the xr session is ended either by the device or manually done
  48819. */
  48820. onXRSessionEnded: Observable<any>;
  48821. /**
  48822. * Fires when the xr session is ended either by the device or manually done
  48823. */
  48824. onXRSessionInit: Observable<XRSession>;
  48825. /**
  48826. * Underlying xr session
  48827. */
  48828. session: XRSession;
  48829. /**
  48830. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48831. * or get the offset the player is currently at.
  48832. */
  48833. viewerReferenceSpace: XRReferenceSpace;
  48834. /**
  48835. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48836. * @param scene The scene which the session should be created for
  48837. */
  48838. constructor(
  48839. /** The scene which the session should be created for */
  48840. scene: Scene);
  48841. /**
  48842. * The current reference space used in this session. This reference space can constantly change!
  48843. * It is mainly used to offset the camera's position.
  48844. */
  48845. get referenceSpace(): XRReferenceSpace;
  48846. /**
  48847. * Set a new reference space and triggers the observable
  48848. */
  48849. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48850. /**
  48851. * Disposes of the session manager
  48852. */
  48853. dispose(): void;
  48854. /**
  48855. * Stops the xrSession and restores the render loop
  48856. * @returns Promise which resolves after it exits XR
  48857. */
  48858. exitXRAsync(): Promise<void>;
  48859. /**
  48860. * Gets the correct render target texture to be rendered this frame for this eye
  48861. * @param eye the eye for which to get the render target
  48862. * @returns the render target for the specified eye
  48863. */
  48864. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48865. /**
  48866. * Creates a WebXRRenderTarget object for the XR session
  48867. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48868. * @param options optional options to provide when creating a new render target
  48869. * @returns a WebXR render target to which the session can render
  48870. */
  48871. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48872. /**
  48873. * Initializes the manager
  48874. * After initialization enterXR can be called to start an XR session
  48875. * @returns Promise which resolves after it is initialized
  48876. */
  48877. initializeAsync(): Promise<void>;
  48878. /**
  48879. * Initializes an xr session
  48880. * @param xrSessionMode mode to initialize
  48881. * @param xrSessionInit defines optional and required values to pass to the session builder
  48882. * @returns a promise which will resolve once the session has been initialized
  48883. */
  48884. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48885. /**
  48886. * Checks if a session would be supported for the creation options specified
  48887. * @param sessionMode session mode to check if supported eg. immersive-vr
  48888. * @returns A Promise that resolves to true if supported and false if not
  48889. */
  48890. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48891. /**
  48892. * Resets the reference space to the one started the session
  48893. */
  48894. resetReferenceSpace(): void;
  48895. /**
  48896. * Starts rendering to the xr layer
  48897. */
  48898. runXRRenderLoop(): void;
  48899. /**
  48900. * Sets the reference space on the xr session
  48901. * @param referenceSpaceType space to set
  48902. * @returns a promise that will resolve once the reference space has been set
  48903. */
  48904. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48905. /**
  48906. * Updates the render state of the session
  48907. * @param state state to set
  48908. * @returns a promise that resolves once the render state has been updated
  48909. */
  48910. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48911. /**
  48912. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48913. * @param sessionMode defines the session to test
  48914. * @returns a promise with boolean as final value
  48915. */
  48916. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48917. private _createRenderTargetTexture;
  48918. }
  48919. }
  48920. declare module "babylonjs/XR/webXRCamera" {
  48921. import { Vector3 } from "babylonjs/Maths/math.vector";
  48922. import { Scene } from "babylonjs/scene";
  48923. import { Camera } from "babylonjs/Cameras/camera";
  48924. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48925. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48926. import { Observable } from "babylonjs/Misc/observable";
  48927. /**
  48928. * WebXR Camera which holds the views for the xrSession
  48929. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48930. */
  48931. export class WebXRCamera extends FreeCamera {
  48932. private _xrSessionManager;
  48933. private _firstFrame;
  48934. private _referenceQuaternion;
  48935. private _referencedPosition;
  48936. private _xrInvPositionCache;
  48937. private _xrInvQuaternionCache;
  48938. /**
  48939. * Observable raised before camera teleportation
  48940. */
  48941. onBeforeCameraTeleport: Observable<Vector3>;
  48942. /**
  48943. * Observable raised after camera teleportation
  48944. */
  48945. onAfterCameraTeleport: Observable<Vector3>;
  48946. /**
  48947. * Should position compensation execute on first frame.
  48948. * This is used when copying the position from a native (non XR) camera
  48949. */
  48950. compensateOnFirstFrame: boolean;
  48951. /**
  48952. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48953. * @param name the name of the camera
  48954. * @param scene the scene to add the camera to
  48955. * @param _xrSessionManager a constructed xr session manager
  48956. */
  48957. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48958. /**
  48959. * Return the user's height, unrelated to the current ground.
  48960. * This will be the y position of this camera, when ground level is 0.
  48961. */
  48962. get realWorldHeight(): number;
  48963. /** @hidden */
  48964. _updateForDualEyeDebugging(): void;
  48965. /**
  48966. * Sets this camera's transformation based on a non-vr camera
  48967. * @param otherCamera the non-vr camera to copy the transformation from
  48968. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48969. */
  48970. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48971. /**
  48972. * Gets the current instance class name ("WebXRCamera").
  48973. * @returns the class name
  48974. */
  48975. getClassName(): string;
  48976. private _rotate180;
  48977. private _updateFromXRSession;
  48978. private _updateNumberOfRigCameras;
  48979. private _updateReferenceSpace;
  48980. private _updateReferenceSpaceOffset;
  48981. }
  48982. }
  48983. declare module "babylonjs/XR/webXRFeaturesManager" {
  48984. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48985. import { IDisposable } from "babylonjs/scene";
  48986. /**
  48987. * Defining the interface required for a (webxr) feature
  48988. */
  48989. export interface IWebXRFeature extends IDisposable {
  48990. /**
  48991. * Is this feature attached
  48992. */
  48993. attached: boolean;
  48994. /**
  48995. * Should auto-attach be disabled?
  48996. */
  48997. disableAutoAttach: boolean;
  48998. /**
  48999. * Attach the feature to the session
  49000. * Will usually be called by the features manager
  49001. *
  49002. * @param force should attachment be forced (even when already attached)
  49003. * @returns true if successful.
  49004. */
  49005. attach(force?: boolean): boolean;
  49006. /**
  49007. * Detach the feature from the session
  49008. * Will usually be called by the features manager
  49009. *
  49010. * @returns true if successful.
  49011. */
  49012. detach(): boolean;
  49013. /**
  49014. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  49015. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  49016. *
  49017. * @returns whether or not the feature is compatible in this environment
  49018. */
  49019. isCompatible(): boolean;
  49020. /**
  49021. * Was this feature disposed;
  49022. */
  49023. isDisposed: boolean;
  49024. /**
  49025. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  49026. */
  49027. xrNativeFeatureName?: string;
  49028. /**
  49029. * A list of (Babylon WebXR) features this feature depends on
  49030. */
  49031. dependsOn?: string[];
  49032. }
  49033. /**
  49034. * A list of the currently available features without referencing them
  49035. */
  49036. export class WebXRFeatureName {
  49037. /**
  49038. * The name of the anchor system feature
  49039. */
  49040. static readonly ANCHOR_SYSTEM: string;
  49041. /**
  49042. * The name of the background remover feature
  49043. */
  49044. static readonly BACKGROUND_REMOVER: string;
  49045. /**
  49046. * The name of the hit test feature
  49047. */
  49048. static readonly HIT_TEST: string;
  49049. /**
  49050. * physics impostors for xr controllers feature
  49051. */
  49052. static readonly PHYSICS_CONTROLLERS: string;
  49053. /**
  49054. * The name of the plane detection feature
  49055. */
  49056. static readonly PLANE_DETECTION: string;
  49057. /**
  49058. * The name of the pointer selection feature
  49059. */
  49060. static readonly POINTER_SELECTION: string;
  49061. /**
  49062. * The name of the teleportation feature
  49063. */
  49064. static readonly TELEPORTATION: string;
  49065. /**
  49066. * The name of the feature points feature.
  49067. */
  49068. static readonly FEATURE_POINTS: string;
  49069. /**
  49070. * The name of the hand tracking feature.
  49071. */
  49072. static readonly HAND_TRACKING: string;
  49073. }
  49074. /**
  49075. * Defining the constructor of a feature. Used to register the modules.
  49076. */
  49077. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49078. /**
  49079. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49080. * It is mainly used in AR sessions.
  49081. *
  49082. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49083. */
  49084. export class WebXRFeaturesManager implements IDisposable {
  49085. private _xrSessionManager;
  49086. private static readonly _AvailableFeatures;
  49087. private _features;
  49088. /**
  49089. * constructs a new features manages.
  49090. *
  49091. * @param _xrSessionManager an instance of WebXRSessionManager
  49092. */
  49093. constructor(_xrSessionManager: WebXRSessionManager);
  49094. /**
  49095. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49096. * Mainly used internally.
  49097. *
  49098. * @param featureName the name of the feature to register
  49099. * @param constructorFunction the function used to construct the module
  49100. * @param version the (babylon) version of the module
  49101. * @param stable is that a stable version of this module
  49102. */
  49103. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49104. /**
  49105. * Returns a constructor of a specific feature.
  49106. *
  49107. * @param featureName the name of the feature to construct
  49108. * @param version the version of the feature to load
  49109. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49110. * @param options optional options provided to the module.
  49111. * @returns a function that, when called, will return a new instance of this feature
  49112. */
  49113. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49114. /**
  49115. * Can be used to return the list of features currently registered
  49116. *
  49117. * @returns an Array of available features
  49118. */
  49119. static GetAvailableFeatures(): string[];
  49120. /**
  49121. * Gets the versions available for a specific feature
  49122. * @param featureName the name of the feature
  49123. * @returns an array with the available versions
  49124. */
  49125. static GetAvailableVersions(featureName: string): string[];
  49126. /**
  49127. * Return the latest unstable version of this feature
  49128. * @param featureName the name of the feature to search
  49129. * @returns the version number. if not found will return -1
  49130. */
  49131. static GetLatestVersionOfFeature(featureName: string): number;
  49132. /**
  49133. * Return the latest stable version of this feature
  49134. * @param featureName the name of the feature to search
  49135. * @returns the version number. if not found will return -1
  49136. */
  49137. static GetStableVersionOfFeature(featureName: string): number;
  49138. /**
  49139. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49140. * Can be used during a session to start a feature
  49141. * @param featureName the name of feature to attach
  49142. */
  49143. attachFeature(featureName: string): void;
  49144. /**
  49145. * Can be used inside a session or when the session ends to detach a specific feature
  49146. * @param featureName the name of the feature to detach
  49147. */
  49148. detachFeature(featureName: string): void;
  49149. /**
  49150. * Used to disable an already-enabled feature
  49151. * The feature will be disposed and will be recreated once enabled.
  49152. * @param featureName the feature to disable
  49153. * @returns true if disable was successful
  49154. */
  49155. disableFeature(featureName: string | {
  49156. Name: string;
  49157. }): boolean;
  49158. /**
  49159. * dispose this features manager
  49160. */
  49161. dispose(): void;
  49162. /**
  49163. * 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.
  49164. * 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.
  49165. *
  49166. * @param featureName the name of the feature to load or the class of the feature
  49167. * @param version optional version to load. if not provided the latest version will be enabled
  49168. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49169. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49170. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49171. * @returns a new constructed feature or throws an error if feature not found.
  49172. */
  49173. enableFeature(featureName: string | {
  49174. Name: string;
  49175. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49176. /**
  49177. * get the implementation of an enabled feature.
  49178. * @param featureName the name of the feature to load
  49179. * @returns the feature class, if found
  49180. */
  49181. getEnabledFeature(featureName: string): IWebXRFeature;
  49182. /**
  49183. * Get the list of enabled features
  49184. * @returns an array of enabled features
  49185. */
  49186. getEnabledFeatures(): string[];
  49187. /**
  49188. * This function will exten the session creation configuration object with enabled features.
  49189. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49190. * according to the defined "required" variable, provided during enableFeature call
  49191. * @param xrSessionInit the xr Session init object to extend
  49192. *
  49193. * @returns an extended XRSessionInit object
  49194. */
  49195. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49196. }
  49197. }
  49198. declare module "babylonjs/XR/webXRExperienceHelper" {
  49199. import { Observable } from "babylonjs/Misc/observable";
  49200. import { IDisposable, Scene } from "babylonjs/scene";
  49201. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49202. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49203. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49204. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49205. /**
  49206. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49207. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49208. */
  49209. export class WebXRExperienceHelper implements IDisposable {
  49210. private scene;
  49211. private _nonVRCamera;
  49212. private _originalSceneAutoClear;
  49213. private _supported;
  49214. /**
  49215. * Camera used to render xr content
  49216. */
  49217. camera: WebXRCamera;
  49218. /** A features manager for this xr session */
  49219. featuresManager: WebXRFeaturesManager;
  49220. /**
  49221. * Observers registered here will be triggered after the camera's initial transformation is set
  49222. * This can be used to set a different ground level or an extra rotation.
  49223. *
  49224. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49225. * to the position set after this observable is done executing.
  49226. */
  49227. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49228. /**
  49229. * Fires when the state of the experience helper has changed
  49230. */
  49231. onStateChangedObservable: Observable<WebXRState>;
  49232. /** Session manager used to keep track of xr session */
  49233. sessionManager: WebXRSessionManager;
  49234. /**
  49235. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49236. */
  49237. state: WebXRState;
  49238. /**
  49239. * Creates a WebXRExperienceHelper
  49240. * @param scene The scene the helper should be created in
  49241. */
  49242. private constructor();
  49243. /**
  49244. * Creates the experience helper
  49245. * @param scene the scene to attach the experience helper to
  49246. * @returns a promise for the experience helper
  49247. */
  49248. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49249. /**
  49250. * Disposes of the experience helper
  49251. */
  49252. dispose(): void;
  49253. /**
  49254. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49255. * @param sessionMode options for the XR session
  49256. * @param referenceSpaceType frame of reference of the XR session
  49257. * @param renderTarget the output canvas that will be used to enter XR mode
  49258. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49259. * @returns promise that resolves after xr mode has entered
  49260. */
  49261. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49262. /**
  49263. * Exits XR mode and returns the scene to its original state
  49264. * @returns promise that resolves after xr mode has exited
  49265. */
  49266. exitXRAsync(): Promise<void>;
  49267. private _nonXRToXRCamera;
  49268. private _setState;
  49269. }
  49270. }
  49271. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49272. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49273. import { Observable } from "babylonjs/Misc/observable";
  49274. import { IDisposable } from "babylonjs/scene";
  49275. /**
  49276. * X-Y values for axes in WebXR
  49277. */
  49278. export interface IWebXRMotionControllerAxesValue {
  49279. /**
  49280. * The value of the x axis
  49281. */
  49282. x: number;
  49283. /**
  49284. * The value of the y-axis
  49285. */
  49286. y: number;
  49287. }
  49288. /**
  49289. * changed / previous values for the values of this component
  49290. */
  49291. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49292. /**
  49293. * current (this frame) value
  49294. */
  49295. current: T;
  49296. /**
  49297. * previous (last change) value
  49298. */
  49299. previous: T;
  49300. }
  49301. /**
  49302. * Represents changes in the component between current frame and last values recorded
  49303. */
  49304. export interface IWebXRMotionControllerComponentChanges {
  49305. /**
  49306. * will be populated with previous and current values if axes changed
  49307. */
  49308. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49309. /**
  49310. * will be populated with previous and current values if pressed changed
  49311. */
  49312. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49313. /**
  49314. * will be populated with previous and current values if touched changed
  49315. */
  49316. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49317. /**
  49318. * will be populated with previous and current values if value changed
  49319. */
  49320. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49321. }
  49322. /**
  49323. * This class represents a single component (for example button or thumbstick) of a motion controller
  49324. */
  49325. export class WebXRControllerComponent implements IDisposable {
  49326. /**
  49327. * the id of this component
  49328. */
  49329. id: string;
  49330. /**
  49331. * the type of the component
  49332. */
  49333. type: MotionControllerComponentType;
  49334. private _buttonIndex;
  49335. private _axesIndices;
  49336. private _axes;
  49337. private _changes;
  49338. private _currentValue;
  49339. private _hasChanges;
  49340. private _pressed;
  49341. private _touched;
  49342. /**
  49343. * button component type
  49344. */
  49345. static BUTTON_TYPE: MotionControllerComponentType;
  49346. /**
  49347. * squeeze component type
  49348. */
  49349. static SQUEEZE_TYPE: MotionControllerComponentType;
  49350. /**
  49351. * Thumbstick component type
  49352. */
  49353. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49354. /**
  49355. * Touchpad component type
  49356. */
  49357. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49358. /**
  49359. * trigger component type
  49360. */
  49361. static TRIGGER_TYPE: MotionControllerComponentType;
  49362. /**
  49363. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49364. * the axes data changes
  49365. */
  49366. onAxisValueChangedObservable: Observable<{
  49367. x: number;
  49368. y: number;
  49369. }>;
  49370. /**
  49371. * Observers registered here will be triggered when the state of a button changes
  49372. * State change is either pressed / touched / value
  49373. */
  49374. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49375. /**
  49376. * Creates a new component for a motion controller.
  49377. * It is created by the motion controller itself
  49378. *
  49379. * @param id the id of this component
  49380. * @param type the type of the component
  49381. * @param _buttonIndex index in the buttons array of the gamepad
  49382. * @param _axesIndices indices of the values in the axes array of the gamepad
  49383. */
  49384. constructor(
  49385. /**
  49386. * the id of this component
  49387. */
  49388. id: string,
  49389. /**
  49390. * the type of the component
  49391. */
  49392. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49393. /**
  49394. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49395. */
  49396. get axes(): IWebXRMotionControllerAxesValue;
  49397. /**
  49398. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49399. */
  49400. get changes(): IWebXRMotionControllerComponentChanges;
  49401. /**
  49402. * Return whether or not the component changed the last frame
  49403. */
  49404. get hasChanges(): boolean;
  49405. /**
  49406. * is the button currently pressed
  49407. */
  49408. get pressed(): boolean;
  49409. /**
  49410. * is the button currently touched
  49411. */
  49412. get touched(): boolean;
  49413. /**
  49414. * Get the current value of this component
  49415. */
  49416. get value(): number;
  49417. /**
  49418. * Dispose this component
  49419. */
  49420. dispose(): void;
  49421. /**
  49422. * Are there axes correlating to this component
  49423. * @return true is axes data is available
  49424. */
  49425. isAxes(): boolean;
  49426. /**
  49427. * Is this component a button (hence - pressable)
  49428. * @returns true if can be pressed
  49429. */
  49430. isButton(): boolean;
  49431. /**
  49432. * update this component using the gamepad object it is in. Called on every frame
  49433. * @param nativeController the native gamepad controller object
  49434. */
  49435. update(nativeController: IMinimalMotionControllerObject): void;
  49436. }
  49437. }
  49438. declare module "babylonjs/Loading/sceneLoader" {
  49439. import { Observable } from "babylonjs/Misc/observable";
  49440. import { Nullable } from "babylonjs/types";
  49441. import { Scene } from "babylonjs/scene";
  49442. import { Engine } from "babylonjs/Engines/engine";
  49443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49444. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49445. import { AssetContainer } from "babylonjs/assetContainer";
  49446. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49447. import { Skeleton } from "babylonjs/Bones/skeleton";
  49448. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49449. import { WebRequest } from "babylonjs/Misc/webRequest";
  49450. /**
  49451. * Interface used to represent data loading progression
  49452. */
  49453. export interface ISceneLoaderProgressEvent {
  49454. /**
  49455. * Defines if data length to load can be evaluated
  49456. */
  49457. readonly lengthComputable: boolean;
  49458. /**
  49459. * Defines the loaded data length
  49460. */
  49461. readonly loaded: number;
  49462. /**
  49463. * Defines the data length to load
  49464. */
  49465. readonly total: number;
  49466. }
  49467. /**
  49468. * Interface used by SceneLoader plugins to define supported file extensions
  49469. */
  49470. export interface ISceneLoaderPluginExtensions {
  49471. /**
  49472. * Defines the list of supported extensions
  49473. */
  49474. [extension: string]: {
  49475. isBinary: boolean;
  49476. };
  49477. }
  49478. /**
  49479. * Interface used by SceneLoader plugin factory
  49480. */
  49481. export interface ISceneLoaderPluginFactory {
  49482. /**
  49483. * Defines the name of the factory
  49484. */
  49485. name: string;
  49486. /**
  49487. * Function called to create a new plugin
  49488. * @return the new plugin
  49489. */
  49490. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49491. /**
  49492. * The callback that returns true if the data can be directly loaded.
  49493. * @param data string containing the file data
  49494. * @returns if the data can be loaded directly
  49495. */
  49496. canDirectLoad?(data: string): boolean;
  49497. }
  49498. /**
  49499. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49500. */
  49501. export interface ISceneLoaderPluginBase {
  49502. /**
  49503. * The friendly name of this plugin.
  49504. */
  49505. name: string;
  49506. /**
  49507. * The file extensions supported by this plugin.
  49508. */
  49509. extensions: string | ISceneLoaderPluginExtensions;
  49510. /**
  49511. * The callback called when loading from a url.
  49512. * @param scene scene loading this url
  49513. * @param url url to load
  49514. * @param onSuccess callback called when the file successfully loads
  49515. * @param onProgress callback called while file is loading (if the server supports this mode)
  49516. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49517. * @param onError callback called when the file fails to load
  49518. * @returns a file request object
  49519. */
  49520. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49521. /**
  49522. * The callback called when loading from a file object.
  49523. * @param scene scene loading this file
  49524. * @param file defines the file to load
  49525. * @param onSuccess defines the callback to call when data is loaded
  49526. * @param onProgress defines the callback to call during loading process
  49527. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49528. * @param onError defines the callback to call when an error occurs
  49529. * @returns a file request object
  49530. */
  49531. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49532. /**
  49533. * The callback that returns true if the data can be directly loaded.
  49534. * @param data string containing the file data
  49535. * @returns if the data can be loaded directly
  49536. */
  49537. canDirectLoad?(data: string): boolean;
  49538. /**
  49539. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49540. * @param scene scene loading this data
  49541. * @param data string containing the data
  49542. * @returns data to pass to the plugin
  49543. */
  49544. directLoad?(scene: Scene, data: string): any;
  49545. /**
  49546. * The callback that allows custom handling of the root url based on the response url.
  49547. * @param rootUrl the original root url
  49548. * @param responseURL the response url if available
  49549. * @returns the new root url
  49550. */
  49551. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49552. }
  49553. /**
  49554. * Interface used to define a SceneLoader plugin
  49555. */
  49556. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49557. /**
  49558. * Import meshes into a scene.
  49559. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49560. * @param scene The scene to import into
  49561. * @param data The data to import
  49562. * @param rootUrl The root url for scene and resources
  49563. * @param meshes The meshes array to import into
  49564. * @param particleSystems The particle systems array to import into
  49565. * @param skeletons The skeletons array to import into
  49566. * @param onError The callback when import fails
  49567. * @returns True if successful or false otherwise
  49568. */
  49569. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49570. /**
  49571. * Load into a scene.
  49572. * @param scene The scene to load into
  49573. * @param data The data to import
  49574. * @param rootUrl The root url for scene and resources
  49575. * @param onError The callback when import fails
  49576. * @returns True if successful or false otherwise
  49577. */
  49578. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49579. /**
  49580. * Load into an asset container.
  49581. * @param scene The scene to load into
  49582. * @param data The data to import
  49583. * @param rootUrl The root url for scene and resources
  49584. * @param onError The callback when import fails
  49585. * @returns The loaded asset container
  49586. */
  49587. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49588. }
  49589. /**
  49590. * Interface used to define an async SceneLoader plugin
  49591. */
  49592. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49593. /**
  49594. * Import meshes into a scene.
  49595. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49596. * @param scene The scene to import into
  49597. * @param data The data to import
  49598. * @param rootUrl The root url for scene and resources
  49599. * @param onProgress The callback when the load progresses
  49600. * @param fileName Defines the name of the file to load
  49601. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49602. */
  49603. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49604. meshes: AbstractMesh[];
  49605. particleSystems: IParticleSystem[];
  49606. skeletons: Skeleton[];
  49607. animationGroups: AnimationGroup[];
  49608. }>;
  49609. /**
  49610. * Load into a scene.
  49611. * @param scene The scene to load into
  49612. * @param data The data to import
  49613. * @param rootUrl The root url for scene and resources
  49614. * @param onProgress The callback when the load progresses
  49615. * @param fileName Defines the name of the file to load
  49616. * @returns Nothing
  49617. */
  49618. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49619. /**
  49620. * Load into an asset container.
  49621. * @param scene The scene to load into
  49622. * @param data The data to import
  49623. * @param rootUrl The root url for scene and resources
  49624. * @param onProgress The callback when the load progresses
  49625. * @param fileName Defines the name of the file to load
  49626. * @returns The loaded asset container
  49627. */
  49628. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49629. }
  49630. /**
  49631. * Mode that determines how to handle old animation groups before loading new ones.
  49632. */
  49633. export enum SceneLoaderAnimationGroupLoadingMode {
  49634. /**
  49635. * Reset all old animations to initial state then dispose them.
  49636. */
  49637. Clean = 0,
  49638. /**
  49639. * Stop all old animations.
  49640. */
  49641. Stop = 1,
  49642. /**
  49643. * Restart old animations from first frame.
  49644. */
  49645. Sync = 2,
  49646. /**
  49647. * Old animations remains untouched.
  49648. */
  49649. NoSync = 3
  49650. }
  49651. /**
  49652. * Defines a plugin registered by the SceneLoader
  49653. */
  49654. interface IRegisteredPlugin {
  49655. /**
  49656. * Defines the plugin to use
  49657. */
  49658. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49659. /**
  49660. * Defines if the plugin supports binary data
  49661. */
  49662. isBinary: boolean;
  49663. }
  49664. /**
  49665. * Class used to load scene from various file formats using registered plugins
  49666. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49667. */
  49668. export class SceneLoader {
  49669. /**
  49670. * No logging while loading
  49671. */
  49672. static readonly NO_LOGGING: number;
  49673. /**
  49674. * Minimal logging while loading
  49675. */
  49676. static readonly MINIMAL_LOGGING: number;
  49677. /**
  49678. * Summary logging while loading
  49679. */
  49680. static readonly SUMMARY_LOGGING: number;
  49681. /**
  49682. * Detailled logging while loading
  49683. */
  49684. static readonly DETAILED_LOGGING: number;
  49685. /**
  49686. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49687. */
  49688. static get ForceFullSceneLoadingForIncremental(): boolean;
  49689. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49690. /**
  49691. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49692. */
  49693. static get ShowLoadingScreen(): boolean;
  49694. static set ShowLoadingScreen(value: boolean);
  49695. /**
  49696. * Defines the current logging level (while loading the scene)
  49697. * @ignorenaming
  49698. */
  49699. static get loggingLevel(): number;
  49700. static set loggingLevel(value: number);
  49701. /**
  49702. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49703. */
  49704. static get CleanBoneMatrixWeights(): boolean;
  49705. static set CleanBoneMatrixWeights(value: boolean);
  49706. /**
  49707. * Event raised when a plugin is used to load a scene
  49708. */
  49709. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49710. private static _registeredPlugins;
  49711. private static _showingLoadingScreen;
  49712. /**
  49713. * Gets the default plugin (used to load Babylon files)
  49714. * @returns the .babylon plugin
  49715. */
  49716. static GetDefaultPlugin(): IRegisteredPlugin;
  49717. private static _GetPluginForExtension;
  49718. private static _GetPluginForDirectLoad;
  49719. private static _GetPluginForFilename;
  49720. private static _GetDirectLoad;
  49721. private static _LoadData;
  49722. private static _GetFileInfo;
  49723. /**
  49724. * Gets a plugin that can load the given extension
  49725. * @param extension defines the extension to load
  49726. * @returns a plugin or null if none works
  49727. */
  49728. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49729. /**
  49730. * Gets a boolean indicating that the given extension can be loaded
  49731. * @param extension defines the extension to load
  49732. * @returns true if the extension is supported
  49733. */
  49734. static IsPluginForExtensionAvailable(extension: string): boolean;
  49735. /**
  49736. * Adds a new plugin to the list of registered plugins
  49737. * @param plugin defines the plugin to add
  49738. */
  49739. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49740. /**
  49741. * Import meshes into a scene
  49742. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49743. * @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)
  49744. * @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)
  49745. * @param scene the instance of BABYLON.Scene to append to
  49746. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  49747. * @param onProgress a callback with a progress event for each file being loaded
  49748. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49749. * @param pluginExtension the extension used to determine the plugin
  49750. * @returns The loaded plugin
  49751. */
  49752. 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>;
  49753. /**
  49754. * Import meshes into a scene
  49755. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49756. * @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)
  49757. * @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)
  49758. * @param scene the instance of BABYLON.Scene to append to
  49759. * @param onProgress a callback with a progress event for each file being loaded
  49760. * @param pluginExtension the extension used to determine the plugin
  49761. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49762. */
  49763. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49764. meshes: AbstractMesh[];
  49765. particleSystems: IParticleSystem[];
  49766. skeletons: Skeleton[];
  49767. animationGroups: AnimationGroup[];
  49768. }>;
  49769. /**
  49770. * Load a scene
  49771. * @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)
  49772. * @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)
  49773. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49774. * @param onSuccess a callback with the scene when import succeeds
  49775. * @param onProgress a callback with a progress event for each file being loaded
  49776. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49777. * @param pluginExtension the extension used to determine the plugin
  49778. * @returns The loaded plugin
  49779. */
  49780. 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>;
  49781. /**
  49782. * Load a scene
  49783. * @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)
  49784. * @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)
  49785. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49786. * @param onProgress a callback with a progress event for each file being loaded
  49787. * @param pluginExtension the extension used to determine the plugin
  49788. * @returns The loaded scene
  49789. */
  49790. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49791. /**
  49792. * Append a scene
  49793. * @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)
  49794. * @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)
  49795. * @param scene is the instance of BABYLON.Scene to append to
  49796. * @param onSuccess a callback with the scene when import succeeds
  49797. * @param onProgress a callback with a progress event for each file being loaded
  49798. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49799. * @param pluginExtension the extension used to determine the plugin
  49800. * @returns The loaded plugin
  49801. */
  49802. 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>;
  49803. /**
  49804. * Append a scene
  49805. * @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)
  49806. * @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)
  49807. * @param scene is the instance of BABYLON.Scene to append to
  49808. * @param onProgress a callback with a progress event for each file being loaded
  49809. * @param pluginExtension the extension used to determine the plugin
  49810. * @returns The given scene
  49811. */
  49812. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49813. /**
  49814. * Load a scene into an asset container
  49815. * @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)
  49816. * @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)
  49817. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49818. * @param onSuccess a callback with the scene when import succeeds
  49819. * @param onProgress a callback with a progress event for each file being loaded
  49820. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49821. * @param pluginExtension the extension used to determine the plugin
  49822. * @returns The loaded plugin
  49823. */
  49824. 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>;
  49825. /**
  49826. * Load a scene into an asset container
  49827. * @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)
  49828. * @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)
  49829. * @param scene is the instance of Scene to append to
  49830. * @param onProgress a callback with a progress event for each file being loaded
  49831. * @param pluginExtension the extension used to determine the plugin
  49832. * @returns The loaded asset container
  49833. */
  49834. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49835. /**
  49836. * Import animations from a file into a scene
  49837. * @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)
  49838. * @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)
  49839. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49840. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49841. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49842. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49843. * @param onSuccess a callback with the scene when import succeeds
  49844. * @param onProgress a callback with a progress event for each file being loaded
  49845. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49846. * @param pluginExtension the extension used to determine the plugin
  49847. */
  49848. 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;
  49849. /**
  49850. * Import animations from a file into a scene
  49851. * @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)
  49852. * @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)
  49853. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49854. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49855. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49856. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49857. * @param onSuccess a callback with the scene when import succeeds
  49858. * @param onProgress a callback with a progress event for each file being loaded
  49859. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49860. * @param pluginExtension the extension used to determine the plugin
  49861. * @returns the updated scene with imported animations
  49862. */
  49863. 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>;
  49864. }
  49865. }
  49866. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49867. import { IDisposable, Scene } from "babylonjs/scene";
  49868. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49869. import { Observable } from "babylonjs/Misc/observable";
  49870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49871. import { Nullable } from "babylonjs/types";
  49872. /**
  49873. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49874. */
  49875. export type MotionControllerHandedness = "none" | "left" | "right";
  49876. /**
  49877. * The type of components available in motion controllers.
  49878. * This is not the name of the component.
  49879. */
  49880. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49881. /**
  49882. * The state of a controller component
  49883. */
  49884. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49885. /**
  49886. * The schema of motion controller layout.
  49887. * No object will be initialized using this interface
  49888. * This is used just to define the profile.
  49889. */
  49890. export interface IMotionControllerLayout {
  49891. /**
  49892. * Path to load the assets. Usually relative to the base path
  49893. */
  49894. assetPath: string;
  49895. /**
  49896. * Available components (unsorted)
  49897. */
  49898. components: {
  49899. /**
  49900. * A map of component Ids
  49901. */
  49902. [componentId: string]: {
  49903. /**
  49904. * The type of input the component outputs
  49905. */
  49906. type: MotionControllerComponentType;
  49907. /**
  49908. * The indices of this component in the gamepad object
  49909. */
  49910. gamepadIndices: {
  49911. /**
  49912. * Index of button
  49913. */
  49914. button?: number;
  49915. /**
  49916. * If available, index of x-axis
  49917. */
  49918. xAxis?: number;
  49919. /**
  49920. * If available, index of y-axis
  49921. */
  49922. yAxis?: number;
  49923. };
  49924. /**
  49925. * The mesh's root node name
  49926. */
  49927. rootNodeName: string;
  49928. /**
  49929. * Animation definitions for this model
  49930. */
  49931. visualResponses: {
  49932. [stateKey: string]: {
  49933. /**
  49934. * What property will be animated
  49935. */
  49936. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49937. /**
  49938. * What states influence this visual response
  49939. */
  49940. states: MotionControllerComponentStateType[];
  49941. /**
  49942. * Type of animation - movement or visibility
  49943. */
  49944. valueNodeProperty: "transform" | "visibility";
  49945. /**
  49946. * Base node name to move. Its position will be calculated according to the min and max nodes
  49947. */
  49948. valueNodeName?: string;
  49949. /**
  49950. * Minimum movement node
  49951. */
  49952. minNodeName?: string;
  49953. /**
  49954. * Max movement node
  49955. */
  49956. maxNodeName?: string;
  49957. };
  49958. };
  49959. /**
  49960. * If touch enabled, what is the name of node to display user feedback
  49961. */
  49962. touchPointNodeName?: string;
  49963. };
  49964. };
  49965. /**
  49966. * Is it xr standard mapping or not
  49967. */
  49968. gamepadMapping: "" | "xr-standard";
  49969. /**
  49970. * Base root node of this entire model
  49971. */
  49972. rootNodeName: string;
  49973. /**
  49974. * Defines the main button component id
  49975. */
  49976. selectComponentId: string;
  49977. }
  49978. /**
  49979. * A definition for the layout map in the input profile
  49980. */
  49981. export interface IMotionControllerLayoutMap {
  49982. /**
  49983. * Layouts with handedness type as a key
  49984. */
  49985. [handedness: string]: IMotionControllerLayout;
  49986. }
  49987. /**
  49988. * The XR Input profile schema
  49989. * Profiles can be found here:
  49990. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49991. */
  49992. export interface IMotionControllerProfile {
  49993. /**
  49994. * fallback profiles for this profileId
  49995. */
  49996. fallbackProfileIds: string[];
  49997. /**
  49998. * The layout map, with handedness as key
  49999. */
  50000. layouts: IMotionControllerLayoutMap;
  50001. /**
  50002. * The id of this profile
  50003. * correlates to the profile(s) in the xrInput.profiles array
  50004. */
  50005. profileId: string;
  50006. }
  50007. /**
  50008. * A helper-interface for the 3 meshes needed for controller button animation
  50009. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  50010. */
  50011. export interface IMotionControllerButtonMeshMap {
  50012. /**
  50013. * the mesh that defines the pressed value mesh position.
  50014. * This is used to find the max-position of this button
  50015. */
  50016. pressedMesh: AbstractMesh;
  50017. /**
  50018. * the mesh that defines the unpressed value mesh position.
  50019. * This is used to find the min (or initial) position of this button
  50020. */
  50021. unpressedMesh: AbstractMesh;
  50022. /**
  50023. * The mesh that will be changed when value changes
  50024. */
  50025. valueMesh: AbstractMesh;
  50026. }
  50027. /**
  50028. * A helper-interface for the 3 meshes needed for controller axis animation.
  50029. * This will be expanded when touchpad animations are fully supported
  50030. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  50031. */
  50032. export interface IMotionControllerMeshMap {
  50033. /**
  50034. * the mesh that defines the maximum value mesh position.
  50035. */
  50036. maxMesh?: AbstractMesh;
  50037. /**
  50038. * the mesh that defines the minimum value mesh position.
  50039. */
  50040. minMesh?: AbstractMesh;
  50041. /**
  50042. * The mesh that will be changed when axis value changes
  50043. */
  50044. valueMesh?: AbstractMesh;
  50045. }
  50046. /**
  50047. * The elements needed for change-detection of the gamepad objects in motion controllers
  50048. */
  50049. export interface IMinimalMotionControllerObject {
  50050. /**
  50051. * Available axes of this controller
  50052. */
  50053. axes: number[];
  50054. /**
  50055. * An array of available buttons
  50056. */
  50057. buttons: Array<{
  50058. /**
  50059. * Value of the button/trigger
  50060. */
  50061. value: number;
  50062. /**
  50063. * If the button/trigger is currently touched
  50064. */
  50065. touched: boolean;
  50066. /**
  50067. * If the button/trigger is currently pressed
  50068. */
  50069. pressed: boolean;
  50070. }>;
  50071. /**
  50072. * EXPERIMENTAL haptic support.
  50073. */
  50074. hapticActuators?: Array<{
  50075. pulse: (value: number, duration: number) => Promise<boolean>;
  50076. }>;
  50077. }
  50078. /**
  50079. * An Abstract Motion controller
  50080. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50081. * Each component has an observable to check for changes in value and state
  50082. */
  50083. export abstract class WebXRAbstractMotionController implements IDisposable {
  50084. protected scene: Scene;
  50085. protected layout: IMotionControllerLayout;
  50086. /**
  50087. * The gamepad object correlating to this controller
  50088. */
  50089. gamepadObject: IMinimalMotionControllerObject;
  50090. /**
  50091. * handedness (left/right/none) of this controller
  50092. */
  50093. handedness: MotionControllerHandedness;
  50094. private _initComponent;
  50095. private _modelReady;
  50096. /**
  50097. * A map of components (WebXRControllerComponent) in this motion controller
  50098. * Components have a ComponentType and can also have both button and axis definitions
  50099. */
  50100. readonly components: {
  50101. [id: string]: WebXRControllerComponent;
  50102. };
  50103. /**
  50104. * Disable the model's animation. Can be set at any time.
  50105. */
  50106. disableAnimation: boolean;
  50107. /**
  50108. * Observers registered here will be triggered when the model of this controller is done loading
  50109. */
  50110. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50111. /**
  50112. * The profile id of this motion controller
  50113. */
  50114. abstract profileId: string;
  50115. /**
  50116. * The root mesh of the model. It is null if the model was not yet initialized
  50117. */
  50118. rootMesh: Nullable<AbstractMesh>;
  50119. /**
  50120. * constructs a new abstract motion controller
  50121. * @param scene the scene to which the model of the controller will be added
  50122. * @param layout The profile layout to load
  50123. * @param gamepadObject The gamepad object correlating to this controller
  50124. * @param handedness handedness (left/right/none) of this controller
  50125. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50126. */
  50127. constructor(scene: Scene, layout: IMotionControllerLayout,
  50128. /**
  50129. * The gamepad object correlating to this controller
  50130. */
  50131. gamepadObject: IMinimalMotionControllerObject,
  50132. /**
  50133. * handedness (left/right/none) of this controller
  50134. */
  50135. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50136. /**
  50137. * Dispose this controller, the model mesh and all its components
  50138. */
  50139. dispose(): void;
  50140. /**
  50141. * Returns all components of specific type
  50142. * @param type the type to search for
  50143. * @return an array of components with this type
  50144. */
  50145. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50146. /**
  50147. * get a component based an its component id as defined in layout.components
  50148. * @param id the id of the component
  50149. * @returns the component correlates to the id or undefined if not found
  50150. */
  50151. getComponent(id: string): WebXRControllerComponent;
  50152. /**
  50153. * Get the list of components available in this motion controller
  50154. * @returns an array of strings correlating to available components
  50155. */
  50156. getComponentIds(): string[];
  50157. /**
  50158. * Get the first component of specific type
  50159. * @param type type of component to find
  50160. * @return a controller component or null if not found
  50161. */
  50162. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50163. /**
  50164. * Get the main (Select) component of this controller as defined in the layout
  50165. * @returns the main component of this controller
  50166. */
  50167. getMainComponent(): WebXRControllerComponent;
  50168. /**
  50169. * Loads the model correlating to this controller
  50170. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50171. * @returns A promise fulfilled with the result of the model loading
  50172. */
  50173. loadModel(): Promise<boolean>;
  50174. /**
  50175. * Update this model using the current XRFrame
  50176. * @param xrFrame the current xr frame to use and update the model
  50177. */
  50178. updateFromXRFrame(xrFrame: XRFrame): void;
  50179. /**
  50180. * Backwards compatibility due to a deeply-integrated typo
  50181. */
  50182. get handness(): XREye;
  50183. /**
  50184. * Pulse (vibrate) this controller
  50185. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50186. * Consecutive calls to this function will cancel the last pulse call
  50187. *
  50188. * @param value the strength of the pulse in 0.0...1.0 range
  50189. * @param duration Duration of the pulse in milliseconds
  50190. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50191. * @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
  50192. */
  50193. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50194. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50195. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50196. /**
  50197. * Moves the axis on the controller mesh based on its current state
  50198. * @param axis the index of the axis
  50199. * @param axisValue the value of the axis which determines the meshes new position
  50200. * @hidden
  50201. */
  50202. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50203. /**
  50204. * Update the model itself with the current frame data
  50205. * @param xrFrame the frame to use for updating the model mesh
  50206. */
  50207. protected updateModel(xrFrame: XRFrame): void;
  50208. /**
  50209. * Get the filename and path for this controller's model
  50210. * @returns a map of filename and path
  50211. */
  50212. protected abstract _getFilenameAndPath(): {
  50213. filename: string;
  50214. path: string;
  50215. };
  50216. /**
  50217. * This function is called before the mesh is loaded. It checks for loading constraints.
  50218. * For example, this function can check if the GLB loader is available
  50219. * If this function returns false, the generic controller will be loaded instead
  50220. * @returns Is the client ready to load the mesh
  50221. */
  50222. protected abstract _getModelLoadingConstraints(): boolean;
  50223. /**
  50224. * This function will be called after the model was successfully loaded and can be used
  50225. * for mesh transformations before it is available for the user
  50226. * @param meshes the loaded meshes
  50227. */
  50228. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50229. /**
  50230. * Set the root mesh for this controller. Important for the WebXR controller class
  50231. * @param meshes the loaded meshes
  50232. */
  50233. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50234. /**
  50235. * A function executed each frame that updates the mesh (if needed)
  50236. * @param xrFrame the current xrFrame
  50237. */
  50238. protected abstract _updateModel(xrFrame: XRFrame): void;
  50239. private _getGenericFilenameAndPath;
  50240. private _getGenericParentMesh;
  50241. }
  50242. }
  50243. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50244. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50246. import { Scene } from "babylonjs/scene";
  50247. /**
  50248. * A generic trigger-only motion controller for WebXR
  50249. */
  50250. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50251. /**
  50252. * Static version of the profile id of this controller
  50253. */
  50254. static ProfileId: string;
  50255. profileId: string;
  50256. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50257. protected _getFilenameAndPath(): {
  50258. filename: string;
  50259. path: string;
  50260. };
  50261. protected _getModelLoadingConstraints(): boolean;
  50262. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50263. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50264. protected _updateModel(): void;
  50265. }
  50266. }
  50267. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50268. import { Vector4 } from "babylonjs/Maths/math.vector";
  50269. import { Mesh } from "babylonjs/Meshes/mesh";
  50270. import { Scene } from "babylonjs/scene";
  50271. import { Nullable } from "babylonjs/types";
  50272. /**
  50273. * Class containing static functions to help procedurally build meshes
  50274. */
  50275. export class SphereBuilder {
  50276. /**
  50277. * Creates a sphere mesh
  50278. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50279. * * 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`)
  50280. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50281. * * 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
  50282. * * 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)
  50283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50286. * @param name defines the name of the mesh
  50287. * @param options defines the options used to create the mesh
  50288. * @param scene defines the hosting scene
  50289. * @returns the sphere mesh
  50290. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50291. */
  50292. static CreateSphere(name: string, options: {
  50293. segments?: number;
  50294. diameter?: number;
  50295. diameterX?: number;
  50296. diameterY?: number;
  50297. diameterZ?: number;
  50298. arc?: number;
  50299. slice?: number;
  50300. sideOrientation?: number;
  50301. frontUVs?: Vector4;
  50302. backUVs?: Vector4;
  50303. updatable?: boolean;
  50304. }, scene?: Nullable<Scene>): Mesh;
  50305. }
  50306. }
  50307. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50309. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50310. import { Scene } from "babylonjs/scene";
  50311. /**
  50312. * A profiled motion controller has its profile loaded from an online repository.
  50313. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50314. */
  50315. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50316. private _repositoryUrl;
  50317. private _buttonMeshMapping;
  50318. private _touchDots;
  50319. /**
  50320. * The profile ID of this controller. Will be populated when the controller initializes.
  50321. */
  50322. profileId: string;
  50323. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50324. dispose(): void;
  50325. protected _getFilenameAndPath(): {
  50326. filename: string;
  50327. path: string;
  50328. };
  50329. protected _getModelLoadingConstraints(): boolean;
  50330. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50331. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50332. protected _updateModel(_xrFrame: XRFrame): void;
  50333. }
  50334. }
  50335. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50336. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50337. import { Scene } from "babylonjs/scene";
  50338. /**
  50339. * A construction function type to create a new controller based on an xrInput object
  50340. */
  50341. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50342. /**
  50343. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50344. *
  50345. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50346. * it should be replaced with auto-loaded controllers.
  50347. *
  50348. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50349. */
  50350. export class WebXRMotionControllerManager {
  50351. private static _AvailableControllers;
  50352. private static _Fallbacks;
  50353. private static _ProfileLoadingPromises;
  50354. private static _ProfilesList;
  50355. /**
  50356. * The base URL of the online controller repository. Can be changed at any time.
  50357. */
  50358. static BaseRepositoryUrl: string;
  50359. /**
  50360. * Which repository gets priority - local or online
  50361. */
  50362. static PrioritizeOnlineRepository: boolean;
  50363. /**
  50364. * Use the online repository, or use only locally-defined controllers
  50365. */
  50366. static UseOnlineRepository: boolean;
  50367. /**
  50368. * Clear the cache used for profile loading and reload when requested again
  50369. */
  50370. static ClearProfilesCache(): void;
  50371. /**
  50372. * Register the default fallbacks.
  50373. * This function is called automatically when this file is imported.
  50374. */
  50375. static DefaultFallbacks(): void;
  50376. /**
  50377. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50378. * @param profileId the profile to which a fallback needs to be found
  50379. * @return an array with corresponding fallback profiles
  50380. */
  50381. static FindFallbackWithProfileId(profileId: string): string[];
  50382. /**
  50383. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50384. * The order of search:
  50385. *
  50386. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50387. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50388. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50389. * 4) return the generic trigger controller if none were found
  50390. *
  50391. * @param xrInput the xrInput to which a new controller is initialized
  50392. * @param scene the scene to which the model will be added
  50393. * @param forceProfile force a certain profile for this controller
  50394. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50395. */
  50396. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50397. /**
  50398. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50399. *
  50400. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50401. *
  50402. * @param type the profile type to register
  50403. * @param constructFunction the function to be called when loading this profile
  50404. */
  50405. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50406. /**
  50407. * Register a fallback to a specific profile.
  50408. * @param profileId the profileId that will receive the fallbacks
  50409. * @param fallbacks A list of fallback profiles
  50410. */
  50411. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50412. /**
  50413. * Will update the list of profiles available in the repository
  50414. * @return a promise that resolves to a map of profiles available online
  50415. */
  50416. static UpdateProfilesList(): Promise<{
  50417. [profile: string]: string;
  50418. }>;
  50419. private static _LoadProfileFromRepository;
  50420. private static _LoadProfilesFromAvailableControllers;
  50421. }
  50422. }
  50423. declare module "babylonjs/XR/webXRInputSource" {
  50424. import { Observable } from "babylonjs/Misc/observable";
  50425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50426. import { Ray } from "babylonjs/Culling/ray";
  50427. import { Scene } from "babylonjs/scene";
  50428. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50429. /**
  50430. * Configuration options for the WebXR controller creation
  50431. */
  50432. export interface IWebXRControllerOptions {
  50433. /**
  50434. * Should the controller mesh be animated when a user interacts with it
  50435. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50436. */
  50437. disableMotionControllerAnimation?: boolean;
  50438. /**
  50439. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50440. */
  50441. doNotLoadControllerMesh?: boolean;
  50442. /**
  50443. * Force a specific controller type for this controller.
  50444. * This can be used when creating your own profile or when testing different controllers
  50445. */
  50446. forceControllerProfile?: string;
  50447. /**
  50448. * Defines a rendering group ID for meshes that will be loaded.
  50449. * This is for the default controllers only.
  50450. */
  50451. renderingGroupId?: number;
  50452. }
  50453. /**
  50454. * Represents an XR controller
  50455. */
  50456. export class WebXRInputSource {
  50457. private _scene;
  50458. /** The underlying input source for the controller */
  50459. inputSource: XRInputSource;
  50460. private _options;
  50461. private _tmpVector;
  50462. private _uniqueId;
  50463. private _disposed;
  50464. /**
  50465. * 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
  50466. */
  50467. grip?: AbstractMesh;
  50468. /**
  50469. * If available, this is the gamepad object related to this controller.
  50470. * Using this object it is possible to get click events and trackpad changes of the
  50471. * webxr controller that is currently being used.
  50472. */
  50473. motionController?: WebXRAbstractMotionController;
  50474. /**
  50475. * Event that fires when the controller is removed/disposed.
  50476. * The object provided as event data is this controller, after associated assets were disposed.
  50477. * uniqueId is still available.
  50478. */
  50479. onDisposeObservable: Observable<WebXRInputSource>;
  50480. /**
  50481. * Will be triggered when the mesh associated with the motion controller is done loading.
  50482. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50483. * A shortened version of controller -> motion controller -> on mesh loaded.
  50484. */
  50485. onMeshLoadedObservable: Observable<AbstractMesh>;
  50486. /**
  50487. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50488. */
  50489. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50490. /**
  50491. * Pointer which can be used to select objects or attach a visible laser to
  50492. */
  50493. pointer: AbstractMesh;
  50494. /**
  50495. * Creates the input source object
  50496. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50497. * @param _scene the scene which the controller should be associated to
  50498. * @param inputSource the underlying input source for the controller
  50499. * @param _options options for this controller creation
  50500. */
  50501. constructor(_scene: Scene,
  50502. /** The underlying input source for the controller */
  50503. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50504. /**
  50505. * Get this controllers unique id
  50506. */
  50507. get uniqueId(): string;
  50508. /**
  50509. * Disposes of the object
  50510. */
  50511. dispose(): void;
  50512. /**
  50513. * Gets a world space ray coming from the pointer or grip
  50514. * @param result the resulting ray
  50515. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50516. */
  50517. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50518. /**
  50519. * Updates the controller pose based on the given XRFrame
  50520. * @param xrFrame xr frame to update the pose with
  50521. * @param referenceSpace reference space to use
  50522. */
  50523. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50524. }
  50525. }
  50526. declare module "babylonjs/XR/webXRInput" {
  50527. import { Observable } from "babylonjs/Misc/observable";
  50528. import { IDisposable } from "babylonjs/scene";
  50529. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50530. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50531. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50532. /**
  50533. * The schema for initialization options of the XR Input class
  50534. */
  50535. export interface IWebXRInputOptions {
  50536. /**
  50537. * If set to true no model will be automatically loaded
  50538. */
  50539. doNotLoadControllerMeshes?: boolean;
  50540. /**
  50541. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50542. * If not found, the xr input profile data will be used.
  50543. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50544. */
  50545. forceInputProfile?: string;
  50546. /**
  50547. * Do not send a request to the controller repository to load the profile.
  50548. *
  50549. * Instead, use the controllers available in babylon itself.
  50550. */
  50551. disableOnlineControllerRepository?: boolean;
  50552. /**
  50553. * A custom URL for the controllers repository
  50554. */
  50555. customControllersRepositoryURL?: string;
  50556. /**
  50557. * Should the controller model's components not move according to the user input
  50558. */
  50559. disableControllerAnimation?: boolean;
  50560. /**
  50561. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50562. */
  50563. controllerOptions?: IWebXRControllerOptions;
  50564. }
  50565. /**
  50566. * XR input used to track XR inputs such as controllers/rays
  50567. */
  50568. export class WebXRInput implements IDisposable {
  50569. /**
  50570. * the xr session manager for this session
  50571. */
  50572. xrSessionManager: WebXRSessionManager;
  50573. /**
  50574. * the WebXR camera for this session. Mainly used for teleportation
  50575. */
  50576. xrCamera: WebXRCamera;
  50577. private readonly options;
  50578. /**
  50579. * XR controllers being tracked
  50580. */
  50581. controllers: Array<WebXRInputSource>;
  50582. private _frameObserver;
  50583. private _sessionEndedObserver;
  50584. private _sessionInitObserver;
  50585. /**
  50586. * Event when a controller has been connected/added
  50587. */
  50588. onControllerAddedObservable: Observable<WebXRInputSource>;
  50589. /**
  50590. * Event when a controller has been removed/disconnected
  50591. */
  50592. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50593. /**
  50594. * Initializes the WebXRInput
  50595. * @param xrSessionManager the xr session manager for this session
  50596. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50597. * @param options = initialization options for this xr input
  50598. */
  50599. constructor(
  50600. /**
  50601. * the xr session manager for this session
  50602. */
  50603. xrSessionManager: WebXRSessionManager,
  50604. /**
  50605. * the WebXR camera for this session. Mainly used for teleportation
  50606. */
  50607. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50608. private _onInputSourcesChange;
  50609. private _addAndRemoveControllers;
  50610. /**
  50611. * Disposes of the object
  50612. */
  50613. dispose(): void;
  50614. }
  50615. }
  50616. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50617. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50618. import { Observable, EventState } from "babylonjs/Misc/observable";
  50619. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50620. /**
  50621. * This is the base class for all WebXR features.
  50622. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50623. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50624. */
  50625. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50626. protected _xrSessionManager: WebXRSessionManager;
  50627. private _attached;
  50628. private _removeOnDetach;
  50629. /**
  50630. * Is this feature disposed?
  50631. */
  50632. isDisposed: boolean;
  50633. /**
  50634. * Should auto-attach be disabled?
  50635. */
  50636. disableAutoAttach: boolean;
  50637. /**
  50638. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50639. */
  50640. xrNativeFeatureName: string;
  50641. /**
  50642. * Construct a new (abstract) WebXR feature
  50643. * @param _xrSessionManager the xr session manager for this feature
  50644. */
  50645. constructor(_xrSessionManager: WebXRSessionManager);
  50646. /**
  50647. * Is this feature attached
  50648. */
  50649. get attached(): boolean;
  50650. /**
  50651. * attach this feature
  50652. *
  50653. * @param force should attachment be forced (even when already attached)
  50654. * @returns true if successful, false is failed or already attached
  50655. */
  50656. attach(force?: boolean): boolean;
  50657. /**
  50658. * detach this feature.
  50659. *
  50660. * @returns true if successful, false if failed or already detached
  50661. */
  50662. detach(): boolean;
  50663. /**
  50664. * Dispose this feature and all of the resources attached
  50665. */
  50666. dispose(): void;
  50667. /**
  50668. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50669. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50670. *
  50671. * @returns whether or not the feature is compatible in this environment
  50672. */
  50673. isCompatible(): boolean;
  50674. /**
  50675. * This is used to register callbacks that will automatically be removed when detach is called.
  50676. * @param observable the observable to which the observer will be attached
  50677. * @param callback the callback to register
  50678. */
  50679. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50680. /**
  50681. * Code in this function will be executed on each xrFrame received from the browser.
  50682. * This function will not execute after the feature is detached.
  50683. * @param _xrFrame the current frame
  50684. */
  50685. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50686. }
  50687. }
  50688. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50689. import { IDisposable, Scene } from "babylonjs/scene";
  50690. import { Nullable } from "babylonjs/types";
  50691. import { Observable } from "babylonjs/Misc/observable";
  50692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50693. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50694. import { Camera } from "babylonjs/Cameras/camera";
  50695. /**
  50696. * Renders a layer on top of an existing scene
  50697. */
  50698. export class UtilityLayerRenderer implements IDisposable {
  50699. /** the original scene that will be rendered on top of */
  50700. originalScene: Scene;
  50701. private _pointerCaptures;
  50702. private _lastPointerEvents;
  50703. private static _DefaultUtilityLayer;
  50704. private static _DefaultKeepDepthUtilityLayer;
  50705. private _sharedGizmoLight;
  50706. private _renderCamera;
  50707. /**
  50708. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50709. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50710. * @returns the camera that is used when rendering the utility layer
  50711. */
  50712. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50713. /**
  50714. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50715. * @param cam the camera that should be used when rendering the utility layer
  50716. */
  50717. setRenderCamera(cam: Nullable<Camera>): void;
  50718. /**
  50719. * @hidden
  50720. * Light which used by gizmos to get light shading
  50721. */
  50722. _getSharedGizmoLight(): HemisphericLight;
  50723. /**
  50724. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50725. */
  50726. pickUtilitySceneFirst: boolean;
  50727. /**
  50728. * 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)
  50729. */
  50730. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50731. /**
  50732. * 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)
  50733. */
  50734. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50735. /**
  50736. * The scene that is rendered on top of the original scene
  50737. */
  50738. utilityLayerScene: Scene;
  50739. /**
  50740. * If the utility layer should automatically be rendered on top of existing scene
  50741. */
  50742. shouldRender: boolean;
  50743. /**
  50744. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50745. */
  50746. onlyCheckPointerDownEvents: boolean;
  50747. /**
  50748. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50749. */
  50750. processAllEvents: boolean;
  50751. /**
  50752. * Observable raised when the pointer move from the utility layer scene to the main scene
  50753. */
  50754. onPointerOutObservable: Observable<number>;
  50755. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50756. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50757. private _afterRenderObserver;
  50758. private _sceneDisposeObserver;
  50759. private _originalPointerObserver;
  50760. /**
  50761. * Instantiates a UtilityLayerRenderer
  50762. * @param originalScene the original scene that will be rendered on top of
  50763. * @param handleEvents boolean indicating if the utility layer should handle events
  50764. */
  50765. constructor(
  50766. /** the original scene that will be rendered on top of */
  50767. originalScene: Scene, handleEvents?: boolean);
  50768. private _notifyObservers;
  50769. /**
  50770. * Renders the utility layers scene on top of the original scene
  50771. */
  50772. render(): void;
  50773. /**
  50774. * Disposes of the renderer
  50775. */
  50776. dispose(): void;
  50777. private _updateCamera;
  50778. }
  50779. }
  50780. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50781. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50783. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50784. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50785. import { Scene } from "babylonjs/scene";
  50786. import { Nullable } from "babylonjs/types";
  50787. import { Color3 } from "babylonjs/Maths/math.color";
  50788. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50789. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50790. /**
  50791. * Options interface for the pointer selection module
  50792. */
  50793. export interface IWebXRControllerPointerSelectionOptions {
  50794. /**
  50795. * if provided, this scene will be used to render meshes.
  50796. */
  50797. customUtilityLayerScene?: Scene;
  50798. /**
  50799. * 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)
  50800. * If not disabled, the last picked point will be used to execute a pointer up event
  50801. * If disabled, pointer up event will be triggered right after the pointer down event.
  50802. * Used in screen and gaze target ray mode only
  50803. */
  50804. disablePointerUpOnTouchOut: boolean;
  50805. /**
  50806. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50807. */
  50808. forceGazeMode: boolean;
  50809. /**
  50810. * 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
  50811. * to start a new countdown to the pointer down event.
  50812. * Defaults to 1.
  50813. */
  50814. gazeModePointerMovedFactor?: number;
  50815. /**
  50816. * Different button type to use instead of the main component
  50817. */
  50818. overrideButtonId?: string;
  50819. /**
  50820. * use this rendering group id for the meshes (optional)
  50821. */
  50822. renderingGroupId?: number;
  50823. /**
  50824. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50825. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50826. * 3000 means 3 seconds between pointing at something and selecting it
  50827. */
  50828. timeToSelect?: number;
  50829. /**
  50830. * Should meshes created here be added to a utility layer or the main scene
  50831. */
  50832. useUtilityLayer?: boolean;
  50833. /**
  50834. * Optional WebXR camera to be used for gaze selection
  50835. */
  50836. gazeCamera?: WebXRCamera;
  50837. /**
  50838. * the xr input to use with this pointer selection
  50839. */
  50840. xrInput: WebXRInput;
  50841. }
  50842. /**
  50843. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50844. */
  50845. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50846. private readonly _options;
  50847. private static _idCounter;
  50848. private _attachController;
  50849. private _controllers;
  50850. private _scene;
  50851. private _tmpVectorForPickCompare;
  50852. /**
  50853. * The module's name
  50854. */
  50855. static readonly Name: string;
  50856. /**
  50857. * The (Babylon) version of this module.
  50858. * This is an integer representing the implementation version.
  50859. * This number does not correspond to the WebXR specs version
  50860. */
  50861. static readonly Version: number;
  50862. /**
  50863. * Disable lighting on the laser pointer (so it will always be visible)
  50864. */
  50865. disablePointerLighting: boolean;
  50866. /**
  50867. * Disable lighting on the selection mesh (so it will always be visible)
  50868. */
  50869. disableSelectionMeshLighting: boolean;
  50870. /**
  50871. * Should the laser pointer be displayed
  50872. */
  50873. displayLaserPointer: boolean;
  50874. /**
  50875. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50876. */
  50877. displaySelectionMesh: boolean;
  50878. /**
  50879. * This color will be set to the laser pointer when selection is triggered
  50880. */
  50881. laserPointerPickedColor: Color3;
  50882. /**
  50883. * Default color of the laser pointer
  50884. */
  50885. laserPointerDefaultColor: Color3;
  50886. /**
  50887. * default color of the selection ring
  50888. */
  50889. selectionMeshDefaultColor: Color3;
  50890. /**
  50891. * This color will be applied to the selection ring when selection is triggered
  50892. */
  50893. selectionMeshPickedColor: Color3;
  50894. /**
  50895. * Optional filter to be used for ray selection. This predicate shares behavior with
  50896. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50897. */
  50898. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50899. /**
  50900. * constructs a new background remover module
  50901. * @param _xrSessionManager the session manager for this module
  50902. * @param _options read-only options to be used in this module
  50903. */
  50904. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50905. /**
  50906. * attach this feature
  50907. * Will usually be called by the features manager
  50908. *
  50909. * @returns true if successful.
  50910. */
  50911. attach(): boolean;
  50912. /**
  50913. * detach this feature.
  50914. * Will usually be called by the features manager
  50915. *
  50916. * @returns true if successful.
  50917. */
  50918. detach(): boolean;
  50919. /**
  50920. * Will get the mesh under a specific pointer.
  50921. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50922. * @param controllerId the controllerId to check
  50923. * @returns The mesh under pointer or null if no mesh is under the pointer
  50924. */
  50925. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50926. /**
  50927. * Get the xr controller that correlates to the pointer id in the pointer event
  50928. *
  50929. * @param id the pointer id to search for
  50930. * @returns the controller that correlates to this id or null if not found
  50931. */
  50932. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50933. protected _onXRFrame(_xrFrame: XRFrame): void;
  50934. private _attachGazeMode;
  50935. private _attachScreenRayMode;
  50936. private _attachTrackedPointerRayMode;
  50937. private _convertNormalToDirectionOfRay;
  50938. private _detachController;
  50939. private _generateNewMeshPair;
  50940. private _pickingMoved;
  50941. private _updatePointerDistance;
  50942. /** @hidden */
  50943. get lasterPointerDefaultColor(): Color3;
  50944. }
  50945. }
  50946. declare module "babylonjs/XR/webXREnterExitUI" {
  50947. import { Nullable } from "babylonjs/types";
  50948. import { Observable } from "babylonjs/Misc/observable";
  50949. import { IDisposable, Scene } from "babylonjs/scene";
  50950. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50951. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50952. /**
  50953. * Button which can be used to enter a different mode of XR
  50954. */
  50955. export class WebXREnterExitUIButton {
  50956. /** button element */
  50957. element: HTMLElement;
  50958. /** XR initialization options for the button */
  50959. sessionMode: XRSessionMode;
  50960. /** Reference space type */
  50961. referenceSpaceType: XRReferenceSpaceType;
  50962. /**
  50963. * Creates a WebXREnterExitUIButton
  50964. * @param element button element
  50965. * @param sessionMode XR initialization session mode
  50966. * @param referenceSpaceType the type of reference space to be used
  50967. */
  50968. constructor(
  50969. /** button element */
  50970. element: HTMLElement,
  50971. /** XR initialization options for the button */
  50972. sessionMode: XRSessionMode,
  50973. /** Reference space type */
  50974. referenceSpaceType: XRReferenceSpaceType);
  50975. /**
  50976. * Extendable function which can be used to update the button's visuals when the state changes
  50977. * @param activeButton the current active button in the UI
  50978. */
  50979. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50980. }
  50981. /**
  50982. * Options to create the webXR UI
  50983. */
  50984. export class WebXREnterExitUIOptions {
  50985. /**
  50986. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50987. */
  50988. customButtons?: Array<WebXREnterExitUIButton>;
  50989. /**
  50990. * A reference space type to use when creating the default button.
  50991. * Default is local-floor
  50992. */
  50993. referenceSpaceType?: XRReferenceSpaceType;
  50994. /**
  50995. * Context to enter xr with
  50996. */
  50997. renderTarget?: Nullable<WebXRRenderTarget>;
  50998. /**
  50999. * A session mode to use when creating the default button.
  51000. * Default is immersive-vr
  51001. */
  51002. sessionMode?: XRSessionMode;
  51003. /**
  51004. * A list of optional features to init the session with
  51005. */
  51006. optionalFeatures?: string[];
  51007. /**
  51008. * A list of optional features to init the session with
  51009. */
  51010. requiredFeatures?: string[];
  51011. }
  51012. /**
  51013. * UI to allow the user to enter/exit XR mode
  51014. */
  51015. export class WebXREnterExitUI implements IDisposable {
  51016. private scene;
  51017. /** version of the options passed to this UI */
  51018. options: WebXREnterExitUIOptions;
  51019. private _activeButton;
  51020. private _buttons;
  51021. /**
  51022. * The HTML Div Element to which buttons are added.
  51023. */
  51024. readonly overlay: HTMLDivElement;
  51025. /**
  51026. * Fired every time the active button is changed.
  51027. *
  51028. * When xr is entered via a button that launches xr that button will be the callback parameter
  51029. *
  51030. * When exiting xr the callback parameter will be null)
  51031. */
  51032. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  51033. /**
  51034. *
  51035. * @param scene babylon scene object to use
  51036. * @param options (read-only) version of the options passed to this UI
  51037. */
  51038. private constructor();
  51039. /**
  51040. * Creates UI to allow the user to enter/exit XR mode
  51041. * @param scene the scene to add the ui to
  51042. * @param helper the xr experience helper to enter/exit xr with
  51043. * @param options options to configure the UI
  51044. * @returns the created ui
  51045. */
  51046. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  51047. /**
  51048. * Disposes of the XR UI component
  51049. */
  51050. dispose(): void;
  51051. private _updateButtons;
  51052. }
  51053. }
  51054. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51055. import { Vector3 } from "babylonjs/Maths/math.vector";
  51056. import { Color4 } from "babylonjs/Maths/math.color";
  51057. import { Nullable } from "babylonjs/types";
  51058. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51059. import { Scene } from "babylonjs/scene";
  51060. /**
  51061. * Class containing static functions to help procedurally build meshes
  51062. */
  51063. export class LinesBuilder {
  51064. /**
  51065. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51066. * * 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
  51067. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51068. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51069. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51070. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51071. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51072. * * 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
  51073. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51075. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51076. * @param name defines the name of the new line system
  51077. * @param options defines the options used to create the line system
  51078. * @param scene defines the hosting scene
  51079. * @returns a new line system mesh
  51080. */
  51081. static CreateLineSystem(name: string, options: {
  51082. lines: Vector3[][];
  51083. updatable?: boolean;
  51084. instance?: Nullable<LinesMesh>;
  51085. colors?: Nullable<Color4[][]>;
  51086. useVertexAlpha?: boolean;
  51087. }, scene: Nullable<Scene>): LinesMesh;
  51088. /**
  51089. * Creates a line mesh
  51090. * 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
  51091. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51092. * * The parameter `points` is an array successive Vector3
  51093. * * 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
  51094. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51095. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51096. * * When updating an instance, remember that only point positions can change, not the number of points
  51097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51098. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51099. * @param name defines the name of the new line system
  51100. * @param options defines the options used to create the line system
  51101. * @param scene defines the hosting scene
  51102. * @returns a new line mesh
  51103. */
  51104. static CreateLines(name: string, options: {
  51105. points: Vector3[];
  51106. updatable?: boolean;
  51107. instance?: Nullable<LinesMesh>;
  51108. colors?: Color4[];
  51109. useVertexAlpha?: boolean;
  51110. }, scene?: Nullable<Scene>): LinesMesh;
  51111. /**
  51112. * Creates a dashed line mesh
  51113. * * 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
  51114. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51115. * * The parameter `points` is an array successive Vector3
  51116. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51117. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51118. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51119. * * 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
  51120. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51121. * * When updating an instance, remember that only point positions can change, not the number of points
  51122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51123. * @param name defines the name of the mesh
  51124. * @param options defines the options used to create the mesh
  51125. * @param scene defines the hosting scene
  51126. * @returns the dashed line mesh
  51127. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51128. */
  51129. static CreateDashedLines(name: string, options: {
  51130. points: Vector3[];
  51131. dashSize?: number;
  51132. gapSize?: number;
  51133. dashNb?: number;
  51134. updatable?: boolean;
  51135. instance?: LinesMesh;
  51136. useVertexAlpha?: boolean;
  51137. }, scene?: Nullable<Scene>): LinesMesh;
  51138. }
  51139. }
  51140. declare module "babylonjs/Misc/timer" {
  51141. import { Observable, Observer } from "babylonjs/Misc/observable";
  51142. import { Nullable } from "babylonjs/types";
  51143. import { IDisposable } from "babylonjs/scene";
  51144. /**
  51145. * Construction options for a timer
  51146. */
  51147. export interface ITimerOptions<T> {
  51148. /**
  51149. * Time-to-end
  51150. */
  51151. timeout: number;
  51152. /**
  51153. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51154. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51155. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51156. */
  51157. contextObservable: Observable<T>;
  51158. /**
  51159. * Optional parameters when adding an observer to the observable
  51160. */
  51161. observableParameters?: {
  51162. mask?: number;
  51163. insertFirst?: boolean;
  51164. scope?: any;
  51165. };
  51166. /**
  51167. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51168. */
  51169. breakCondition?: (data?: ITimerData<T>) => boolean;
  51170. /**
  51171. * Will be triggered when the time condition has met
  51172. */
  51173. onEnded?: (data: ITimerData<any>) => void;
  51174. /**
  51175. * Will be triggered when the break condition has met (prematurely ended)
  51176. */
  51177. onAborted?: (data: ITimerData<any>) => void;
  51178. /**
  51179. * Optional function to execute on each tick (or count)
  51180. */
  51181. onTick?: (data: ITimerData<any>) => void;
  51182. }
  51183. /**
  51184. * An interface defining the data sent by the timer
  51185. */
  51186. export interface ITimerData<T> {
  51187. /**
  51188. * When did it start
  51189. */
  51190. startTime: number;
  51191. /**
  51192. * Time now
  51193. */
  51194. currentTime: number;
  51195. /**
  51196. * Time passed since started
  51197. */
  51198. deltaTime: number;
  51199. /**
  51200. * How much is completed, in [0.0...1.0].
  51201. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51202. */
  51203. completeRate: number;
  51204. /**
  51205. * What the registered observable sent in the last count
  51206. */
  51207. payload: T;
  51208. }
  51209. /**
  51210. * The current state of the timer
  51211. */
  51212. export enum TimerState {
  51213. /**
  51214. * Timer initialized, not yet started
  51215. */
  51216. INIT = 0,
  51217. /**
  51218. * Timer started and counting
  51219. */
  51220. STARTED = 1,
  51221. /**
  51222. * Timer ended (whether aborted or time reached)
  51223. */
  51224. ENDED = 2
  51225. }
  51226. /**
  51227. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51228. *
  51229. * @param options options with which to initialize this timer
  51230. */
  51231. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51232. /**
  51233. * An advanced implementation of a timer class
  51234. */
  51235. export class AdvancedTimer<T = any> implements IDisposable {
  51236. /**
  51237. * Will notify each time the timer calculates the remaining time
  51238. */
  51239. onEachCountObservable: Observable<ITimerData<T>>;
  51240. /**
  51241. * Will trigger when the timer was aborted due to the break condition
  51242. */
  51243. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51244. /**
  51245. * Will trigger when the timer ended successfully
  51246. */
  51247. onTimerEndedObservable: Observable<ITimerData<T>>;
  51248. /**
  51249. * Will trigger when the timer state has changed
  51250. */
  51251. onStateChangedObservable: Observable<TimerState>;
  51252. private _observer;
  51253. private _contextObservable;
  51254. private _observableParameters;
  51255. private _startTime;
  51256. private _timer;
  51257. private _state;
  51258. private _breakCondition;
  51259. private _timeToEnd;
  51260. private _breakOnNextTick;
  51261. /**
  51262. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51263. * @param options construction options for this advanced timer
  51264. */
  51265. constructor(options: ITimerOptions<T>);
  51266. /**
  51267. * set a breaking condition for this timer. Default is to never break during count
  51268. * @param predicate the new break condition. Returns true to break, false otherwise
  51269. */
  51270. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51271. /**
  51272. * Reset ALL associated observables in this advanced timer
  51273. */
  51274. clearObservables(): void;
  51275. /**
  51276. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51277. *
  51278. * @param timeToEnd how much time to measure until timer ended
  51279. */
  51280. start(timeToEnd?: number): void;
  51281. /**
  51282. * Will force a stop on the next tick.
  51283. */
  51284. stop(): void;
  51285. /**
  51286. * Dispose this timer, clearing all resources
  51287. */
  51288. dispose(): void;
  51289. private _setState;
  51290. private _tick;
  51291. private _stop;
  51292. }
  51293. }
  51294. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51295. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51296. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51297. import { Nullable } from "babylonjs/types";
  51298. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51300. import { Vector3 } from "babylonjs/Maths/math.vector";
  51301. import { Material } from "babylonjs/Materials/material";
  51302. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51303. import { Scene } from "babylonjs/scene";
  51304. /**
  51305. * The options container for the teleportation module
  51306. */
  51307. export interface IWebXRTeleportationOptions {
  51308. /**
  51309. * if provided, this scene will be used to render meshes.
  51310. */
  51311. customUtilityLayerScene?: Scene;
  51312. /**
  51313. * Values to configure the default target mesh
  51314. */
  51315. defaultTargetMeshOptions?: {
  51316. /**
  51317. * Fill color of the teleportation area
  51318. */
  51319. teleportationFillColor?: string;
  51320. /**
  51321. * Border color for the teleportation area
  51322. */
  51323. teleportationBorderColor?: string;
  51324. /**
  51325. * Disable the mesh's animation sequence
  51326. */
  51327. disableAnimation?: boolean;
  51328. /**
  51329. * Disable lighting on the material or the ring and arrow
  51330. */
  51331. disableLighting?: boolean;
  51332. /**
  51333. * Override the default material of the torus and arrow
  51334. */
  51335. torusArrowMaterial?: Material;
  51336. };
  51337. /**
  51338. * A list of meshes to use as floor meshes.
  51339. * Meshes can be added and removed after initializing the feature using the
  51340. * addFloorMesh and removeFloorMesh functions
  51341. * If empty, rotation will still work
  51342. */
  51343. floorMeshes?: AbstractMesh[];
  51344. /**
  51345. * use this rendering group id for the meshes (optional)
  51346. */
  51347. renderingGroupId?: number;
  51348. /**
  51349. * Should teleportation move only to snap points
  51350. */
  51351. snapPointsOnly?: boolean;
  51352. /**
  51353. * An array of points to which the teleportation will snap to.
  51354. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51355. */
  51356. snapPositions?: Vector3[];
  51357. /**
  51358. * How close should the teleportation ray be in order to snap to position.
  51359. * Default to 0.8 units (meters)
  51360. */
  51361. snapToPositionRadius?: number;
  51362. /**
  51363. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51364. * If you want to support rotation, make sure your mesh has a direction indicator.
  51365. *
  51366. * When left untouched, the default mesh will be initialized.
  51367. */
  51368. teleportationTargetMesh?: AbstractMesh;
  51369. /**
  51370. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51371. */
  51372. timeToTeleport?: number;
  51373. /**
  51374. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51375. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51376. */
  51377. useMainComponentOnly?: boolean;
  51378. /**
  51379. * Should meshes created here be added to a utility layer or the main scene
  51380. */
  51381. useUtilityLayer?: boolean;
  51382. /**
  51383. * Babylon XR Input class for controller
  51384. */
  51385. xrInput: WebXRInput;
  51386. /**
  51387. * Meshes that the teleportation ray cannot go through
  51388. */
  51389. pickBlockerMeshes?: AbstractMesh[];
  51390. }
  51391. /**
  51392. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51393. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51394. * the input of the attached controllers.
  51395. */
  51396. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51397. private _options;
  51398. private _controllers;
  51399. private _currentTeleportationControllerId;
  51400. private _floorMeshes;
  51401. private _quadraticBezierCurve;
  51402. private _selectionFeature;
  51403. private _snapToPositions;
  51404. private _snappedToPoint;
  51405. private _teleportationRingMaterial?;
  51406. private _tmpRay;
  51407. private _tmpVector;
  51408. private _tmpQuaternion;
  51409. /**
  51410. * The module's name
  51411. */
  51412. static readonly Name: string;
  51413. /**
  51414. * The (Babylon) version of this module.
  51415. * This is an integer representing the implementation version.
  51416. * This number does not correspond to the webxr specs version
  51417. */
  51418. static readonly Version: number;
  51419. /**
  51420. * Is movement backwards enabled
  51421. */
  51422. backwardsMovementEnabled: boolean;
  51423. /**
  51424. * Distance to travel when moving backwards
  51425. */
  51426. backwardsTeleportationDistance: number;
  51427. /**
  51428. * The distance from the user to the inspection point in the direction of the controller
  51429. * A higher number will allow the user to move further
  51430. * defaults to 5 (meters, in xr units)
  51431. */
  51432. parabolicCheckRadius: number;
  51433. /**
  51434. * Should the module support parabolic ray on top of direct ray
  51435. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51436. * Very helpful when moving between floors / different heights
  51437. */
  51438. parabolicRayEnabled: boolean;
  51439. /**
  51440. * How much rotation should be applied when rotating right and left
  51441. */
  51442. rotationAngle: number;
  51443. /**
  51444. * Is rotation enabled when moving forward?
  51445. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51446. */
  51447. rotationEnabled: boolean;
  51448. /**
  51449. * constructs a new anchor system
  51450. * @param _xrSessionManager an instance of WebXRSessionManager
  51451. * @param _options configuration object for this feature
  51452. */
  51453. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51454. /**
  51455. * Get the snapPointsOnly flag
  51456. */
  51457. get snapPointsOnly(): boolean;
  51458. /**
  51459. * Sets the snapPointsOnly flag
  51460. * @param snapToPoints should teleportation be exclusively to snap points
  51461. */
  51462. set snapPointsOnly(snapToPoints: boolean);
  51463. /**
  51464. * Add a new mesh to the floor meshes array
  51465. * @param mesh the mesh to use as floor mesh
  51466. */
  51467. addFloorMesh(mesh: AbstractMesh): void;
  51468. /**
  51469. * Add a new snap-to point to fix teleportation to this position
  51470. * @param newSnapPoint The new Snap-To point
  51471. */
  51472. addSnapPoint(newSnapPoint: Vector3): void;
  51473. attach(): boolean;
  51474. detach(): boolean;
  51475. dispose(): void;
  51476. /**
  51477. * Remove a mesh from the floor meshes array
  51478. * @param mesh the mesh to remove
  51479. */
  51480. removeFloorMesh(mesh: AbstractMesh): void;
  51481. /**
  51482. * Remove a mesh from the floor meshes array using its name
  51483. * @param name the mesh name to remove
  51484. */
  51485. removeFloorMeshByName(name: string): void;
  51486. /**
  51487. * 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
  51488. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51489. * @returns was the point found and removed or not
  51490. */
  51491. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51492. /**
  51493. * This function sets a selection feature that will be disabled when
  51494. * the forward ray is shown and will be reattached when hidden.
  51495. * This is used to remove the selection rays when moving.
  51496. * @param selectionFeature the feature to disable when forward movement is enabled
  51497. */
  51498. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51499. protected _onXRFrame(_xrFrame: XRFrame): void;
  51500. private _attachController;
  51501. private _createDefaultTargetMesh;
  51502. private _detachController;
  51503. private _findClosestSnapPointWithRadius;
  51504. private _setTargetMeshPosition;
  51505. private _setTargetMeshVisibility;
  51506. private _showParabolicPath;
  51507. private _teleportForward;
  51508. }
  51509. }
  51510. declare module "babylonjs/XR/webXRDefaultExperience" {
  51511. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51512. import { Scene } from "babylonjs/scene";
  51513. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51514. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51515. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51516. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51518. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51519. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51520. /**
  51521. * Options for the default xr helper
  51522. */
  51523. export class WebXRDefaultExperienceOptions {
  51524. /**
  51525. * Enable or disable default UI to enter XR
  51526. */
  51527. disableDefaultUI?: boolean;
  51528. /**
  51529. * Should teleportation not initialize. defaults to false.
  51530. */
  51531. disableTeleportation?: boolean;
  51532. /**
  51533. * Floor meshes that will be used for teleport
  51534. */
  51535. floorMeshes?: Array<AbstractMesh>;
  51536. /**
  51537. * If set to true, the first frame will not be used to reset position
  51538. * The first frame is mainly used when copying transformation from the old camera
  51539. * Mainly used in AR
  51540. */
  51541. ignoreNativeCameraTransformation?: boolean;
  51542. /**
  51543. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51544. */
  51545. inputOptions?: IWebXRInputOptions;
  51546. /**
  51547. * optional configuration for the output canvas
  51548. */
  51549. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51550. /**
  51551. * optional UI options. This can be used among other to change session mode and reference space type
  51552. */
  51553. uiOptions?: WebXREnterExitUIOptions;
  51554. /**
  51555. * When loading teleportation and pointer select, use stable versions instead of latest.
  51556. */
  51557. useStablePlugins?: boolean;
  51558. /**
  51559. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51560. */
  51561. renderingGroupId?: number;
  51562. /**
  51563. * A list of optional features to init the session with
  51564. * If set to true, all features we support will be added
  51565. */
  51566. optionalFeatures?: boolean | string[];
  51567. }
  51568. /**
  51569. * Default experience which provides a similar setup to the previous webVRExperience
  51570. */
  51571. export class WebXRDefaultExperience {
  51572. /**
  51573. * Base experience
  51574. */
  51575. baseExperience: WebXRExperienceHelper;
  51576. /**
  51577. * Enables ui for entering/exiting xr
  51578. */
  51579. enterExitUI: WebXREnterExitUI;
  51580. /**
  51581. * Input experience extension
  51582. */
  51583. input: WebXRInput;
  51584. /**
  51585. * Enables laser pointer and selection
  51586. */
  51587. pointerSelection: WebXRControllerPointerSelection;
  51588. /**
  51589. * Default target xr should render to
  51590. */
  51591. renderTarget: WebXRRenderTarget;
  51592. /**
  51593. * Enables teleportation
  51594. */
  51595. teleportation: WebXRMotionControllerTeleportation;
  51596. private constructor();
  51597. /**
  51598. * Creates the default xr experience
  51599. * @param scene scene
  51600. * @param options options for basic configuration
  51601. * @returns resulting WebXRDefaultExperience
  51602. */
  51603. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51604. /**
  51605. * DIsposes of the experience helper
  51606. */
  51607. dispose(): void;
  51608. }
  51609. }
  51610. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51611. import { Observable } from "babylonjs/Misc/observable";
  51612. import { Nullable } from "babylonjs/types";
  51613. import { Camera } from "babylonjs/Cameras/camera";
  51614. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51615. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51616. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51617. import { Scene } from "babylonjs/scene";
  51618. import { Vector3 } from "babylonjs/Maths/math.vector";
  51619. import { Color3 } from "babylonjs/Maths/math.color";
  51620. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51622. import { Mesh } from "babylonjs/Meshes/mesh";
  51623. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51624. import { EasingFunction } from "babylonjs/Animations/easing";
  51625. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51626. import "babylonjs/Meshes/Builders/groundBuilder";
  51627. import "babylonjs/Meshes/Builders/torusBuilder";
  51628. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51629. import "babylonjs/Gamepads/gamepadSceneComponent";
  51630. import "babylonjs/Animations/animatable";
  51631. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51632. /**
  51633. * Options to modify the vr teleportation behavior.
  51634. */
  51635. export interface VRTeleportationOptions {
  51636. /**
  51637. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51638. */
  51639. floorMeshName?: string;
  51640. /**
  51641. * A list of meshes to be used as the teleportation floor. (default: empty)
  51642. */
  51643. floorMeshes?: Mesh[];
  51644. /**
  51645. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51646. */
  51647. teleportationMode?: number;
  51648. /**
  51649. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51650. */
  51651. teleportationTime?: number;
  51652. /**
  51653. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51654. */
  51655. teleportationSpeed?: number;
  51656. /**
  51657. * The easing function used in the animation or null for Linear. (default CircleEase)
  51658. */
  51659. easingFunction?: EasingFunction;
  51660. }
  51661. /**
  51662. * Options to modify the vr experience helper's behavior.
  51663. */
  51664. export interface VRExperienceHelperOptions extends WebVROptions {
  51665. /**
  51666. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51667. */
  51668. createDeviceOrientationCamera?: boolean;
  51669. /**
  51670. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51671. */
  51672. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51673. /**
  51674. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51675. */
  51676. laserToggle?: boolean;
  51677. /**
  51678. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51679. */
  51680. floorMeshes?: Mesh[];
  51681. /**
  51682. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51683. */
  51684. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51685. /**
  51686. * Defines if WebXR should be used instead of WebVR (if available)
  51687. */
  51688. useXR?: boolean;
  51689. }
  51690. /**
  51691. * Event containing information after VR has been entered
  51692. */
  51693. export class OnAfterEnteringVRObservableEvent {
  51694. /**
  51695. * If entering vr was successful
  51696. */
  51697. success: boolean;
  51698. }
  51699. /**
  51700. * Helps to quickly add VR support to an existing scene.
  51701. * See https://doc.babylonjs.com/how_to/webvr_helper
  51702. */
  51703. export class VRExperienceHelper {
  51704. /** Options to modify the vr experience helper's behavior. */
  51705. webVROptions: VRExperienceHelperOptions;
  51706. private _scene;
  51707. private _position;
  51708. private _btnVR;
  51709. private _btnVRDisplayed;
  51710. private _webVRsupported;
  51711. private _webVRready;
  51712. private _webVRrequesting;
  51713. private _webVRpresenting;
  51714. private _hasEnteredVR;
  51715. private _fullscreenVRpresenting;
  51716. private _inputElement;
  51717. private _webVRCamera;
  51718. private _vrDeviceOrientationCamera;
  51719. private _deviceOrientationCamera;
  51720. private _existingCamera;
  51721. private _onKeyDown;
  51722. private _onVrDisplayPresentChange;
  51723. private _onVRDisplayChanged;
  51724. private _onVRRequestPresentStart;
  51725. private _onVRRequestPresentComplete;
  51726. /**
  51727. * 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)
  51728. */
  51729. enableGazeEvenWhenNoPointerLock: boolean;
  51730. /**
  51731. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51732. */
  51733. exitVROnDoubleTap: boolean;
  51734. /**
  51735. * Observable raised right before entering VR.
  51736. */
  51737. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51738. /**
  51739. * Observable raised when entering VR has completed.
  51740. */
  51741. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51742. /**
  51743. * Observable raised when exiting VR.
  51744. */
  51745. onExitingVRObservable: Observable<VRExperienceHelper>;
  51746. /**
  51747. * Observable raised when controller mesh is loaded.
  51748. */
  51749. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51750. /** Return this.onEnteringVRObservable
  51751. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51752. */
  51753. get onEnteringVR(): Observable<VRExperienceHelper>;
  51754. /** Return this.onExitingVRObservable
  51755. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51756. */
  51757. get onExitingVR(): Observable<VRExperienceHelper>;
  51758. /** Return this.onControllerMeshLoadedObservable
  51759. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51760. */
  51761. get onControllerMeshLoaded(): Observable<WebVRController>;
  51762. private _rayLength;
  51763. private _useCustomVRButton;
  51764. private _teleportationRequested;
  51765. private _teleportActive;
  51766. private _floorMeshName;
  51767. private _floorMeshesCollection;
  51768. private _teleportationMode;
  51769. private _teleportationTime;
  51770. private _teleportationSpeed;
  51771. private _teleportationEasing;
  51772. private _rotationAllowed;
  51773. private _teleportBackwardsVector;
  51774. private _teleportationTarget;
  51775. private _isDefaultTeleportationTarget;
  51776. private _postProcessMove;
  51777. private _teleportationFillColor;
  51778. private _teleportationBorderColor;
  51779. private _rotationAngle;
  51780. private _haloCenter;
  51781. private _cameraGazer;
  51782. private _padSensibilityUp;
  51783. private _padSensibilityDown;
  51784. private _leftController;
  51785. private _rightController;
  51786. private _gazeColor;
  51787. private _laserColor;
  51788. private _pickedLaserColor;
  51789. private _pickedGazeColor;
  51790. /**
  51791. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51792. */
  51793. onNewMeshSelected: Observable<AbstractMesh>;
  51794. /**
  51795. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51796. * This observable will provide the mesh and the controller used to select the mesh
  51797. */
  51798. onMeshSelectedWithController: Observable<{
  51799. mesh: AbstractMesh;
  51800. controller: WebVRController;
  51801. }>;
  51802. /**
  51803. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51804. */
  51805. onNewMeshPicked: Observable<PickingInfo>;
  51806. private _circleEase;
  51807. /**
  51808. * Observable raised before camera teleportation
  51809. */
  51810. onBeforeCameraTeleport: Observable<Vector3>;
  51811. /**
  51812. * Observable raised after camera teleportation
  51813. */
  51814. onAfterCameraTeleport: Observable<Vector3>;
  51815. /**
  51816. * Observable raised when current selected mesh gets unselected
  51817. */
  51818. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51819. private _raySelectionPredicate;
  51820. /**
  51821. * To be optionaly changed by user to define custom ray selection
  51822. */
  51823. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51824. /**
  51825. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51826. */
  51827. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51828. /**
  51829. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51830. */
  51831. teleportationEnabled: boolean;
  51832. private _defaultHeight;
  51833. private _teleportationInitialized;
  51834. private _interactionsEnabled;
  51835. private _interactionsRequested;
  51836. private _displayGaze;
  51837. private _displayLaserPointer;
  51838. /**
  51839. * The mesh used to display where the user is going to teleport.
  51840. */
  51841. get teleportationTarget(): Mesh;
  51842. /**
  51843. * Sets the mesh to be used to display where the user is going to teleport.
  51844. */
  51845. set teleportationTarget(value: Mesh);
  51846. /**
  51847. * 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
  51848. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51849. * See https://doc.babylonjs.com/resources/baking_transformations
  51850. */
  51851. get gazeTrackerMesh(): Mesh;
  51852. set gazeTrackerMesh(value: Mesh);
  51853. /**
  51854. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51855. */
  51856. updateGazeTrackerScale: boolean;
  51857. /**
  51858. * If the gaze trackers color should be updated when selecting meshes
  51859. */
  51860. updateGazeTrackerColor: boolean;
  51861. /**
  51862. * If the controller laser color should be updated when selecting meshes
  51863. */
  51864. updateControllerLaserColor: boolean;
  51865. /**
  51866. * The gaze tracking mesh corresponding to the left controller
  51867. */
  51868. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51869. /**
  51870. * The gaze tracking mesh corresponding to the right controller
  51871. */
  51872. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51873. /**
  51874. * If the ray of the gaze should be displayed.
  51875. */
  51876. get displayGaze(): boolean;
  51877. /**
  51878. * Sets if the ray of the gaze should be displayed.
  51879. */
  51880. set displayGaze(value: boolean);
  51881. /**
  51882. * If the ray of the LaserPointer should be displayed.
  51883. */
  51884. get displayLaserPointer(): boolean;
  51885. /**
  51886. * Sets if the ray of the LaserPointer should be displayed.
  51887. */
  51888. set displayLaserPointer(value: boolean);
  51889. /**
  51890. * The deviceOrientationCamera used as the camera when not in VR.
  51891. */
  51892. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51893. /**
  51894. * Based on the current WebVR support, returns the current VR camera used.
  51895. */
  51896. get currentVRCamera(): Nullable<Camera>;
  51897. /**
  51898. * The webVRCamera which is used when in VR.
  51899. */
  51900. get webVRCamera(): WebVRFreeCamera;
  51901. /**
  51902. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51903. */
  51904. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51905. /**
  51906. * The html button that is used to trigger entering into VR.
  51907. */
  51908. get vrButton(): Nullable<HTMLButtonElement>;
  51909. private get _teleportationRequestInitiated();
  51910. /**
  51911. * Defines whether or not Pointer lock should be requested when switching to
  51912. * full screen.
  51913. */
  51914. requestPointerLockOnFullScreen: boolean;
  51915. /**
  51916. * If asking to force XR, this will be populated with the default xr experience
  51917. */
  51918. xr: WebXRDefaultExperience;
  51919. /**
  51920. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51921. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51922. */
  51923. xrTestDone: boolean;
  51924. /**
  51925. * Instantiates a VRExperienceHelper.
  51926. * Helps to quickly add VR support to an existing scene.
  51927. * @param scene The scene the VRExperienceHelper belongs to.
  51928. * @param webVROptions Options to modify the vr experience helper's behavior.
  51929. */
  51930. constructor(scene: Scene,
  51931. /** Options to modify the vr experience helper's behavior. */
  51932. webVROptions?: VRExperienceHelperOptions);
  51933. private completeVRInit;
  51934. private _onDefaultMeshLoaded;
  51935. private _onResize;
  51936. private _onFullscreenChange;
  51937. /**
  51938. * Gets a value indicating if we are currently in VR mode.
  51939. */
  51940. get isInVRMode(): boolean;
  51941. private onVrDisplayPresentChange;
  51942. private onVRDisplayChanged;
  51943. private moveButtonToBottomRight;
  51944. private displayVRButton;
  51945. private updateButtonVisibility;
  51946. private _cachedAngularSensibility;
  51947. /**
  51948. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51949. * Otherwise, will use the fullscreen API.
  51950. */
  51951. enterVR(): void;
  51952. /**
  51953. * Attempt to exit VR, or fullscreen.
  51954. */
  51955. exitVR(): void;
  51956. /**
  51957. * The position of the vr experience helper.
  51958. */
  51959. get position(): Vector3;
  51960. /**
  51961. * Sets the position of the vr experience helper.
  51962. */
  51963. set position(value: Vector3);
  51964. /**
  51965. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51966. */
  51967. enableInteractions(): void;
  51968. private get _noControllerIsActive();
  51969. private beforeRender;
  51970. private _isTeleportationFloor;
  51971. /**
  51972. * Adds a floor mesh to be used for teleportation.
  51973. * @param floorMesh the mesh to be used for teleportation.
  51974. */
  51975. addFloorMesh(floorMesh: Mesh): void;
  51976. /**
  51977. * Removes a floor mesh from being used for teleportation.
  51978. * @param floorMesh the mesh to be removed.
  51979. */
  51980. removeFloorMesh(floorMesh: Mesh): void;
  51981. /**
  51982. * Enables interactions and teleportation using the VR controllers and gaze.
  51983. * @param vrTeleportationOptions options to modify teleportation behavior.
  51984. */
  51985. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51986. private _onNewGamepadConnected;
  51987. private _tryEnableInteractionOnController;
  51988. private _onNewGamepadDisconnected;
  51989. private _enableInteractionOnController;
  51990. private _checkTeleportWithRay;
  51991. private _checkRotate;
  51992. private _checkTeleportBackwards;
  51993. private _enableTeleportationOnController;
  51994. private _createTeleportationCircles;
  51995. private _displayTeleportationTarget;
  51996. private _hideTeleportationTarget;
  51997. private _rotateCamera;
  51998. private _moveTeleportationSelectorTo;
  51999. private _workingVector;
  52000. private _workingQuaternion;
  52001. private _workingMatrix;
  52002. /**
  52003. * Time Constant Teleportation Mode
  52004. */
  52005. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52006. /**
  52007. * Speed Constant Teleportation Mode
  52008. */
  52009. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52010. /**
  52011. * Teleports the users feet to the desired location
  52012. * @param location The location where the user's feet should be placed
  52013. */
  52014. teleportCamera(location: Vector3): void;
  52015. private _convertNormalToDirectionOfRay;
  52016. private _castRayAndSelectObject;
  52017. private _notifySelectedMeshUnselected;
  52018. /**
  52019. * Permanently set new colors for the laser pointer
  52020. * @param color the new laser color
  52021. * @param pickedColor the new laser color when picked mesh detected
  52022. */
  52023. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52024. /**
  52025. * Set lighting enabled / disabled on the laser pointer of both controllers
  52026. * @param enabled should the lighting be enabled on the laser pointer
  52027. */
  52028. setLaserLightingState(enabled?: boolean): void;
  52029. /**
  52030. * Permanently set new colors for the gaze pointer
  52031. * @param color the new gaze color
  52032. * @param pickedColor the new gaze color when picked mesh detected
  52033. */
  52034. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52035. /**
  52036. * Sets the color of the laser ray from the vr controllers.
  52037. * @param color new color for the ray.
  52038. */
  52039. changeLaserColor(color: Color3): void;
  52040. /**
  52041. * Sets the color of the ray from the vr headsets gaze.
  52042. * @param color new color for the ray.
  52043. */
  52044. changeGazeColor(color: Color3): void;
  52045. /**
  52046. * Exits VR and disposes of the vr experience helper
  52047. */
  52048. dispose(): void;
  52049. /**
  52050. * Gets the name of the VRExperienceHelper class
  52051. * @returns "VRExperienceHelper"
  52052. */
  52053. getClassName(): string;
  52054. }
  52055. }
  52056. declare module "babylonjs/Cameras/VR/index" {
  52057. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52058. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52059. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52060. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52061. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52062. export * from "babylonjs/Cameras/VR/webVRCamera";
  52063. }
  52064. declare module "babylonjs/Cameras/RigModes/index" {
  52065. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52066. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52067. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52068. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52069. }
  52070. declare module "babylonjs/Cameras/index" {
  52071. export * from "babylonjs/Cameras/Inputs/index";
  52072. export * from "babylonjs/Cameras/cameraInputsManager";
  52073. export * from "babylonjs/Cameras/camera";
  52074. export * from "babylonjs/Cameras/targetCamera";
  52075. export * from "babylonjs/Cameras/freeCamera";
  52076. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52077. export * from "babylonjs/Cameras/touchCamera";
  52078. export * from "babylonjs/Cameras/arcRotateCamera";
  52079. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52080. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52081. export * from "babylonjs/Cameras/flyCamera";
  52082. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52083. export * from "babylonjs/Cameras/followCamera";
  52084. export * from "babylonjs/Cameras/followCameraInputsManager";
  52085. export * from "babylonjs/Cameras/gamepadCamera";
  52086. export * from "babylonjs/Cameras/Stereoscopic/index";
  52087. export * from "babylonjs/Cameras/universalCamera";
  52088. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52089. export * from "babylonjs/Cameras/VR/index";
  52090. export * from "babylonjs/Cameras/RigModes/index";
  52091. }
  52092. declare module "babylonjs/Collisions/index" {
  52093. export * from "babylonjs/Collisions/collider";
  52094. export * from "babylonjs/Collisions/collisionCoordinator";
  52095. export * from "babylonjs/Collisions/pickingInfo";
  52096. export * from "babylonjs/Collisions/intersectionInfo";
  52097. export * from "babylonjs/Collisions/meshCollisionData";
  52098. }
  52099. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52100. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52101. import { Vector3 } from "babylonjs/Maths/math.vector";
  52102. import { Ray } from "babylonjs/Culling/ray";
  52103. import { Plane } from "babylonjs/Maths/math.plane";
  52104. /**
  52105. * Contains an array of blocks representing the octree
  52106. */
  52107. export interface IOctreeContainer<T> {
  52108. /**
  52109. * Blocks within the octree
  52110. */
  52111. blocks: Array<OctreeBlock<T>>;
  52112. }
  52113. /**
  52114. * Class used to store a cell in an octree
  52115. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52116. */
  52117. export class OctreeBlock<T> {
  52118. /**
  52119. * Gets the content of the current block
  52120. */
  52121. entries: T[];
  52122. /**
  52123. * Gets the list of block children
  52124. */
  52125. blocks: Array<OctreeBlock<T>>;
  52126. private _depth;
  52127. private _maxDepth;
  52128. private _capacity;
  52129. private _minPoint;
  52130. private _maxPoint;
  52131. private _boundingVectors;
  52132. private _creationFunc;
  52133. /**
  52134. * Creates a new block
  52135. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52136. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52137. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52138. * @param depth defines the current depth of this block in the octree
  52139. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52140. * @param creationFunc defines a callback to call when an element is added to the block
  52141. */
  52142. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52143. /**
  52144. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52145. */
  52146. get capacity(): number;
  52147. /**
  52148. * Gets the minimum vector (in world space) of the block's bounding box
  52149. */
  52150. get minPoint(): Vector3;
  52151. /**
  52152. * Gets the maximum vector (in world space) of the block's bounding box
  52153. */
  52154. get maxPoint(): Vector3;
  52155. /**
  52156. * Add a new element to this block
  52157. * @param entry defines the element to add
  52158. */
  52159. addEntry(entry: T): void;
  52160. /**
  52161. * Remove an element from this block
  52162. * @param entry defines the element to remove
  52163. */
  52164. removeEntry(entry: T): void;
  52165. /**
  52166. * Add an array of elements to this block
  52167. * @param entries defines the array of elements to add
  52168. */
  52169. addEntries(entries: T[]): void;
  52170. /**
  52171. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52172. * @param frustumPlanes defines the frustum planes to test
  52173. * @param selection defines the array to store current content if selection is positive
  52174. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52175. */
  52176. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52177. /**
  52178. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52179. * @param sphereCenter defines the bounding sphere center
  52180. * @param sphereRadius defines the bounding sphere radius
  52181. * @param selection defines the array to store current content if selection is positive
  52182. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52183. */
  52184. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52185. /**
  52186. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52187. * @param ray defines the ray to test with
  52188. * @param selection defines the array to store current content if selection is positive
  52189. */
  52190. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52191. /**
  52192. * Subdivide the content into child blocks (this block will then be empty)
  52193. */
  52194. createInnerBlocks(): void;
  52195. /**
  52196. * @hidden
  52197. */
  52198. 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;
  52199. }
  52200. }
  52201. declare module "babylonjs/Culling/Octrees/octree" {
  52202. import { SmartArray } from "babylonjs/Misc/smartArray";
  52203. import { Vector3 } from "babylonjs/Maths/math.vector";
  52204. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52206. import { Ray } from "babylonjs/Culling/ray";
  52207. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52208. import { Plane } from "babylonjs/Maths/math.plane";
  52209. /**
  52210. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52211. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52212. */
  52213. export class Octree<T> {
  52214. /** 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.) */
  52215. maxDepth: number;
  52216. /**
  52217. * Blocks within the octree containing objects
  52218. */
  52219. blocks: Array<OctreeBlock<T>>;
  52220. /**
  52221. * Content stored in the octree
  52222. */
  52223. dynamicContent: T[];
  52224. private _maxBlockCapacity;
  52225. private _selectionContent;
  52226. private _creationFunc;
  52227. /**
  52228. * Creates a octree
  52229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52230. * @param creationFunc function to be used to instatiate the octree
  52231. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52232. * @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.)
  52233. */
  52234. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52235. /** 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.) */
  52236. maxDepth?: number);
  52237. /**
  52238. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52239. * @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);
  52240. * @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);
  52241. * @param entries meshes to be added to the octree blocks
  52242. */
  52243. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52244. /**
  52245. * Adds a mesh to the octree
  52246. * @param entry Mesh to add to the octree
  52247. */
  52248. addMesh(entry: T): void;
  52249. /**
  52250. * Remove an element from the octree
  52251. * @param entry defines the element to remove
  52252. */
  52253. removeMesh(entry: T): void;
  52254. /**
  52255. * Selects an array of meshes within the frustum
  52256. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52257. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52258. * @returns array of meshes within the frustum
  52259. */
  52260. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52261. /**
  52262. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52263. * @param sphereCenter defines the bounding sphere center
  52264. * @param sphereRadius defines the bounding sphere radius
  52265. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52266. * @returns an array of objects that intersect the sphere
  52267. */
  52268. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52269. /**
  52270. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52271. * @param ray defines the ray to test with
  52272. * @returns array of intersected objects
  52273. */
  52274. intersectsRay(ray: Ray): SmartArray<T>;
  52275. /**
  52276. * Adds a mesh into the octree block if it intersects the block
  52277. */
  52278. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52279. /**
  52280. * Adds a submesh into the octree block if it intersects the block
  52281. */
  52282. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52283. }
  52284. }
  52285. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52286. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52287. import { Scene } from "babylonjs/scene";
  52288. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52290. import { Ray } from "babylonjs/Culling/ray";
  52291. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52292. import { Collider } from "babylonjs/Collisions/collider";
  52293. module "babylonjs/scene" {
  52294. interface Scene {
  52295. /**
  52296. * @hidden
  52297. * Backing Filed
  52298. */
  52299. _selectionOctree: Octree<AbstractMesh>;
  52300. /**
  52301. * Gets the octree used to boost mesh selection (picking)
  52302. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52303. */
  52304. selectionOctree: Octree<AbstractMesh>;
  52305. /**
  52306. * Creates or updates the octree used to boost selection (picking)
  52307. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52308. * @param maxCapacity defines the maximum capacity per leaf
  52309. * @param maxDepth defines the maximum depth of the octree
  52310. * @returns an octree of AbstractMesh
  52311. */
  52312. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52313. }
  52314. }
  52315. module "babylonjs/Meshes/abstractMesh" {
  52316. interface AbstractMesh {
  52317. /**
  52318. * @hidden
  52319. * Backing Field
  52320. */
  52321. _submeshesOctree: Octree<SubMesh>;
  52322. /**
  52323. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52324. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52325. * @param maxCapacity defines the maximum size of each block (64 by default)
  52326. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52327. * @returns the new octree
  52328. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52329. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52330. */
  52331. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52332. }
  52333. }
  52334. /**
  52335. * Defines the octree scene component responsible to manage any octrees
  52336. * in a given scene.
  52337. */
  52338. export class OctreeSceneComponent {
  52339. /**
  52340. * The component name help to identify the component in the list of scene components.
  52341. */
  52342. readonly name: string;
  52343. /**
  52344. * The scene the component belongs to.
  52345. */
  52346. scene: Scene;
  52347. /**
  52348. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52349. */
  52350. readonly checksIsEnabled: boolean;
  52351. /**
  52352. * Creates a new instance of the component for the given scene
  52353. * @param scene Defines the scene to register the component in
  52354. */
  52355. constructor(scene: Scene);
  52356. /**
  52357. * Registers the component in a given scene
  52358. */
  52359. register(): void;
  52360. /**
  52361. * Return the list of active meshes
  52362. * @returns the list of active meshes
  52363. */
  52364. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52365. /**
  52366. * Return the list of active sub meshes
  52367. * @param mesh The mesh to get the candidates sub meshes from
  52368. * @returns the list of active sub meshes
  52369. */
  52370. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52371. private _tempRay;
  52372. /**
  52373. * Return the list of sub meshes intersecting with a given local ray
  52374. * @param mesh defines the mesh to find the submesh for
  52375. * @param localRay defines the ray in local space
  52376. * @returns the list of intersecting sub meshes
  52377. */
  52378. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52379. /**
  52380. * Return the list of sub meshes colliding with a collider
  52381. * @param mesh defines the mesh to find the submesh for
  52382. * @param collider defines the collider to evaluate the collision against
  52383. * @returns the list of colliding sub meshes
  52384. */
  52385. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52386. /**
  52387. * Rebuilds the elements related to this component in case of
  52388. * context lost for instance.
  52389. */
  52390. rebuild(): void;
  52391. /**
  52392. * Disposes the component and the associated ressources.
  52393. */
  52394. dispose(): void;
  52395. }
  52396. }
  52397. declare module "babylonjs/Culling/Octrees/index" {
  52398. export * from "babylonjs/Culling/Octrees/octree";
  52399. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52400. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52401. }
  52402. declare module "babylonjs/Culling/index" {
  52403. export * from "babylonjs/Culling/boundingBox";
  52404. export * from "babylonjs/Culling/boundingInfo";
  52405. export * from "babylonjs/Culling/boundingSphere";
  52406. export * from "babylonjs/Culling/Octrees/index";
  52407. export * from "babylonjs/Culling/ray";
  52408. }
  52409. declare module "babylonjs/Gizmos/gizmo" {
  52410. import { Nullable } from "babylonjs/types";
  52411. import { IDisposable } from "babylonjs/scene";
  52412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52413. import { Mesh } from "babylonjs/Meshes/mesh";
  52414. import { Node } from "babylonjs/node";
  52415. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52416. /**
  52417. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52418. */
  52419. export class Gizmo implements IDisposable {
  52420. /** The utility layer the gizmo will be added to */
  52421. gizmoLayer: UtilityLayerRenderer;
  52422. /**
  52423. * The root mesh of the gizmo
  52424. */
  52425. _rootMesh: Mesh;
  52426. private _attachedMesh;
  52427. private _attachedNode;
  52428. /**
  52429. * Ratio for the scale of the gizmo (Default: 1)
  52430. */
  52431. protected _scaleRatio: number;
  52432. /**
  52433. * boolean updated by pointermove when a gizmo mesh is hovered
  52434. */
  52435. protected _isHovered: boolean;
  52436. /**
  52437. * Ratio for the scale of the gizmo (Default: 1)
  52438. */
  52439. set scaleRatio(value: number);
  52440. get scaleRatio(): number;
  52441. /**
  52442. * True when the mouse pointer is hovered a gizmo mesh
  52443. */
  52444. get isHovered(): boolean;
  52445. /**
  52446. * If a custom mesh has been set (Default: false)
  52447. */
  52448. protected _customMeshSet: boolean;
  52449. /**
  52450. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52451. * * When set, interactions will be enabled
  52452. */
  52453. get attachedMesh(): Nullable<AbstractMesh>;
  52454. set attachedMesh(value: Nullable<AbstractMesh>);
  52455. /**
  52456. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52457. * * When set, interactions will be enabled
  52458. */
  52459. get attachedNode(): Nullable<Node>;
  52460. set attachedNode(value: Nullable<Node>);
  52461. /**
  52462. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52463. * @param mesh The mesh to replace the default mesh of the gizmo
  52464. */
  52465. setCustomMesh(mesh: Mesh): void;
  52466. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52467. /**
  52468. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52469. */
  52470. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52471. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52472. /**
  52473. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52474. */
  52475. updateGizmoPositionToMatchAttachedMesh: boolean;
  52476. /**
  52477. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52478. */
  52479. updateScale: boolean;
  52480. protected _interactionsEnabled: boolean;
  52481. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52482. private _beforeRenderObserver;
  52483. private _tempQuaternion;
  52484. private _tempVector;
  52485. private _tempVector2;
  52486. private _tempMatrix1;
  52487. private _tempMatrix2;
  52488. private _rightHandtoLeftHandMatrix;
  52489. /**
  52490. * Creates a gizmo
  52491. * @param gizmoLayer The utility layer the gizmo will be added to
  52492. */
  52493. constructor(
  52494. /** The utility layer the gizmo will be added to */
  52495. gizmoLayer?: UtilityLayerRenderer);
  52496. /**
  52497. * Updates the gizmo to match the attached mesh's position/rotation
  52498. */
  52499. protected _update(): void;
  52500. /**
  52501. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52502. * @param value Node, TransformNode or mesh
  52503. */
  52504. protected _matrixChanged(): void;
  52505. /**
  52506. * Disposes of the gizmo
  52507. */
  52508. dispose(): void;
  52509. }
  52510. }
  52511. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52512. import { Observable } from "babylonjs/Misc/observable";
  52513. import { Nullable } from "babylonjs/types";
  52514. import { Vector3 } from "babylonjs/Maths/math.vector";
  52515. import { Color3 } from "babylonjs/Maths/math.color";
  52516. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52517. import { Node } from "babylonjs/node";
  52518. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52519. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52520. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52521. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52522. import { Scene } from "babylonjs/scene";
  52523. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52524. /**
  52525. * Single plane drag gizmo
  52526. */
  52527. export class PlaneDragGizmo extends Gizmo {
  52528. /**
  52529. * Drag behavior responsible for the gizmos dragging interactions
  52530. */
  52531. dragBehavior: PointerDragBehavior;
  52532. private _pointerObserver;
  52533. /**
  52534. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52535. */
  52536. snapDistance: number;
  52537. /**
  52538. * Event that fires each time the gizmo snaps to a new location.
  52539. * * snapDistance is the the change in distance
  52540. */
  52541. onSnapObservable: Observable<{
  52542. snapDistance: number;
  52543. }>;
  52544. private _plane;
  52545. private _coloredMaterial;
  52546. private _hoverMaterial;
  52547. private _isEnabled;
  52548. private _parent;
  52549. /** @hidden */
  52550. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52551. /** @hidden */
  52552. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52553. /**
  52554. * Creates a PlaneDragGizmo
  52555. * @param gizmoLayer The utility layer the gizmo will be added to
  52556. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52557. * @param color The color of the gizmo
  52558. */
  52559. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52560. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52561. /**
  52562. * If the gizmo is enabled
  52563. */
  52564. set isEnabled(value: boolean);
  52565. get isEnabled(): boolean;
  52566. /**
  52567. * Disposes of the gizmo
  52568. */
  52569. dispose(): void;
  52570. }
  52571. }
  52572. declare module "babylonjs/Gizmos/positionGizmo" {
  52573. import { Observable } from "babylonjs/Misc/observable";
  52574. import { Nullable } from "babylonjs/types";
  52575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52576. import { Node } from "babylonjs/node";
  52577. import { Mesh } from "babylonjs/Meshes/mesh";
  52578. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52579. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52580. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52581. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52582. /**
  52583. * Gizmo that enables dragging a mesh along 3 axis
  52584. */
  52585. export class PositionGizmo extends Gizmo {
  52586. /**
  52587. * Internal gizmo used for interactions on the x axis
  52588. */
  52589. xGizmo: AxisDragGizmo;
  52590. /**
  52591. * Internal gizmo used for interactions on the y axis
  52592. */
  52593. yGizmo: AxisDragGizmo;
  52594. /**
  52595. * Internal gizmo used for interactions on the z axis
  52596. */
  52597. zGizmo: AxisDragGizmo;
  52598. /**
  52599. * Internal gizmo used for interactions on the yz plane
  52600. */
  52601. xPlaneGizmo: PlaneDragGizmo;
  52602. /**
  52603. * Internal gizmo used for interactions on the xz plane
  52604. */
  52605. yPlaneGizmo: PlaneDragGizmo;
  52606. /**
  52607. * Internal gizmo used for interactions on the xy plane
  52608. */
  52609. zPlaneGizmo: PlaneDragGizmo;
  52610. /**
  52611. * private variables
  52612. */
  52613. private _meshAttached;
  52614. private _nodeAttached;
  52615. private _snapDistance;
  52616. /** Fires an event when any of it's sub gizmos are dragged */
  52617. onDragStartObservable: Observable<unknown>;
  52618. /** Fires an event when any of it's sub gizmos are released from dragging */
  52619. onDragEndObservable: Observable<unknown>;
  52620. /**
  52621. * If set to true, planar drag is enabled
  52622. */
  52623. private _planarGizmoEnabled;
  52624. get attachedMesh(): Nullable<AbstractMesh>;
  52625. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52626. get attachedNode(): Nullable<Node>;
  52627. set attachedNode(node: Nullable<Node>);
  52628. /**
  52629. * True when the mouse pointer is hovering a gizmo mesh
  52630. */
  52631. get isHovered(): boolean;
  52632. /**
  52633. * Creates a PositionGizmo
  52634. * @param gizmoLayer The utility layer the gizmo will be added to
  52635. @param thickness display gizmo axis thickness
  52636. */
  52637. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52638. /**
  52639. * If the planar drag gizmo is enabled
  52640. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52641. */
  52642. set planarGizmoEnabled(value: boolean);
  52643. get planarGizmoEnabled(): boolean;
  52644. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52645. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52646. /**
  52647. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52648. */
  52649. set snapDistance(value: number);
  52650. get snapDistance(): number;
  52651. /**
  52652. * Ratio for the scale of the gizmo (Default: 1)
  52653. */
  52654. set scaleRatio(value: number);
  52655. get scaleRatio(): number;
  52656. /**
  52657. * Disposes of the gizmo
  52658. */
  52659. dispose(): void;
  52660. /**
  52661. * CustomMeshes are not supported by this gizmo
  52662. * @param mesh The mesh to replace the default mesh of the gizmo
  52663. */
  52664. setCustomMesh(mesh: Mesh): void;
  52665. }
  52666. }
  52667. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52668. import { Observable } from "babylonjs/Misc/observable";
  52669. import { Nullable } from "babylonjs/types";
  52670. import { Vector3 } from "babylonjs/Maths/math.vector";
  52671. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52672. import { Node } from "babylonjs/node";
  52673. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52674. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52675. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52676. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52677. import { Scene } from "babylonjs/scene";
  52678. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52679. import { Color3 } from "babylonjs/Maths/math.color";
  52680. /**
  52681. * Single axis drag gizmo
  52682. */
  52683. export class AxisDragGizmo extends Gizmo {
  52684. /**
  52685. * Drag behavior responsible for the gizmos dragging interactions
  52686. */
  52687. dragBehavior: PointerDragBehavior;
  52688. private _pointerObserver;
  52689. /**
  52690. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52691. */
  52692. snapDistance: number;
  52693. /**
  52694. * Event that fires each time the gizmo snaps to a new location.
  52695. * * snapDistance is the the change in distance
  52696. */
  52697. onSnapObservable: Observable<{
  52698. snapDistance: number;
  52699. }>;
  52700. private _isEnabled;
  52701. private _parent;
  52702. private _arrow;
  52703. private _coloredMaterial;
  52704. private _hoverMaterial;
  52705. /** @hidden */
  52706. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52707. /** @hidden */
  52708. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52709. /**
  52710. * Creates an AxisDragGizmo
  52711. * @param gizmoLayer The utility layer the gizmo will be added to
  52712. * @param dragAxis The axis which the gizmo will be able to drag on
  52713. * @param color The color of the gizmo
  52714. * @param thickness display gizmo axis thickness
  52715. */
  52716. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52717. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52718. /**
  52719. * If the gizmo is enabled
  52720. */
  52721. set isEnabled(value: boolean);
  52722. get isEnabled(): boolean;
  52723. /**
  52724. * Disposes of the gizmo
  52725. */
  52726. dispose(): void;
  52727. }
  52728. }
  52729. declare module "babylonjs/Debug/axesViewer" {
  52730. import { Vector3 } from "babylonjs/Maths/math.vector";
  52731. import { Nullable } from "babylonjs/types";
  52732. import { Scene } from "babylonjs/scene";
  52733. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52734. /**
  52735. * The Axes viewer will show 3 axes in a specific point in space
  52736. */
  52737. export class AxesViewer {
  52738. private _xAxis;
  52739. private _yAxis;
  52740. private _zAxis;
  52741. private _scaleLinesFactor;
  52742. private _instanced;
  52743. /**
  52744. * Gets the hosting scene
  52745. */
  52746. scene: Nullable<Scene>;
  52747. /**
  52748. * Gets or sets a number used to scale line length
  52749. */
  52750. scaleLines: number;
  52751. /** Gets the node hierarchy used to render x-axis */
  52752. get xAxis(): TransformNode;
  52753. /** Gets the node hierarchy used to render y-axis */
  52754. get yAxis(): TransformNode;
  52755. /** Gets the node hierarchy used to render z-axis */
  52756. get zAxis(): TransformNode;
  52757. /**
  52758. * Creates a new AxesViewer
  52759. * @param scene defines the hosting scene
  52760. * @param scaleLines defines a number used to scale line length (1 by default)
  52761. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52762. * @param xAxis defines the node hierarchy used to render the x-axis
  52763. * @param yAxis defines the node hierarchy used to render the y-axis
  52764. * @param zAxis defines the node hierarchy used to render the z-axis
  52765. */
  52766. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52767. /**
  52768. * Force the viewer to update
  52769. * @param position defines the position of the viewer
  52770. * @param xaxis defines the x axis of the viewer
  52771. * @param yaxis defines the y axis of the viewer
  52772. * @param zaxis defines the z axis of the viewer
  52773. */
  52774. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52775. /**
  52776. * Creates an instance of this axes viewer.
  52777. * @returns a new axes viewer with instanced meshes
  52778. */
  52779. createInstance(): AxesViewer;
  52780. /** Releases resources */
  52781. dispose(): void;
  52782. private static _SetRenderingGroupId;
  52783. }
  52784. }
  52785. declare module "babylonjs/Debug/boneAxesViewer" {
  52786. import { Nullable } from "babylonjs/types";
  52787. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52788. import { Vector3 } from "babylonjs/Maths/math.vector";
  52789. import { Mesh } from "babylonjs/Meshes/mesh";
  52790. import { Bone } from "babylonjs/Bones/bone";
  52791. import { Scene } from "babylonjs/scene";
  52792. /**
  52793. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52794. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52795. */
  52796. export class BoneAxesViewer extends AxesViewer {
  52797. /**
  52798. * Gets or sets the target mesh where to display the axes viewer
  52799. */
  52800. mesh: Nullable<Mesh>;
  52801. /**
  52802. * Gets or sets the target bone where to display the axes viewer
  52803. */
  52804. bone: Nullable<Bone>;
  52805. /** Gets current position */
  52806. pos: Vector3;
  52807. /** Gets direction of X axis */
  52808. xaxis: Vector3;
  52809. /** Gets direction of Y axis */
  52810. yaxis: Vector3;
  52811. /** Gets direction of Z axis */
  52812. zaxis: Vector3;
  52813. /**
  52814. * Creates a new BoneAxesViewer
  52815. * @param scene defines the hosting scene
  52816. * @param bone defines the target bone
  52817. * @param mesh defines the target mesh
  52818. * @param scaleLines defines a scaling factor for line length (1 by default)
  52819. */
  52820. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52821. /**
  52822. * Force the viewer to update
  52823. */
  52824. update(): void;
  52825. /** Releases resources */
  52826. dispose(): void;
  52827. }
  52828. }
  52829. declare module "babylonjs/Debug/debugLayer" {
  52830. import { Scene } from "babylonjs/scene";
  52831. /**
  52832. * Interface used to define scene explorer extensibility option
  52833. */
  52834. export interface IExplorerExtensibilityOption {
  52835. /**
  52836. * Define the option label
  52837. */
  52838. label: string;
  52839. /**
  52840. * Defines the action to execute on click
  52841. */
  52842. action: (entity: any) => void;
  52843. }
  52844. /**
  52845. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52846. */
  52847. export interface IExplorerExtensibilityGroup {
  52848. /**
  52849. * Defines a predicate to test if a given type mut be extended
  52850. */
  52851. predicate: (entity: any) => boolean;
  52852. /**
  52853. * Gets the list of options added to a type
  52854. */
  52855. entries: IExplorerExtensibilityOption[];
  52856. }
  52857. /**
  52858. * Interface used to define the options to use to create the Inspector
  52859. */
  52860. export interface IInspectorOptions {
  52861. /**
  52862. * Display in overlay mode (default: false)
  52863. */
  52864. overlay?: boolean;
  52865. /**
  52866. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52867. */
  52868. globalRoot?: HTMLElement;
  52869. /**
  52870. * Display the Scene explorer
  52871. */
  52872. showExplorer?: boolean;
  52873. /**
  52874. * Display the property inspector
  52875. */
  52876. showInspector?: boolean;
  52877. /**
  52878. * Display in embed mode (both panes on the right)
  52879. */
  52880. embedMode?: boolean;
  52881. /**
  52882. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52883. */
  52884. handleResize?: boolean;
  52885. /**
  52886. * Allow the panes to popup (default: true)
  52887. */
  52888. enablePopup?: boolean;
  52889. /**
  52890. * Allow the panes to be closed by users (default: true)
  52891. */
  52892. enableClose?: boolean;
  52893. /**
  52894. * Optional list of extensibility entries
  52895. */
  52896. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52897. /**
  52898. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52899. */
  52900. inspectorURL?: string;
  52901. /**
  52902. * Optional initial tab (default to DebugLayerTab.Properties)
  52903. */
  52904. initialTab?: DebugLayerTab;
  52905. }
  52906. module "babylonjs/scene" {
  52907. interface Scene {
  52908. /**
  52909. * @hidden
  52910. * Backing field
  52911. */
  52912. _debugLayer: DebugLayer;
  52913. /**
  52914. * Gets the debug layer (aka Inspector) associated with the scene
  52915. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52916. */
  52917. debugLayer: DebugLayer;
  52918. }
  52919. }
  52920. /**
  52921. * Enum of inspector action tab
  52922. */
  52923. export enum DebugLayerTab {
  52924. /**
  52925. * Properties tag (default)
  52926. */
  52927. Properties = 0,
  52928. /**
  52929. * Debug tab
  52930. */
  52931. Debug = 1,
  52932. /**
  52933. * Statistics tab
  52934. */
  52935. Statistics = 2,
  52936. /**
  52937. * Tools tab
  52938. */
  52939. Tools = 3,
  52940. /**
  52941. * Settings tab
  52942. */
  52943. Settings = 4
  52944. }
  52945. /**
  52946. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52947. * what is happening in your scene
  52948. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52949. */
  52950. export class DebugLayer {
  52951. /**
  52952. * Define the url to get the inspector script from.
  52953. * By default it uses the babylonjs CDN.
  52954. * @ignoreNaming
  52955. */
  52956. static InspectorURL: string;
  52957. private _scene;
  52958. private BJSINSPECTOR;
  52959. private _onPropertyChangedObservable?;
  52960. /**
  52961. * Observable triggered when a property is changed through the inspector.
  52962. */
  52963. get onPropertyChangedObservable(): any;
  52964. /**
  52965. * Instantiates a new debug layer.
  52966. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52967. * what is happening in your scene
  52968. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52969. * @param scene Defines the scene to inspect
  52970. */
  52971. constructor(scene: Scene);
  52972. /** Creates the inspector window. */
  52973. private _createInspector;
  52974. /**
  52975. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52976. * @param entity defines the entity to select
  52977. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52978. */
  52979. select(entity: any, lineContainerTitles?: string | string[]): void;
  52980. /** Get the inspector from bundle or global */
  52981. private _getGlobalInspector;
  52982. /**
  52983. * Get if the inspector is visible or not.
  52984. * @returns true if visible otherwise, false
  52985. */
  52986. isVisible(): boolean;
  52987. /**
  52988. * Hide the inspector and close its window.
  52989. */
  52990. hide(): void;
  52991. /**
  52992. * Update the scene in the inspector
  52993. */
  52994. setAsActiveScene(): void;
  52995. /**
  52996. * Launch the debugLayer.
  52997. * @param config Define the configuration of the inspector
  52998. * @return a promise fulfilled when the debug layer is visible
  52999. */
  53000. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53001. }
  53002. }
  53003. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  53004. import { Nullable } from "babylonjs/types";
  53005. import { Scene } from "babylonjs/scene";
  53006. import { Vector4 } from "babylonjs/Maths/math.vector";
  53007. import { Color4 } from "babylonjs/Maths/math.color";
  53008. import { Mesh } from "babylonjs/Meshes/mesh";
  53009. /**
  53010. * Class containing static functions to help procedurally build meshes
  53011. */
  53012. export class BoxBuilder {
  53013. /**
  53014. * Creates a box mesh
  53015. * * The parameter `size` sets the size (float) of each box side (default 1)
  53016. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53017. * * 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)
  53018. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53020. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53022. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53023. * @param name defines the name of the mesh
  53024. * @param options defines the options used to create the mesh
  53025. * @param scene defines the hosting scene
  53026. * @returns the box mesh
  53027. */
  53028. static CreateBox(name: string, options: {
  53029. size?: number;
  53030. width?: number;
  53031. height?: number;
  53032. depth?: number;
  53033. faceUV?: Vector4[];
  53034. faceColors?: Color4[];
  53035. sideOrientation?: number;
  53036. frontUVs?: Vector4;
  53037. backUVs?: Vector4;
  53038. wrap?: boolean;
  53039. topBaseAt?: number;
  53040. bottomBaseAt?: number;
  53041. updatable?: boolean;
  53042. }, scene?: Nullable<Scene>): Mesh;
  53043. }
  53044. }
  53045. declare module "babylonjs/Debug/physicsViewer" {
  53046. import { Nullable } from "babylonjs/types";
  53047. import { Scene } from "babylonjs/scene";
  53048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53049. import { Mesh } from "babylonjs/Meshes/mesh";
  53050. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53051. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53052. /**
  53053. * Used to show the physics impostor around the specific mesh
  53054. */
  53055. export class PhysicsViewer {
  53056. /** @hidden */
  53057. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53058. /** @hidden */
  53059. protected _meshes: Array<Nullable<AbstractMesh>>;
  53060. /** @hidden */
  53061. protected _scene: Nullable<Scene>;
  53062. /** @hidden */
  53063. protected _numMeshes: number;
  53064. /** @hidden */
  53065. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53066. private _renderFunction;
  53067. private _utilityLayer;
  53068. private _debugBoxMesh;
  53069. private _debugSphereMesh;
  53070. private _debugCylinderMesh;
  53071. private _debugMaterial;
  53072. private _debugMeshMeshes;
  53073. /**
  53074. * Creates a new PhysicsViewer
  53075. * @param scene defines the hosting scene
  53076. */
  53077. constructor(scene: Scene);
  53078. /** @hidden */
  53079. protected _updateDebugMeshes(): void;
  53080. /**
  53081. * Renders a specified physic impostor
  53082. * @param impostor defines the impostor to render
  53083. * @param targetMesh defines the mesh represented by the impostor
  53084. * @returns the new debug mesh used to render the impostor
  53085. */
  53086. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53087. /**
  53088. * Hides a specified physic impostor
  53089. * @param impostor defines the impostor to hide
  53090. */
  53091. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53092. private _getDebugMaterial;
  53093. private _getDebugBoxMesh;
  53094. private _getDebugSphereMesh;
  53095. private _getDebugCylinderMesh;
  53096. private _getDebugMeshMesh;
  53097. private _getDebugMesh;
  53098. /** Releases all resources */
  53099. dispose(): void;
  53100. }
  53101. }
  53102. declare module "babylonjs/Debug/rayHelper" {
  53103. import { Nullable } from "babylonjs/types";
  53104. import { Ray } from "babylonjs/Culling/ray";
  53105. import { Vector3 } from "babylonjs/Maths/math.vector";
  53106. import { Color3 } from "babylonjs/Maths/math.color";
  53107. import { Scene } from "babylonjs/scene";
  53108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53109. import "babylonjs/Meshes/Builders/linesBuilder";
  53110. /**
  53111. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53112. * in order to better appreciate the issue one might have.
  53113. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53114. */
  53115. export class RayHelper {
  53116. /**
  53117. * Defines the ray we are currently tryin to visualize.
  53118. */
  53119. ray: Nullable<Ray>;
  53120. private _renderPoints;
  53121. private _renderLine;
  53122. private _renderFunction;
  53123. private _scene;
  53124. private _onAfterRenderObserver;
  53125. private _onAfterStepObserver;
  53126. private _attachedToMesh;
  53127. private _meshSpaceDirection;
  53128. private _meshSpaceOrigin;
  53129. /**
  53130. * Helper function to create a colored helper in a scene in one line.
  53131. * @param ray Defines the ray we are currently tryin to visualize
  53132. * @param scene Defines the scene the ray is used in
  53133. * @param color Defines the color we want to see the ray in
  53134. * @returns The newly created ray helper.
  53135. */
  53136. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53137. /**
  53138. * Instantiate a new ray helper.
  53139. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53140. * in order to better appreciate the issue one might have.
  53141. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53142. * @param ray Defines the ray we are currently tryin to visualize
  53143. */
  53144. constructor(ray: Ray);
  53145. /**
  53146. * Shows the ray we are willing to debug.
  53147. * @param scene Defines the scene the ray needs to be rendered in
  53148. * @param color Defines the color the ray needs to be rendered in
  53149. */
  53150. show(scene: Scene, color?: Color3): void;
  53151. /**
  53152. * Hides the ray we are debugging.
  53153. */
  53154. hide(): void;
  53155. private _render;
  53156. /**
  53157. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53158. * @param mesh Defines the mesh we want the helper attached to
  53159. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53160. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53161. * @param length Defines the length of the ray
  53162. */
  53163. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53164. /**
  53165. * Detach the ray helper from the mesh it has previously been attached to.
  53166. */
  53167. detachFromMesh(): void;
  53168. private _updateToMesh;
  53169. /**
  53170. * Dispose the helper and release its associated resources.
  53171. */
  53172. dispose(): void;
  53173. }
  53174. }
  53175. declare module "babylonjs/Debug/ISkeletonViewer" {
  53176. import { Skeleton } from "babylonjs/Bones/skeleton";
  53177. import { Color3 } from "babylonjs/Maths/math.color";
  53178. /**
  53179. * Defines the options associated with the creation of a SkeletonViewer.
  53180. */
  53181. export interface ISkeletonViewerOptions {
  53182. /** Should the system pause animations before building the Viewer? */
  53183. pauseAnimations: boolean;
  53184. /** Should the system return the skeleton to rest before building? */
  53185. returnToRest: boolean;
  53186. /** public Display Mode of the Viewer */
  53187. displayMode: number;
  53188. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53189. displayOptions: ISkeletonViewerDisplayOptions;
  53190. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53191. computeBonesUsingShaders: boolean;
  53192. /** Flag ignore non weighted bones */
  53193. useAllBones: boolean;
  53194. }
  53195. /**
  53196. * Defines how to display the various bone meshes for the viewer.
  53197. */
  53198. export interface ISkeletonViewerDisplayOptions {
  53199. /** How far down to start tapering the bone spurs */
  53200. midStep?: number;
  53201. /** How big is the midStep? */
  53202. midStepFactor?: number;
  53203. /** Base for the Sphere Size */
  53204. sphereBaseSize?: number;
  53205. /** The ratio of the sphere to the longest bone in units */
  53206. sphereScaleUnit?: number;
  53207. /** Ratio for the Sphere Size */
  53208. sphereFactor?: number;
  53209. /** Whether to show local axes or not */
  53210. showLocalAxes?: boolean;
  53211. /** Length of each local axis */
  53212. localAxesSize?: number;
  53213. }
  53214. /**
  53215. * Defines the constructor options for the BoneWeight Shader.
  53216. */
  53217. export interface IBoneWeightShaderOptions {
  53218. /** Skeleton to Map */
  53219. skeleton: Skeleton;
  53220. /** Colors for Uninfluenced bones */
  53221. colorBase?: Color3;
  53222. /** Colors for 0.0-0.25 Weight bones */
  53223. colorZero?: Color3;
  53224. /** Color for 0.25-0.5 Weight Influence */
  53225. colorQuarter?: Color3;
  53226. /** Color for 0.5-0.75 Weight Influence */
  53227. colorHalf?: Color3;
  53228. /** Color for 0.75-1 Weight Influence */
  53229. colorFull?: Color3;
  53230. /** Color for Zero Weight Influence */
  53231. targetBoneIndex?: number;
  53232. }
  53233. /**
  53234. * Simple structure of the gradient steps for the Color Map.
  53235. */
  53236. export interface ISkeletonMapShaderColorMapKnot {
  53237. /** Color of the Knot */
  53238. color: Color3;
  53239. /** Location of the Knot */
  53240. location: number;
  53241. }
  53242. /**
  53243. * Defines the constructor options for the SkeletonMap Shader.
  53244. */
  53245. export interface ISkeletonMapShaderOptions {
  53246. /** Skeleton to Map */
  53247. skeleton: Skeleton;
  53248. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53249. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53250. }
  53251. }
  53252. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53253. import { Nullable } from "babylonjs/types";
  53254. import { Scene } from "babylonjs/scene";
  53255. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53256. import { Color4 } from "babylonjs/Maths/math.color";
  53257. import { Mesh } from "babylonjs/Meshes/mesh";
  53258. /**
  53259. * Class containing static functions to help procedurally build meshes
  53260. */
  53261. export class RibbonBuilder {
  53262. /**
  53263. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53264. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53265. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53266. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53267. * * 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
  53268. * * 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
  53269. * * 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
  53270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53273. * * 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
  53274. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53275. * * 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
  53276. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53278. * @param name defines the name of the mesh
  53279. * @param options defines the options used to create the mesh
  53280. * @param scene defines the hosting scene
  53281. * @returns the ribbon mesh
  53282. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53283. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53284. */
  53285. static CreateRibbon(name: string, options: {
  53286. pathArray: Vector3[][];
  53287. closeArray?: boolean;
  53288. closePath?: boolean;
  53289. offset?: number;
  53290. updatable?: boolean;
  53291. sideOrientation?: number;
  53292. frontUVs?: Vector4;
  53293. backUVs?: Vector4;
  53294. instance?: Mesh;
  53295. invertUV?: boolean;
  53296. uvs?: Vector2[];
  53297. colors?: Color4[];
  53298. }, scene?: Nullable<Scene>): Mesh;
  53299. }
  53300. }
  53301. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53302. import { Nullable } from "babylonjs/types";
  53303. import { Scene } from "babylonjs/scene";
  53304. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53305. import { Mesh } from "babylonjs/Meshes/mesh";
  53306. /**
  53307. * Class containing static functions to help procedurally build meshes
  53308. */
  53309. export class ShapeBuilder {
  53310. /**
  53311. * 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.
  53312. * * 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.
  53313. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53314. * * 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.
  53315. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53316. * * 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
  53317. * * 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
  53318. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53321. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53323. * @param name defines the name of the mesh
  53324. * @param options defines the options used to create the mesh
  53325. * @param scene defines the hosting scene
  53326. * @returns the extruded shape mesh
  53327. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53329. */
  53330. static ExtrudeShape(name: string, options: {
  53331. shape: Vector3[];
  53332. path: Vector3[];
  53333. scale?: number;
  53334. rotation?: number;
  53335. cap?: number;
  53336. updatable?: boolean;
  53337. sideOrientation?: number;
  53338. frontUVs?: Vector4;
  53339. backUVs?: Vector4;
  53340. instance?: Mesh;
  53341. invertUV?: boolean;
  53342. }, scene?: Nullable<Scene>): Mesh;
  53343. /**
  53344. * Creates an custom extruded shape mesh.
  53345. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53346. * * 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.
  53347. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53348. * * 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
  53349. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53350. * * 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
  53351. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53352. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53353. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53354. * * 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
  53355. * * 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
  53356. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53359. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53361. * @param name defines the name of the mesh
  53362. * @param options defines the options used to create the mesh
  53363. * @param scene defines the hosting scene
  53364. * @returns the custom extruded shape mesh
  53365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53366. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53368. */
  53369. static ExtrudeShapeCustom(name: string, options: {
  53370. shape: Vector3[];
  53371. path: Vector3[];
  53372. scaleFunction?: any;
  53373. rotationFunction?: any;
  53374. ribbonCloseArray?: boolean;
  53375. ribbonClosePath?: boolean;
  53376. cap?: number;
  53377. updatable?: boolean;
  53378. sideOrientation?: number;
  53379. frontUVs?: Vector4;
  53380. backUVs?: Vector4;
  53381. instance?: Mesh;
  53382. invertUV?: boolean;
  53383. }, scene?: Nullable<Scene>): Mesh;
  53384. private static _ExtrudeShapeGeneric;
  53385. }
  53386. }
  53387. declare module "babylonjs/Debug/skeletonViewer" {
  53388. import { Color3 } from "babylonjs/Maths/math.color";
  53389. import { Scene } from "babylonjs/scene";
  53390. import { Nullable } from "babylonjs/types";
  53391. import { Skeleton } from "babylonjs/Bones/skeleton";
  53392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53393. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53394. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53395. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53396. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53397. /**
  53398. * Class used to render a debug view of a given skeleton
  53399. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53400. */
  53401. export class SkeletonViewer {
  53402. /** defines the skeleton to render */
  53403. skeleton: Skeleton;
  53404. /** defines the mesh attached to the skeleton */
  53405. mesh: AbstractMesh;
  53406. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53407. autoUpdateBonesMatrices: boolean;
  53408. /** defines the rendering group id to use with the viewer */
  53409. renderingGroupId: number;
  53410. /** is the options for the viewer */
  53411. options: Partial<ISkeletonViewerOptions>;
  53412. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53413. static readonly DISPLAY_LINES: number;
  53414. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53415. static readonly DISPLAY_SPHERES: number;
  53416. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53417. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53418. /** public static method to create a BoneWeight Shader
  53419. * @param options The constructor options
  53420. * @param scene The scene that the shader is scoped to
  53421. * @returns The created ShaderMaterial
  53422. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53423. */
  53424. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53425. /** public static method to create a BoneWeight Shader
  53426. * @param options The constructor options
  53427. * @param scene The scene that the shader is scoped to
  53428. * @returns The created ShaderMaterial
  53429. */
  53430. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53431. /** private static method to create a BoneWeight Shader
  53432. * @param size The size of the buffer to create (usually the bone count)
  53433. * @param colorMap The gradient data to generate
  53434. * @param scene The scene that the shader is scoped to
  53435. * @returns an Array of floats from the color gradient values
  53436. */
  53437. private static _CreateBoneMapColorBuffer;
  53438. /** If SkeletonViewer scene scope. */
  53439. private _scene;
  53440. /** Gets or sets the color used to render the skeleton */
  53441. color: Color3;
  53442. /** Array of the points of the skeleton fo the line view. */
  53443. private _debugLines;
  53444. /** The SkeletonViewers Mesh. */
  53445. private _debugMesh;
  53446. /** The local axes Meshes. */
  53447. private _localAxes;
  53448. /** If SkeletonViewer is enabled. */
  53449. private _isEnabled;
  53450. /** If SkeletonViewer is ready. */
  53451. private _ready;
  53452. /** SkeletonViewer render observable. */
  53453. private _obs;
  53454. /** The Utility Layer to render the gizmos in. */
  53455. private _utilityLayer;
  53456. private _boneIndices;
  53457. /** Gets the Scene. */
  53458. get scene(): Scene;
  53459. /** Gets the utilityLayer. */
  53460. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53461. /** Checks Ready Status. */
  53462. get isReady(): Boolean;
  53463. /** Sets Ready Status. */
  53464. set ready(value: boolean);
  53465. /** Gets the debugMesh */
  53466. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53467. /** Sets the debugMesh */
  53468. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53469. /** Gets the displayMode */
  53470. get displayMode(): number;
  53471. /** Sets the displayMode */
  53472. set displayMode(value: number);
  53473. /**
  53474. * Creates a new SkeletonViewer
  53475. * @param skeleton defines the skeleton to render
  53476. * @param mesh defines the mesh attached to the skeleton
  53477. * @param scene defines the hosting scene
  53478. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53479. * @param renderingGroupId defines the rendering group id to use with the viewer
  53480. * @param options All of the extra constructor options for the SkeletonViewer
  53481. */
  53482. constructor(
  53483. /** defines the skeleton to render */
  53484. skeleton: Skeleton,
  53485. /** defines the mesh attached to the skeleton */
  53486. mesh: AbstractMesh,
  53487. /** The Scene scope*/
  53488. scene: Scene,
  53489. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53490. autoUpdateBonesMatrices?: boolean,
  53491. /** defines the rendering group id to use with the viewer */
  53492. renderingGroupId?: number,
  53493. /** is the options for the viewer */
  53494. options?: Partial<ISkeletonViewerOptions>);
  53495. /** The Dynamic bindings for the update functions */
  53496. private _bindObs;
  53497. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53498. update(): void;
  53499. /** Gets or sets a boolean indicating if the viewer is enabled */
  53500. set isEnabled(value: boolean);
  53501. get isEnabled(): boolean;
  53502. private _getBonePosition;
  53503. private _getLinesForBonesWithLength;
  53504. private _getLinesForBonesNoLength;
  53505. /** function to revert the mesh and scene back to the initial state. */
  53506. private _revert;
  53507. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  53508. private _getAbsoluteBindPoseToRef;
  53509. /** function to build and bind sphere joint points and spur bone representations. */
  53510. private _buildSpheresAndSpurs;
  53511. private _buildLocalAxes;
  53512. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53513. private _displayLinesUpdate;
  53514. /** Changes the displayMode of the skeleton viewer
  53515. * @param mode The displayMode numerical value
  53516. */
  53517. changeDisplayMode(mode: number): void;
  53518. /** Sets a display option of the skeleton viewer
  53519. *
  53520. * | Option | Type | Default | Description |
  53521. * | --------------- | ------- | ------- | ----------- |
  53522. * | 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`. |
  53523. * | 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`. |
  53524. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53525. * | 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`. |
  53526. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  53527. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  53528. *
  53529. * @param option String of the option name
  53530. * @param value The numerical option value
  53531. */
  53532. changeDisplayOptions(option: string, value: number): void;
  53533. /** Release associated resources */
  53534. dispose(): void;
  53535. }
  53536. }
  53537. declare module "babylonjs/Debug/index" {
  53538. export * from "babylonjs/Debug/axesViewer";
  53539. export * from "babylonjs/Debug/boneAxesViewer";
  53540. export * from "babylonjs/Debug/debugLayer";
  53541. export * from "babylonjs/Debug/physicsViewer";
  53542. export * from "babylonjs/Debug/rayHelper";
  53543. export * from "babylonjs/Debug/skeletonViewer";
  53544. export * from "babylonjs/Debug/ISkeletonViewer";
  53545. }
  53546. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53547. /**
  53548. * Enum for Device Types
  53549. */
  53550. export enum DeviceType {
  53551. /** Generic */
  53552. Generic = 0,
  53553. /** Keyboard */
  53554. Keyboard = 1,
  53555. /** Mouse */
  53556. Mouse = 2,
  53557. /** Touch Pointers */
  53558. Touch = 3,
  53559. /** PS4 Dual Shock */
  53560. DualShock = 4,
  53561. /** Xbox */
  53562. Xbox = 5,
  53563. /** Switch Controller */
  53564. Switch = 6
  53565. }
  53566. /**
  53567. * Enum for All Pointers (Touch/Mouse)
  53568. */
  53569. export enum PointerInput {
  53570. /** Horizontal Axis */
  53571. Horizontal = 0,
  53572. /** Vertical Axis */
  53573. Vertical = 1,
  53574. /** Left Click or Touch */
  53575. LeftClick = 2,
  53576. /** Middle Click */
  53577. MiddleClick = 3,
  53578. /** Right Click */
  53579. RightClick = 4,
  53580. /** Browser Back */
  53581. BrowserBack = 5,
  53582. /** Browser Forward */
  53583. BrowserForward = 6
  53584. }
  53585. /**
  53586. * Enum for Dual Shock Gamepad
  53587. */
  53588. export enum DualShockInput {
  53589. /** Cross */
  53590. Cross = 0,
  53591. /** Circle */
  53592. Circle = 1,
  53593. /** Square */
  53594. Square = 2,
  53595. /** Triangle */
  53596. Triangle = 3,
  53597. /** L1 */
  53598. L1 = 4,
  53599. /** R1 */
  53600. R1 = 5,
  53601. /** L2 */
  53602. L2 = 6,
  53603. /** R2 */
  53604. R2 = 7,
  53605. /** Share */
  53606. Share = 8,
  53607. /** Options */
  53608. Options = 9,
  53609. /** L3 */
  53610. L3 = 10,
  53611. /** R3 */
  53612. R3 = 11,
  53613. /** DPadUp */
  53614. DPadUp = 12,
  53615. /** DPadDown */
  53616. DPadDown = 13,
  53617. /** DPadLeft */
  53618. DPadLeft = 14,
  53619. /** DRight */
  53620. DPadRight = 15,
  53621. /** Home */
  53622. Home = 16,
  53623. /** TouchPad */
  53624. TouchPad = 17,
  53625. /** LStickXAxis */
  53626. LStickXAxis = 18,
  53627. /** LStickYAxis */
  53628. LStickYAxis = 19,
  53629. /** RStickXAxis */
  53630. RStickXAxis = 20,
  53631. /** RStickYAxis */
  53632. RStickYAxis = 21
  53633. }
  53634. /**
  53635. * Enum for Xbox Gamepad
  53636. */
  53637. export enum XboxInput {
  53638. /** A */
  53639. A = 0,
  53640. /** B */
  53641. B = 1,
  53642. /** X */
  53643. X = 2,
  53644. /** Y */
  53645. Y = 3,
  53646. /** LB */
  53647. LB = 4,
  53648. /** RB */
  53649. RB = 5,
  53650. /** LT */
  53651. LT = 6,
  53652. /** RT */
  53653. RT = 7,
  53654. /** Back */
  53655. Back = 8,
  53656. /** Start */
  53657. Start = 9,
  53658. /** LS */
  53659. LS = 10,
  53660. /** RS */
  53661. RS = 11,
  53662. /** DPadUp */
  53663. DPadUp = 12,
  53664. /** DPadDown */
  53665. DPadDown = 13,
  53666. /** DPadLeft */
  53667. DPadLeft = 14,
  53668. /** DRight */
  53669. DPadRight = 15,
  53670. /** Home */
  53671. Home = 16,
  53672. /** LStickXAxis */
  53673. LStickXAxis = 17,
  53674. /** LStickYAxis */
  53675. LStickYAxis = 18,
  53676. /** RStickXAxis */
  53677. RStickXAxis = 19,
  53678. /** RStickYAxis */
  53679. RStickYAxis = 20
  53680. }
  53681. /**
  53682. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53683. */
  53684. export enum SwitchInput {
  53685. /** B */
  53686. B = 0,
  53687. /** A */
  53688. A = 1,
  53689. /** Y */
  53690. Y = 2,
  53691. /** X */
  53692. X = 3,
  53693. /** L */
  53694. L = 4,
  53695. /** R */
  53696. R = 5,
  53697. /** ZL */
  53698. ZL = 6,
  53699. /** ZR */
  53700. ZR = 7,
  53701. /** Minus */
  53702. Minus = 8,
  53703. /** Plus */
  53704. Plus = 9,
  53705. /** LS */
  53706. LS = 10,
  53707. /** RS */
  53708. RS = 11,
  53709. /** DPadUp */
  53710. DPadUp = 12,
  53711. /** DPadDown */
  53712. DPadDown = 13,
  53713. /** DPadLeft */
  53714. DPadLeft = 14,
  53715. /** DRight */
  53716. DPadRight = 15,
  53717. /** Home */
  53718. Home = 16,
  53719. /** Capture */
  53720. Capture = 17,
  53721. /** LStickXAxis */
  53722. LStickXAxis = 18,
  53723. /** LStickYAxis */
  53724. LStickYAxis = 19,
  53725. /** RStickXAxis */
  53726. RStickXAxis = 20,
  53727. /** RStickYAxis */
  53728. RStickYAxis = 21
  53729. }
  53730. }
  53731. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53732. import { Engine } from "babylonjs/Engines/engine";
  53733. import { IDisposable } from "babylonjs/scene";
  53734. import { Nullable } from "babylonjs/types";
  53735. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53736. /**
  53737. * This class will take all inputs from Keyboard, Pointer, and
  53738. * any Gamepads and provide a polling system that all devices
  53739. * will use. This class assumes that there will only be one
  53740. * pointer device and one keyboard.
  53741. */
  53742. export class DeviceInputSystem implements IDisposable {
  53743. /**
  53744. * Callback to be triggered when a device is connected
  53745. */
  53746. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53747. /**
  53748. * Callback to be triggered when a device is disconnected
  53749. */
  53750. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53751. /**
  53752. * Callback to be triggered when event driven input is updated
  53753. */
  53754. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53755. private _inputs;
  53756. private _gamepads;
  53757. private _keyboardActive;
  53758. private _pointerActive;
  53759. private _elementToAttachTo;
  53760. private _keyboardDownEvent;
  53761. private _keyboardUpEvent;
  53762. private _pointerMoveEvent;
  53763. private _pointerDownEvent;
  53764. private _pointerUpEvent;
  53765. private _gamepadConnectedEvent;
  53766. private _gamepadDisconnectedEvent;
  53767. private static _MAX_KEYCODES;
  53768. private static _MAX_POINTER_INPUTS;
  53769. private constructor();
  53770. /**
  53771. * Creates a new DeviceInputSystem instance
  53772. * @param engine Engine to pull input element from
  53773. * @returns The new instance
  53774. */
  53775. static Create(engine: Engine): DeviceInputSystem;
  53776. /**
  53777. * Checks for current device input value, given an id and input index
  53778. * @param deviceName Id of connected device
  53779. * @param inputIndex Index of device input
  53780. * @returns Current value of input
  53781. */
  53782. /**
  53783. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53784. * @param deviceType Enum specifiying device type
  53785. * @param deviceSlot "Slot" or index that device is referenced in
  53786. * @param inputIndex Id of input to be checked
  53787. * @returns Current value of input
  53788. */
  53789. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53790. /**
  53791. * Dispose of all the eventlisteners
  53792. */
  53793. dispose(): void;
  53794. /**
  53795. * Add device and inputs to device array
  53796. * @param deviceType Enum specifiying device type
  53797. * @param deviceSlot "Slot" or index that device is referenced in
  53798. * @param numberOfInputs Number of input entries to create for given device
  53799. */
  53800. private _registerDevice;
  53801. /**
  53802. * Given a specific device name, remove that device from the device map
  53803. * @param deviceType Enum specifiying device type
  53804. * @param deviceSlot "Slot" or index that device is referenced in
  53805. */
  53806. private _unregisterDevice;
  53807. /**
  53808. * Handle all actions that come from keyboard interaction
  53809. */
  53810. private _handleKeyActions;
  53811. /**
  53812. * Handle all actions that come from pointer interaction
  53813. */
  53814. private _handlePointerActions;
  53815. /**
  53816. * Handle all actions that come from gamepad interaction
  53817. */
  53818. private _handleGamepadActions;
  53819. /**
  53820. * Update all non-event based devices with each frame
  53821. * @param deviceType Enum specifiying device type
  53822. * @param deviceSlot "Slot" or index that device is referenced in
  53823. * @param inputIndex Id of input to be checked
  53824. */
  53825. private _updateDevice;
  53826. /**
  53827. * Gets DeviceType from the device name
  53828. * @param deviceName Name of Device from DeviceInputSystem
  53829. * @returns DeviceType enum value
  53830. */
  53831. private _getGamepadDeviceType;
  53832. }
  53833. }
  53834. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53835. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53836. /**
  53837. * Type to handle enforcement of inputs
  53838. */
  53839. 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;
  53840. }
  53841. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53842. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53843. import { Engine } from "babylonjs/Engines/engine";
  53844. import { IDisposable } from "babylonjs/scene";
  53845. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53846. import { Nullable } from "babylonjs/types";
  53847. import { Observable } from "babylonjs/Misc/observable";
  53848. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53849. /**
  53850. * Class that handles all input for a specific device
  53851. */
  53852. export class DeviceSource<T extends DeviceType> {
  53853. /** Type of device */
  53854. readonly deviceType: DeviceType;
  53855. /** "Slot" or index that device is referenced in */
  53856. readonly deviceSlot: number;
  53857. /**
  53858. * Observable to handle device input changes per device
  53859. */
  53860. readonly onInputChangedObservable: Observable<{
  53861. inputIndex: DeviceInput<T>;
  53862. previousState: Nullable<number>;
  53863. currentState: Nullable<number>;
  53864. }>;
  53865. private readonly _deviceInputSystem;
  53866. /**
  53867. * Default Constructor
  53868. * @param deviceInputSystem Reference to DeviceInputSystem
  53869. * @param deviceType Type of device
  53870. * @param deviceSlot "Slot" or index that device is referenced in
  53871. */
  53872. constructor(deviceInputSystem: DeviceInputSystem,
  53873. /** Type of device */
  53874. deviceType: DeviceType,
  53875. /** "Slot" or index that device is referenced in */
  53876. deviceSlot?: number);
  53877. /**
  53878. * Get input for specific input
  53879. * @param inputIndex index of specific input on device
  53880. * @returns Input value from DeviceInputSystem
  53881. */
  53882. getInput(inputIndex: DeviceInput<T>): number;
  53883. }
  53884. /**
  53885. * Class to keep track of devices
  53886. */
  53887. export class DeviceSourceManager implements IDisposable {
  53888. /**
  53889. * Observable to be triggered when before a device is connected
  53890. */
  53891. readonly onBeforeDeviceConnectedObservable: Observable<{
  53892. deviceType: DeviceType;
  53893. deviceSlot: number;
  53894. }>;
  53895. /**
  53896. * Observable to be triggered when before a device is disconnected
  53897. */
  53898. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53899. deviceType: DeviceType;
  53900. deviceSlot: number;
  53901. }>;
  53902. /**
  53903. * Observable to be triggered when after a device is connected
  53904. */
  53905. readonly onAfterDeviceConnectedObservable: Observable<{
  53906. deviceType: DeviceType;
  53907. deviceSlot: number;
  53908. }>;
  53909. /**
  53910. * Observable to be triggered when after a device is disconnected
  53911. */
  53912. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53913. deviceType: DeviceType;
  53914. deviceSlot: number;
  53915. }>;
  53916. private readonly _devices;
  53917. private readonly _firstDevice;
  53918. private readonly _deviceInputSystem;
  53919. /**
  53920. * Default Constructor
  53921. * @param engine engine to pull input element from
  53922. */
  53923. constructor(engine: Engine);
  53924. /**
  53925. * Gets a DeviceSource, given a type and slot
  53926. * @param deviceType Enum specifying device type
  53927. * @param deviceSlot "Slot" or index that device is referenced in
  53928. * @returns DeviceSource object
  53929. */
  53930. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53931. /**
  53932. * Gets an array of DeviceSource objects for a given device type
  53933. * @param deviceType Enum specifying device type
  53934. * @returns Array of DeviceSource objects
  53935. */
  53936. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53937. /**
  53938. * Dispose of DeviceInputSystem and other parts
  53939. */
  53940. dispose(): void;
  53941. /**
  53942. * Function to add device name to device list
  53943. * @param deviceType Enum specifying device type
  53944. * @param deviceSlot "Slot" or index that device is referenced in
  53945. */
  53946. private _addDevice;
  53947. /**
  53948. * Function to remove device name to device list
  53949. * @param deviceType Enum specifying device type
  53950. * @param deviceSlot "Slot" or index that device is referenced in
  53951. */
  53952. private _removeDevice;
  53953. /**
  53954. * Updates array storing first connected device of each type
  53955. * @param type Type of Device
  53956. */
  53957. private _updateFirstDevices;
  53958. }
  53959. }
  53960. declare module "babylonjs/DeviceInput/index" {
  53961. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53962. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53963. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53964. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53965. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53966. }
  53967. declare module "babylonjs/Engines/nullEngine" {
  53968. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53969. import { Engine } from "babylonjs/Engines/engine";
  53970. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53971. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53972. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53973. import { Effect } from "babylonjs/Materials/effect";
  53974. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53975. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53976. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53977. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53978. /**
  53979. * Options to create the null engine
  53980. */
  53981. export class NullEngineOptions {
  53982. /**
  53983. * Render width (Default: 512)
  53984. */
  53985. renderWidth: number;
  53986. /**
  53987. * Render height (Default: 256)
  53988. */
  53989. renderHeight: number;
  53990. /**
  53991. * Texture size (Default: 512)
  53992. */
  53993. textureSize: number;
  53994. /**
  53995. * If delta time between frames should be constant
  53996. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53997. */
  53998. deterministicLockstep: boolean;
  53999. /**
  54000. * Maximum about of steps between frames (Default: 4)
  54001. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54002. */
  54003. lockstepMaxSteps: number;
  54004. /**
  54005. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54006. */
  54007. useHighPrecisionMatrix?: boolean;
  54008. }
  54009. /**
  54010. * The null engine class provides support for headless version of babylon.js.
  54011. * This can be used in server side scenario or for testing purposes
  54012. */
  54013. export class NullEngine extends Engine {
  54014. private _options;
  54015. /**
  54016. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54017. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54018. * @returns true if engine is in deterministic lock step mode
  54019. */
  54020. isDeterministicLockStep(): boolean;
  54021. /**
  54022. * Gets the max steps when engine is running in deterministic lock step
  54023. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54024. * @returns the max steps
  54025. */
  54026. getLockstepMaxSteps(): number;
  54027. /**
  54028. * Gets the current hardware scaling level.
  54029. * By default the hardware scaling level is computed from the window device ratio.
  54030. * 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.
  54031. * @returns a number indicating the current hardware scaling level
  54032. */
  54033. getHardwareScalingLevel(): number;
  54034. constructor(options?: NullEngineOptions);
  54035. /**
  54036. * Creates a vertex buffer
  54037. * @param vertices the data for the vertex buffer
  54038. * @returns the new WebGL static buffer
  54039. */
  54040. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54041. /**
  54042. * Creates a new index buffer
  54043. * @param indices defines the content of the index buffer
  54044. * @param updatable defines if the index buffer must be updatable
  54045. * @returns a new webGL buffer
  54046. */
  54047. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54048. /**
  54049. * Clear the current render buffer or the current render target (if any is set up)
  54050. * @param color defines the color to use
  54051. * @param backBuffer defines if the back buffer must be cleared
  54052. * @param depth defines if the depth buffer must be cleared
  54053. * @param stencil defines if the stencil buffer must be cleared
  54054. */
  54055. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54056. /**
  54057. * Gets the current render width
  54058. * @param useScreen defines if screen size must be used (or the current render target if any)
  54059. * @returns a number defining the current render width
  54060. */
  54061. getRenderWidth(useScreen?: boolean): number;
  54062. /**
  54063. * Gets the current render height
  54064. * @param useScreen defines if screen size must be used (or the current render target if any)
  54065. * @returns a number defining the current render height
  54066. */
  54067. getRenderHeight(useScreen?: boolean): number;
  54068. /**
  54069. * Set the WebGL's viewport
  54070. * @param viewport defines the viewport element to be used
  54071. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54072. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54073. */
  54074. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54075. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54076. /**
  54077. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54078. * @param pipelineContext defines the pipeline context to use
  54079. * @param uniformsNames defines the list of uniform names
  54080. * @returns an array of webGL uniform locations
  54081. */
  54082. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54083. /**
  54084. * Gets the lsit of active attributes for a given webGL program
  54085. * @param pipelineContext defines the pipeline context to use
  54086. * @param attributesNames defines the list of attribute names to get
  54087. * @returns an array of indices indicating the offset of each attribute
  54088. */
  54089. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54090. /**
  54091. * Binds an effect to the webGL context
  54092. * @param effect defines the effect to bind
  54093. */
  54094. bindSamplers(effect: Effect): void;
  54095. /**
  54096. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54097. * @param effect defines the effect to activate
  54098. */
  54099. enableEffect(effect: Effect): void;
  54100. /**
  54101. * Set various states to the webGL context
  54102. * @param culling defines backface culling state
  54103. * @param zOffset defines the value to apply to zOffset (0 by default)
  54104. * @param force defines if states must be applied even if cache is up to date
  54105. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54106. */
  54107. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54108. /**
  54109. * Set the value of an uniform to an array of int32
  54110. * @param uniform defines the webGL uniform location where to store the value
  54111. * @param array defines the array of int32 to store
  54112. * @returns true if value was set
  54113. */
  54114. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54115. /**
  54116. * Set the value of an uniform to an array of int32 (stored as vec2)
  54117. * @param uniform defines the webGL uniform location where to store the value
  54118. * @param array defines the array of int32 to store
  54119. * @returns true if value was set
  54120. */
  54121. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54122. /**
  54123. * Set the value of an uniform to an array of int32 (stored as vec3)
  54124. * @param uniform defines the webGL uniform location where to store the value
  54125. * @param array defines the array of int32 to store
  54126. * @returns true if value was set
  54127. */
  54128. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54129. /**
  54130. * Set the value of an uniform to an array of int32 (stored as vec4)
  54131. * @param uniform defines the webGL uniform location where to store the value
  54132. * @param array defines the array of int32 to store
  54133. * @returns true if value was set
  54134. */
  54135. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54136. /**
  54137. * Set the value of an uniform to an array of float32
  54138. * @param uniform defines the webGL uniform location where to store the value
  54139. * @param array defines the array of float32 to store
  54140. * @returns true if value was set
  54141. */
  54142. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54143. /**
  54144. * Set the value of an uniform to an array of float32 (stored as vec2)
  54145. * @param uniform defines the webGL uniform location where to store the value
  54146. * @param array defines the array of float32 to store
  54147. * @returns true if value was set
  54148. */
  54149. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54150. /**
  54151. * Set the value of an uniform to an array of float32 (stored as vec3)
  54152. * @param uniform defines the webGL uniform location where to store the value
  54153. * @param array defines the array of float32 to store
  54154. * @returns true if value was set
  54155. */
  54156. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54157. /**
  54158. * Set the value of an uniform to an array of float32 (stored as vec4)
  54159. * @param uniform defines the webGL uniform location where to store the value
  54160. * @param array defines the array of float32 to store
  54161. * @returns true if value was set
  54162. */
  54163. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54164. /**
  54165. * Set the value of an uniform to an array of number
  54166. * @param uniform defines the webGL uniform location where to store the value
  54167. * @param array defines the array of number to store
  54168. * @returns true if value was set
  54169. */
  54170. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54171. /**
  54172. * Set the value of an uniform to an array of number (stored as vec2)
  54173. * @param uniform defines the webGL uniform location where to store the value
  54174. * @param array defines the array of number to store
  54175. * @returns true if value was set
  54176. */
  54177. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  54178. /**
  54179. * Set the value of an uniform to an array of number (stored as vec3)
  54180. * @param uniform defines the webGL uniform location where to store the value
  54181. * @param array defines the array of number to store
  54182. * @returns true if value was set
  54183. */
  54184. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  54185. /**
  54186. * Set the value of an uniform to an array of number (stored as vec4)
  54187. * @param uniform defines the webGL uniform location where to store the value
  54188. * @param array defines the array of number to store
  54189. * @returns true if value was set
  54190. */
  54191. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  54192. /**
  54193. * Set the value of an uniform to an array of float32 (stored as matrices)
  54194. * @param uniform defines the webGL uniform location where to store the value
  54195. * @param matrices defines the array of float32 to store
  54196. * @returns true if value was set
  54197. */
  54198. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  54199. /**
  54200. * Set the value of an uniform to a matrix (3x3)
  54201. * @param uniform defines the webGL uniform location where to store the value
  54202. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54203. * @returns true if value was set
  54204. */
  54205. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54206. /**
  54207. * Set the value of an uniform to a matrix (2x2)
  54208. * @param uniform defines the webGL uniform location where to store the value
  54209. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54210. * @returns true if value was set
  54211. */
  54212. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54213. /**
  54214. * Set the value of an uniform to a number (float)
  54215. * @param uniform defines the webGL uniform location where to store the value
  54216. * @param value defines the float number to store
  54217. * @returns true if value was set
  54218. */
  54219. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  54220. /**
  54221. * Set the value of an uniform to a vec2
  54222. * @param uniform defines the webGL uniform location where to store the value
  54223. * @param x defines the 1st component of the value
  54224. * @param y defines the 2nd component of the value
  54225. * @returns true if value was set
  54226. */
  54227. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  54228. /**
  54229. * Set the value of an uniform to a vec3
  54230. * @param uniform defines the webGL uniform location where to store the value
  54231. * @param x defines the 1st component of the value
  54232. * @param y defines the 2nd component of the value
  54233. * @param z defines the 3rd component of the value
  54234. * @returns true if value was set
  54235. */
  54236. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  54237. /**
  54238. * Set the value of an uniform to a boolean
  54239. * @param uniform defines the webGL uniform location where to store the value
  54240. * @param bool defines the boolean to store
  54241. * @returns true if value was set
  54242. */
  54243. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  54244. /**
  54245. * Set the value of an uniform to a vec4
  54246. * @param uniform defines the webGL uniform location where to store the value
  54247. * @param x defines the 1st component of the value
  54248. * @param y defines the 2nd component of the value
  54249. * @param z defines the 3rd component of the value
  54250. * @param w defines the 4th component of the value
  54251. * @returns true if value was set
  54252. */
  54253. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  54254. /**
  54255. * Sets the current alpha mode
  54256. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54257. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54258. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54259. */
  54260. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54261. /**
  54262. * Bind webGl buffers directly to the webGL context
  54263. * @param vertexBuffers defines the vertex buffer to bind
  54264. * @param indexBuffer defines the index buffer to bind
  54265. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54266. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54267. * @param effect defines the effect associated with the vertex buffer
  54268. */
  54269. bindBuffers(vertexBuffers: {
  54270. [key: string]: VertexBuffer;
  54271. }, indexBuffer: DataBuffer, effect: Effect): void;
  54272. /**
  54273. * Force the entire cache to be cleared
  54274. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54275. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54276. */
  54277. wipeCaches(bruteForce?: boolean): void;
  54278. /**
  54279. * Send a draw order
  54280. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54281. * @param indexStart defines the starting index
  54282. * @param indexCount defines the number of index to draw
  54283. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54284. */
  54285. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54286. /**
  54287. * Draw a list of indexed primitives
  54288. * @param fillMode defines the primitive to use
  54289. * @param indexStart defines the starting index
  54290. * @param indexCount defines the number of index to draw
  54291. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54292. */
  54293. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54294. /**
  54295. * Draw a list of unindexed primitives
  54296. * @param fillMode defines the primitive to use
  54297. * @param verticesStart defines the index of first vertex to draw
  54298. * @param verticesCount defines the count of vertices to draw
  54299. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54300. */
  54301. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54302. /** @hidden */
  54303. _createTexture(): WebGLTexture;
  54304. /** @hidden */
  54305. _releaseTexture(texture: InternalTexture): void;
  54306. /**
  54307. * Usually called from Texture.ts.
  54308. * Passed information to create a WebGLTexture
  54309. * @param urlArg defines a value which contains one of the following:
  54310. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54311. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54312. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54313. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54314. * @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)
  54315. * @param scene needed for loading to the correct scene
  54316. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54317. * @param onLoad optional callback to be called upon successful completion
  54318. * @param onError optional callback to be called upon failure
  54319. * @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
  54320. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54321. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54322. * @param forcedExtension defines the extension to use to pick the right loader
  54323. * @param mimeType defines an optional mime type
  54324. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54325. */
  54326. 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;
  54327. /**
  54328. * Creates a new render target texture
  54329. * @param size defines the size of the texture
  54330. * @param options defines the options used to create the texture
  54331. * @returns a new render target texture stored in an InternalTexture
  54332. */
  54333. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54334. /**
  54335. * Update the sampling mode of a given texture
  54336. * @param samplingMode defines the required sampling mode
  54337. * @param texture defines the texture to update
  54338. */
  54339. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54340. /**
  54341. * Binds the frame buffer to the specified texture.
  54342. * @param texture The texture to render to or null for the default canvas
  54343. * @param faceIndex The face of the texture to render to in case of cube texture
  54344. * @param requiredWidth The width of the target to render to
  54345. * @param requiredHeight The height of the target to render to
  54346. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54347. * @param lodLevel defines le lod level to bind to the frame buffer
  54348. */
  54349. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54350. /**
  54351. * Unbind the current render target texture from the webGL context
  54352. * @param texture defines the render target texture to unbind
  54353. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54354. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54355. */
  54356. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54357. /**
  54358. * Creates a dynamic vertex buffer
  54359. * @param vertices the data for the dynamic vertex buffer
  54360. * @returns the new WebGL dynamic buffer
  54361. */
  54362. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54363. /**
  54364. * Update the content of a dynamic texture
  54365. * @param texture defines the texture to update
  54366. * @param canvas defines the canvas containing the source
  54367. * @param invertY defines if data must be stored with Y axis inverted
  54368. * @param premulAlpha defines if alpha is stored as premultiplied
  54369. * @param format defines the format of the data
  54370. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54371. */
  54372. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54373. /**
  54374. * Gets a boolean indicating if all created effects are ready
  54375. * @returns true if all effects are ready
  54376. */
  54377. areAllEffectsReady(): boolean;
  54378. /**
  54379. * @hidden
  54380. * Get the current error code of the webGL context
  54381. * @returns the error code
  54382. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54383. */
  54384. getError(): number;
  54385. /** @hidden */
  54386. _getUnpackAlignement(): number;
  54387. /** @hidden */
  54388. _unpackFlipY(value: boolean): void;
  54389. /**
  54390. * Update a dynamic index buffer
  54391. * @param indexBuffer defines the target index buffer
  54392. * @param indices defines the data to update
  54393. * @param offset defines the offset in the target index buffer where update should start
  54394. */
  54395. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54396. /**
  54397. * Updates a dynamic vertex buffer.
  54398. * @param vertexBuffer the vertex buffer to update
  54399. * @param vertices the data used to update the vertex buffer
  54400. * @param byteOffset the byte offset of the data (optional)
  54401. * @param byteLength the byte length of the data (optional)
  54402. */
  54403. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54404. /** @hidden */
  54405. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54406. /** @hidden */
  54407. _bindTexture(channel: number, texture: InternalTexture): void;
  54408. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54409. /**
  54410. * 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
  54411. */
  54412. releaseEffects(): void;
  54413. displayLoadingUI(): void;
  54414. hideLoadingUI(): void;
  54415. /** @hidden */
  54416. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54417. /** @hidden */
  54418. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54419. /** @hidden */
  54420. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54421. /** @hidden */
  54422. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54423. }
  54424. }
  54425. declare module "babylonjs/Instrumentation/timeToken" {
  54426. import { Nullable } from "babylonjs/types";
  54427. /**
  54428. * @hidden
  54429. **/
  54430. export class _TimeToken {
  54431. _startTimeQuery: Nullable<WebGLQuery>;
  54432. _endTimeQuery: Nullable<WebGLQuery>;
  54433. _timeElapsedQuery: Nullable<WebGLQuery>;
  54434. _timeElapsedQueryEnded: boolean;
  54435. }
  54436. }
  54437. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54438. import { Nullable, int } from "babylonjs/types";
  54439. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54440. /** @hidden */
  54441. export class _OcclusionDataStorage {
  54442. /** @hidden */
  54443. occlusionInternalRetryCounter: number;
  54444. /** @hidden */
  54445. isOcclusionQueryInProgress: boolean;
  54446. /** @hidden */
  54447. isOccluded: boolean;
  54448. /** @hidden */
  54449. occlusionRetryCount: number;
  54450. /** @hidden */
  54451. occlusionType: number;
  54452. /** @hidden */
  54453. occlusionQueryAlgorithmType: number;
  54454. }
  54455. module "babylonjs/Engines/engine" {
  54456. interface Engine {
  54457. /**
  54458. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54459. * @return the new query
  54460. */
  54461. createQuery(): WebGLQuery;
  54462. /**
  54463. * Delete and release a webGL query
  54464. * @param query defines the query to delete
  54465. * @return the current engine
  54466. */
  54467. deleteQuery(query: WebGLQuery): Engine;
  54468. /**
  54469. * Check if a given query has resolved and got its value
  54470. * @param query defines the query to check
  54471. * @returns true if the query got its value
  54472. */
  54473. isQueryResultAvailable(query: WebGLQuery): boolean;
  54474. /**
  54475. * Gets the value of a given query
  54476. * @param query defines the query to check
  54477. * @returns the value of the query
  54478. */
  54479. getQueryResult(query: WebGLQuery): number;
  54480. /**
  54481. * Initiates an occlusion query
  54482. * @param algorithmType defines the algorithm to use
  54483. * @param query defines the query to use
  54484. * @returns the current engine
  54485. * @see https://doc.babylonjs.com/features/occlusionquery
  54486. */
  54487. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54488. /**
  54489. * Ends an occlusion query
  54490. * @see https://doc.babylonjs.com/features/occlusionquery
  54491. * @param algorithmType defines the algorithm to use
  54492. * @returns the current engine
  54493. */
  54494. endOcclusionQuery(algorithmType: number): Engine;
  54495. /**
  54496. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54497. * Please note that only one query can be issued at a time
  54498. * @returns a time token used to track the time span
  54499. */
  54500. startTimeQuery(): Nullable<_TimeToken>;
  54501. /**
  54502. * Ends a time query
  54503. * @param token defines the token used to measure the time span
  54504. * @returns the time spent (in ns)
  54505. */
  54506. endTimeQuery(token: _TimeToken): int;
  54507. /** @hidden */
  54508. _currentNonTimestampToken: Nullable<_TimeToken>;
  54509. /** @hidden */
  54510. _createTimeQuery(): WebGLQuery;
  54511. /** @hidden */
  54512. _deleteTimeQuery(query: WebGLQuery): void;
  54513. /** @hidden */
  54514. _getGlAlgorithmType(algorithmType: number): number;
  54515. /** @hidden */
  54516. _getTimeQueryResult(query: WebGLQuery): any;
  54517. /** @hidden */
  54518. _getTimeQueryAvailability(query: WebGLQuery): any;
  54519. }
  54520. }
  54521. module "babylonjs/Meshes/abstractMesh" {
  54522. interface AbstractMesh {
  54523. /**
  54524. * Backing filed
  54525. * @hidden
  54526. */
  54527. __occlusionDataStorage: _OcclusionDataStorage;
  54528. /**
  54529. * Access property
  54530. * @hidden
  54531. */
  54532. _occlusionDataStorage: _OcclusionDataStorage;
  54533. /**
  54534. * 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.
  54535. * The default value is -1 which means don't break the query and wait till the result
  54536. * @see https://doc.babylonjs.com/features/occlusionquery
  54537. */
  54538. occlusionRetryCount: number;
  54539. /**
  54540. * 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:
  54541. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54542. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54543. * * 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.
  54544. * @see https://doc.babylonjs.com/features/occlusionquery
  54545. */
  54546. occlusionType: number;
  54547. /**
  54548. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54549. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54550. * * 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.
  54551. * @see https://doc.babylonjs.com/features/occlusionquery
  54552. */
  54553. occlusionQueryAlgorithmType: number;
  54554. /**
  54555. * 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
  54556. * @see https://doc.babylonjs.com/features/occlusionquery
  54557. */
  54558. isOccluded: boolean;
  54559. /**
  54560. * Flag to check the progress status of the query
  54561. * @see https://doc.babylonjs.com/features/occlusionquery
  54562. */
  54563. isOcclusionQueryInProgress: boolean;
  54564. }
  54565. }
  54566. }
  54567. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54568. import { Nullable } from "babylonjs/types";
  54569. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54570. /** @hidden */
  54571. export var _forceTransformFeedbackToBundle: boolean;
  54572. module "babylonjs/Engines/engine" {
  54573. interface Engine {
  54574. /**
  54575. * Creates a webGL transform feedback object
  54576. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54577. * @returns the webGL transform feedback object
  54578. */
  54579. createTransformFeedback(): WebGLTransformFeedback;
  54580. /**
  54581. * Delete a webGL transform feedback object
  54582. * @param value defines the webGL transform feedback object to delete
  54583. */
  54584. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54585. /**
  54586. * Bind a webGL transform feedback object to the webgl context
  54587. * @param value defines the webGL transform feedback object to bind
  54588. */
  54589. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54590. /**
  54591. * Begins a transform feedback operation
  54592. * @param usePoints defines if points or triangles must be used
  54593. */
  54594. beginTransformFeedback(usePoints: boolean): void;
  54595. /**
  54596. * Ends a transform feedback operation
  54597. */
  54598. endTransformFeedback(): void;
  54599. /**
  54600. * Specify the varyings to use with transform feedback
  54601. * @param program defines the associated webGL program
  54602. * @param value defines the list of strings representing the varying names
  54603. */
  54604. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54605. /**
  54606. * Bind a webGL buffer for a transform feedback operation
  54607. * @param value defines the webGL buffer to bind
  54608. */
  54609. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54610. }
  54611. }
  54612. }
  54613. declare module "babylonjs/Engines/Extensions/engine.views" {
  54614. import { Camera } from "babylonjs/Cameras/camera";
  54615. import { Nullable } from "babylonjs/types";
  54616. /**
  54617. * Class used to define an additional view for the engine
  54618. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54619. */
  54620. export class EngineView {
  54621. /** Defines the canvas where to render the view */
  54622. target: HTMLCanvasElement;
  54623. /** Defines an optional camera used to render the view (will use active camera else) */
  54624. camera?: Camera;
  54625. }
  54626. module "babylonjs/Engines/engine" {
  54627. interface Engine {
  54628. /**
  54629. * Gets or sets the HTML element to use for attaching events
  54630. */
  54631. inputElement: Nullable<HTMLElement>;
  54632. /**
  54633. * Gets the current engine view
  54634. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54635. */
  54636. activeView: Nullable<EngineView>;
  54637. /** Gets or sets the list of views */
  54638. views: EngineView[];
  54639. /**
  54640. * Register a new child canvas
  54641. * @param canvas defines the canvas to register
  54642. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54643. * @returns the associated view
  54644. */
  54645. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54646. /**
  54647. * Remove a registered child canvas
  54648. * @param canvas defines the canvas to remove
  54649. * @returns the current engine
  54650. */
  54651. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54652. }
  54653. }
  54654. }
  54655. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54656. import { Nullable } from "babylonjs/types";
  54657. module "babylonjs/Engines/engine" {
  54658. interface Engine {
  54659. /** @hidden */
  54660. _excludedCompressedTextures: string[];
  54661. /** @hidden */
  54662. _textureFormatInUse: string;
  54663. /**
  54664. * Gets the list of texture formats supported
  54665. */
  54666. readonly texturesSupported: Array<string>;
  54667. /**
  54668. * Gets the texture format in use
  54669. */
  54670. readonly textureFormatInUse: Nullable<string>;
  54671. /**
  54672. * Set the compressed texture extensions or file names to skip.
  54673. *
  54674. * @param skippedFiles defines the list of those texture files you want to skip
  54675. * Example: [".dds", ".env", "myfile.png"]
  54676. */
  54677. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54678. /**
  54679. * Set the compressed texture format to use, based on the formats you have, and the formats
  54680. * supported by the hardware / browser.
  54681. *
  54682. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54683. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54684. * to API arguments needed to compressed textures. This puts the burden on the container
  54685. * generator to house the arcane code for determining these for current & future formats.
  54686. *
  54687. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54688. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54689. *
  54690. * Note: The result of this call is not taken into account when a texture is base64.
  54691. *
  54692. * @param formatsAvailable defines the list of those format families you have created
  54693. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54694. *
  54695. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54696. * @returns The extension selected.
  54697. */
  54698. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54699. }
  54700. }
  54701. }
  54702. declare module "babylonjs/Engines/Extensions/index" {
  54703. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54704. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54705. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54706. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54707. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54708. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54709. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54710. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54711. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54712. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54713. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54714. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54715. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54716. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54717. export * from "babylonjs/Engines/Extensions/engine.views";
  54718. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54719. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54720. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54721. }
  54722. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54723. import { Nullable } from "babylonjs/types";
  54724. /**
  54725. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54726. */
  54727. export interface CubeMapInfo {
  54728. /**
  54729. * The pixel array for the front face.
  54730. * This is stored in format, left to right, up to down format.
  54731. */
  54732. front: Nullable<ArrayBufferView>;
  54733. /**
  54734. * The pixel array for the back face.
  54735. * This is stored in format, left to right, up to down format.
  54736. */
  54737. back: Nullable<ArrayBufferView>;
  54738. /**
  54739. * The pixel array for the left face.
  54740. * This is stored in format, left to right, up to down format.
  54741. */
  54742. left: Nullable<ArrayBufferView>;
  54743. /**
  54744. * The pixel array for the right face.
  54745. * This is stored in format, left to right, up to down format.
  54746. */
  54747. right: Nullable<ArrayBufferView>;
  54748. /**
  54749. * The pixel array for the up face.
  54750. * This is stored in format, left to right, up to down format.
  54751. */
  54752. up: Nullable<ArrayBufferView>;
  54753. /**
  54754. * The pixel array for the down face.
  54755. * This is stored in format, left to right, up to down format.
  54756. */
  54757. down: Nullable<ArrayBufferView>;
  54758. /**
  54759. * The size of the cubemap stored.
  54760. *
  54761. * Each faces will be size * size pixels.
  54762. */
  54763. size: number;
  54764. /**
  54765. * The format of the texture.
  54766. *
  54767. * RGBA, RGB.
  54768. */
  54769. format: number;
  54770. /**
  54771. * The type of the texture data.
  54772. *
  54773. * UNSIGNED_INT, FLOAT.
  54774. */
  54775. type: number;
  54776. /**
  54777. * Specifies whether the texture is in gamma space.
  54778. */
  54779. gammaSpace: boolean;
  54780. }
  54781. /**
  54782. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54783. */
  54784. export class PanoramaToCubeMapTools {
  54785. private static FACE_LEFT;
  54786. private static FACE_RIGHT;
  54787. private static FACE_FRONT;
  54788. private static FACE_BACK;
  54789. private static FACE_DOWN;
  54790. private static FACE_UP;
  54791. /**
  54792. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54793. *
  54794. * @param float32Array The source data.
  54795. * @param inputWidth The width of the input panorama.
  54796. * @param inputHeight The height of the input panorama.
  54797. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54798. * @return The cubemap data
  54799. */
  54800. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54801. private static CreateCubemapTexture;
  54802. private static CalcProjectionSpherical;
  54803. }
  54804. }
  54805. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54806. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54807. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54808. import { Nullable } from "babylonjs/types";
  54809. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54810. /**
  54811. * Helper class dealing with the extraction of spherical polynomial dataArray
  54812. * from a cube map.
  54813. */
  54814. export class CubeMapToSphericalPolynomialTools {
  54815. private static FileFaces;
  54816. /**
  54817. * Converts a texture to the according Spherical Polynomial data.
  54818. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54819. *
  54820. * @param texture The texture to extract the information from.
  54821. * @return The Spherical Polynomial data.
  54822. */
  54823. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54824. /**
  54825. * Converts a cubemap to the according Spherical Polynomial data.
  54826. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54827. *
  54828. * @param cubeInfo The Cube map to extract the information from.
  54829. * @return The Spherical Polynomial data.
  54830. */
  54831. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54832. }
  54833. }
  54834. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54835. import { Nullable } from "babylonjs/types";
  54836. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54837. module "babylonjs/Materials/Textures/baseTexture" {
  54838. interface BaseTexture {
  54839. /**
  54840. * Get the polynomial representation of the texture data.
  54841. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54842. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54843. */
  54844. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54845. }
  54846. }
  54847. }
  54848. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54849. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54850. /** @hidden */
  54851. export var rgbdEncodePixelShader: {
  54852. name: string;
  54853. shader: string;
  54854. };
  54855. }
  54856. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54857. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54858. /** @hidden */
  54859. export var rgbdDecodePixelShader: {
  54860. name: string;
  54861. shader: string;
  54862. };
  54863. }
  54864. declare module "babylonjs/Misc/environmentTextureTools" {
  54865. import { Nullable } from "babylonjs/types";
  54866. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54867. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54868. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54869. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54870. import "babylonjs/Engines/Extensions/engine.readTexture";
  54871. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54872. import "babylonjs/Shaders/rgbdEncode.fragment";
  54873. import "babylonjs/Shaders/rgbdDecode.fragment";
  54874. /**
  54875. * Raw texture data and descriptor sufficient for WebGL texture upload
  54876. */
  54877. export interface EnvironmentTextureInfo {
  54878. /**
  54879. * Version of the environment map
  54880. */
  54881. version: number;
  54882. /**
  54883. * Width of image
  54884. */
  54885. width: number;
  54886. /**
  54887. * Irradiance information stored in the file.
  54888. */
  54889. irradiance: any;
  54890. /**
  54891. * Specular information stored in the file.
  54892. */
  54893. specular: any;
  54894. }
  54895. /**
  54896. * Defines One Image in the file. It requires only the position in the file
  54897. * as well as the length.
  54898. */
  54899. interface BufferImageData {
  54900. /**
  54901. * Length of the image data.
  54902. */
  54903. length: number;
  54904. /**
  54905. * Position of the data from the null terminator delimiting the end of the JSON.
  54906. */
  54907. position: number;
  54908. }
  54909. /**
  54910. * Defines the specular data enclosed in the file.
  54911. * This corresponds to the version 1 of the data.
  54912. */
  54913. export interface EnvironmentTextureSpecularInfoV1 {
  54914. /**
  54915. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54916. */
  54917. specularDataPosition?: number;
  54918. /**
  54919. * This contains all the images data needed to reconstruct the cubemap.
  54920. */
  54921. mipmaps: Array<BufferImageData>;
  54922. /**
  54923. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54924. */
  54925. lodGenerationScale: number;
  54926. }
  54927. /**
  54928. * Sets of helpers addressing the serialization and deserialization of environment texture
  54929. * stored in a BabylonJS env file.
  54930. * Those files are usually stored as .env files.
  54931. */
  54932. export class EnvironmentTextureTools {
  54933. /**
  54934. * Magic number identifying the env file.
  54935. */
  54936. private static _MagicBytes;
  54937. /**
  54938. * Gets the environment info from an env file.
  54939. * @param data The array buffer containing the .env bytes.
  54940. * @returns the environment file info (the json header) if successfully parsed.
  54941. */
  54942. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54943. /**
  54944. * Creates an environment texture from a loaded cube texture.
  54945. * @param texture defines the cube texture to convert in env file
  54946. * @return a promise containing the environment data if succesfull.
  54947. */
  54948. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54949. /**
  54950. * Creates a JSON representation of the spherical data.
  54951. * @param texture defines the texture containing the polynomials
  54952. * @return the JSON representation of the spherical info
  54953. */
  54954. private static _CreateEnvTextureIrradiance;
  54955. /**
  54956. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54957. * @param data the image data
  54958. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54959. * @return the views described by info providing access to the underlying buffer
  54960. */
  54961. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54962. /**
  54963. * Uploads the texture info contained in the env file to the GPU.
  54964. * @param texture defines the internal texture to upload to
  54965. * @param data defines the data to load
  54966. * @param info defines the texture info retrieved through the GetEnvInfo method
  54967. * @returns a promise
  54968. */
  54969. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54970. private static _OnImageReadyAsync;
  54971. /**
  54972. * Uploads the levels of image data to the GPU.
  54973. * @param texture defines the internal texture to upload to
  54974. * @param imageData defines the array buffer views of image data [mipmap][face]
  54975. * @returns a promise
  54976. */
  54977. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54978. /**
  54979. * Uploads spherical polynomials information to the texture.
  54980. * @param texture defines the texture we are trying to upload the information to
  54981. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54982. */
  54983. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54984. /** @hidden */
  54985. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54986. }
  54987. }
  54988. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54989. /**
  54990. * Class used to inline functions in shader code
  54991. */
  54992. export class ShaderCodeInliner {
  54993. private static readonly _RegexpFindFunctionNameAndType;
  54994. private _sourceCode;
  54995. private _functionDescr;
  54996. private _numMaxIterations;
  54997. /** Gets or sets the token used to mark the functions to inline */
  54998. inlineToken: string;
  54999. /** Gets or sets the debug mode */
  55000. debug: boolean;
  55001. /** Gets the code after the inlining process */
  55002. get code(): string;
  55003. /**
  55004. * Initializes the inliner
  55005. * @param sourceCode shader code source to inline
  55006. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55007. */
  55008. constructor(sourceCode: string, numMaxIterations?: number);
  55009. /**
  55010. * Start the processing of the shader code
  55011. */
  55012. processCode(): void;
  55013. private _collectFunctions;
  55014. private _processInlining;
  55015. private _extractBetweenMarkers;
  55016. private _skipWhitespaces;
  55017. private _removeComments;
  55018. private _replaceFunctionCallsByCode;
  55019. private _findBackward;
  55020. private _escapeRegExp;
  55021. private _replaceNames;
  55022. }
  55023. }
  55024. declare module "babylonjs/Engines/nativeEngine" {
  55025. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  55026. import { Engine } from "babylonjs/Engines/engine";
  55027. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  55028. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55029. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55030. import { Effect } from "babylonjs/Materials/effect";
  55031. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  55032. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  55033. import { IColor4Like } from "babylonjs/Maths/math.like";
  55034. import { Scene } from "babylonjs/scene";
  55035. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  55036. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  55037. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  55038. /**
  55039. * Container for accessors for natively-stored mesh data buffers.
  55040. */
  55041. class NativeDataBuffer extends DataBuffer {
  55042. /**
  55043. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55044. */
  55045. nativeIndexBuffer?: any;
  55046. /**
  55047. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55048. */
  55049. nativeVertexBuffer?: any;
  55050. }
  55051. /** @hidden */
  55052. class NativeTexture extends InternalTexture {
  55053. getInternalTexture(): InternalTexture;
  55054. getViewCount(): number;
  55055. }
  55056. /** @hidden */
  55057. export class NativeEngine extends Engine {
  55058. private readonly _native;
  55059. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55060. private readonly INVALID_HANDLE;
  55061. private _boundBuffersVertexArray;
  55062. private _currentDepthTest;
  55063. getHardwareScalingLevel(): number;
  55064. constructor();
  55065. dispose(): void;
  55066. /**
  55067. * Can be used to override the current requestAnimationFrame requester.
  55068. * @hidden
  55069. */
  55070. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55071. /**
  55072. * Override default engine behavior.
  55073. * @param color
  55074. * @param backBuffer
  55075. * @param depth
  55076. * @param stencil
  55077. */
  55078. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55079. /**
  55080. * Gets host document
  55081. * @returns the host document object
  55082. */
  55083. getHostDocument(): Nullable<Document>;
  55084. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55085. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55086. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55087. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55088. [key: string]: VertexBuffer;
  55089. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55090. bindBuffers(vertexBuffers: {
  55091. [key: string]: VertexBuffer;
  55092. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55093. recordVertexArrayObject(vertexBuffers: {
  55094. [key: string]: VertexBuffer;
  55095. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55096. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55097. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55098. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55099. /**
  55100. * Draw a list of indexed primitives
  55101. * @param fillMode defines the primitive to use
  55102. * @param indexStart defines the starting index
  55103. * @param indexCount defines the number of index to draw
  55104. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55105. */
  55106. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55107. /**
  55108. * Draw a list of unindexed primitives
  55109. * @param fillMode defines the primitive to use
  55110. * @param verticesStart defines the index of first vertex to draw
  55111. * @param verticesCount defines the count of vertices to draw
  55112. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55113. */
  55114. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55115. createPipelineContext(): IPipelineContext;
  55116. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55117. /** @hidden */
  55118. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55119. /** @hidden */
  55120. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55121. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55122. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55123. protected _setProgram(program: WebGLProgram): void;
  55124. _releaseEffect(effect: Effect): void;
  55125. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55126. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55127. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55128. bindSamplers(effect: Effect): void;
  55129. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55130. getRenderWidth(useScreen?: boolean): number;
  55131. getRenderHeight(useScreen?: boolean): number;
  55132. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55133. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55134. /**
  55135. * Set the z offset to apply to current rendering
  55136. * @param value defines the offset to apply
  55137. */
  55138. setZOffset(value: number): void;
  55139. /**
  55140. * Gets the current value of the zOffset
  55141. * @returns the current zOffset state
  55142. */
  55143. getZOffset(): number;
  55144. /**
  55145. * Enable or disable depth buffering
  55146. * @param enable defines the state to set
  55147. */
  55148. setDepthBuffer(enable: boolean): void;
  55149. /**
  55150. * Gets a boolean indicating if depth writing is enabled
  55151. * @returns the current depth writing state
  55152. */
  55153. getDepthWrite(): boolean;
  55154. setDepthFunctionToGreater(): void;
  55155. setDepthFunctionToGreaterOrEqual(): void;
  55156. setDepthFunctionToLess(): void;
  55157. setDepthFunctionToLessOrEqual(): void;
  55158. /**
  55159. * Enable or disable depth writing
  55160. * @param enable defines the state to set
  55161. */
  55162. setDepthWrite(enable: boolean): void;
  55163. /**
  55164. * Enable or disable color writing
  55165. * @param enable defines the state to set
  55166. */
  55167. setColorWrite(enable: boolean): void;
  55168. /**
  55169. * Gets a boolean indicating if color writing is enabled
  55170. * @returns the current color writing state
  55171. */
  55172. getColorWrite(): boolean;
  55173. /**
  55174. * Sets alpha constants used by some alpha blending modes
  55175. * @param r defines the red component
  55176. * @param g defines the green component
  55177. * @param b defines the blue component
  55178. * @param a defines the alpha component
  55179. */
  55180. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55181. /**
  55182. * Sets the current alpha mode
  55183. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55184. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55185. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55186. */
  55187. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55188. /**
  55189. * Gets the current alpha mode
  55190. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55191. * @returns the current alpha mode
  55192. */
  55193. getAlphaMode(): number;
  55194. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55195. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55196. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55197. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55198. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55199. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55200. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55201. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55202. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55203. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55204. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55205. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55206. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55207. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55208. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55209. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55210. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55211. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55212. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55213. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55214. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55215. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55216. wipeCaches(bruteForce?: boolean): void;
  55217. _createTexture(): WebGLTexture;
  55218. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55219. /**
  55220. * Usually called from Texture.ts.
  55221. * Passed information to create a WebGLTexture
  55222. * @param url defines a value which contains one of the following:
  55223. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55224. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55225. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55226. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55227. * @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)
  55228. * @param scene needed for loading to the correct scene
  55229. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55230. * @param onLoad optional callback to be called upon successful completion
  55231. * @param onError optional callback to be called upon failure
  55232. * @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
  55233. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55234. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55235. * @param forcedExtension defines the extension to use to pick the right loader
  55236. * @param mimeType defines an optional mime type
  55237. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55238. */
  55239. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  55240. /**
  55241. * Creates a cube texture
  55242. * @param rootUrl defines the url where the files to load is located
  55243. * @param scene defines the current scene
  55244. * @param files defines the list of files to load (1 per face)
  55245. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55246. * @param onLoad defines an optional callback raised when the texture is loaded
  55247. * @param onError defines an optional callback raised if there is an issue to load the texture
  55248. * @param format defines the format of the data
  55249. * @param forcedExtension defines the extension to use to pick the right loader
  55250. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55251. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55252. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55253. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55254. * @returns the cube texture as an InternalTexture
  55255. */
  55256. 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;
  55257. private _getSamplingFilter;
  55258. private static _GetNativeTextureFormat;
  55259. createRenderTargetTexture(size: number | {
  55260. width: number;
  55261. height: number;
  55262. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55263. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55264. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55265. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55266. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55267. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55268. /**
  55269. * Updates a dynamic vertex buffer.
  55270. * @param vertexBuffer the vertex buffer to update
  55271. * @param data the data used to update the vertex buffer
  55272. * @param byteOffset the byte offset of the data (optional)
  55273. * @param byteLength the byte length of the data (optional)
  55274. */
  55275. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55276. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55277. private _updateAnisotropicLevel;
  55278. private _getAddressMode;
  55279. /** @hidden */
  55280. _bindTexture(channel: number, texture: InternalTexture): void;
  55281. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55282. releaseEffects(): void;
  55283. /** @hidden */
  55284. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55285. /** @hidden */
  55286. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55287. /** @hidden */
  55288. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55289. /** @hidden */
  55290. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55291. }
  55292. }
  55293. declare module "babylonjs/Engines/index" {
  55294. export * from "babylonjs/Engines/constants";
  55295. export * from "babylonjs/Engines/engineCapabilities";
  55296. export * from "babylonjs/Engines/instancingAttributeInfo";
  55297. export * from "babylonjs/Engines/thinEngine";
  55298. export * from "babylonjs/Engines/engine";
  55299. export * from "babylonjs/Engines/engineStore";
  55300. export * from "babylonjs/Engines/nullEngine";
  55301. export * from "babylonjs/Engines/Extensions/index";
  55302. export * from "babylonjs/Engines/IPipelineContext";
  55303. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55304. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55305. export * from "babylonjs/Engines/nativeEngine";
  55306. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55307. export * from "babylonjs/Engines/performanceConfigurator";
  55308. }
  55309. declare module "babylonjs/Events/clipboardEvents" {
  55310. /**
  55311. * Gather the list of clipboard event types as constants.
  55312. */
  55313. export class ClipboardEventTypes {
  55314. /**
  55315. * The clipboard event is fired when a copy command is active (pressed).
  55316. */
  55317. static readonly COPY: number;
  55318. /**
  55319. * The clipboard event is fired when a cut command is active (pressed).
  55320. */
  55321. static readonly CUT: number;
  55322. /**
  55323. * The clipboard event is fired when a paste command is active (pressed).
  55324. */
  55325. static readonly PASTE: number;
  55326. }
  55327. /**
  55328. * This class is used to store clipboard related info for the onClipboardObservable event.
  55329. */
  55330. export class ClipboardInfo {
  55331. /**
  55332. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55333. */
  55334. type: number;
  55335. /**
  55336. * Defines the related dom event
  55337. */
  55338. event: ClipboardEvent;
  55339. /**
  55340. *Creates an instance of ClipboardInfo.
  55341. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55342. * @param event Defines the related dom event
  55343. */
  55344. constructor(
  55345. /**
  55346. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55347. */
  55348. type: number,
  55349. /**
  55350. * Defines the related dom event
  55351. */
  55352. event: ClipboardEvent);
  55353. /**
  55354. * Get the clipboard event's type from the keycode.
  55355. * @param keyCode Defines the keyCode for the current keyboard event.
  55356. * @return {number}
  55357. */
  55358. static GetTypeFromCharacter(keyCode: number): number;
  55359. }
  55360. }
  55361. declare module "babylonjs/Events/index" {
  55362. export * from "babylonjs/Events/keyboardEvents";
  55363. export * from "babylonjs/Events/pointerEvents";
  55364. export * from "babylonjs/Events/clipboardEvents";
  55365. }
  55366. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55367. import { Scene } from "babylonjs/scene";
  55368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55369. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55370. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55371. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55372. /**
  55373. * Google Daydream controller
  55374. */
  55375. export class DaydreamController extends WebVRController {
  55376. /**
  55377. * Base Url for the controller model.
  55378. */
  55379. static MODEL_BASE_URL: string;
  55380. /**
  55381. * File name for the controller model.
  55382. */
  55383. static MODEL_FILENAME: string;
  55384. /**
  55385. * Gamepad Id prefix used to identify Daydream Controller.
  55386. */
  55387. static readonly GAMEPAD_ID_PREFIX: string;
  55388. /**
  55389. * Creates a new DaydreamController from a gamepad
  55390. * @param vrGamepad the gamepad that the controller should be created from
  55391. */
  55392. constructor(vrGamepad: any);
  55393. /**
  55394. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55395. * @param scene scene in which to add meshes
  55396. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55397. */
  55398. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55399. /**
  55400. * Called once for each button that changed state since the last frame
  55401. * @param buttonIdx Which button index changed
  55402. * @param state New state of the button
  55403. * @param changes Which properties on the state changed since last frame
  55404. */
  55405. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55406. }
  55407. }
  55408. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55409. import { Scene } from "babylonjs/scene";
  55410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55411. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55412. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55413. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55414. /**
  55415. * Gear VR Controller
  55416. */
  55417. export class GearVRController extends WebVRController {
  55418. /**
  55419. * Base Url for the controller model.
  55420. */
  55421. static MODEL_BASE_URL: string;
  55422. /**
  55423. * File name for the controller model.
  55424. */
  55425. static MODEL_FILENAME: string;
  55426. /**
  55427. * Gamepad Id prefix used to identify this controller.
  55428. */
  55429. static readonly GAMEPAD_ID_PREFIX: string;
  55430. private readonly _buttonIndexToObservableNameMap;
  55431. /**
  55432. * Creates a new GearVRController from a gamepad
  55433. * @param vrGamepad the gamepad that the controller should be created from
  55434. */
  55435. constructor(vrGamepad: any);
  55436. /**
  55437. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55438. * @param scene scene in which to add meshes
  55439. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55440. */
  55441. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55442. /**
  55443. * Called once for each button that changed state since the last frame
  55444. * @param buttonIdx Which button index changed
  55445. * @param state New state of the button
  55446. * @param changes Which properties on the state changed since last frame
  55447. */
  55448. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55449. }
  55450. }
  55451. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55452. import { Scene } from "babylonjs/scene";
  55453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55454. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55455. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55456. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55457. /**
  55458. * Generic Controller
  55459. */
  55460. export class GenericController extends WebVRController {
  55461. /**
  55462. * Base Url for the controller model.
  55463. */
  55464. static readonly MODEL_BASE_URL: string;
  55465. /**
  55466. * File name for the controller model.
  55467. */
  55468. static readonly MODEL_FILENAME: string;
  55469. /**
  55470. * Creates a new GenericController from a gamepad
  55471. * @param vrGamepad the gamepad that the controller should be created from
  55472. */
  55473. constructor(vrGamepad: any);
  55474. /**
  55475. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55476. * @param scene scene in which to add meshes
  55477. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55478. */
  55479. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55480. /**
  55481. * Called once for each button that changed state since the last frame
  55482. * @param buttonIdx Which button index changed
  55483. * @param state New state of the button
  55484. * @param changes Which properties on the state changed since last frame
  55485. */
  55486. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55487. }
  55488. }
  55489. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55490. import { Observable } from "babylonjs/Misc/observable";
  55491. import { Scene } from "babylonjs/scene";
  55492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55493. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55494. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55495. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55496. /**
  55497. * Oculus Touch Controller
  55498. */
  55499. export class OculusTouchController extends WebVRController {
  55500. /**
  55501. * Base Url for the controller model.
  55502. */
  55503. static MODEL_BASE_URL: string;
  55504. /**
  55505. * File name for the left controller model.
  55506. */
  55507. static MODEL_LEFT_FILENAME: string;
  55508. /**
  55509. * File name for the right controller model.
  55510. */
  55511. static MODEL_RIGHT_FILENAME: string;
  55512. /**
  55513. * Base Url for the Quest controller model.
  55514. */
  55515. static QUEST_MODEL_BASE_URL: string;
  55516. /**
  55517. * @hidden
  55518. * If the controllers are running on a device that needs the updated Quest controller models
  55519. */
  55520. static _IsQuest: boolean;
  55521. /**
  55522. * Fired when the secondary trigger on this controller is modified
  55523. */
  55524. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55525. /**
  55526. * Fired when the thumb rest on this controller is modified
  55527. */
  55528. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55529. /**
  55530. * Creates a new OculusTouchController from a gamepad
  55531. * @param vrGamepad the gamepad that the controller should be created from
  55532. */
  55533. constructor(vrGamepad: any);
  55534. /**
  55535. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55536. * @param scene scene in which to add meshes
  55537. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55538. */
  55539. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55540. /**
  55541. * Fired when the A button on this controller is modified
  55542. */
  55543. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55544. /**
  55545. * Fired when the B button on this controller is modified
  55546. */
  55547. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55548. /**
  55549. * Fired when the X button on this controller is modified
  55550. */
  55551. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55552. /**
  55553. * Fired when the Y button on this controller is modified
  55554. */
  55555. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55556. /**
  55557. * Called once for each button that changed state since the last frame
  55558. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55559. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55560. * 2) secondary trigger (same)
  55561. * 3) A (right) X (left), touch, pressed = value
  55562. * 4) B / Y
  55563. * 5) thumb rest
  55564. * @param buttonIdx Which button index changed
  55565. * @param state New state of the button
  55566. * @param changes Which properties on the state changed since last frame
  55567. */
  55568. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55569. }
  55570. }
  55571. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55572. import { Scene } from "babylonjs/scene";
  55573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55574. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55575. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55576. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55577. import { Observable } from "babylonjs/Misc/observable";
  55578. /**
  55579. * Vive Controller
  55580. */
  55581. export class ViveController extends WebVRController {
  55582. /**
  55583. * Base Url for the controller model.
  55584. */
  55585. static MODEL_BASE_URL: string;
  55586. /**
  55587. * File name for the controller model.
  55588. */
  55589. static MODEL_FILENAME: string;
  55590. /**
  55591. * Creates a new ViveController from a gamepad
  55592. * @param vrGamepad the gamepad that the controller should be created from
  55593. */
  55594. constructor(vrGamepad: any);
  55595. /**
  55596. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55597. * @param scene scene in which to add meshes
  55598. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55599. */
  55600. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55601. /**
  55602. * Fired when the left button on this controller is modified
  55603. */
  55604. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55605. /**
  55606. * Fired when the right button on this controller is modified
  55607. */
  55608. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55609. /**
  55610. * Fired when the menu button on this controller is modified
  55611. */
  55612. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55613. /**
  55614. * Called once for each button that changed state since the last frame
  55615. * Vive mapping:
  55616. * 0: touchpad
  55617. * 1: trigger
  55618. * 2: left AND right buttons
  55619. * 3: menu button
  55620. * @param buttonIdx Which button index changed
  55621. * @param state New state of the button
  55622. * @param changes Which properties on the state changed since last frame
  55623. */
  55624. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55625. }
  55626. }
  55627. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55628. import { Observable } from "babylonjs/Misc/observable";
  55629. import { Scene } from "babylonjs/scene";
  55630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55631. import { Ray } from "babylonjs/Culling/ray";
  55632. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55633. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55634. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55635. /**
  55636. * Defines the WindowsMotionController object that the state of the windows motion controller
  55637. */
  55638. export class WindowsMotionController extends WebVRController {
  55639. /**
  55640. * The base url used to load the left and right controller models
  55641. */
  55642. static MODEL_BASE_URL: string;
  55643. /**
  55644. * The name of the left controller model file
  55645. */
  55646. static MODEL_LEFT_FILENAME: string;
  55647. /**
  55648. * The name of the right controller model file
  55649. */
  55650. static MODEL_RIGHT_FILENAME: string;
  55651. /**
  55652. * The controller name prefix for this controller type
  55653. */
  55654. static readonly GAMEPAD_ID_PREFIX: string;
  55655. /**
  55656. * The controller id pattern for this controller type
  55657. */
  55658. private static readonly GAMEPAD_ID_PATTERN;
  55659. private _loadedMeshInfo;
  55660. protected readonly _mapping: {
  55661. buttons: string[];
  55662. buttonMeshNames: {
  55663. trigger: string;
  55664. menu: string;
  55665. grip: string;
  55666. thumbstick: string;
  55667. trackpad: string;
  55668. };
  55669. buttonObservableNames: {
  55670. trigger: string;
  55671. menu: string;
  55672. grip: string;
  55673. thumbstick: string;
  55674. trackpad: string;
  55675. };
  55676. axisMeshNames: string[];
  55677. pointingPoseMeshName: string;
  55678. };
  55679. /**
  55680. * Fired when the trackpad on this controller is clicked
  55681. */
  55682. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55683. /**
  55684. * Fired when the trackpad on this controller is modified
  55685. */
  55686. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55687. /**
  55688. * The current x and y values of this controller's trackpad
  55689. */
  55690. trackpad: StickValues;
  55691. /**
  55692. * Creates a new WindowsMotionController from a gamepad
  55693. * @param vrGamepad the gamepad that the controller should be created from
  55694. */
  55695. constructor(vrGamepad: any);
  55696. /**
  55697. * Fired when the trigger on this controller is modified
  55698. */
  55699. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55700. /**
  55701. * Fired when the menu button on this controller is modified
  55702. */
  55703. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55704. /**
  55705. * Fired when the grip button on this controller is modified
  55706. */
  55707. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55708. /**
  55709. * Fired when the thumbstick button on this controller is modified
  55710. */
  55711. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55712. /**
  55713. * Fired when the touchpad button on this controller is modified
  55714. */
  55715. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55716. /**
  55717. * Fired when the touchpad values on this controller are modified
  55718. */
  55719. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55720. protected _updateTrackpad(): void;
  55721. /**
  55722. * Called once per frame by the engine.
  55723. */
  55724. update(): void;
  55725. /**
  55726. * Called once for each button that changed state since the last frame
  55727. * @param buttonIdx Which button index changed
  55728. * @param state New state of the button
  55729. * @param changes Which properties on the state changed since last frame
  55730. */
  55731. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55732. /**
  55733. * Moves the buttons on the controller mesh based on their current state
  55734. * @param buttonName the name of the button to move
  55735. * @param buttonValue the value of the button which determines the buttons new position
  55736. */
  55737. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55738. /**
  55739. * Moves the axis on the controller mesh based on its current state
  55740. * @param axis the index of the axis
  55741. * @param axisValue the value of the axis which determines the meshes new position
  55742. * @hidden
  55743. */
  55744. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55745. /**
  55746. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55747. * @param scene scene in which to add meshes
  55748. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55749. */
  55750. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55751. /**
  55752. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55753. * can be transformed by button presses and axes values, based on this._mapping.
  55754. *
  55755. * @param scene scene in which the meshes exist
  55756. * @param meshes list of meshes that make up the controller model to process
  55757. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55758. */
  55759. private processModel;
  55760. private createMeshInfo;
  55761. /**
  55762. * Gets the ray of the controller in the direction the controller is pointing
  55763. * @param length the length the resulting ray should be
  55764. * @returns a ray in the direction the controller is pointing
  55765. */
  55766. getForwardRay(length?: number): Ray;
  55767. /**
  55768. * Disposes of the controller
  55769. */
  55770. dispose(): void;
  55771. }
  55772. /**
  55773. * This class represents a new windows motion controller in XR.
  55774. */
  55775. export class XRWindowsMotionController extends WindowsMotionController {
  55776. /**
  55777. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55778. */
  55779. protected readonly _mapping: {
  55780. buttons: string[];
  55781. buttonMeshNames: {
  55782. trigger: string;
  55783. menu: string;
  55784. grip: string;
  55785. thumbstick: string;
  55786. trackpad: string;
  55787. };
  55788. buttonObservableNames: {
  55789. trigger: string;
  55790. menu: string;
  55791. grip: string;
  55792. thumbstick: string;
  55793. trackpad: string;
  55794. };
  55795. axisMeshNames: string[];
  55796. pointingPoseMeshName: string;
  55797. };
  55798. /**
  55799. * Construct a new XR-Based windows motion controller
  55800. *
  55801. * @param gamepadInfo the gamepad object from the browser
  55802. */
  55803. constructor(gamepadInfo: any);
  55804. /**
  55805. * holds the thumbstick values (X,Y)
  55806. */
  55807. thumbstickValues: StickValues;
  55808. /**
  55809. * Fired when the thumbstick on this controller is clicked
  55810. */
  55811. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55812. /**
  55813. * Fired when the thumbstick on this controller is modified
  55814. */
  55815. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55816. /**
  55817. * Fired when the touchpad button on this controller is modified
  55818. */
  55819. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55820. /**
  55821. * Fired when the touchpad values on this controller are modified
  55822. */
  55823. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55824. /**
  55825. * Fired when the thumbstick button on this controller is modified
  55826. * here to prevent breaking changes
  55827. */
  55828. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55829. /**
  55830. * updating the thumbstick(!) and not the trackpad.
  55831. * This is named this way due to the difference between WebVR and XR and to avoid
  55832. * changing the parent class.
  55833. */
  55834. protected _updateTrackpad(): void;
  55835. /**
  55836. * Disposes the class with joy
  55837. */
  55838. dispose(): void;
  55839. }
  55840. }
  55841. declare module "babylonjs/Gamepads/Controllers/index" {
  55842. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55843. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55844. export * from "babylonjs/Gamepads/Controllers/genericController";
  55845. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55846. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55847. export * from "babylonjs/Gamepads/Controllers/viveController";
  55848. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55849. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55850. }
  55851. declare module "babylonjs/Gamepads/index" {
  55852. export * from "babylonjs/Gamepads/Controllers/index";
  55853. export * from "babylonjs/Gamepads/gamepad";
  55854. export * from "babylonjs/Gamepads/gamepadManager";
  55855. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55856. export * from "babylonjs/Gamepads/xboxGamepad";
  55857. export * from "babylonjs/Gamepads/dualShockGamepad";
  55858. }
  55859. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55860. import { Scene } from "babylonjs/scene";
  55861. import { Vector4 } from "babylonjs/Maths/math.vector";
  55862. import { Color4 } from "babylonjs/Maths/math.color";
  55863. import { Mesh } from "babylonjs/Meshes/mesh";
  55864. import { Nullable } from "babylonjs/types";
  55865. /**
  55866. * Class containing static functions to help procedurally build meshes
  55867. */
  55868. export class PolyhedronBuilder {
  55869. /**
  55870. * Creates a polyhedron mesh
  55871. * * 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
  55872. * * The parameter `size` (positive float, default 1) sets the polygon size
  55873. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55874. * * 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`
  55875. * * 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
  55876. * * 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)`)
  55877. * * 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
  55878. * * 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
  55879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55882. * @param name defines the name of the mesh
  55883. * @param options defines the options used to create the mesh
  55884. * @param scene defines the hosting scene
  55885. * @returns the polyhedron mesh
  55886. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55887. */
  55888. static CreatePolyhedron(name: string, options: {
  55889. type?: number;
  55890. size?: number;
  55891. sizeX?: number;
  55892. sizeY?: number;
  55893. sizeZ?: number;
  55894. custom?: any;
  55895. faceUV?: Vector4[];
  55896. faceColors?: Color4[];
  55897. flat?: boolean;
  55898. updatable?: boolean;
  55899. sideOrientation?: number;
  55900. frontUVs?: Vector4;
  55901. backUVs?: Vector4;
  55902. }, scene?: Nullable<Scene>): Mesh;
  55903. }
  55904. }
  55905. declare module "babylonjs/Gizmos/scaleGizmo" {
  55906. import { Observable } from "babylonjs/Misc/observable";
  55907. import { Nullable } from "babylonjs/types";
  55908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55909. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55910. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55911. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55912. import { Node } from "babylonjs/node";
  55913. /**
  55914. * Gizmo that enables scaling a mesh along 3 axis
  55915. */
  55916. export class ScaleGizmo extends Gizmo {
  55917. /**
  55918. * Internal gizmo used for interactions on the x axis
  55919. */
  55920. xGizmo: AxisScaleGizmo;
  55921. /**
  55922. * Internal gizmo used for interactions on the y axis
  55923. */
  55924. yGizmo: AxisScaleGizmo;
  55925. /**
  55926. * Internal gizmo used for interactions on the z axis
  55927. */
  55928. zGizmo: AxisScaleGizmo;
  55929. /**
  55930. * Internal gizmo used to scale all axis equally
  55931. */
  55932. uniformScaleGizmo: AxisScaleGizmo;
  55933. private _meshAttached;
  55934. private _nodeAttached;
  55935. private _snapDistance;
  55936. private _uniformScalingMesh;
  55937. private _octahedron;
  55938. private _sensitivity;
  55939. /** Fires an event when any of it's sub gizmos are dragged */
  55940. onDragStartObservable: Observable<unknown>;
  55941. /** Fires an event when any of it's sub gizmos are released from dragging */
  55942. onDragEndObservable: Observable<unknown>;
  55943. get attachedMesh(): Nullable<AbstractMesh>;
  55944. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55945. get attachedNode(): Nullable<Node>;
  55946. set attachedNode(node: Nullable<Node>);
  55947. /**
  55948. * True when the mouse pointer is hovering a gizmo mesh
  55949. */
  55950. get isHovered(): boolean;
  55951. /**
  55952. * Creates a ScaleGizmo
  55953. * @param gizmoLayer The utility layer the gizmo will be added to
  55954. * @param thickness display gizmo axis thickness
  55955. */
  55956. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55957. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55958. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55959. /**
  55960. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55961. */
  55962. set snapDistance(value: number);
  55963. get snapDistance(): number;
  55964. /**
  55965. * Ratio for the scale of the gizmo (Default: 1)
  55966. */
  55967. set scaleRatio(value: number);
  55968. get scaleRatio(): number;
  55969. /**
  55970. * Sensitivity factor for dragging (Default: 1)
  55971. */
  55972. set sensitivity(value: number);
  55973. get sensitivity(): number;
  55974. /**
  55975. * Disposes of the gizmo
  55976. */
  55977. dispose(): void;
  55978. }
  55979. }
  55980. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55981. import { Observable } from "babylonjs/Misc/observable";
  55982. import { Nullable } from "babylonjs/types";
  55983. import { Vector3 } from "babylonjs/Maths/math.vector";
  55984. import { Node } from "babylonjs/node";
  55985. import { Mesh } from "babylonjs/Meshes/mesh";
  55986. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55987. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55988. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55989. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55990. import { Color3 } from "babylonjs/Maths/math.color";
  55991. /**
  55992. * Single axis scale gizmo
  55993. */
  55994. export class AxisScaleGizmo extends Gizmo {
  55995. /**
  55996. * Drag behavior responsible for the gizmos dragging interactions
  55997. */
  55998. dragBehavior: PointerDragBehavior;
  55999. private _pointerObserver;
  56000. /**
  56001. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56002. */
  56003. snapDistance: number;
  56004. /**
  56005. * Event that fires each time the gizmo snaps to a new location.
  56006. * * snapDistance is the the change in distance
  56007. */
  56008. onSnapObservable: Observable<{
  56009. snapDistance: number;
  56010. }>;
  56011. /**
  56012. * If the scaling operation should be done on all axis (default: false)
  56013. */
  56014. uniformScaling: boolean;
  56015. /**
  56016. * Custom sensitivity value for the drag strength
  56017. */
  56018. sensitivity: number;
  56019. private _isEnabled;
  56020. private _parent;
  56021. private _arrow;
  56022. private _coloredMaterial;
  56023. private _hoverMaterial;
  56024. /**
  56025. * Creates an AxisScaleGizmo
  56026. * @param gizmoLayer The utility layer the gizmo will be added to
  56027. * @param dragAxis The axis which the gizmo will be able to scale on
  56028. * @param color The color of the gizmo
  56029. * @param thickness display gizmo axis thickness
  56030. */
  56031. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56032. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56033. /**
  56034. * If the gizmo is enabled
  56035. */
  56036. set isEnabled(value: boolean);
  56037. get isEnabled(): boolean;
  56038. /**
  56039. * Disposes of the gizmo
  56040. */
  56041. dispose(): void;
  56042. /**
  56043. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56044. * @param mesh The mesh to replace the default mesh of the gizmo
  56045. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56046. */
  56047. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56048. }
  56049. }
  56050. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56051. import { Observable } from "babylonjs/Misc/observable";
  56052. import { Nullable } from "babylonjs/types";
  56053. import { Vector3 } from "babylonjs/Maths/math.vector";
  56054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56055. import { Mesh } from "babylonjs/Meshes/mesh";
  56056. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56057. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56058. import { Color3 } from "babylonjs/Maths/math.color";
  56059. import "babylonjs/Meshes/Builders/boxBuilder";
  56060. /**
  56061. * Bounding box gizmo
  56062. */
  56063. export class BoundingBoxGizmo extends Gizmo {
  56064. private _lineBoundingBox;
  56065. private _rotateSpheresParent;
  56066. private _scaleBoxesParent;
  56067. private _boundingDimensions;
  56068. private _renderObserver;
  56069. private _pointerObserver;
  56070. private _scaleDragSpeed;
  56071. private _tmpQuaternion;
  56072. private _tmpVector;
  56073. private _tmpRotationMatrix;
  56074. /**
  56075. * 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)
  56076. */
  56077. ignoreChildren: boolean;
  56078. /**
  56079. * 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)
  56080. */
  56081. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56082. /**
  56083. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56084. */
  56085. rotationSphereSize: number;
  56086. /**
  56087. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56088. */
  56089. scaleBoxSize: number;
  56090. /**
  56091. * 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)
  56092. */
  56093. fixedDragMeshScreenSize: boolean;
  56094. /**
  56095. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56096. */
  56097. fixedDragMeshScreenSizeDistanceFactor: number;
  56098. /**
  56099. * Fired when a rotation sphere or scale box is dragged
  56100. */
  56101. onDragStartObservable: Observable<{}>;
  56102. /**
  56103. * Fired when a scale box is dragged
  56104. */
  56105. onScaleBoxDragObservable: Observable<{}>;
  56106. /**
  56107. * Fired when a scale box drag is ended
  56108. */
  56109. onScaleBoxDragEndObservable: Observable<{}>;
  56110. /**
  56111. * Fired when a rotation sphere is dragged
  56112. */
  56113. onRotationSphereDragObservable: Observable<{}>;
  56114. /**
  56115. * Fired when a rotation sphere drag is ended
  56116. */
  56117. onRotationSphereDragEndObservable: Observable<{}>;
  56118. /**
  56119. * 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)
  56120. */
  56121. scalePivot: Nullable<Vector3>;
  56122. /**
  56123. * Mesh used as a pivot to rotate the attached node
  56124. */
  56125. private _anchorMesh;
  56126. private _existingMeshScale;
  56127. private _dragMesh;
  56128. private pointerDragBehavior;
  56129. private coloredMaterial;
  56130. private hoverColoredMaterial;
  56131. /**
  56132. * Sets the color of the bounding box gizmo
  56133. * @param color the color to set
  56134. */
  56135. setColor(color: Color3): void;
  56136. /**
  56137. * Creates an BoundingBoxGizmo
  56138. * @param gizmoLayer The utility layer the gizmo will be added to
  56139. * @param color The color of the gizmo
  56140. */
  56141. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56142. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56143. private _selectNode;
  56144. /**
  56145. * Updates the bounding box information for the Gizmo
  56146. */
  56147. updateBoundingBox(): void;
  56148. private _updateRotationSpheres;
  56149. private _updateScaleBoxes;
  56150. /**
  56151. * Enables rotation on the specified axis and disables rotation on the others
  56152. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56153. */
  56154. setEnabledRotationAxis(axis: string): void;
  56155. /**
  56156. * Enables/disables scaling
  56157. * @param enable if scaling should be enabled
  56158. * @param homogeneousScaling defines if scaling should only be homogeneous
  56159. */
  56160. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56161. private _updateDummy;
  56162. /**
  56163. * Enables a pointer drag behavior on the bounding box of the gizmo
  56164. */
  56165. enableDragBehavior(): void;
  56166. /**
  56167. * Disposes of the gizmo
  56168. */
  56169. dispose(): void;
  56170. /**
  56171. * 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)
  56172. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56173. * @returns the bounding box mesh with the passed in mesh as a child
  56174. */
  56175. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56176. /**
  56177. * CustomMeshes are not supported by this gizmo
  56178. * @param mesh The mesh to replace the default mesh of the gizmo
  56179. */
  56180. setCustomMesh(mesh: Mesh): void;
  56181. }
  56182. }
  56183. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56184. import { Observable } from "babylonjs/Misc/observable";
  56185. import { Nullable } from "babylonjs/types";
  56186. import { Vector3 } from "babylonjs/Maths/math.vector";
  56187. import { Color3 } from "babylonjs/Maths/math.color";
  56188. import { Node } from "babylonjs/node";
  56189. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56190. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56191. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56192. import "babylonjs/Meshes/Builders/linesBuilder";
  56193. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56194. /**
  56195. * Single plane rotation gizmo
  56196. */
  56197. export class PlaneRotationGizmo extends Gizmo {
  56198. /**
  56199. * Drag behavior responsible for the gizmos dragging interactions
  56200. */
  56201. dragBehavior: PointerDragBehavior;
  56202. private _pointerObserver;
  56203. /**
  56204. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56205. */
  56206. snapDistance: number;
  56207. /**
  56208. * Event that fires each time the gizmo snaps to a new location.
  56209. * * snapDistance is the the change in distance
  56210. */
  56211. onSnapObservable: Observable<{
  56212. snapDistance: number;
  56213. }>;
  56214. private _isEnabled;
  56215. private _parent;
  56216. /**
  56217. * Creates a PlaneRotationGizmo
  56218. * @param gizmoLayer The utility layer the gizmo will be added to
  56219. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56220. * @param color The color of the gizmo
  56221. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56222. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56223. * @param thickness display gizmo axis thickness
  56224. */
  56225. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56226. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56227. /**
  56228. * If the gizmo is enabled
  56229. */
  56230. set isEnabled(value: boolean);
  56231. get isEnabled(): boolean;
  56232. /**
  56233. * Disposes of the gizmo
  56234. */
  56235. dispose(): void;
  56236. }
  56237. }
  56238. declare module "babylonjs/Gizmos/rotationGizmo" {
  56239. import { Observable } from "babylonjs/Misc/observable";
  56240. import { Nullable } from "babylonjs/types";
  56241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56242. import { Mesh } from "babylonjs/Meshes/mesh";
  56243. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56244. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56245. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56246. import { Node } from "babylonjs/node";
  56247. /**
  56248. * Gizmo that enables rotating a mesh along 3 axis
  56249. */
  56250. export class RotationGizmo extends Gizmo {
  56251. /**
  56252. * Internal gizmo used for interactions on the x axis
  56253. */
  56254. xGizmo: PlaneRotationGizmo;
  56255. /**
  56256. * Internal gizmo used for interactions on the y axis
  56257. */
  56258. yGizmo: PlaneRotationGizmo;
  56259. /**
  56260. * Internal gizmo used for interactions on the z axis
  56261. */
  56262. zGizmo: PlaneRotationGizmo;
  56263. /** Fires an event when any of it's sub gizmos are dragged */
  56264. onDragStartObservable: Observable<unknown>;
  56265. /** Fires an event when any of it's sub gizmos are released from dragging */
  56266. onDragEndObservable: Observable<unknown>;
  56267. private _meshAttached;
  56268. private _nodeAttached;
  56269. get attachedMesh(): Nullable<AbstractMesh>;
  56270. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56271. get attachedNode(): Nullable<Node>;
  56272. set attachedNode(node: Nullable<Node>);
  56273. /**
  56274. * True when the mouse pointer is hovering a gizmo mesh
  56275. */
  56276. get isHovered(): boolean;
  56277. /**
  56278. * Creates a RotationGizmo
  56279. * @param gizmoLayer The utility layer the gizmo will be added to
  56280. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56281. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56282. * @param thickness display gizmo axis thickness
  56283. */
  56284. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56285. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56286. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56287. /**
  56288. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56289. */
  56290. set snapDistance(value: number);
  56291. get snapDistance(): number;
  56292. /**
  56293. * Ratio for the scale of the gizmo (Default: 1)
  56294. */
  56295. set scaleRatio(value: number);
  56296. get scaleRatio(): number;
  56297. /**
  56298. * Disposes of the gizmo
  56299. */
  56300. dispose(): void;
  56301. /**
  56302. * CustomMeshes are not supported by this gizmo
  56303. * @param mesh The mesh to replace the default mesh of the gizmo
  56304. */
  56305. setCustomMesh(mesh: Mesh): void;
  56306. }
  56307. }
  56308. declare module "babylonjs/Gizmos/gizmoManager" {
  56309. import { Observable } from "babylonjs/Misc/observable";
  56310. import { Nullable } from "babylonjs/types";
  56311. import { Scene, IDisposable } from "babylonjs/scene";
  56312. import { Node } from "babylonjs/node";
  56313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56314. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56315. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56316. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56317. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56318. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56319. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56320. /**
  56321. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56322. */
  56323. export class GizmoManager implements IDisposable {
  56324. private scene;
  56325. /**
  56326. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56327. */
  56328. gizmos: {
  56329. positionGizmo: Nullable<PositionGizmo>;
  56330. rotationGizmo: Nullable<RotationGizmo>;
  56331. scaleGizmo: Nullable<ScaleGizmo>;
  56332. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56333. };
  56334. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56335. clearGizmoOnEmptyPointerEvent: boolean;
  56336. /** Fires an event when the manager is attached to a mesh */
  56337. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56338. /** Fires an event when the manager is attached to a node */
  56339. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56340. private _gizmosEnabled;
  56341. private _pointerObserver;
  56342. private _attachedMesh;
  56343. private _attachedNode;
  56344. private _boundingBoxColor;
  56345. private _defaultUtilityLayer;
  56346. private _defaultKeepDepthUtilityLayer;
  56347. private _thickness;
  56348. /**
  56349. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56350. */
  56351. boundingBoxDragBehavior: SixDofDragBehavior;
  56352. /**
  56353. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56354. */
  56355. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56356. /**
  56357. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56358. */
  56359. attachableNodes: Nullable<Array<Node>>;
  56360. /**
  56361. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56362. */
  56363. usePointerToAttachGizmos: boolean;
  56364. /**
  56365. * Utility layer that the bounding box gizmo belongs to
  56366. */
  56367. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56368. /**
  56369. * Utility layer that all gizmos besides bounding box belong to
  56370. */
  56371. get utilityLayer(): UtilityLayerRenderer;
  56372. /**
  56373. * True when the mouse pointer is hovering a gizmo mesh
  56374. */
  56375. get isHovered(): boolean;
  56376. /**
  56377. * Instatiates a gizmo manager
  56378. * @param scene the scene to overlay the gizmos on top of
  56379. * @param thickness display gizmo axis thickness
  56380. */
  56381. constructor(scene: Scene, thickness?: number);
  56382. /**
  56383. * Attaches a set of gizmos to the specified mesh
  56384. * @param mesh The mesh the gizmo's should be attached to
  56385. */
  56386. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56387. /**
  56388. * Attaches a set of gizmos to the specified node
  56389. * @param node The node the gizmo's should be attached to
  56390. */
  56391. attachToNode(node: Nullable<Node>): void;
  56392. /**
  56393. * If the position gizmo is enabled
  56394. */
  56395. set positionGizmoEnabled(value: boolean);
  56396. get positionGizmoEnabled(): boolean;
  56397. /**
  56398. * If the rotation gizmo is enabled
  56399. */
  56400. set rotationGizmoEnabled(value: boolean);
  56401. get rotationGizmoEnabled(): boolean;
  56402. /**
  56403. * If the scale gizmo is enabled
  56404. */
  56405. set scaleGizmoEnabled(value: boolean);
  56406. get scaleGizmoEnabled(): boolean;
  56407. /**
  56408. * If the boundingBox gizmo is enabled
  56409. */
  56410. set boundingBoxGizmoEnabled(value: boolean);
  56411. get boundingBoxGizmoEnabled(): boolean;
  56412. /**
  56413. * Disposes of the gizmo manager
  56414. */
  56415. dispose(): void;
  56416. }
  56417. }
  56418. declare module "babylonjs/Lights/directionalLight" {
  56419. import { Camera } from "babylonjs/Cameras/camera";
  56420. import { Scene } from "babylonjs/scene";
  56421. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56423. import { Light } from "babylonjs/Lights/light";
  56424. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56425. import { Effect } from "babylonjs/Materials/effect";
  56426. /**
  56427. * A directional light is defined by a direction (what a surprise!).
  56428. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56429. * 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.
  56430. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56431. */
  56432. export class DirectionalLight extends ShadowLight {
  56433. private _shadowFrustumSize;
  56434. /**
  56435. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56436. */
  56437. get shadowFrustumSize(): number;
  56438. /**
  56439. * Specifies a fix frustum size for the shadow generation.
  56440. */
  56441. set shadowFrustumSize(value: number);
  56442. private _shadowOrthoScale;
  56443. /**
  56444. * Gets the shadow projection scale against the optimal computed one.
  56445. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56446. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56447. */
  56448. get shadowOrthoScale(): number;
  56449. /**
  56450. * Sets the shadow projection scale against the optimal computed one.
  56451. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56452. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56453. */
  56454. set shadowOrthoScale(value: number);
  56455. /**
  56456. * Automatically compute the projection matrix to best fit (including all the casters)
  56457. * on each frame.
  56458. */
  56459. autoUpdateExtends: boolean;
  56460. /**
  56461. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56462. * on each frame. autoUpdateExtends must be set to true for this to work
  56463. */
  56464. autoCalcShadowZBounds: boolean;
  56465. private _orthoLeft;
  56466. private _orthoRight;
  56467. private _orthoTop;
  56468. private _orthoBottom;
  56469. /**
  56470. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56471. * The directional light is emitted from everywhere in the given direction.
  56472. * It can cast shadows.
  56473. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56474. * @param name The friendly name of the light
  56475. * @param direction The direction of the light
  56476. * @param scene The scene the light belongs to
  56477. */
  56478. constructor(name: string, direction: Vector3, scene: Scene);
  56479. /**
  56480. * Returns the string "DirectionalLight".
  56481. * @return The class name
  56482. */
  56483. getClassName(): string;
  56484. /**
  56485. * Returns the integer 1.
  56486. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56487. */
  56488. getTypeID(): number;
  56489. /**
  56490. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56491. * Returns the DirectionalLight Shadow projection matrix.
  56492. */
  56493. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56494. /**
  56495. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56496. * Returns the DirectionalLight Shadow projection matrix.
  56497. */
  56498. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56499. /**
  56500. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56501. * Returns the DirectionalLight Shadow projection matrix.
  56502. */
  56503. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56504. protected _buildUniformLayout(): void;
  56505. /**
  56506. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56507. * @param effect The effect to update
  56508. * @param lightIndex The index of the light in the effect to update
  56509. * @returns The directional light
  56510. */
  56511. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56512. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56513. /**
  56514. * Gets the minZ used for shadow according to both the scene and the light.
  56515. *
  56516. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56517. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56518. * @param activeCamera The camera we are returning the min for
  56519. * @returns the depth min z
  56520. */
  56521. getDepthMinZ(activeCamera: Camera): number;
  56522. /**
  56523. * Gets the maxZ used for shadow according to both the scene and the light.
  56524. *
  56525. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56526. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56527. * @param activeCamera The camera we are returning the max for
  56528. * @returns the depth max z
  56529. */
  56530. getDepthMaxZ(activeCamera: Camera): number;
  56531. /**
  56532. * Prepares the list of defines specific to the light type.
  56533. * @param defines the list of defines
  56534. * @param lightIndex defines the index of the light for the effect
  56535. */
  56536. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56537. }
  56538. }
  56539. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56540. import { Mesh } from "babylonjs/Meshes/mesh";
  56541. /**
  56542. * Class containing static functions to help procedurally build meshes
  56543. */
  56544. export class HemisphereBuilder {
  56545. /**
  56546. * Creates a hemisphere mesh
  56547. * @param name defines the name of the mesh
  56548. * @param options defines the options used to create the mesh
  56549. * @param scene defines the hosting scene
  56550. * @returns the hemisphere mesh
  56551. */
  56552. static CreateHemisphere(name: string, options: {
  56553. segments?: number;
  56554. diameter?: number;
  56555. sideOrientation?: number;
  56556. }, scene: any): Mesh;
  56557. }
  56558. }
  56559. declare module "babylonjs/Lights/spotLight" {
  56560. import { Nullable } from "babylonjs/types";
  56561. import { Scene } from "babylonjs/scene";
  56562. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56564. import { Effect } from "babylonjs/Materials/effect";
  56565. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56566. import { Light } from "babylonjs/Lights/light";
  56567. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56568. /**
  56569. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56570. * These values define a cone of light starting from the position, emitting toward the direction.
  56571. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56572. * and the exponent defines the speed of the decay of the light with distance (reach).
  56573. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56574. */
  56575. export class SpotLight extends ShadowLight {
  56576. private _angle;
  56577. private _innerAngle;
  56578. private _cosHalfAngle;
  56579. private _lightAngleScale;
  56580. private _lightAngleOffset;
  56581. /**
  56582. * Gets the cone angle of the spot light in Radians.
  56583. */
  56584. get angle(): number;
  56585. /**
  56586. * Sets the cone angle of the spot light in Radians.
  56587. */
  56588. set angle(value: number);
  56589. /**
  56590. * Only used in gltf falloff mode, this defines the angle where
  56591. * the directional falloff will start before cutting at angle which could be seen
  56592. * as outer angle.
  56593. */
  56594. get innerAngle(): number;
  56595. /**
  56596. * Only used in gltf falloff mode, this defines the angle where
  56597. * the directional falloff will start before cutting at angle which could be seen
  56598. * as outer angle.
  56599. */
  56600. set innerAngle(value: number);
  56601. private _shadowAngleScale;
  56602. /**
  56603. * Allows scaling the angle of the light for shadow generation only.
  56604. */
  56605. get shadowAngleScale(): number;
  56606. /**
  56607. * Allows scaling the angle of the light for shadow generation only.
  56608. */
  56609. set shadowAngleScale(value: number);
  56610. /**
  56611. * The light decay speed with the distance from the emission spot.
  56612. */
  56613. exponent: number;
  56614. private _projectionTextureMatrix;
  56615. /**
  56616. * Allows reading the projecton texture
  56617. */
  56618. get projectionTextureMatrix(): Matrix;
  56619. protected _projectionTextureLightNear: number;
  56620. /**
  56621. * Gets the near clip of the Spotlight for texture projection.
  56622. */
  56623. get projectionTextureLightNear(): number;
  56624. /**
  56625. * Sets the near clip of the Spotlight for texture projection.
  56626. */
  56627. set projectionTextureLightNear(value: number);
  56628. protected _projectionTextureLightFar: number;
  56629. /**
  56630. * Gets the far clip of the Spotlight for texture projection.
  56631. */
  56632. get projectionTextureLightFar(): number;
  56633. /**
  56634. * Sets the far clip of the Spotlight for texture projection.
  56635. */
  56636. set projectionTextureLightFar(value: number);
  56637. protected _projectionTextureUpDirection: Vector3;
  56638. /**
  56639. * Gets the Up vector of the Spotlight for texture projection.
  56640. */
  56641. get projectionTextureUpDirection(): Vector3;
  56642. /**
  56643. * Sets the Up vector of the Spotlight for texture projection.
  56644. */
  56645. set projectionTextureUpDirection(value: Vector3);
  56646. private _projectionTexture;
  56647. /**
  56648. * Gets the projection texture of the light.
  56649. */
  56650. get projectionTexture(): Nullable<BaseTexture>;
  56651. /**
  56652. * Sets the projection texture of the light.
  56653. */
  56654. set projectionTexture(value: Nullable<BaseTexture>);
  56655. private _projectionTextureViewLightDirty;
  56656. private _projectionTextureProjectionLightDirty;
  56657. private _projectionTextureDirty;
  56658. private _projectionTextureViewTargetVector;
  56659. private _projectionTextureViewLightMatrix;
  56660. private _projectionTextureProjectionLightMatrix;
  56661. private _projectionTextureScalingMatrix;
  56662. /**
  56663. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56664. * It can cast shadows.
  56665. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56666. * @param name The light friendly name
  56667. * @param position The position of the spot light in the scene
  56668. * @param direction The direction of the light in the scene
  56669. * @param angle The cone angle of the light in Radians
  56670. * @param exponent The light decay speed with the distance from the emission spot
  56671. * @param scene The scene the lights belongs to
  56672. */
  56673. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56674. /**
  56675. * Returns the string "SpotLight".
  56676. * @returns the class name
  56677. */
  56678. getClassName(): string;
  56679. /**
  56680. * Returns the integer 2.
  56681. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56682. */
  56683. getTypeID(): number;
  56684. /**
  56685. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56686. */
  56687. protected _setDirection(value: Vector3): void;
  56688. /**
  56689. * Overrides the position setter to recompute the projection texture view light Matrix.
  56690. */
  56691. protected _setPosition(value: Vector3): void;
  56692. /**
  56693. * 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.
  56694. * Returns the SpotLight.
  56695. */
  56696. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56697. protected _computeProjectionTextureViewLightMatrix(): void;
  56698. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56699. /**
  56700. * Main function for light texture projection matrix computing.
  56701. */
  56702. protected _computeProjectionTextureMatrix(): void;
  56703. protected _buildUniformLayout(): void;
  56704. private _computeAngleValues;
  56705. /**
  56706. * Sets the passed Effect "effect" with the Light textures.
  56707. * @param effect The effect to update
  56708. * @param lightIndex The index of the light in the effect to update
  56709. * @returns The light
  56710. */
  56711. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56712. /**
  56713. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56714. * @param effect The effect to update
  56715. * @param lightIndex The index of the light in the effect to update
  56716. * @returns The spot light
  56717. */
  56718. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56719. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56720. /**
  56721. * Disposes the light and the associated resources.
  56722. */
  56723. dispose(): void;
  56724. /**
  56725. * Prepares the list of defines specific to the light type.
  56726. * @param defines the list of defines
  56727. * @param lightIndex defines the index of the light for the effect
  56728. */
  56729. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56730. }
  56731. }
  56732. declare module "babylonjs/Gizmos/lightGizmo" {
  56733. import { Nullable } from "babylonjs/types";
  56734. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56735. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56736. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56737. import { Light } from "babylonjs/Lights/light";
  56738. import { Observable } from "babylonjs/Misc/observable";
  56739. /**
  56740. * Gizmo that enables viewing a light
  56741. */
  56742. export class LightGizmo extends Gizmo {
  56743. private _lightMesh;
  56744. private _material;
  56745. private _cachedPosition;
  56746. private _cachedForward;
  56747. private _attachedMeshParent;
  56748. private _pointerObserver;
  56749. /**
  56750. * Event that fires each time the gizmo is clicked
  56751. */
  56752. onClickedObservable: Observable<Light>;
  56753. /**
  56754. * Creates a LightGizmo
  56755. * @param gizmoLayer The utility layer the gizmo will be added to
  56756. */
  56757. constructor(gizmoLayer?: UtilityLayerRenderer);
  56758. private _light;
  56759. /**
  56760. * The light that the gizmo is attached to
  56761. */
  56762. set light(light: Nullable<Light>);
  56763. get light(): Nullable<Light>;
  56764. /**
  56765. * Gets the material used to render the light gizmo
  56766. */
  56767. get material(): StandardMaterial;
  56768. /**
  56769. * @hidden
  56770. * Updates the gizmo to match the attached mesh's position/rotation
  56771. */
  56772. protected _update(): void;
  56773. private static _Scale;
  56774. /**
  56775. * Creates the lines for a light mesh
  56776. */
  56777. private static _CreateLightLines;
  56778. /**
  56779. * Disposes of the light gizmo
  56780. */
  56781. dispose(): void;
  56782. private static _CreateHemisphericLightMesh;
  56783. private static _CreatePointLightMesh;
  56784. private static _CreateSpotLightMesh;
  56785. private static _CreateDirectionalLightMesh;
  56786. }
  56787. }
  56788. declare module "babylonjs/Gizmos/cameraGizmo" {
  56789. import { Nullable } from "babylonjs/types";
  56790. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56791. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56792. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56793. import { Camera } from "babylonjs/Cameras/camera";
  56794. import { Observable } from "babylonjs/Misc/observable";
  56795. /**
  56796. * Gizmo that enables viewing a camera
  56797. */
  56798. export class CameraGizmo extends Gizmo {
  56799. private _cameraMesh;
  56800. private _cameraLinesMesh;
  56801. private _material;
  56802. private _pointerObserver;
  56803. /**
  56804. * Event that fires each time the gizmo is clicked
  56805. */
  56806. onClickedObservable: Observable<Camera>;
  56807. /**
  56808. * Creates a CameraGizmo
  56809. * @param gizmoLayer The utility layer the gizmo will be added to
  56810. */
  56811. constructor(gizmoLayer?: UtilityLayerRenderer);
  56812. private _camera;
  56813. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56814. get displayFrustum(): boolean;
  56815. set displayFrustum(value: boolean);
  56816. /**
  56817. * The camera that the gizmo is attached to
  56818. */
  56819. set camera(camera: Nullable<Camera>);
  56820. get camera(): Nullable<Camera>;
  56821. /**
  56822. * Gets the material used to render the camera gizmo
  56823. */
  56824. get material(): StandardMaterial;
  56825. /**
  56826. * @hidden
  56827. * Updates the gizmo to match the attached mesh's position/rotation
  56828. */
  56829. protected _update(): void;
  56830. private static _Scale;
  56831. private _invProjection;
  56832. /**
  56833. * Disposes of the camera gizmo
  56834. */
  56835. dispose(): void;
  56836. private static _CreateCameraMesh;
  56837. private static _CreateCameraFrustum;
  56838. }
  56839. }
  56840. declare module "babylonjs/Gizmos/index" {
  56841. export * from "babylonjs/Gizmos/axisDragGizmo";
  56842. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56843. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56844. export * from "babylonjs/Gizmos/gizmo";
  56845. export * from "babylonjs/Gizmos/gizmoManager";
  56846. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56847. export * from "babylonjs/Gizmos/positionGizmo";
  56848. export * from "babylonjs/Gizmos/rotationGizmo";
  56849. export * from "babylonjs/Gizmos/scaleGizmo";
  56850. export * from "babylonjs/Gizmos/lightGizmo";
  56851. export * from "babylonjs/Gizmos/cameraGizmo";
  56852. export * from "babylonjs/Gizmos/planeDragGizmo";
  56853. }
  56854. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56855. /** @hidden */
  56856. export var backgroundFragmentDeclaration: {
  56857. name: string;
  56858. shader: string;
  56859. };
  56860. }
  56861. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56862. /** @hidden */
  56863. export var backgroundUboDeclaration: {
  56864. name: string;
  56865. shader: string;
  56866. };
  56867. }
  56868. declare module "babylonjs/Shaders/background.fragment" {
  56869. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56870. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56871. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56872. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56873. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56874. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56875. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56876. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56877. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56878. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56879. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56880. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56881. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56882. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56883. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56884. /** @hidden */
  56885. export var backgroundPixelShader: {
  56886. name: string;
  56887. shader: string;
  56888. };
  56889. }
  56890. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56891. /** @hidden */
  56892. export var backgroundVertexDeclaration: {
  56893. name: string;
  56894. shader: string;
  56895. };
  56896. }
  56897. declare module "babylonjs/Shaders/background.vertex" {
  56898. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56899. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56900. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56901. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56902. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56903. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56904. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56905. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56906. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56907. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56908. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56909. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56910. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56911. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56912. /** @hidden */
  56913. export var backgroundVertexShader: {
  56914. name: string;
  56915. shader: string;
  56916. };
  56917. }
  56918. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56919. import { Nullable, int, float } from "babylonjs/types";
  56920. import { Scene } from "babylonjs/scene";
  56921. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56922. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56924. import { Mesh } from "babylonjs/Meshes/mesh";
  56925. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56926. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56927. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56928. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56929. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56930. import { Color3 } from "babylonjs/Maths/math.color";
  56931. import "babylonjs/Shaders/background.fragment";
  56932. import "babylonjs/Shaders/background.vertex";
  56933. /**
  56934. * Background material used to create an efficient environement around your scene.
  56935. */
  56936. export class BackgroundMaterial extends PushMaterial {
  56937. /**
  56938. * Standard reflectance value at parallel view angle.
  56939. */
  56940. static StandardReflectance0: number;
  56941. /**
  56942. * Standard reflectance value at grazing angle.
  56943. */
  56944. static StandardReflectance90: number;
  56945. protected _primaryColor: Color3;
  56946. /**
  56947. * Key light Color (multiply against the environement texture)
  56948. */
  56949. primaryColor: Color3;
  56950. protected __perceptualColor: Nullable<Color3>;
  56951. /**
  56952. * Experimental Internal Use Only.
  56953. *
  56954. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56955. * This acts as a helper to set the primary color to a more "human friendly" value.
  56956. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56957. * output color as close as possible from the chosen value.
  56958. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56959. * part of lighting setup.)
  56960. */
  56961. get _perceptualColor(): Nullable<Color3>;
  56962. set _perceptualColor(value: Nullable<Color3>);
  56963. protected _primaryColorShadowLevel: float;
  56964. /**
  56965. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56966. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56967. */
  56968. get primaryColorShadowLevel(): float;
  56969. set primaryColorShadowLevel(value: float);
  56970. protected _primaryColorHighlightLevel: float;
  56971. /**
  56972. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56973. * The primary color is used at the level chosen to define what the white area would look.
  56974. */
  56975. get primaryColorHighlightLevel(): float;
  56976. set primaryColorHighlightLevel(value: float);
  56977. protected _reflectionTexture: Nullable<BaseTexture>;
  56978. /**
  56979. * Reflection Texture used in the material.
  56980. * Should be author in a specific way for the best result (refer to the documentation).
  56981. */
  56982. reflectionTexture: Nullable<BaseTexture>;
  56983. protected _reflectionBlur: float;
  56984. /**
  56985. * Reflection Texture level of blur.
  56986. *
  56987. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56988. * texture twice.
  56989. */
  56990. reflectionBlur: float;
  56991. protected _diffuseTexture: Nullable<BaseTexture>;
  56992. /**
  56993. * Diffuse Texture used in the material.
  56994. * Should be author in a specific way for the best result (refer to the documentation).
  56995. */
  56996. diffuseTexture: Nullable<BaseTexture>;
  56997. protected _shadowLights: Nullable<IShadowLight[]>;
  56998. /**
  56999. * Specify the list of lights casting shadow on the material.
  57000. * All scene shadow lights will be included if null.
  57001. */
  57002. shadowLights: Nullable<IShadowLight[]>;
  57003. protected _shadowLevel: float;
  57004. /**
  57005. * Helps adjusting the shadow to a softer level if required.
  57006. * 0 means black shadows and 1 means no shadows.
  57007. */
  57008. shadowLevel: float;
  57009. protected _sceneCenter: Vector3;
  57010. /**
  57011. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57012. * It is usually zero but might be interesting to modify according to your setup.
  57013. */
  57014. sceneCenter: Vector3;
  57015. protected _opacityFresnel: boolean;
  57016. /**
  57017. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57018. * This helps ensuring a nice transition when the camera goes under the ground.
  57019. */
  57020. opacityFresnel: boolean;
  57021. protected _reflectionFresnel: boolean;
  57022. /**
  57023. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57024. * This helps adding a mirror texture on the ground.
  57025. */
  57026. reflectionFresnel: boolean;
  57027. protected _reflectionFalloffDistance: number;
  57028. /**
  57029. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57030. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57031. */
  57032. reflectionFalloffDistance: number;
  57033. protected _reflectionAmount: number;
  57034. /**
  57035. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57036. */
  57037. reflectionAmount: number;
  57038. protected _reflectionReflectance0: number;
  57039. /**
  57040. * This specifies the weight of the reflection at grazing angle.
  57041. */
  57042. reflectionReflectance0: number;
  57043. protected _reflectionReflectance90: number;
  57044. /**
  57045. * This specifies the weight of the reflection at a perpendicular point of view.
  57046. */
  57047. reflectionReflectance90: number;
  57048. /**
  57049. * Sets the reflection reflectance fresnel values according to the default standard
  57050. * empirically know to work well :-)
  57051. */
  57052. set reflectionStandardFresnelWeight(value: number);
  57053. protected _useRGBColor: boolean;
  57054. /**
  57055. * Helps to directly use the maps channels instead of their level.
  57056. */
  57057. useRGBColor: boolean;
  57058. protected _enableNoise: boolean;
  57059. /**
  57060. * This helps reducing the banding effect that could occur on the background.
  57061. */
  57062. enableNoise: boolean;
  57063. /**
  57064. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57065. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57066. * Recommended to be keep at 1.0 except for special cases.
  57067. */
  57068. get fovMultiplier(): number;
  57069. set fovMultiplier(value: number);
  57070. private _fovMultiplier;
  57071. /**
  57072. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57073. */
  57074. useEquirectangularFOV: boolean;
  57075. private _maxSimultaneousLights;
  57076. /**
  57077. * Number of Simultaneous lights allowed on the material.
  57078. */
  57079. maxSimultaneousLights: int;
  57080. private _shadowOnly;
  57081. /**
  57082. * Make the material only render shadows
  57083. */
  57084. shadowOnly: boolean;
  57085. /**
  57086. * Default configuration related to image processing available in the Background Material.
  57087. */
  57088. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57089. /**
  57090. * Keep track of the image processing observer to allow dispose and replace.
  57091. */
  57092. private _imageProcessingObserver;
  57093. /**
  57094. * Attaches a new image processing configuration to the PBR Material.
  57095. * @param configuration (if null the scene configuration will be use)
  57096. */
  57097. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57098. /**
  57099. * Gets the image processing configuration used either in this material.
  57100. */
  57101. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57102. /**
  57103. * Sets the Default image processing configuration used either in the this material.
  57104. *
  57105. * If sets to null, the scene one is in use.
  57106. */
  57107. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57108. /**
  57109. * Gets wether the color curves effect is enabled.
  57110. */
  57111. get cameraColorCurvesEnabled(): boolean;
  57112. /**
  57113. * Sets wether the color curves effect is enabled.
  57114. */
  57115. set cameraColorCurvesEnabled(value: boolean);
  57116. /**
  57117. * Gets wether the color grading effect is enabled.
  57118. */
  57119. get cameraColorGradingEnabled(): boolean;
  57120. /**
  57121. * Gets wether the color grading effect is enabled.
  57122. */
  57123. set cameraColorGradingEnabled(value: boolean);
  57124. /**
  57125. * Gets wether tonemapping is enabled or not.
  57126. */
  57127. get cameraToneMappingEnabled(): boolean;
  57128. /**
  57129. * Sets wether tonemapping is enabled or not
  57130. */
  57131. set cameraToneMappingEnabled(value: boolean);
  57132. /**
  57133. * The camera exposure used on this material.
  57134. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57135. * This corresponds to a photographic exposure.
  57136. */
  57137. get cameraExposure(): float;
  57138. /**
  57139. * The camera exposure used on this material.
  57140. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57141. * This corresponds to a photographic exposure.
  57142. */
  57143. set cameraExposure(value: float);
  57144. /**
  57145. * Gets The camera contrast used on this material.
  57146. */
  57147. get cameraContrast(): float;
  57148. /**
  57149. * Sets The camera contrast used on this material.
  57150. */
  57151. set cameraContrast(value: float);
  57152. /**
  57153. * Gets the Color Grading 2D Lookup Texture.
  57154. */
  57155. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57156. /**
  57157. * Sets the Color Grading 2D Lookup Texture.
  57158. */
  57159. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57160. /**
  57161. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57162. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57163. * 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;
  57164. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57165. */
  57166. get cameraColorCurves(): Nullable<ColorCurves>;
  57167. /**
  57168. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57169. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57170. * 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;
  57171. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57172. */
  57173. set cameraColorCurves(value: Nullable<ColorCurves>);
  57174. /**
  57175. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57176. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57177. */
  57178. switchToBGR: boolean;
  57179. private _renderTargets;
  57180. private _reflectionControls;
  57181. private _white;
  57182. private _primaryShadowColor;
  57183. private _primaryHighlightColor;
  57184. /**
  57185. * Instantiates a Background Material in the given scene
  57186. * @param name The friendly name of the material
  57187. * @param scene The scene to add the material to
  57188. */
  57189. constructor(name: string, scene: Scene);
  57190. /**
  57191. * Gets a boolean indicating that current material needs to register RTT
  57192. */
  57193. get hasRenderTargetTextures(): boolean;
  57194. /**
  57195. * The entire material has been created in order to prevent overdraw.
  57196. * @returns false
  57197. */
  57198. needAlphaTesting(): boolean;
  57199. /**
  57200. * The entire material has been created in order to prevent overdraw.
  57201. * @returns true if blending is enable
  57202. */
  57203. needAlphaBlending(): boolean;
  57204. /**
  57205. * Checks wether the material is ready to be rendered for a given mesh.
  57206. * @param mesh The mesh to render
  57207. * @param subMesh The submesh to check against
  57208. * @param useInstances Specify wether or not the material is used with instances
  57209. * @returns true if all the dependencies are ready (Textures, Effects...)
  57210. */
  57211. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57212. /**
  57213. * Compute the primary color according to the chosen perceptual color.
  57214. */
  57215. private _computePrimaryColorFromPerceptualColor;
  57216. /**
  57217. * Compute the highlights and shadow colors according to their chosen levels.
  57218. */
  57219. private _computePrimaryColors;
  57220. /**
  57221. * Build the uniform buffer used in the material.
  57222. */
  57223. buildUniformLayout(): void;
  57224. /**
  57225. * Unbind the material.
  57226. */
  57227. unbind(): void;
  57228. /**
  57229. * Bind only the world matrix to the material.
  57230. * @param world The world matrix to bind.
  57231. */
  57232. bindOnlyWorldMatrix(world: Matrix): void;
  57233. /**
  57234. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57235. * @param world The world matrix to bind.
  57236. * @param subMesh The submesh to bind for.
  57237. */
  57238. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57239. /**
  57240. * Checks to see if a texture is used in the material.
  57241. * @param texture - Base texture to use.
  57242. * @returns - Boolean specifying if a texture is used in the material.
  57243. */
  57244. hasTexture(texture: BaseTexture): boolean;
  57245. /**
  57246. * Dispose the material.
  57247. * @param forceDisposeEffect Force disposal of the associated effect.
  57248. * @param forceDisposeTextures Force disposal of the associated textures.
  57249. */
  57250. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57251. /**
  57252. * Clones the material.
  57253. * @param name The cloned name.
  57254. * @returns The cloned material.
  57255. */
  57256. clone(name: string): BackgroundMaterial;
  57257. /**
  57258. * Serializes the current material to its JSON representation.
  57259. * @returns The JSON representation.
  57260. */
  57261. serialize(): any;
  57262. /**
  57263. * Gets the class name of the material
  57264. * @returns "BackgroundMaterial"
  57265. */
  57266. getClassName(): string;
  57267. /**
  57268. * Parse a JSON input to create back a background material.
  57269. * @param source The JSON data to parse
  57270. * @param scene The scene to create the parsed material in
  57271. * @param rootUrl The root url of the assets the material depends upon
  57272. * @returns the instantiated BackgroundMaterial.
  57273. */
  57274. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57275. }
  57276. }
  57277. declare module "babylonjs/Helpers/environmentHelper" {
  57278. import { Observable } from "babylonjs/Misc/observable";
  57279. import { Nullable } from "babylonjs/types";
  57280. import { Scene } from "babylonjs/scene";
  57281. import { Vector3 } from "babylonjs/Maths/math.vector";
  57282. import { Color3 } from "babylonjs/Maths/math.color";
  57283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57284. import { Mesh } from "babylonjs/Meshes/mesh";
  57285. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57286. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57287. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57288. import "babylonjs/Meshes/Builders/planeBuilder";
  57289. import "babylonjs/Meshes/Builders/boxBuilder";
  57290. /**
  57291. * Represents the different options available during the creation of
  57292. * a Environment helper.
  57293. *
  57294. * This can control the default ground, skybox and image processing setup of your scene.
  57295. */
  57296. export interface IEnvironmentHelperOptions {
  57297. /**
  57298. * Specifies whether or not to create a ground.
  57299. * True by default.
  57300. */
  57301. createGround: boolean;
  57302. /**
  57303. * Specifies the ground size.
  57304. * 15 by default.
  57305. */
  57306. groundSize: number;
  57307. /**
  57308. * The texture used on the ground for the main color.
  57309. * Comes from the BabylonJS CDN by default.
  57310. *
  57311. * Remarks: Can be either a texture or a url.
  57312. */
  57313. groundTexture: string | BaseTexture;
  57314. /**
  57315. * The color mixed in the ground texture by default.
  57316. * BabylonJS clearColor by default.
  57317. */
  57318. groundColor: Color3;
  57319. /**
  57320. * Specifies the ground opacity.
  57321. * 1 by default.
  57322. */
  57323. groundOpacity: number;
  57324. /**
  57325. * Enables the ground to receive shadows.
  57326. * True by default.
  57327. */
  57328. enableGroundShadow: boolean;
  57329. /**
  57330. * Helps preventing the shadow to be fully black on the ground.
  57331. * 0.5 by default.
  57332. */
  57333. groundShadowLevel: number;
  57334. /**
  57335. * Creates a mirror texture attach to the ground.
  57336. * false by default.
  57337. */
  57338. enableGroundMirror: boolean;
  57339. /**
  57340. * Specifies the ground mirror size ratio.
  57341. * 0.3 by default as the default kernel is 64.
  57342. */
  57343. groundMirrorSizeRatio: number;
  57344. /**
  57345. * Specifies the ground mirror blur kernel size.
  57346. * 64 by default.
  57347. */
  57348. groundMirrorBlurKernel: number;
  57349. /**
  57350. * Specifies the ground mirror visibility amount.
  57351. * 1 by default
  57352. */
  57353. groundMirrorAmount: number;
  57354. /**
  57355. * Specifies the ground mirror reflectance weight.
  57356. * This uses the standard weight of the background material to setup the fresnel effect
  57357. * of the mirror.
  57358. * 1 by default.
  57359. */
  57360. groundMirrorFresnelWeight: number;
  57361. /**
  57362. * Specifies the ground mirror Falloff distance.
  57363. * This can helps reducing the size of the reflection.
  57364. * 0 by Default.
  57365. */
  57366. groundMirrorFallOffDistance: number;
  57367. /**
  57368. * Specifies the ground mirror texture type.
  57369. * Unsigned Int by Default.
  57370. */
  57371. groundMirrorTextureType: number;
  57372. /**
  57373. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57374. * the shown objects.
  57375. */
  57376. groundYBias: number;
  57377. /**
  57378. * Specifies whether or not to create a skybox.
  57379. * True by default.
  57380. */
  57381. createSkybox: boolean;
  57382. /**
  57383. * Specifies the skybox size.
  57384. * 20 by default.
  57385. */
  57386. skyboxSize: number;
  57387. /**
  57388. * The texture used on the skybox for the main color.
  57389. * Comes from the BabylonJS CDN by default.
  57390. *
  57391. * Remarks: Can be either a texture or a url.
  57392. */
  57393. skyboxTexture: string | BaseTexture;
  57394. /**
  57395. * The color mixed in the skybox texture by default.
  57396. * BabylonJS clearColor by default.
  57397. */
  57398. skyboxColor: Color3;
  57399. /**
  57400. * The background rotation around the Y axis of the scene.
  57401. * This helps aligning the key lights of your scene with the background.
  57402. * 0 by default.
  57403. */
  57404. backgroundYRotation: number;
  57405. /**
  57406. * Compute automatically the size of the elements to best fit with the scene.
  57407. */
  57408. sizeAuto: boolean;
  57409. /**
  57410. * Default position of the rootMesh if autoSize is not true.
  57411. */
  57412. rootPosition: Vector3;
  57413. /**
  57414. * Sets up the image processing in the scene.
  57415. * true by default.
  57416. */
  57417. setupImageProcessing: boolean;
  57418. /**
  57419. * The texture used as your environment texture in the scene.
  57420. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57421. *
  57422. * Remarks: Can be either a texture or a url.
  57423. */
  57424. environmentTexture: string | BaseTexture;
  57425. /**
  57426. * The value of the exposure to apply to the scene.
  57427. * 0.6 by default if setupImageProcessing is true.
  57428. */
  57429. cameraExposure: number;
  57430. /**
  57431. * The value of the contrast to apply to the scene.
  57432. * 1.6 by default if setupImageProcessing is true.
  57433. */
  57434. cameraContrast: number;
  57435. /**
  57436. * Specifies whether or not tonemapping should be enabled in the scene.
  57437. * true by default if setupImageProcessing is true.
  57438. */
  57439. toneMappingEnabled: boolean;
  57440. }
  57441. /**
  57442. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57443. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57444. * It also helps with the default setup of your imageProcessing configuration.
  57445. */
  57446. export class EnvironmentHelper {
  57447. /**
  57448. * Default ground texture URL.
  57449. */
  57450. private static _groundTextureCDNUrl;
  57451. /**
  57452. * Default skybox texture URL.
  57453. */
  57454. private static _skyboxTextureCDNUrl;
  57455. /**
  57456. * Default environment texture URL.
  57457. */
  57458. private static _environmentTextureCDNUrl;
  57459. /**
  57460. * Creates the default options for the helper.
  57461. */
  57462. private static _getDefaultOptions;
  57463. private _rootMesh;
  57464. /**
  57465. * Gets the root mesh created by the helper.
  57466. */
  57467. get rootMesh(): Mesh;
  57468. private _skybox;
  57469. /**
  57470. * Gets the skybox created by the helper.
  57471. */
  57472. get skybox(): Nullable<Mesh>;
  57473. private _skyboxTexture;
  57474. /**
  57475. * Gets the skybox texture created by the helper.
  57476. */
  57477. get skyboxTexture(): Nullable<BaseTexture>;
  57478. private _skyboxMaterial;
  57479. /**
  57480. * Gets the skybox material created by the helper.
  57481. */
  57482. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57483. private _ground;
  57484. /**
  57485. * Gets the ground mesh created by the helper.
  57486. */
  57487. get ground(): Nullable<Mesh>;
  57488. private _groundTexture;
  57489. /**
  57490. * Gets the ground texture created by the helper.
  57491. */
  57492. get groundTexture(): Nullable<BaseTexture>;
  57493. private _groundMirror;
  57494. /**
  57495. * Gets the ground mirror created by the helper.
  57496. */
  57497. get groundMirror(): Nullable<MirrorTexture>;
  57498. /**
  57499. * Gets the ground mirror render list to helps pushing the meshes
  57500. * you wish in the ground reflection.
  57501. */
  57502. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57503. private _groundMaterial;
  57504. /**
  57505. * Gets the ground material created by the helper.
  57506. */
  57507. get groundMaterial(): Nullable<BackgroundMaterial>;
  57508. /**
  57509. * Stores the creation options.
  57510. */
  57511. private readonly _scene;
  57512. private _options;
  57513. /**
  57514. * This observable will be notified with any error during the creation of the environment,
  57515. * mainly texture creation errors.
  57516. */
  57517. onErrorObservable: Observable<{
  57518. message?: string;
  57519. exception?: any;
  57520. }>;
  57521. /**
  57522. * constructor
  57523. * @param options Defines the options we want to customize the helper
  57524. * @param scene The scene to add the material to
  57525. */
  57526. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57527. /**
  57528. * Updates the background according to the new options
  57529. * @param options
  57530. */
  57531. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57532. /**
  57533. * Sets the primary color of all the available elements.
  57534. * @param color the main color to affect to the ground and the background
  57535. */
  57536. setMainColor(color: Color3): void;
  57537. /**
  57538. * Setup the image processing according to the specified options.
  57539. */
  57540. private _setupImageProcessing;
  57541. /**
  57542. * Setup the environment texture according to the specified options.
  57543. */
  57544. private _setupEnvironmentTexture;
  57545. /**
  57546. * Setup the background according to the specified options.
  57547. */
  57548. private _setupBackground;
  57549. /**
  57550. * Get the scene sizes according to the setup.
  57551. */
  57552. private _getSceneSize;
  57553. /**
  57554. * Setup the ground according to the specified options.
  57555. */
  57556. private _setupGround;
  57557. /**
  57558. * Setup the ground material according to the specified options.
  57559. */
  57560. private _setupGroundMaterial;
  57561. /**
  57562. * Setup the ground diffuse texture according to the specified options.
  57563. */
  57564. private _setupGroundDiffuseTexture;
  57565. /**
  57566. * Setup the ground mirror texture according to the specified options.
  57567. */
  57568. private _setupGroundMirrorTexture;
  57569. /**
  57570. * Setup the ground to receive the mirror texture.
  57571. */
  57572. private _setupMirrorInGroundMaterial;
  57573. /**
  57574. * Setup the skybox according to the specified options.
  57575. */
  57576. private _setupSkybox;
  57577. /**
  57578. * Setup the skybox material according to the specified options.
  57579. */
  57580. private _setupSkyboxMaterial;
  57581. /**
  57582. * Setup the skybox reflection texture according to the specified options.
  57583. */
  57584. private _setupSkyboxReflectionTexture;
  57585. private _errorHandler;
  57586. /**
  57587. * Dispose all the elements created by the Helper.
  57588. */
  57589. dispose(): void;
  57590. }
  57591. }
  57592. declare module "babylonjs/Helpers/textureDome" {
  57593. import { Scene } from "babylonjs/scene";
  57594. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57595. import { Mesh } from "babylonjs/Meshes/mesh";
  57596. import { Texture } from "babylonjs/Materials/Textures/texture";
  57597. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57598. import "babylonjs/Meshes/Builders/sphereBuilder";
  57599. import { Nullable } from "babylonjs/types";
  57600. import { Observable } from "babylonjs/Misc/observable";
  57601. /**
  57602. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57603. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57604. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57605. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57606. */
  57607. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57608. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57609. /**
  57610. * Define the source as a Monoscopic panoramic 360/180.
  57611. */
  57612. static readonly MODE_MONOSCOPIC: number;
  57613. /**
  57614. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57615. */
  57616. static readonly MODE_TOPBOTTOM: number;
  57617. /**
  57618. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57619. */
  57620. static readonly MODE_SIDEBYSIDE: number;
  57621. private _halfDome;
  57622. protected _useDirectMapping: boolean;
  57623. /**
  57624. * The texture being displayed on the sphere
  57625. */
  57626. protected _texture: T;
  57627. /**
  57628. * Gets the texture being displayed on the sphere
  57629. */
  57630. get texture(): T;
  57631. /**
  57632. * Sets the texture being displayed on the sphere
  57633. */
  57634. set texture(newTexture: T);
  57635. /**
  57636. * The skybox material
  57637. */
  57638. protected _material: BackgroundMaterial;
  57639. /**
  57640. * The surface used for the dome
  57641. */
  57642. protected _mesh: Mesh;
  57643. /**
  57644. * Gets the mesh used for the dome.
  57645. */
  57646. get mesh(): Mesh;
  57647. /**
  57648. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57649. */
  57650. private _halfDomeMask;
  57651. /**
  57652. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57653. * Also see the options.resolution property.
  57654. */
  57655. get fovMultiplier(): number;
  57656. set fovMultiplier(value: number);
  57657. protected _textureMode: number;
  57658. /**
  57659. * Gets or set the current texture mode for the texture. It can be:
  57660. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57661. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57662. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57663. */
  57664. get textureMode(): number;
  57665. /**
  57666. * Sets the current texture mode for the texture. It can be:
  57667. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57668. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57669. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57670. */
  57671. set textureMode(value: number);
  57672. /**
  57673. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57674. */
  57675. get halfDome(): boolean;
  57676. /**
  57677. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57678. */
  57679. set halfDome(enabled: boolean);
  57680. /**
  57681. * Oberserver used in Stereoscopic VR Mode.
  57682. */
  57683. private _onBeforeCameraRenderObserver;
  57684. /**
  57685. * Observable raised when an error occured while loading the 360 image
  57686. */
  57687. onLoadErrorObservable: Observable<string>;
  57688. /**
  57689. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57690. * @param name Element's name, child elements will append suffixes for their own names.
  57691. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57692. * @param options An object containing optional or exposed sub element properties
  57693. */
  57694. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57695. resolution?: number;
  57696. clickToPlay?: boolean;
  57697. autoPlay?: boolean;
  57698. loop?: boolean;
  57699. size?: number;
  57700. poster?: string;
  57701. faceForward?: boolean;
  57702. useDirectMapping?: boolean;
  57703. halfDomeMode?: boolean;
  57704. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57705. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57706. protected _changeTextureMode(value: number): void;
  57707. /**
  57708. * Releases resources associated with this node.
  57709. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57710. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57711. */
  57712. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57713. }
  57714. }
  57715. declare module "babylonjs/Helpers/photoDome" {
  57716. import { Scene } from "babylonjs/scene";
  57717. import { Texture } from "babylonjs/Materials/Textures/texture";
  57718. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57719. /**
  57720. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57721. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57722. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57723. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57724. */
  57725. export class PhotoDome extends TextureDome<Texture> {
  57726. /**
  57727. * Define the image as a Monoscopic panoramic 360 image.
  57728. */
  57729. static readonly MODE_MONOSCOPIC: number;
  57730. /**
  57731. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57732. */
  57733. static readonly MODE_TOPBOTTOM: number;
  57734. /**
  57735. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57736. */
  57737. static readonly MODE_SIDEBYSIDE: number;
  57738. /**
  57739. * Gets or sets the texture being displayed on the sphere
  57740. */
  57741. get photoTexture(): Texture;
  57742. /**
  57743. * sets the texture being displayed on the sphere
  57744. */
  57745. set photoTexture(value: Texture);
  57746. /**
  57747. * Gets the current video mode for the video. It can be:
  57748. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57749. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57750. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57751. */
  57752. get imageMode(): number;
  57753. /**
  57754. * Sets the current video mode for the video. It can be:
  57755. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57756. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57757. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57758. */
  57759. set imageMode(value: number);
  57760. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57761. }
  57762. }
  57763. declare module "babylonjs/Misc/rgbdTextureTools" {
  57764. import "babylonjs/Shaders/rgbdDecode.fragment";
  57765. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57766. import { Texture } from "babylonjs/Materials/Textures/texture";
  57767. /**
  57768. * Class used to host RGBD texture specific utilities
  57769. */
  57770. export class RGBDTextureTools {
  57771. /**
  57772. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57773. * @param texture the texture to expand.
  57774. */
  57775. static ExpandRGBDTexture(texture: Texture): void;
  57776. }
  57777. }
  57778. declare module "babylonjs/Misc/brdfTextureTools" {
  57779. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57780. import { Scene } from "babylonjs/scene";
  57781. /**
  57782. * Class used to host texture specific utilities
  57783. */
  57784. export class BRDFTextureTools {
  57785. /**
  57786. * Prevents texture cache collision
  57787. */
  57788. private static _instanceNumber;
  57789. /**
  57790. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57791. * @param scene defines the hosting scene
  57792. * @returns the environment BRDF texture
  57793. */
  57794. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57795. private static _environmentBRDFBase64Texture;
  57796. }
  57797. }
  57798. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57799. import { Nullable } from "babylonjs/types";
  57800. import { Color3 } from "babylonjs/Maths/math.color";
  57801. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57802. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57803. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57804. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57805. import { Engine } from "babylonjs/Engines/engine";
  57806. import { Scene } from "babylonjs/scene";
  57807. /**
  57808. * @hidden
  57809. */
  57810. export interface IMaterialClearCoatDefines {
  57811. CLEARCOAT: boolean;
  57812. CLEARCOAT_DEFAULTIOR: boolean;
  57813. CLEARCOAT_TEXTURE: boolean;
  57814. CLEARCOAT_TEXTUREDIRECTUV: number;
  57815. CLEARCOAT_BUMP: boolean;
  57816. CLEARCOAT_BUMPDIRECTUV: number;
  57817. CLEARCOAT_TINT: boolean;
  57818. CLEARCOAT_TINT_TEXTURE: boolean;
  57819. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57820. /** @hidden */
  57821. _areTexturesDirty: boolean;
  57822. }
  57823. /**
  57824. * Define the code related to the clear coat parameters of the pbr material.
  57825. */
  57826. export class PBRClearCoatConfiguration {
  57827. /**
  57828. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57829. * The default fits with a polyurethane material.
  57830. */
  57831. private static readonly _DefaultIndexOfRefraction;
  57832. private _isEnabled;
  57833. /**
  57834. * Defines if the clear coat is enabled in the material.
  57835. */
  57836. isEnabled: boolean;
  57837. /**
  57838. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57839. */
  57840. intensity: number;
  57841. /**
  57842. * Defines the clear coat layer roughness.
  57843. */
  57844. roughness: number;
  57845. private _indexOfRefraction;
  57846. /**
  57847. * Defines the index of refraction of the clear coat.
  57848. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57849. * The default fits with a polyurethane material.
  57850. * Changing the default value is more performance intensive.
  57851. */
  57852. indexOfRefraction: number;
  57853. private _texture;
  57854. /**
  57855. * Stores the clear coat values in a texture.
  57856. */
  57857. texture: Nullable<BaseTexture>;
  57858. private _bumpTexture;
  57859. /**
  57860. * Define the clear coat specific bump texture.
  57861. */
  57862. bumpTexture: Nullable<BaseTexture>;
  57863. private _isTintEnabled;
  57864. /**
  57865. * Defines if the clear coat tint is enabled in the material.
  57866. */
  57867. isTintEnabled: boolean;
  57868. /**
  57869. * Defines the clear coat tint of the material.
  57870. * This is only use if tint is enabled
  57871. */
  57872. tintColor: Color3;
  57873. /**
  57874. * Defines the distance at which the tint color should be found in the
  57875. * clear coat media.
  57876. * This is only use if tint is enabled
  57877. */
  57878. tintColorAtDistance: number;
  57879. /**
  57880. * Defines the clear coat layer thickness.
  57881. * This is only use if tint is enabled
  57882. */
  57883. tintThickness: number;
  57884. private _tintTexture;
  57885. /**
  57886. * Stores the clear tint values in a texture.
  57887. * rgb is tint
  57888. * a is a thickness factor
  57889. */
  57890. tintTexture: Nullable<BaseTexture>;
  57891. /** @hidden */
  57892. private _internalMarkAllSubMeshesAsTexturesDirty;
  57893. /** @hidden */
  57894. _markAllSubMeshesAsTexturesDirty(): void;
  57895. /**
  57896. * Instantiate a new istance of clear coat configuration.
  57897. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57898. */
  57899. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57900. /**
  57901. * Gets wehter the submesh is ready to be used or not.
  57902. * @param defines the list of "defines" to update.
  57903. * @param scene defines the scene the material belongs to.
  57904. * @param engine defines the engine the material belongs to.
  57905. * @param disableBumpMap defines wether the material disables bump or not.
  57906. * @returns - boolean indicating that the submesh is ready or not.
  57907. */
  57908. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57909. /**
  57910. * Checks to see if a texture is used in the material.
  57911. * @param defines the list of "defines" to update.
  57912. * @param scene defines the scene to the material belongs to.
  57913. */
  57914. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57915. /**
  57916. * Binds the material data.
  57917. * @param uniformBuffer defines the Uniform buffer to fill in.
  57918. * @param scene defines the scene the material belongs to.
  57919. * @param engine defines the engine the material belongs to.
  57920. * @param disableBumpMap defines wether the material disables bump or not.
  57921. * @param isFrozen defines wether the material is frozen or not.
  57922. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57923. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57924. */
  57925. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57926. /**
  57927. * Checks to see if a texture is used in the material.
  57928. * @param texture - Base texture to use.
  57929. * @returns - Boolean specifying if a texture is used in the material.
  57930. */
  57931. hasTexture(texture: BaseTexture): boolean;
  57932. /**
  57933. * Returns an array of the actively used textures.
  57934. * @param activeTextures Array of BaseTextures
  57935. */
  57936. getActiveTextures(activeTextures: BaseTexture[]): void;
  57937. /**
  57938. * Returns the animatable textures.
  57939. * @param animatables Array of animatable textures.
  57940. */
  57941. getAnimatables(animatables: IAnimatable[]): void;
  57942. /**
  57943. * Disposes the resources of the material.
  57944. * @param forceDisposeTextures - Forces the disposal of all textures.
  57945. */
  57946. dispose(forceDisposeTextures?: boolean): void;
  57947. /**
  57948. * Get the current class name of the texture useful for serialization or dynamic coding.
  57949. * @returns "PBRClearCoatConfiguration"
  57950. */
  57951. getClassName(): string;
  57952. /**
  57953. * Add fallbacks to the effect fallbacks list.
  57954. * @param defines defines the Base texture to use.
  57955. * @param fallbacks defines the current fallback list.
  57956. * @param currentRank defines the current fallback rank.
  57957. * @returns the new fallback rank.
  57958. */
  57959. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57960. /**
  57961. * Add the required uniforms to the current list.
  57962. * @param uniforms defines the current uniform list.
  57963. */
  57964. static AddUniforms(uniforms: string[]): void;
  57965. /**
  57966. * Add the required samplers to the current list.
  57967. * @param samplers defines the current sampler list.
  57968. */
  57969. static AddSamplers(samplers: string[]): void;
  57970. /**
  57971. * Add the required uniforms to the current buffer.
  57972. * @param uniformBuffer defines the current uniform buffer.
  57973. */
  57974. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57975. /**
  57976. * Makes a duplicate of the current configuration into another one.
  57977. * @param clearCoatConfiguration define the config where to copy the info
  57978. */
  57979. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57980. /**
  57981. * Serializes this clear coat configuration.
  57982. * @returns - An object with the serialized config.
  57983. */
  57984. serialize(): any;
  57985. /**
  57986. * Parses a anisotropy Configuration from a serialized object.
  57987. * @param source - Serialized object.
  57988. * @param scene Defines the scene we are parsing for
  57989. * @param rootUrl Defines the rootUrl to load from
  57990. */
  57991. parse(source: any, scene: Scene, rootUrl: string): void;
  57992. }
  57993. }
  57994. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57995. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57997. import { Vector2 } from "babylonjs/Maths/math.vector";
  57998. import { Scene } from "babylonjs/scene";
  57999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58000. import { Nullable } from "babylonjs/types";
  58001. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58002. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58003. /**
  58004. * @hidden
  58005. */
  58006. export interface IMaterialAnisotropicDefines {
  58007. ANISOTROPIC: boolean;
  58008. ANISOTROPIC_TEXTURE: boolean;
  58009. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58010. MAINUV1: boolean;
  58011. _areTexturesDirty: boolean;
  58012. _needUVs: boolean;
  58013. }
  58014. /**
  58015. * Define the code related to the anisotropic parameters of the pbr material.
  58016. */
  58017. export class PBRAnisotropicConfiguration {
  58018. private _isEnabled;
  58019. /**
  58020. * Defines if the anisotropy is enabled in the material.
  58021. */
  58022. isEnabled: boolean;
  58023. /**
  58024. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  58025. */
  58026. intensity: number;
  58027. /**
  58028. * Defines if the effect is along the tangents, bitangents or in between.
  58029. * By default, the effect is "strectching" the highlights along the tangents.
  58030. */
  58031. direction: Vector2;
  58032. private _texture;
  58033. /**
  58034. * Stores the anisotropy values in a texture.
  58035. * rg is direction (like normal from -1 to 1)
  58036. * b is a intensity
  58037. */
  58038. texture: Nullable<BaseTexture>;
  58039. /** @hidden */
  58040. private _internalMarkAllSubMeshesAsTexturesDirty;
  58041. /** @hidden */
  58042. _markAllSubMeshesAsTexturesDirty(): void;
  58043. /**
  58044. * Instantiate a new istance of anisotropy configuration.
  58045. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58046. */
  58047. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58048. /**
  58049. * Specifies that the submesh is ready to be used.
  58050. * @param defines the list of "defines" to update.
  58051. * @param scene defines the scene the material belongs to.
  58052. * @returns - boolean indicating that the submesh is ready or not.
  58053. */
  58054. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  58055. /**
  58056. * Checks to see if a texture is used in the material.
  58057. * @param defines the list of "defines" to update.
  58058. * @param mesh the mesh we are preparing the defines for.
  58059. * @param scene defines the scene the material belongs to.
  58060. */
  58061. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  58062. /**
  58063. * Binds the material data.
  58064. * @param uniformBuffer defines the Uniform buffer to fill in.
  58065. * @param scene defines the scene the material belongs to.
  58066. * @param isFrozen defines wether the material is frozen or not.
  58067. */
  58068. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58069. /**
  58070. * Checks to see if a texture is used in the material.
  58071. * @param texture - Base texture to use.
  58072. * @returns - Boolean specifying if a texture is used in the material.
  58073. */
  58074. hasTexture(texture: BaseTexture): boolean;
  58075. /**
  58076. * Returns an array of the actively used textures.
  58077. * @param activeTextures Array of BaseTextures
  58078. */
  58079. getActiveTextures(activeTextures: BaseTexture[]): void;
  58080. /**
  58081. * Returns the animatable textures.
  58082. * @param animatables Array of animatable textures.
  58083. */
  58084. getAnimatables(animatables: IAnimatable[]): void;
  58085. /**
  58086. * Disposes the resources of the material.
  58087. * @param forceDisposeTextures - Forces the disposal of all textures.
  58088. */
  58089. dispose(forceDisposeTextures?: boolean): void;
  58090. /**
  58091. * Get the current class name of the texture useful for serialization or dynamic coding.
  58092. * @returns "PBRAnisotropicConfiguration"
  58093. */
  58094. getClassName(): string;
  58095. /**
  58096. * Add fallbacks to the effect fallbacks list.
  58097. * @param defines defines the Base texture to use.
  58098. * @param fallbacks defines the current fallback list.
  58099. * @param currentRank defines the current fallback rank.
  58100. * @returns the new fallback rank.
  58101. */
  58102. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58103. /**
  58104. * Add the required uniforms to the current list.
  58105. * @param uniforms defines the current uniform list.
  58106. */
  58107. static AddUniforms(uniforms: string[]): void;
  58108. /**
  58109. * Add the required uniforms to the current buffer.
  58110. * @param uniformBuffer defines the current uniform buffer.
  58111. */
  58112. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58113. /**
  58114. * Add the required samplers to the current list.
  58115. * @param samplers defines the current sampler list.
  58116. */
  58117. static AddSamplers(samplers: string[]): void;
  58118. /**
  58119. * Makes a duplicate of the current configuration into another one.
  58120. * @param anisotropicConfiguration define the config where to copy the info
  58121. */
  58122. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  58123. /**
  58124. * Serializes this anisotropy configuration.
  58125. * @returns - An object with the serialized config.
  58126. */
  58127. serialize(): any;
  58128. /**
  58129. * Parses a anisotropy Configuration from a serialized object.
  58130. * @param source - Serialized object.
  58131. * @param scene Defines the scene we are parsing for
  58132. * @param rootUrl Defines the rootUrl to load from
  58133. */
  58134. parse(source: any, scene: Scene, rootUrl: string): void;
  58135. }
  58136. }
  58137. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  58138. import { Scene } from "babylonjs/scene";
  58139. /**
  58140. * @hidden
  58141. */
  58142. export interface IMaterialBRDFDefines {
  58143. BRDF_V_HEIGHT_CORRELATED: boolean;
  58144. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58145. SPHERICAL_HARMONICS: boolean;
  58146. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58147. /** @hidden */
  58148. _areMiscDirty: boolean;
  58149. }
  58150. /**
  58151. * Define the code related to the BRDF parameters of the pbr material.
  58152. */
  58153. export class PBRBRDFConfiguration {
  58154. /**
  58155. * Default value used for the energy conservation.
  58156. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58157. */
  58158. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  58159. /**
  58160. * Default value used for the Smith Visibility Height Correlated mode.
  58161. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58162. */
  58163. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  58164. /**
  58165. * Default value used for the IBL diffuse part.
  58166. * This can help switching back to the polynomials mode globally which is a tiny bit
  58167. * less GPU intensive at the drawback of a lower quality.
  58168. */
  58169. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  58170. /**
  58171. * Default value used for activating energy conservation for the specular workflow.
  58172. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58173. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58174. */
  58175. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58176. private _useEnergyConservation;
  58177. /**
  58178. * Defines if the material uses energy conservation.
  58179. */
  58180. useEnergyConservation: boolean;
  58181. private _useSmithVisibilityHeightCorrelated;
  58182. /**
  58183. * LEGACY Mode set to false
  58184. * Defines if the material uses height smith correlated visibility term.
  58185. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58186. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58187. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58188. * Not relying on height correlated will also disable energy conservation.
  58189. */
  58190. useSmithVisibilityHeightCorrelated: boolean;
  58191. private _useSphericalHarmonics;
  58192. /**
  58193. * LEGACY Mode set to false
  58194. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58195. * diffuse part of the IBL.
  58196. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58197. * to the ground truth.
  58198. */
  58199. useSphericalHarmonics: boolean;
  58200. private _useSpecularGlossinessInputEnergyConservation;
  58201. /**
  58202. * Defines if the material uses energy conservation, when the specular workflow is active.
  58203. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58204. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58205. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58206. */
  58207. useSpecularGlossinessInputEnergyConservation: boolean;
  58208. /** @hidden */
  58209. private _internalMarkAllSubMeshesAsMiscDirty;
  58210. /** @hidden */
  58211. _markAllSubMeshesAsMiscDirty(): void;
  58212. /**
  58213. * Instantiate a new istance of clear coat configuration.
  58214. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58215. */
  58216. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58217. /**
  58218. * Checks to see if a texture is used in the material.
  58219. * @param defines the list of "defines" to update.
  58220. */
  58221. prepareDefines(defines: IMaterialBRDFDefines): void;
  58222. /**
  58223. * Get the current class name of the texture useful for serialization or dynamic coding.
  58224. * @returns "PBRClearCoatConfiguration"
  58225. */
  58226. getClassName(): string;
  58227. /**
  58228. * Makes a duplicate of the current configuration into another one.
  58229. * @param brdfConfiguration define the config where to copy the info
  58230. */
  58231. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58232. /**
  58233. * Serializes this BRDF configuration.
  58234. * @returns - An object with the serialized config.
  58235. */
  58236. serialize(): any;
  58237. /**
  58238. * Parses a anisotropy Configuration from a serialized object.
  58239. * @param source - Serialized object.
  58240. * @param scene Defines the scene we are parsing for
  58241. * @param rootUrl Defines the rootUrl to load from
  58242. */
  58243. parse(source: any, scene: Scene, rootUrl: string): void;
  58244. }
  58245. }
  58246. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58247. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58248. import { Color3 } from "babylonjs/Maths/math.color";
  58249. import { Scene } from "babylonjs/scene";
  58250. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58251. import { Nullable } from "babylonjs/types";
  58252. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58253. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58254. /**
  58255. * @hidden
  58256. */
  58257. export interface IMaterialSheenDefines {
  58258. SHEEN: boolean;
  58259. SHEEN_TEXTURE: boolean;
  58260. SHEEN_TEXTUREDIRECTUV: number;
  58261. SHEEN_LINKWITHALBEDO: boolean;
  58262. SHEEN_ROUGHNESS: boolean;
  58263. SHEEN_ALBEDOSCALING: boolean;
  58264. /** @hidden */
  58265. _areTexturesDirty: boolean;
  58266. }
  58267. /**
  58268. * Define the code related to the Sheen parameters of the pbr material.
  58269. */
  58270. export class PBRSheenConfiguration {
  58271. private _isEnabled;
  58272. /**
  58273. * Defines if the material uses sheen.
  58274. */
  58275. isEnabled: boolean;
  58276. private _linkSheenWithAlbedo;
  58277. /**
  58278. * Defines if the sheen is linked to the sheen color.
  58279. */
  58280. linkSheenWithAlbedo: boolean;
  58281. /**
  58282. * Defines the sheen intensity.
  58283. */
  58284. intensity: number;
  58285. /**
  58286. * Defines the sheen color.
  58287. */
  58288. color: Color3;
  58289. private _texture;
  58290. /**
  58291. * Stores the sheen tint values in a texture.
  58292. * rgb is tint
  58293. * a is a intensity or roughness if roughness has been defined
  58294. */
  58295. texture: Nullable<BaseTexture>;
  58296. private _roughness;
  58297. /**
  58298. * Defines the sheen roughness.
  58299. * It is not taken into account if linkSheenWithAlbedo is true.
  58300. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58301. */
  58302. roughness: Nullable<number>;
  58303. private _albedoScaling;
  58304. /**
  58305. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58306. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58307. * making it easier to setup and tweak the effect
  58308. */
  58309. albedoScaling: boolean;
  58310. /** @hidden */
  58311. private _internalMarkAllSubMeshesAsTexturesDirty;
  58312. /** @hidden */
  58313. _markAllSubMeshesAsTexturesDirty(): void;
  58314. /**
  58315. * Instantiate a new istance of clear coat configuration.
  58316. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58317. */
  58318. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58319. /**
  58320. * Specifies that the submesh is ready to be used.
  58321. * @param defines the list of "defines" to update.
  58322. * @param scene defines the scene the material belongs to.
  58323. * @returns - boolean indicating that the submesh is ready or not.
  58324. */
  58325. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58326. /**
  58327. * Checks to see if a texture is used in the material.
  58328. * @param defines the list of "defines" to update.
  58329. * @param scene defines the scene the material belongs to.
  58330. */
  58331. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58332. /**
  58333. * Binds the material data.
  58334. * @param uniformBuffer defines the Uniform buffer to fill in.
  58335. * @param scene defines the scene the material belongs to.
  58336. * @param isFrozen defines wether the material is frozen or not.
  58337. */
  58338. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58339. /**
  58340. * Checks to see if a texture is used in the material.
  58341. * @param texture - Base texture to use.
  58342. * @returns - Boolean specifying if a texture is used in the material.
  58343. */
  58344. hasTexture(texture: BaseTexture): boolean;
  58345. /**
  58346. * Returns an array of the actively used textures.
  58347. * @param activeTextures Array of BaseTextures
  58348. */
  58349. getActiveTextures(activeTextures: BaseTexture[]): void;
  58350. /**
  58351. * Returns the animatable textures.
  58352. * @param animatables Array of animatable textures.
  58353. */
  58354. getAnimatables(animatables: IAnimatable[]): void;
  58355. /**
  58356. * Disposes the resources of the material.
  58357. * @param forceDisposeTextures - Forces the disposal of all textures.
  58358. */
  58359. dispose(forceDisposeTextures?: boolean): void;
  58360. /**
  58361. * Get the current class name of the texture useful for serialization or dynamic coding.
  58362. * @returns "PBRSheenConfiguration"
  58363. */
  58364. getClassName(): string;
  58365. /**
  58366. * Add fallbacks to the effect fallbacks list.
  58367. * @param defines defines the Base texture to use.
  58368. * @param fallbacks defines the current fallback list.
  58369. * @param currentRank defines the current fallback rank.
  58370. * @returns the new fallback rank.
  58371. */
  58372. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58373. /**
  58374. * Add the required uniforms to the current list.
  58375. * @param uniforms defines the current uniform list.
  58376. */
  58377. static AddUniforms(uniforms: string[]): void;
  58378. /**
  58379. * Add the required uniforms to the current buffer.
  58380. * @param uniformBuffer defines the current uniform buffer.
  58381. */
  58382. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58383. /**
  58384. * Add the required samplers to the current list.
  58385. * @param samplers defines the current sampler list.
  58386. */
  58387. static AddSamplers(samplers: string[]): void;
  58388. /**
  58389. * Makes a duplicate of the current configuration into another one.
  58390. * @param sheenConfiguration define the config where to copy the info
  58391. */
  58392. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58393. /**
  58394. * Serializes this BRDF configuration.
  58395. * @returns - An object with the serialized config.
  58396. */
  58397. serialize(): any;
  58398. /**
  58399. * Parses a anisotropy Configuration from a serialized object.
  58400. * @param source - Serialized object.
  58401. * @param scene Defines the scene we are parsing for
  58402. * @param rootUrl Defines the rootUrl to load from
  58403. */
  58404. parse(source: any, scene: Scene, rootUrl: string): void;
  58405. }
  58406. }
  58407. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58408. import { Nullable } from "babylonjs/types";
  58409. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58410. import { Color3 } from "babylonjs/Maths/math.color";
  58411. import { SmartArray } from "babylonjs/Misc/smartArray";
  58412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58413. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58414. import { Effect } from "babylonjs/Materials/effect";
  58415. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58416. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58417. import { Engine } from "babylonjs/Engines/engine";
  58418. import { Scene } from "babylonjs/scene";
  58419. /**
  58420. * @hidden
  58421. */
  58422. export interface IMaterialSubSurfaceDefines {
  58423. SUBSURFACE: boolean;
  58424. SS_REFRACTION: boolean;
  58425. SS_TRANSLUCENCY: boolean;
  58426. SS_SCATTERING: boolean;
  58427. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58428. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58429. SS_REFRACTIONMAP_3D: boolean;
  58430. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58431. SS_LODINREFRACTIONALPHA: boolean;
  58432. SS_GAMMAREFRACTION: boolean;
  58433. SS_RGBDREFRACTION: boolean;
  58434. SS_LINEARSPECULARREFRACTION: boolean;
  58435. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58436. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58437. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58438. /** @hidden */
  58439. _areTexturesDirty: boolean;
  58440. }
  58441. /**
  58442. * Define the code related to the sub surface parameters of the pbr material.
  58443. */
  58444. export class PBRSubSurfaceConfiguration {
  58445. private _isRefractionEnabled;
  58446. /**
  58447. * Defines if the refraction is enabled in the material.
  58448. */
  58449. isRefractionEnabled: boolean;
  58450. private _isTranslucencyEnabled;
  58451. /**
  58452. * Defines if the translucency is enabled in the material.
  58453. */
  58454. isTranslucencyEnabled: boolean;
  58455. private _isScatteringEnabled;
  58456. /**
  58457. * Defines if the sub surface scattering is enabled in the material.
  58458. */
  58459. isScatteringEnabled: boolean;
  58460. private _scatteringDiffusionProfileIndex;
  58461. /**
  58462. * Diffusion profile for subsurface scattering.
  58463. * Useful for better scattering in the skins or foliages.
  58464. */
  58465. get scatteringDiffusionProfile(): Nullable<Color3>;
  58466. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58467. /**
  58468. * Defines the refraction intensity of the material.
  58469. * The refraction when enabled replaces the Diffuse part of the material.
  58470. * The intensity helps transitionning between diffuse and refraction.
  58471. */
  58472. refractionIntensity: number;
  58473. /**
  58474. * Defines the translucency intensity of the material.
  58475. * When translucency has been enabled, this defines how much of the "translucency"
  58476. * is addded to the diffuse part of the material.
  58477. */
  58478. translucencyIntensity: number;
  58479. /**
  58480. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58481. */
  58482. useAlbedoToTintRefraction: boolean;
  58483. private _thicknessTexture;
  58484. /**
  58485. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58486. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58487. * 0 would mean minimumThickness
  58488. * 1 would mean maximumThickness
  58489. * The other channels might be use as a mask to vary the different effects intensity.
  58490. */
  58491. thicknessTexture: Nullable<BaseTexture>;
  58492. private _refractionTexture;
  58493. /**
  58494. * Defines the texture to use for refraction.
  58495. */
  58496. refractionTexture: Nullable<BaseTexture>;
  58497. private _indexOfRefraction;
  58498. /**
  58499. * Index of refraction of the material base layer.
  58500. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58501. *
  58502. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58503. *
  58504. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58505. */
  58506. indexOfRefraction: number;
  58507. private _volumeIndexOfRefraction;
  58508. /**
  58509. * Index of refraction of the material's volume.
  58510. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58511. *
  58512. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58513. * the volume will use the same IOR as the surface.
  58514. */
  58515. get volumeIndexOfRefraction(): number;
  58516. set volumeIndexOfRefraction(value: number);
  58517. private _invertRefractionY;
  58518. /**
  58519. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58520. */
  58521. invertRefractionY: boolean;
  58522. private _linkRefractionWithTransparency;
  58523. /**
  58524. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58525. * Materials half opaque for instance using refraction could benefit from this control.
  58526. */
  58527. linkRefractionWithTransparency: boolean;
  58528. /**
  58529. * Defines the minimum thickness stored in the thickness map.
  58530. * If no thickness map is defined, this value will be used to simulate thickness.
  58531. */
  58532. minimumThickness: number;
  58533. /**
  58534. * Defines the maximum thickness stored in the thickness map.
  58535. */
  58536. maximumThickness: number;
  58537. /**
  58538. * Defines the volume tint of the material.
  58539. * This is used for both translucency and scattering.
  58540. */
  58541. tintColor: Color3;
  58542. /**
  58543. * Defines the distance at which the tint color should be found in the media.
  58544. * This is used for refraction only.
  58545. */
  58546. tintColorAtDistance: number;
  58547. /**
  58548. * Defines how far each channel transmit through the media.
  58549. * It is defined as a color to simplify it selection.
  58550. */
  58551. diffusionDistance: Color3;
  58552. private _useMaskFromThicknessTexture;
  58553. /**
  58554. * Stores the intensity of the different subsurface effects in the thickness texture.
  58555. * * the green channel is the translucency intensity.
  58556. * * the blue channel is the scattering intensity.
  58557. * * the alpha channel is the refraction intensity.
  58558. */
  58559. useMaskFromThicknessTexture: boolean;
  58560. private _scene;
  58561. /** @hidden */
  58562. private _internalMarkAllSubMeshesAsTexturesDirty;
  58563. private _internalMarkScenePrePassDirty;
  58564. /** @hidden */
  58565. _markAllSubMeshesAsTexturesDirty(): void;
  58566. /** @hidden */
  58567. _markScenePrePassDirty(): void;
  58568. /**
  58569. * Instantiate a new istance of sub surface configuration.
  58570. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58571. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58572. * @param scene The scene
  58573. */
  58574. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58575. /**
  58576. * Gets wehter the submesh is ready to be used or not.
  58577. * @param defines the list of "defines" to update.
  58578. * @param scene defines the scene the material belongs to.
  58579. * @returns - boolean indicating that the submesh is ready or not.
  58580. */
  58581. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58582. /**
  58583. * Checks to see if a texture is used in the material.
  58584. * @param defines the list of "defines" to update.
  58585. * @param scene defines the scene to the material belongs to.
  58586. */
  58587. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58588. /**
  58589. * Binds the material data.
  58590. * @param uniformBuffer defines the Uniform buffer to fill in.
  58591. * @param scene defines the scene the material belongs to.
  58592. * @param engine defines the engine the material belongs to.
  58593. * @param isFrozen defines whether the material is frozen or not.
  58594. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58595. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58596. */
  58597. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58598. /**
  58599. * Unbinds the material from the mesh.
  58600. * @param activeEffect defines the effect that should be unbound from.
  58601. * @returns true if unbound, otherwise false
  58602. */
  58603. unbind(activeEffect: Effect): boolean;
  58604. /**
  58605. * Returns the texture used for refraction or null if none is used.
  58606. * @param scene defines the scene the material belongs to.
  58607. * @returns - Refraction texture if present. If no refraction texture and refraction
  58608. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58609. */
  58610. private _getRefractionTexture;
  58611. /**
  58612. * Returns true if alpha blending should be disabled.
  58613. */
  58614. get disableAlphaBlending(): boolean;
  58615. /**
  58616. * Fills the list of render target textures.
  58617. * @param renderTargets the list of render targets to update
  58618. */
  58619. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58620. /**
  58621. * Checks to see if a texture is used in the material.
  58622. * @param texture - Base texture to use.
  58623. * @returns - Boolean specifying if a texture is used in the material.
  58624. */
  58625. hasTexture(texture: BaseTexture): boolean;
  58626. /**
  58627. * Gets a boolean indicating that current material needs to register RTT
  58628. * @returns true if this uses a render target otherwise false.
  58629. */
  58630. hasRenderTargetTextures(): boolean;
  58631. /**
  58632. * Returns an array of the actively used textures.
  58633. * @param activeTextures Array of BaseTextures
  58634. */
  58635. getActiveTextures(activeTextures: BaseTexture[]): void;
  58636. /**
  58637. * Returns the animatable textures.
  58638. * @param animatables Array of animatable textures.
  58639. */
  58640. getAnimatables(animatables: IAnimatable[]): void;
  58641. /**
  58642. * Disposes the resources of the material.
  58643. * @param forceDisposeTextures - Forces the disposal of all textures.
  58644. */
  58645. dispose(forceDisposeTextures?: boolean): void;
  58646. /**
  58647. * Get the current class name of the texture useful for serialization or dynamic coding.
  58648. * @returns "PBRSubSurfaceConfiguration"
  58649. */
  58650. getClassName(): string;
  58651. /**
  58652. * Add fallbacks to the effect fallbacks list.
  58653. * @param defines defines the Base texture to use.
  58654. * @param fallbacks defines the current fallback list.
  58655. * @param currentRank defines the current fallback rank.
  58656. * @returns the new fallback rank.
  58657. */
  58658. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58659. /**
  58660. * Add the required uniforms to the current list.
  58661. * @param uniforms defines the current uniform list.
  58662. */
  58663. static AddUniforms(uniforms: string[]): void;
  58664. /**
  58665. * Add the required samplers to the current list.
  58666. * @param samplers defines the current sampler list.
  58667. */
  58668. static AddSamplers(samplers: string[]): void;
  58669. /**
  58670. * Add the required uniforms to the current buffer.
  58671. * @param uniformBuffer defines the current uniform buffer.
  58672. */
  58673. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58674. /**
  58675. * Makes a duplicate of the current configuration into another one.
  58676. * @param configuration define the config where to copy the info
  58677. */
  58678. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58679. /**
  58680. * Serializes this Sub Surface configuration.
  58681. * @returns - An object with the serialized config.
  58682. */
  58683. serialize(): any;
  58684. /**
  58685. * Parses a anisotropy Configuration from a serialized object.
  58686. * @param source - Serialized object.
  58687. * @param scene Defines the scene we are parsing for
  58688. * @param rootUrl Defines the rootUrl to load from
  58689. */
  58690. parse(source: any, scene: Scene, rootUrl: string): void;
  58691. }
  58692. }
  58693. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58694. /** @hidden */
  58695. export var pbrFragmentDeclaration: {
  58696. name: string;
  58697. shader: string;
  58698. };
  58699. }
  58700. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58701. /** @hidden */
  58702. export var pbrUboDeclaration: {
  58703. name: string;
  58704. shader: string;
  58705. };
  58706. }
  58707. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58708. /** @hidden */
  58709. export var pbrFragmentExtraDeclaration: {
  58710. name: string;
  58711. shader: string;
  58712. };
  58713. }
  58714. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58715. /** @hidden */
  58716. export var pbrFragmentSamplersDeclaration: {
  58717. name: string;
  58718. shader: string;
  58719. };
  58720. }
  58721. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  58722. /** @hidden */
  58723. export var subSurfaceScatteringFunctions: {
  58724. name: string;
  58725. shader: string;
  58726. };
  58727. }
  58728. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58729. /** @hidden */
  58730. export var importanceSampling: {
  58731. name: string;
  58732. shader: string;
  58733. };
  58734. }
  58735. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58736. /** @hidden */
  58737. export var pbrHelperFunctions: {
  58738. name: string;
  58739. shader: string;
  58740. };
  58741. }
  58742. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58743. /** @hidden */
  58744. export var harmonicsFunctions: {
  58745. name: string;
  58746. shader: string;
  58747. };
  58748. }
  58749. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58750. /** @hidden */
  58751. export var pbrDirectLightingSetupFunctions: {
  58752. name: string;
  58753. shader: string;
  58754. };
  58755. }
  58756. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58757. /** @hidden */
  58758. export var pbrDirectLightingFalloffFunctions: {
  58759. name: string;
  58760. shader: string;
  58761. };
  58762. }
  58763. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58764. /** @hidden */
  58765. export var pbrBRDFFunctions: {
  58766. name: string;
  58767. shader: string;
  58768. };
  58769. }
  58770. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58771. /** @hidden */
  58772. export var hdrFilteringFunctions: {
  58773. name: string;
  58774. shader: string;
  58775. };
  58776. }
  58777. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58778. /** @hidden */
  58779. export var pbrDirectLightingFunctions: {
  58780. name: string;
  58781. shader: string;
  58782. };
  58783. }
  58784. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58785. /** @hidden */
  58786. export var pbrIBLFunctions: {
  58787. name: string;
  58788. shader: string;
  58789. };
  58790. }
  58791. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58792. /** @hidden */
  58793. export var pbrBlockAlbedoOpacity: {
  58794. name: string;
  58795. shader: string;
  58796. };
  58797. }
  58798. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58799. /** @hidden */
  58800. export var pbrBlockReflectivity: {
  58801. name: string;
  58802. shader: string;
  58803. };
  58804. }
  58805. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58806. /** @hidden */
  58807. export var pbrBlockAmbientOcclusion: {
  58808. name: string;
  58809. shader: string;
  58810. };
  58811. }
  58812. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58813. /** @hidden */
  58814. export var pbrBlockAlphaFresnel: {
  58815. name: string;
  58816. shader: string;
  58817. };
  58818. }
  58819. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58820. /** @hidden */
  58821. export var pbrBlockAnisotropic: {
  58822. name: string;
  58823. shader: string;
  58824. };
  58825. }
  58826. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58827. /** @hidden */
  58828. export var pbrBlockReflection: {
  58829. name: string;
  58830. shader: string;
  58831. };
  58832. }
  58833. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58834. /** @hidden */
  58835. export var pbrBlockSheen: {
  58836. name: string;
  58837. shader: string;
  58838. };
  58839. }
  58840. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58841. /** @hidden */
  58842. export var pbrBlockClearcoat: {
  58843. name: string;
  58844. shader: string;
  58845. };
  58846. }
  58847. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58848. /** @hidden */
  58849. export var pbrBlockSubSurface: {
  58850. name: string;
  58851. shader: string;
  58852. };
  58853. }
  58854. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58855. /** @hidden */
  58856. export var pbrBlockNormalGeometric: {
  58857. name: string;
  58858. shader: string;
  58859. };
  58860. }
  58861. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58862. /** @hidden */
  58863. export var pbrBlockNormalFinal: {
  58864. name: string;
  58865. shader: string;
  58866. };
  58867. }
  58868. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58869. /** @hidden */
  58870. export var pbrBlockLightmapInit: {
  58871. name: string;
  58872. shader: string;
  58873. };
  58874. }
  58875. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58876. /** @hidden */
  58877. export var pbrBlockGeometryInfo: {
  58878. name: string;
  58879. shader: string;
  58880. };
  58881. }
  58882. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58883. /** @hidden */
  58884. export var pbrBlockReflectance0: {
  58885. name: string;
  58886. shader: string;
  58887. };
  58888. }
  58889. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58890. /** @hidden */
  58891. export var pbrBlockReflectance: {
  58892. name: string;
  58893. shader: string;
  58894. };
  58895. }
  58896. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58897. /** @hidden */
  58898. export var pbrBlockDirectLighting: {
  58899. name: string;
  58900. shader: string;
  58901. };
  58902. }
  58903. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58904. /** @hidden */
  58905. export var pbrBlockFinalLitComponents: {
  58906. name: string;
  58907. shader: string;
  58908. };
  58909. }
  58910. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58911. /** @hidden */
  58912. export var pbrBlockFinalUnlitComponents: {
  58913. name: string;
  58914. shader: string;
  58915. };
  58916. }
  58917. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58918. /** @hidden */
  58919. export var pbrBlockFinalColorComposition: {
  58920. name: string;
  58921. shader: string;
  58922. };
  58923. }
  58924. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58925. /** @hidden */
  58926. export var pbrBlockImageProcessing: {
  58927. name: string;
  58928. shader: string;
  58929. };
  58930. }
  58931. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58932. /** @hidden */
  58933. export var pbrDebug: {
  58934. name: string;
  58935. shader: string;
  58936. };
  58937. }
  58938. declare module "babylonjs/Shaders/pbr.fragment" {
  58939. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58940. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58941. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58942. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58943. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58944. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58945. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58946. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58947. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58948. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58949. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58950. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58951. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58952. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58953. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58954. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58955. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58956. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58957. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58958. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58959. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58960. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58961. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58962. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58963. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58964. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58965. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58966. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58967. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58968. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58969. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58970. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58971. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58972. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58973. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58974. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58975. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58976. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58977. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58978. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58979. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58980. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58981. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58982. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58983. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58984. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58985. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58986. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58987. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58988. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58989. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58990. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58991. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58992. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58993. /** @hidden */
  58994. export var pbrPixelShader: {
  58995. name: string;
  58996. shader: string;
  58997. };
  58998. }
  58999. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  59000. /** @hidden */
  59001. export var pbrVertexDeclaration: {
  59002. name: string;
  59003. shader: string;
  59004. };
  59005. }
  59006. declare module "babylonjs/Shaders/pbr.vertex" {
  59007. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  59008. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  59009. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59010. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59011. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59012. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  59013. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  59014. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59015. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59016. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59017. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59018. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59019. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59020. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59021. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59022. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59023. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59024. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  59025. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59026. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59027. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59028. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59029. /** @hidden */
  59030. export var pbrVertexShader: {
  59031. name: string;
  59032. shader: string;
  59033. };
  59034. }
  59035. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  59036. import { Nullable } from "babylonjs/types";
  59037. import { Scene } from "babylonjs/scene";
  59038. import { Matrix } from "babylonjs/Maths/math.vector";
  59039. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59041. import { Mesh } from "babylonjs/Meshes/mesh";
  59042. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  59043. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  59044. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  59045. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  59046. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  59047. import { Color3 } from "babylonjs/Maths/math.color";
  59048. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59049. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  59050. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59051. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59052. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59053. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59054. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59055. import "babylonjs/Shaders/pbr.fragment";
  59056. import "babylonjs/Shaders/pbr.vertex";
  59057. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  59058. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  59059. /**
  59060. * Manages the defines for the PBR Material.
  59061. * @hidden
  59062. */
  59063. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  59064. PBR: boolean;
  59065. NUM_SAMPLES: string;
  59066. REALTIME_FILTERING: boolean;
  59067. MAINUV1: boolean;
  59068. MAINUV2: boolean;
  59069. UV1: boolean;
  59070. UV2: boolean;
  59071. ALBEDO: boolean;
  59072. GAMMAALBEDO: boolean;
  59073. ALBEDODIRECTUV: number;
  59074. VERTEXCOLOR: boolean;
  59075. DETAIL: boolean;
  59076. DETAILDIRECTUV: number;
  59077. DETAIL_NORMALBLENDMETHOD: number;
  59078. AMBIENT: boolean;
  59079. AMBIENTDIRECTUV: number;
  59080. AMBIENTINGRAYSCALE: boolean;
  59081. OPACITY: boolean;
  59082. VERTEXALPHA: boolean;
  59083. OPACITYDIRECTUV: number;
  59084. OPACITYRGB: boolean;
  59085. ALPHATEST: boolean;
  59086. DEPTHPREPASS: boolean;
  59087. ALPHABLEND: boolean;
  59088. ALPHAFROMALBEDO: boolean;
  59089. ALPHATESTVALUE: string;
  59090. SPECULAROVERALPHA: boolean;
  59091. RADIANCEOVERALPHA: boolean;
  59092. ALPHAFRESNEL: boolean;
  59093. LINEARALPHAFRESNEL: boolean;
  59094. PREMULTIPLYALPHA: boolean;
  59095. EMISSIVE: boolean;
  59096. EMISSIVEDIRECTUV: number;
  59097. REFLECTIVITY: boolean;
  59098. REFLECTIVITYDIRECTUV: number;
  59099. SPECULARTERM: boolean;
  59100. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  59101. MICROSURFACEAUTOMATIC: boolean;
  59102. LODBASEDMICROSFURACE: boolean;
  59103. MICROSURFACEMAP: boolean;
  59104. MICROSURFACEMAPDIRECTUV: number;
  59105. METALLICWORKFLOW: boolean;
  59106. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  59107. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  59108. METALLNESSSTOREINMETALMAPBLUE: boolean;
  59109. AOSTOREINMETALMAPRED: boolean;
  59110. METALLIC_REFLECTANCE: boolean;
  59111. METALLIC_REFLECTANCEDIRECTUV: number;
  59112. ENVIRONMENTBRDF: boolean;
  59113. ENVIRONMENTBRDF_RGBD: boolean;
  59114. NORMAL: boolean;
  59115. TANGENT: boolean;
  59116. BUMP: boolean;
  59117. BUMPDIRECTUV: number;
  59118. OBJECTSPACE_NORMALMAP: boolean;
  59119. PARALLAX: boolean;
  59120. PARALLAXOCCLUSION: boolean;
  59121. NORMALXYSCALE: boolean;
  59122. LIGHTMAP: boolean;
  59123. LIGHTMAPDIRECTUV: number;
  59124. USELIGHTMAPASSHADOWMAP: boolean;
  59125. GAMMALIGHTMAP: boolean;
  59126. RGBDLIGHTMAP: boolean;
  59127. REFLECTION: boolean;
  59128. REFLECTIONMAP_3D: boolean;
  59129. REFLECTIONMAP_SPHERICAL: boolean;
  59130. REFLECTIONMAP_PLANAR: boolean;
  59131. REFLECTIONMAP_CUBIC: boolean;
  59132. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59133. REFLECTIONMAP_PROJECTION: boolean;
  59134. REFLECTIONMAP_SKYBOX: boolean;
  59135. REFLECTIONMAP_EXPLICIT: boolean;
  59136. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59137. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59138. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59139. INVERTCUBICMAP: boolean;
  59140. USESPHERICALFROMREFLECTIONMAP: boolean;
  59141. USEIRRADIANCEMAP: boolean;
  59142. SPHERICAL_HARMONICS: boolean;
  59143. USESPHERICALINVERTEX: boolean;
  59144. REFLECTIONMAP_OPPOSITEZ: boolean;
  59145. LODINREFLECTIONALPHA: boolean;
  59146. GAMMAREFLECTION: boolean;
  59147. RGBDREFLECTION: boolean;
  59148. LINEARSPECULARREFLECTION: boolean;
  59149. RADIANCEOCCLUSION: boolean;
  59150. HORIZONOCCLUSION: boolean;
  59151. INSTANCES: boolean;
  59152. THIN_INSTANCES: boolean;
  59153. PREPASS: boolean;
  59154. PREPASS_IRRADIANCE: boolean;
  59155. PREPASS_IRRADIANCE_INDEX: number;
  59156. PREPASS_ALBEDO: boolean;
  59157. PREPASS_ALBEDO_INDEX: number;
  59158. PREPASS_DEPTHNORMAL: boolean;
  59159. PREPASS_DEPTHNORMAL_INDEX: number;
  59160. SCENE_MRT_COUNT: number;
  59161. NUM_BONE_INFLUENCERS: number;
  59162. BonesPerMesh: number;
  59163. BONETEXTURE: boolean;
  59164. NONUNIFORMSCALING: boolean;
  59165. MORPHTARGETS: boolean;
  59166. MORPHTARGETS_NORMAL: boolean;
  59167. MORPHTARGETS_TANGENT: boolean;
  59168. MORPHTARGETS_UV: boolean;
  59169. NUM_MORPH_INFLUENCERS: number;
  59170. IMAGEPROCESSING: boolean;
  59171. VIGNETTE: boolean;
  59172. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59173. VIGNETTEBLENDMODEOPAQUE: boolean;
  59174. TONEMAPPING: boolean;
  59175. TONEMAPPING_ACES: boolean;
  59176. CONTRAST: boolean;
  59177. COLORCURVES: boolean;
  59178. COLORGRADING: boolean;
  59179. COLORGRADING3D: boolean;
  59180. SAMPLER3DGREENDEPTH: boolean;
  59181. SAMPLER3DBGRMAP: boolean;
  59182. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59183. EXPOSURE: boolean;
  59184. MULTIVIEW: boolean;
  59185. USEPHYSICALLIGHTFALLOFF: boolean;
  59186. USEGLTFLIGHTFALLOFF: boolean;
  59187. TWOSIDEDLIGHTING: boolean;
  59188. SHADOWFLOAT: boolean;
  59189. CLIPPLANE: boolean;
  59190. CLIPPLANE2: boolean;
  59191. CLIPPLANE3: boolean;
  59192. CLIPPLANE4: boolean;
  59193. CLIPPLANE5: boolean;
  59194. CLIPPLANE6: boolean;
  59195. POINTSIZE: boolean;
  59196. FOG: boolean;
  59197. LOGARITHMICDEPTH: boolean;
  59198. FORCENORMALFORWARD: boolean;
  59199. SPECULARAA: boolean;
  59200. CLEARCOAT: boolean;
  59201. CLEARCOAT_DEFAULTIOR: boolean;
  59202. CLEARCOAT_TEXTURE: boolean;
  59203. CLEARCOAT_TEXTUREDIRECTUV: number;
  59204. CLEARCOAT_BUMP: boolean;
  59205. CLEARCOAT_BUMPDIRECTUV: number;
  59206. CLEARCOAT_TINT: boolean;
  59207. CLEARCOAT_TINT_TEXTURE: boolean;
  59208. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59209. ANISOTROPIC: boolean;
  59210. ANISOTROPIC_TEXTURE: boolean;
  59211. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59212. BRDF_V_HEIGHT_CORRELATED: boolean;
  59213. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59214. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59215. SHEEN: boolean;
  59216. SHEEN_TEXTURE: boolean;
  59217. SHEEN_TEXTUREDIRECTUV: number;
  59218. SHEEN_LINKWITHALBEDO: boolean;
  59219. SHEEN_ROUGHNESS: boolean;
  59220. SHEEN_ALBEDOSCALING: boolean;
  59221. SUBSURFACE: boolean;
  59222. SS_REFRACTION: boolean;
  59223. SS_TRANSLUCENCY: boolean;
  59224. SS_SCATTERING: boolean;
  59225. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59226. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59227. SS_REFRACTIONMAP_3D: boolean;
  59228. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59229. SS_LODINREFRACTIONALPHA: boolean;
  59230. SS_GAMMAREFRACTION: boolean;
  59231. SS_RGBDREFRACTION: boolean;
  59232. SS_LINEARSPECULARREFRACTION: boolean;
  59233. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59234. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59235. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59236. UNLIT: boolean;
  59237. DEBUGMODE: number;
  59238. /**
  59239. * Initializes the PBR Material defines.
  59240. */
  59241. constructor();
  59242. /**
  59243. * Resets the PBR Material defines.
  59244. */
  59245. reset(): void;
  59246. }
  59247. /**
  59248. * The Physically based material base class of BJS.
  59249. *
  59250. * This offers the main features of a standard PBR material.
  59251. * For more information, please refer to the documentation :
  59252. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59253. */
  59254. export abstract class PBRBaseMaterial extends PushMaterial {
  59255. /**
  59256. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59257. */
  59258. static readonly PBRMATERIAL_OPAQUE: number;
  59259. /**
  59260. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59261. */
  59262. static readonly PBRMATERIAL_ALPHATEST: number;
  59263. /**
  59264. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59265. */
  59266. static readonly PBRMATERIAL_ALPHABLEND: number;
  59267. /**
  59268. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59269. * They are also discarded below the alpha cutoff threshold to improve performances.
  59270. */
  59271. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59272. /**
  59273. * Defines the default value of how much AO map is occluding the analytical lights
  59274. * (point spot...).
  59275. */
  59276. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59277. /**
  59278. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59279. */
  59280. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59281. /**
  59282. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59283. * to enhance interoperability with other engines.
  59284. */
  59285. static readonly LIGHTFALLOFF_GLTF: number;
  59286. /**
  59287. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59288. * to enhance interoperability with other materials.
  59289. */
  59290. static readonly LIGHTFALLOFF_STANDARD: number;
  59291. /**
  59292. * Intensity of the direct lights e.g. the four lights available in your scene.
  59293. * This impacts both the direct diffuse and specular highlights.
  59294. */
  59295. protected _directIntensity: number;
  59296. /**
  59297. * Intensity of the emissive part of the material.
  59298. * This helps controlling the emissive effect without modifying the emissive color.
  59299. */
  59300. protected _emissiveIntensity: number;
  59301. /**
  59302. * Intensity of the environment e.g. how much the environment will light the object
  59303. * either through harmonics for rough material or through the refelction for shiny ones.
  59304. */
  59305. protected _environmentIntensity: number;
  59306. /**
  59307. * This is a special control allowing the reduction of the specular highlights coming from the
  59308. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59309. */
  59310. protected _specularIntensity: number;
  59311. /**
  59312. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59313. */
  59314. private _lightingInfos;
  59315. /**
  59316. * Debug Control allowing disabling the bump map on this material.
  59317. */
  59318. protected _disableBumpMap: boolean;
  59319. /**
  59320. * AKA Diffuse Texture in standard nomenclature.
  59321. */
  59322. protected _albedoTexture: Nullable<BaseTexture>;
  59323. /**
  59324. * AKA Occlusion Texture in other nomenclature.
  59325. */
  59326. protected _ambientTexture: Nullable<BaseTexture>;
  59327. /**
  59328. * AKA Occlusion Texture Intensity in other nomenclature.
  59329. */
  59330. protected _ambientTextureStrength: number;
  59331. /**
  59332. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59333. * 1 means it completely occludes it
  59334. * 0 mean it has no impact
  59335. */
  59336. protected _ambientTextureImpactOnAnalyticalLights: number;
  59337. /**
  59338. * Stores the alpha values in a texture.
  59339. */
  59340. protected _opacityTexture: Nullable<BaseTexture>;
  59341. /**
  59342. * Stores the reflection values in a texture.
  59343. */
  59344. protected _reflectionTexture: Nullable<BaseTexture>;
  59345. /**
  59346. * Stores the emissive values in a texture.
  59347. */
  59348. protected _emissiveTexture: Nullable<BaseTexture>;
  59349. /**
  59350. * AKA Specular texture in other nomenclature.
  59351. */
  59352. protected _reflectivityTexture: Nullable<BaseTexture>;
  59353. /**
  59354. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59355. */
  59356. protected _metallicTexture: Nullable<BaseTexture>;
  59357. /**
  59358. * Specifies the metallic scalar of the metallic/roughness workflow.
  59359. * Can also be used to scale the metalness values of the metallic texture.
  59360. */
  59361. protected _metallic: Nullable<number>;
  59362. /**
  59363. * Specifies the roughness scalar of the metallic/roughness workflow.
  59364. * Can also be used to scale the roughness values of the metallic texture.
  59365. */
  59366. protected _roughness: Nullable<number>;
  59367. /**
  59368. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59369. * By default the indexOfrefraction is used to compute F0;
  59370. *
  59371. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59372. *
  59373. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59374. * F90 = metallicReflectanceColor;
  59375. */
  59376. protected _metallicF0Factor: number;
  59377. /**
  59378. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59379. * By default the F90 is always 1;
  59380. *
  59381. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59382. *
  59383. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59384. * F90 = metallicReflectanceColor;
  59385. */
  59386. protected _metallicReflectanceColor: Color3;
  59387. /**
  59388. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59389. * This is multiply against the scalar values defined in the material.
  59390. */
  59391. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59392. /**
  59393. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59394. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59395. */
  59396. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59397. /**
  59398. * Stores surface normal data used to displace a mesh in a texture.
  59399. */
  59400. protected _bumpTexture: Nullable<BaseTexture>;
  59401. /**
  59402. * Stores the pre-calculated light information of a mesh in a texture.
  59403. */
  59404. protected _lightmapTexture: Nullable<BaseTexture>;
  59405. /**
  59406. * The color of a material in ambient lighting.
  59407. */
  59408. protected _ambientColor: Color3;
  59409. /**
  59410. * AKA Diffuse Color in other nomenclature.
  59411. */
  59412. protected _albedoColor: Color3;
  59413. /**
  59414. * AKA Specular Color in other nomenclature.
  59415. */
  59416. protected _reflectivityColor: Color3;
  59417. /**
  59418. * The color applied when light is reflected from a material.
  59419. */
  59420. protected _reflectionColor: Color3;
  59421. /**
  59422. * The color applied when light is emitted from a material.
  59423. */
  59424. protected _emissiveColor: Color3;
  59425. /**
  59426. * AKA Glossiness in other nomenclature.
  59427. */
  59428. protected _microSurface: number;
  59429. /**
  59430. * Specifies that the material will use the light map as a show map.
  59431. */
  59432. protected _useLightmapAsShadowmap: boolean;
  59433. /**
  59434. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59435. * makes the reflect vector face the model (under horizon).
  59436. */
  59437. protected _useHorizonOcclusion: boolean;
  59438. /**
  59439. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59440. * too much the area relying on ambient texture to define their ambient occlusion.
  59441. */
  59442. protected _useRadianceOcclusion: boolean;
  59443. /**
  59444. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59445. */
  59446. protected _useAlphaFromAlbedoTexture: boolean;
  59447. /**
  59448. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59449. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59450. */
  59451. protected _useSpecularOverAlpha: boolean;
  59452. /**
  59453. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59454. */
  59455. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59456. /**
  59457. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59458. */
  59459. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59460. /**
  59461. * Specifies if the metallic texture contains the roughness information in its green channel.
  59462. */
  59463. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59464. /**
  59465. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59466. */
  59467. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59468. /**
  59469. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59470. */
  59471. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59472. /**
  59473. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59474. */
  59475. protected _useAmbientInGrayScale: boolean;
  59476. /**
  59477. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59478. * The material will try to infer what glossiness each pixel should be.
  59479. */
  59480. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59481. /**
  59482. * Defines the falloff type used in this material.
  59483. * It by default is Physical.
  59484. */
  59485. protected _lightFalloff: number;
  59486. /**
  59487. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59488. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59489. */
  59490. protected _useRadianceOverAlpha: boolean;
  59491. /**
  59492. * Allows using an object space normal map (instead of tangent space).
  59493. */
  59494. protected _useObjectSpaceNormalMap: boolean;
  59495. /**
  59496. * Allows using the bump map in parallax mode.
  59497. */
  59498. protected _useParallax: boolean;
  59499. /**
  59500. * Allows using the bump map in parallax occlusion mode.
  59501. */
  59502. protected _useParallaxOcclusion: boolean;
  59503. /**
  59504. * Controls the scale bias of the parallax mode.
  59505. */
  59506. protected _parallaxScaleBias: number;
  59507. /**
  59508. * If sets to true, disables all the lights affecting the material.
  59509. */
  59510. protected _disableLighting: boolean;
  59511. /**
  59512. * Number of Simultaneous lights allowed on the material.
  59513. */
  59514. protected _maxSimultaneousLights: number;
  59515. /**
  59516. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59517. */
  59518. protected _invertNormalMapX: boolean;
  59519. /**
  59520. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59521. */
  59522. protected _invertNormalMapY: boolean;
  59523. /**
  59524. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59525. */
  59526. protected _twoSidedLighting: boolean;
  59527. /**
  59528. * Defines the alpha limits in alpha test mode.
  59529. */
  59530. protected _alphaCutOff: number;
  59531. /**
  59532. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59533. */
  59534. protected _forceAlphaTest: boolean;
  59535. /**
  59536. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59537. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59538. */
  59539. protected _useAlphaFresnel: boolean;
  59540. /**
  59541. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59542. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59543. */
  59544. protected _useLinearAlphaFresnel: boolean;
  59545. /**
  59546. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59547. * from cos thetav and roughness:
  59548. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59549. */
  59550. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59551. /**
  59552. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59553. */
  59554. protected _forceIrradianceInFragment: boolean;
  59555. private _realTimeFiltering;
  59556. /**
  59557. * Enables realtime filtering on the texture.
  59558. */
  59559. get realTimeFiltering(): boolean;
  59560. set realTimeFiltering(b: boolean);
  59561. private _realTimeFilteringQuality;
  59562. /**
  59563. * Quality switch for realtime filtering
  59564. */
  59565. get realTimeFilteringQuality(): number;
  59566. set realTimeFilteringQuality(n: number);
  59567. /**
  59568. * Can this material render to several textures at once
  59569. */
  59570. get canRenderToMRT(): boolean;
  59571. /**
  59572. * Force normal to face away from face.
  59573. */
  59574. protected _forceNormalForward: boolean;
  59575. /**
  59576. * Enables specular anti aliasing in the PBR shader.
  59577. * It will both interacts on the Geometry for analytical and IBL lighting.
  59578. * It also prefilter the roughness map based on the bump values.
  59579. */
  59580. protected _enableSpecularAntiAliasing: boolean;
  59581. /**
  59582. * Default configuration related to image processing available in the PBR Material.
  59583. */
  59584. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59585. /**
  59586. * Keep track of the image processing observer to allow dispose and replace.
  59587. */
  59588. private _imageProcessingObserver;
  59589. /**
  59590. * Attaches a new image processing configuration to the PBR Material.
  59591. * @param configuration
  59592. */
  59593. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59594. /**
  59595. * Stores the available render targets.
  59596. */
  59597. private _renderTargets;
  59598. /**
  59599. * Sets the global ambient color for the material used in lighting calculations.
  59600. */
  59601. private _globalAmbientColor;
  59602. /**
  59603. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59604. */
  59605. private _useLogarithmicDepth;
  59606. /**
  59607. * If set to true, no lighting calculations will be applied.
  59608. */
  59609. private _unlit;
  59610. private _debugMode;
  59611. /**
  59612. * @hidden
  59613. * This is reserved for the inspector.
  59614. * Defines the material debug mode.
  59615. * It helps seeing only some components of the material while troubleshooting.
  59616. */
  59617. debugMode: number;
  59618. /**
  59619. * @hidden
  59620. * This is reserved for the inspector.
  59621. * Specify from where on screen the debug mode should start.
  59622. * The value goes from -1 (full screen) to 1 (not visible)
  59623. * It helps with side by side comparison against the final render
  59624. * This defaults to -1
  59625. */
  59626. private debugLimit;
  59627. /**
  59628. * @hidden
  59629. * This is reserved for the inspector.
  59630. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59631. * You can use the factor to better multiply the final value.
  59632. */
  59633. private debugFactor;
  59634. /**
  59635. * Defines the clear coat layer parameters for the material.
  59636. */
  59637. readonly clearCoat: PBRClearCoatConfiguration;
  59638. /**
  59639. * Defines the anisotropic parameters for the material.
  59640. */
  59641. readonly anisotropy: PBRAnisotropicConfiguration;
  59642. /**
  59643. * Defines the BRDF parameters for the material.
  59644. */
  59645. readonly brdf: PBRBRDFConfiguration;
  59646. /**
  59647. * Defines the Sheen parameters for the material.
  59648. */
  59649. readonly sheen: PBRSheenConfiguration;
  59650. /**
  59651. * Defines the SubSurface parameters for the material.
  59652. */
  59653. readonly subSurface: PBRSubSurfaceConfiguration;
  59654. /**
  59655. * Defines the detail map parameters for the material.
  59656. */
  59657. readonly detailMap: DetailMapConfiguration;
  59658. protected _rebuildInParallel: boolean;
  59659. /**
  59660. * Instantiates a new PBRMaterial instance.
  59661. *
  59662. * @param name The material name
  59663. * @param scene The scene the material will be use in.
  59664. */
  59665. constructor(name: string, scene: Scene);
  59666. /**
  59667. * Gets a boolean indicating that current material needs to register RTT
  59668. */
  59669. get hasRenderTargetTextures(): boolean;
  59670. /**
  59671. * Gets the name of the material class.
  59672. */
  59673. getClassName(): string;
  59674. /**
  59675. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59676. */
  59677. get useLogarithmicDepth(): boolean;
  59678. /**
  59679. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59680. */
  59681. set useLogarithmicDepth(value: boolean);
  59682. /**
  59683. * Returns true if alpha blending should be disabled.
  59684. */
  59685. protected get _disableAlphaBlending(): boolean;
  59686. /**
  59687. * Specifies whether or not this material should be rendered in alpha blend mode.
  59688. */
  59689. needAlphaBlending(): boolean;
  59690. /**
  59691. * Specifies whether or not this material should be rendered in alpha test mode.
  59692. */
  59693. needAlphaTesting(): boolean;
  59694. /**
  59695. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59696. */
  59697. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59698. /**
  59699. * Gets the texture used for the alpha test.
  59700. */
  59701. getAlphaTestTexture(): Nullable<BaseTexture>;
  59702. /**
  59703. * Specifies that the submesh is ready to be used.
  59704. * @param mesh - BJS mesh.
  59705. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59706. * @param useInstances - Specifies that instances should be used.
  59707. * @returns - boolean indicating that the submesh is ready or not.
  59708. */
  59709. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59710. /**
  59711. * Specifies if the material uses metallic roughness workflow.
  59712. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59713. */
  59714. isMetallicWorkflow(): boolean;
  59715. private _prepareEffect;
  59716. private _prepareDefines;
  59717. /**
  59718. * Force shader compilation
  59719. */
  59720. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59721. /**
  59722. * Initializes the uniform buffer layout for the shader.
  59723. */
  59724. buildUniformLayout(): void;
  59725. /**
  59726. * Unbinds the material from the mesh
  59727. */
  59728. unbind(): void;
  59729. /**
  59730. * Binds the submesh data.
  59731. * @param world - The world matrix.
  59732. * @param mesh - The BJS mesh.
  59733. * @param subMesh - A submesh of the BJS mesh.
  59734. */
  59735. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59736. /**
  59737. * Returns the animatable textures.
  59738. * @returns - Array of animatable textures.
  59739. */
  59740. getAnimatables(): IAnimatable[];
  59741. /**
  59742. * Returns the texture used for reflections.
  59743. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59744. */
  59745. private _getReflectionTexture;
  59746. /**
  59747. * Returns an array of the actively used textures.
  59748. * @returns - Array of BaseTextures
  59749. */
  59750. getActiveTextures(): BaseTexture[];
  59751. /**
  59752. * Checks to see if a texture is used in the material.
  59753. * @param texture - Base texture to use.
  59754. * @returns - Boolean specifying if a texture is used in the material.
  59755. */
  59756. hasTexture(texture: BaseTexture): boolean;
  59757. /**
  59758. * Sets the required values to the prepass renderer.
  59759. * @param prePassRenderer defines the prepass renderer to setup
  59760. */
  59761. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59762. /**
  59763. * Disposes the resources of the material.
  59764. * @param forceDisposeEffect - Forces the disposal of effects.
  59765. * @param forceDisposeTextures - Forces the disposal of all textures.
  59766. */
  59767. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59768. }
  59769. }
  59770. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59771. import { Nullable } from "babylonjs/types";
  59772. import { Scene } from "babylonjs/scene";
  59773. import { Color3 } from "babylonjs/Maths/math.color";
  59774. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59775. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59777. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59778. /**
  59779. * The Physically based material of BJS.
  59780. *
  59781. * This offers the main features of a standard PBR material.
  59782. * For more information, please refer to the documentation :
  59783. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59784. */
  59785. export class PBRMaterial extends PBRBaseMaterial {
  59786. /**
  59787. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59788. */
  59789. static readonly PBRMATERIAL_OPAQUE: number;
  59790. /**
  59791. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59792. */
  59793. static readonly PBRMATERIAL_ALPHATEST: number;
  59794. /**
  59795. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59796. */
  59797. static readonly PBRMATERIAL_ALPHABLEND: number;
  59798. /**
  59799. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59800. * They are also discarded below the alpha cutoff threshold to improve performances.
  59801. */
  59802. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59803. /**
  59804. * Defines the default value of how much AO map is occluding the analytical lights
  59805. * (point spot...).
  59806. */
  59807. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59808. /**
  59809. * Intensity of the direct lights e.g. the four lights available in your scene.
  59810. * This impacts both the direct diffuse and specular highlights.
  59811. */
  59812. directIntensity: number;
  59813. /**
  59814. * Intensity of the emissive part of the material.
  59815. * This helps controlling the emissive effect without modifying the emissive color.
  59816. */
  59817. emissiveIntensity: number;
  59818. /**
  59819. * Intensity of the environment e.g. how much the environment will light the object
  59820. * either through harmonics for rough material or through the refelction for shiny ones.
  59821. */
  59822. environmentIntensity: number;
  59823. /**
  59824. * This is a special control allowing the reduction of the specular highlights coming from the
  59825. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59826. */
  59827. specularIntensity: number;
  59828. /**
  59829. * Debug Control allowing disabling the bump map on this material.
  59830. */
  59831. disableBumpMap: boolean;
  59832. /**
  59833. * AKA Diffuse Texture in standard nomenclature.
  59834. */
  59835. albedoTexture: BaseTexture;
  59836. /**
  59837. * AKA Occlusion Texture in other nomenclature.
  59838. */
  59839. ambientTexture: BaseTexture;
  59840. /**
  59841. * AKA Occlusion Texture Intensity in other nomenclature.
  59842. */
  59843. ambientTextureStrength: number;
  59844. /**
  59845. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59846. * 1 means it completely occludes it
  59847. * 0 mean it has no impact
  59848. */
  59849. ambientTextureImpactOnAnalyticalLights: number;
  59850. /**
  59851. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59852. */
  59853. opacityTexture: BaseTexture;
  59854. /**
  59855. * Stores the reflection values in a texture.
  59856. */
  59857. reflectionTexture: Nullable<BaseTexture>;
  59858. /**
  59859. * Stores the emissive values in a texture.
  59860. */
  59861. emissiveTexture: BaseTexture;
  59862. /**
  59863. * AKA Specular texture in other nomenclature.
  59864. */
  59865. reflectivityTexture: BaseTexture;
  59866. /**
  59867. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59868. */
  59869. metallicTexture: BaseTexture;
  59870. /**
  59871. * Specifies the metallic scalar of the metallic/roughness workflow.
  59872. * Can also be used to scale the metalness values of the metallic texture.
  59873. */
  59874. metallic: Nullable<number>;
  59875. /**
  59876. * Specifies the roughness scalar of the metallic/roughness workflow.
  59877. * Can also be used to scale the roughness values of the metallic texture.
  59878. */
  59879. roughness: Nullable<number>;
  59880. /**
  59881. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59882. * By default the indexOfrefraction is used to compute F0;
  59883. *
  59884. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59885. *
  59886. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59887. * F90 = metallicReflectanceColor;
  59888. */
  59889. metallicF0Factor: number;
  59890. /**
  59891. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59892. * By default the F90 is always 1;
  59893. *
  59894. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59895. *
  59896. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59897. * F90 = metallicReflectanceColor;
  59898. */
  59899. metallicReflectanceColor: Color3;
  59900. /**
  59901. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59902. * This is multiply against the scalar values defined in the material.
  59903. */
  59904. metallicReflectanceTexture: Nullable<BaseTexture>;
  59905. /**
  59906. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59907. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59908. */
  59909. microSurfaceTexture: BaseTexture;
  59910. /**
  59911. * Stores surface normal data used to displace a mesh in a texture.
  59912. */
  59913. bumpTexture: BaseTexture;
  59914. /**
  59915. * Stores the pre-calculated light information of a mesh in a texture.
  59916. */
  59917. lightmapTexture: BaseTexture;
  59918. /**
  59919. * Stores the refracted light information in a texture.
  59920. */
  59921. get refractionTexture(): Nullable<BaseTexture>;
  59922. set refractionTexture(value: Nullable<BaseTexture>);
  59923. /**
  59924. * The color of a material in ambient lighting.
  59925. */
  59926. ambientColor: Color3;
  59927. /**
  59928. * AKA Diffuse Color in other nomenclature.
  59929. */
  59930. albedoColor: Color3;
  59931. /**
  59932. * AKA Specular Color in other nomenclature.
  59933. */
  59934. reflectivityColor: Color3;
  59935. /**
  59936. * The color reflected from the material.
  59937. */
  59938. reflectionColor: Color3;
  59939. /**
  59940. * The color emitted from the material.
  59941. */
  59942. emissiveColor: Color3;
  59943. /**
  59944. * AKA Glossiness in other nomenclature.
  59945. */
  59946. microSurface: number;
  59947. /**
  59948. * Index of refraction of the material base layer.
  59949. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59950. *
  59951. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59952. *
  59953. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59954. */
  59955. get indexOfRefraction(): number;
  59956. set indexOfRefraction(value: number);
  59957. /**
  59958. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59959. */
  59960. get invertRefractionY(): boolean;
  59961. set invertRefractionY(value: boolean);
  59962. /**
  59963. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59964. * Materials half opaque for instance using refraction could benefit from this control.
  59965. */
  59966. get linkRefractionWithTransparency(): boolean;
  59967. set linkRefractionWithTransparency(value: boolean);
  59968. /**
  59969. * If true, the light map contains occlusion information instead of lighting info.
  59970. */
  59971. useLightmapAsShadowmap: boolean;
  59972. /**
  59973. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59974. */
  59975. useAlphaFromAlbedoTexture: boolean;
  59976. /**
  59977. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59978. */
  59979. forceAlphaTest: boolean;
  59980. /**
  59981. * Defines the alpha limits in alpha test mode.
  59982. */
  59983. alphaCutOff: number;
  59984. /**
  59985. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59986. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59987. */
  59988. useSpecularOverAlpha: boolean;
  59989. /**
  59990. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59991. */
  59992. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59993. /**
  59994. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59995. */
  59996. useRoughnessFromMetallicTextureAlpha: boolean;
  59997. /**
  59998. * Specifies if the metallic texture contains the roughness information in its green channel.
  59999. */
  60000. useRoughnessFromMetallicTextureGreen: boolean;
  60001. /**
  60002. * Specifies if the metallic texture contains the metallness information in its blue channel.
  60003. */
  60004. useMetallnessFromMetallicTextureBlue: boolean;
  60005. /**
  60006. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  60007. */
  60008. useAmbientOcclusionFromMetallicTextureRed: boolean;
  60009. /**
  60010. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  60011. */
  60012. useAmbientInGrayScale: boolean;
  60013. /**
  60014. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  60015. * The material will try to infer what glossiness each pixel should be.
  60016. */
  60017. useAutoMicroSurfaceFromReflectivityMap: boolean;
  60018. /**
  60019. * BJS is using an harcoded light falloff based on a manually sets up range.
  60020. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60021. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60022. */
  60023. get usePhysicalLightFalloff(): boolean;
  60024. /**
  60025. * BJS is using an harcoded light falloff based on a manually sets up range.
  60026. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60027. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60028. */
  60029. set usePhysicalLightFalloff(value: boolean);
  60030. /**
  60031. * In order to support the falloff compatibility with gltf, a special mode has been added
  60032. * to reproduce the gltf light falloff.
  60033. */
  60034. get useGLTFLightFalloff(): boolean;
  60035. /**
  60036. * In order to support the falloff compatibility with gltf, a special mode has been added
  60037. * to reproduce the gltf light falloff.
  60038. */
  60039. set useGLTFLightFalloff(value: boolean);
  60040. /**
  60041. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  60042. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  60043. */
  60044. useRadianceOverAlpha: boolean;
  60045. /**
  60046. * Allows using an object space normal map (instead of tangent space).
  60047. */
  60048. useObjectSpaceNormalMap: boolean;
  60049. /**
  60050. * Allows using the bump map in parallax mode.
  60051. */
  60052. useParallax: boolean;
  60053. /**
  60054. * Allows using the bump map in parallax occlusion mode.
  60055. */
  60056. useParallaxOcclusion: boolean;
  60057. /**
  60058. * Controls the scale bias of the parallax mode.
  60059. */
  60060. parallaxScaleBias: number;
  60061. /**
  60062. * If sets to true, disables all the lights affecting the material.
  60063. */
  60064. disableLighting: boolean;
  60065. /**
  60066. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  60067. */
  60068. forceIrradianceInFragment: boolean;
  60069. /**
  60070. * Number of Simultaneous lights allowed on the material.
  60071. */
  60072. maxSimultaneousLights: number;
  60073. /**
  60074. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60075. */
  60076. invertNormalMapX: boolean;
  60077. /**
  60078. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60079. */
  60080. invertNormalMapY: boolean;
  60081. /**
  60082. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60083. */
  60084. twoSidedLighting: boolean;
  60085. /**
  60086. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60087. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  60088. */
  60089. useAlphaFresnel: boolean;
  60090. /**
  60091. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60092. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  60093. */
  60094. useLinearAlphaFresnel: boolean;
  60095. /**
  60096. * Let user defines the brdf lookup texture used for IBL.
  60097. * A default 8bit version is embedded but you could point at :
  60098. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  60099. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  60100. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  60101. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  60102. */
  60103. environmentBRDFTexture: Nullable<BaseTexture>;
  60104. /**
  60105. * Force normal to face away from face.
  60106. */
  60107. forceNormalForward: boolean;
  60108. /**
  60109. * Enables specular anti aliasing in the PBR shader.
  60110. * It will both interacts on the Geometry for analytical and IBL lighting.
  60111. * It also prefilter the roughness map based on the bump values.
  60112. */
  60113. enableSpecularAntiAliasing: boolean;
  60114. /**
  60115. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60116. * makes the reflect vector face the model (under horizon).
  60117. */
  60118. useHorizonOcclusion: boolean;
  60119. /**
  60120. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60121. * too much the area relying on ambient texture to define their ambient occlusion.
  60122. */
  60123. useRadianceOcclusion: boolean;
  60124. /**
  60125. * If set to true, no lighting calculations will be applied.
  60126. */
  60127. unlit: boolean;
  60128. /**
  60129. * Gets the image processing configuration used either in this material.
  60130. */
  60131. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60132. /**
  60133. * Sets the Default image processing configuration used either in the this material.
  60134. *
  60135. * If sets to null, the scene one is in use.
  60136. */
  60137. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60138. /**
  60139. * Gets wether the color curves effect is enabled.
  60140. */
  60141. get cameraColorCurvesEnabled(): boolean;
  60142. /**
  60143. * Sets wether the color curves effect is enabled.
  60144. */
  60145. set cameraColorCurvesEnabled(value: boolean);
  60146. /**
  60147. * Gets wether the color grading effect is enabled.
  60148. */
  60149. get cameraColorGradingEnabled(): boolean;
  60150. /**
  60151. * Gets wether the color grading effect is enabled.
  60152. */
  60153. set cameraColorGradingEnabled(value: boolean);
  60154. /**
  60155. * Gets wether tonemapping is enabled or not.
  60156. */
  60157. get cameraToneMappingEnabled(): boolean;
  60158. /**
  60159. * Sets wether tonemapping is enabled or not
  60160. */
  60161. set cameraToneMappingEnabled(value: boolean);
  60162. /**
  60163. * The camera exposure used on this material.
  60164. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60165. * This corresponds to a photographic exposure.
  60166. */
  60167. get cameraExposure(): number;
  60168. /**
  60169. * The camera exposure used on this material.
  60170. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60171. * This corresponds to a photographic exposure.
  60172. */
  60173. set cameraExposure(value: number);
  60174. /**
  60175. * Gets The camera contrast used on this material.
  60176. */
  60177. get cameraContrast(): number;
  60178. /**
  60179. * Sets The camera contrast used on this material.
  60180. */
  60181. set cameraContrast(value: number);
  60182. /**
  60183. * Gets the Color Grading 2D Lookup Texture.
  60184. */
  60185. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60186. /**
  60187. * Sets the Color Grading 2D Lookup Texture.
  60188. */
  60189. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60190. /**
  60191. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60192. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60193. * 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;
  60194. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60195. */
  60196. get cameraColorCurves(): Nullable<ColorCurves>;
  60197. /**
  60198. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60199. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60200. * 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;
  60201. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60202. */
  60203. set cameraColorCurves(value: Nullable<ColorCurves>);
  60204. /**
  60205. * Instantiates a new PBRMaterial instance.
  60206. *
  60207. * @param name The material name
  60208. * @param scene The scene the material will be use in.
  60209. */
  60210. constructor(name: string, scene: Scene);
  60211. /**
  60212. * Returns the name of this material class.
  60213. */
  60214. getClassName(): string;
  60215. /**
  60216. * Makes a duplicate of the current material.
  60217. * @param name - name to use for the new material.
  60218. */
  60219. clone(name: string): PBRMaterial;
  60220. /**
  60221. * Serializes this PBR Material.
  60222. * @returns - An object with the serialized material.
  60223. */
  60224. serialize(): any;
  60225. /**
  60226. * Parses a PBR Material from a serialized object.
  60227. * @param source - Serialized object.
  60228. * @param scene - BJS scene instance.
  60229. * @param rootUrl - url for the scene object
  60230. * @returns - PBRMaterial
  60231. */
  60232. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60233. }
  60234. }
  60235. declare module "babylonjs/Misc/dds" {
  60236. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60238. import { Nullable } from "babylonjs/types";
  60239. import { Scene } from "babylonjs/scene";
  60240. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60241. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60242. /**
  60243. * Direct draw surface info
  60244. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60245. */
  60246. export interface DDSInfo {
  60247. /**
  60248. * Width of the texture
  60249. */
  60250. width: number;
  60251. /**
  60252. * Width of the texture
  60253. */
  60254. height: number;
  60255. /**
  60256. * Number of Mipmaps for the texture
  60257. * @see https://en.wikipedia.org/wiki/Mipmap
  60258. */
  60259. mipmapCount: number;
  60260. /**
  60261. * If the textures format is a known fourCC format
  60262. * @see https://www.fourcc.org/
  60263. */
  60264. isFourCC: boolean;
  60265. /**
  60266. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60267. */
  60268. isRGB: boolean;
  60269. /**
  60270. * If the texture is a lumincance format
  60271. */
  60272. isLuminance: boolean;
  60273. /**
  60274. * If this is a cube texture
  60275. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60276. */
  60277. isCube: boolean;
  60278. /**
  60279. * If the texture is a compressed format eg. FOURCC_DXT1
  60280. */
  60281. isCompressed: boolean;
  60282. /**
  60283. * The dxgiFormat of the texture
  60284. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60285. */
  60286. dxgiFormat: number;
  60287. /**
  60288. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60289. */
  60290. textureType: number;
  60291. /**
  60292. * Sphericle polynomial created for the dds texture
  60293. */
  60294. sphericalPolynomial?: SphericalPolynomial;
  60295. }
  60296. /**
  60297. * Class used to provide DDS decompression tools
  60298. */
  60299. export class DDSTools {
  60300. /**
  60301. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60302. */
  60303. static StoreLODInAlphaChannel: boolean;
  60304. /**
  60305. * Gets DDS information from an array buffer
  60306. * @param data defines the array buffer view to read data from
  60307. * @returns the DDS information
  60308. */
  60309. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60310. private static _FloatView;
  60311. private static _Int32View;
  60312. private static _ToHalfFloat;
  60313. private static _FromHalfFloat;
  60314. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60315. private static _GetHalfFloatRGBAArrayBuffer;
  60316. private static _GetFloatRGBAArrayBuffer;
  60317. private static _GetFloatAsUIntRGBAArrayBuffer;
  60318. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60319. private static _GetRGBAArrayBuffer;
  60320. private static _ExtractLongWordOrder;
  60321. private static _GetRGBArrayBuffer;
  60322. private static _GetLuminanceArrayBuffer;
  60323. /**
  60324. * Uploads DDS Levels to a Babylon Texture
  60325. * @hidden
  60326. */
  60327. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60328. }
  60329. module "babylonjs/Engines/thinEngine" {
  60330. interface ThinEngine {
  60331. /**
  60332. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60333. * @param rootUrl defines the url where the file to load is located
  60334. * @param scene defines the current scene
  60335. * @param lodScale defines scale to apply to the mip map selection
  60336. * @param lodOffset defines offset to apply to the mip map selection
  60337. * @param onLoad defines an optional callback raised when the texture is loaded
  60338. * @param onError defines an optional callback raised if there is an issue to load the texture
  60339. * @param format defines the format of the data
  60340. * @param forcedExtension defines the extension to use to pick the right loader
  60341. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60342. * @returns the cube texture as an InternalTexture
  60343. */
  60344. 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;
  60345. }
  60346. }
  60347. }
  60348. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60349. import { Nullable } from "babylonjs/types";
  60350. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60351. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60352. /**
  60353. * Implementation of the DDS Texture Loader.
  60354. * @hidden
  60355. */
  60356. export class _DDSTextureLoader implements IInternalTextureLoader {
  60357. /**
  60358. * Defines wether the loader supports cascade loading the different faces.
  60359. */
  60360. readonly supportCascades: boolean;
  60361. /**
  60362. * This returns if the loader support the current file information.
  60363. * @param extension defines the file extension of the file being loaded
  60364. * @returns true if the loader can load the specified file
  60365. */
  60366. canLoad(extension: string): boolean;
  60367. /**
  60368. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60369. * @param data contains the texture data
  60370. * @param texture defines the BabylonJS internal texture
  60371. * @param createPolynomials will be true if polynomials have been requested
  60372. * @param onLoad defines the callback to trigger once the texture is ready
  60373. * @param onError defines the callback to trigger in case of error
  60374. */
  60375. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60376. /**
  60377. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60378. * @param data contains the texture data
  60379. * @param texture defines the BabylonJS internal texture
  60380. * @param callback defines the method to call once ready to upload
  60381. */
  60382. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60383. }
  60384. }
  60385. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60386. import { Nullable } from "babylonjs/types";
  60387. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60388. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60389. /**
  60390. * Implementation of the ENV Texture Loader.
  60391. * @hidden
  60392. */
  60393. export class _ENVTextureLoader implements IInternalTextureLoader {
  60394. /**
  60395. * Defines wether the loader supports cascade loading the different faces.
  60396. */
  60397. readonly supportCascades: boolean;
  60398. /**
  60399. * This returns if the loader support the current file information.
  60400. * @param extension defines the file extension of the file being loaded
  60401. * @returns true if the loader can load the specified file
  60402. */
  60403. canLoad(extension: string): boolean;
  60404. /**
  60405. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60406. * @param data contains the texture data
  60407. * @param texture defines the BabylonJS internal texture
  60408. * @param createPolynomials will be true if polynomials have been requested
  60409. * @param onLoad defines the callback to trigger once the texture is ready
  60410. * @param onError defines the callback to trigger in case of error
  60411. */
  60412. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60413. /**
  60414. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60415. * @param data contains the texture data
  60416. * @param texture defines the BabylonJS internal texture
  60417. * @param callback defines the method to call once ready to upload
  60418. */
  60419. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60420. }
  60421. }
  60422. declare module "babylonjs/Misc/khronosTextureContainer" {
  60423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60424. /**
  60425. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60426. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60427. */
  60428. export class KhronosTextureContainer {
  60429. /** contents of the KTX container file */
  60430. data: ArrayBufferView;
  60431. private static HEADER_LEN;
  60432. private static COMPRESSED_2D;
  60433. private static COMPRESSED_3D;
  60434. private static TEX_2D;
  60435. private static TEX_3D;
  60436. /**
  60437. * Gets the openGL type
  60438. */
  60439. glType: number;
  60440. /**
  60441. * Gets the openGL type size
  60442. */
  60443. glTypeSize: number;
  60444. /**
  60445. * Gets the openGL format
  60446. */
  60447. glFormat: number;
  60448. /**
  60449. * Gets the openGL internal format
  60450. */
  60451. glInternalFormat: number;
  60452. /**
  60453. * Gets the base internal format
  60454. */
  60455. glBaseInternalFormat: number;
  60456. /**
  60457. * Gets image width in pixel
  60458. */
  60459. pixelWidth: number;
  60460. /**
  60461. * Gets image height in pixel
  60462. */
  60463. pixelHeight: number;
  60464. /**
  60465. * Gets image depth in pixels
  60466. */
  60467. pixelDepth: number;
  60468. /**
  60469. * Gets the number of array elements
  60470. */
  60471. numberOfArrayElements: number;
  60472. /**
  60473. * Gets the number of faces
  60474. */
  60475. numberOfFaces: number;
  60476. /**
  60477. * Gets the number of mipmap levels
  60478. */
  60479. numberOfMipmapLevels: number;
  60480. /**
  60481. * Gets the bytes of key value data
  60482. */
  60483. bytesOfKeyValueData: number;
  60484. /**
  60485. * Gets the load type
  60486. */
  60487. loadType: number;
  60488. /**
  60489. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60490. */
  60491. isInvalid: boolean;
  60492. /**
  60493. * Creates a new KhronosTextureContainer
  60494. * @param data contents of the KTX container file
  60495. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60496. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60497. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60498. */
  60499. constructor(
  60500. /** contents of the KTX container file */
  60501. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60502. /**
  60503. * Uploads KTX content to a Babylon Texture.
  60504. * It is assumed that the texture has already been created & is currently bound
  60505. * @hidden
  60506. */
  60507. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60508. private _upload2DCompressedLevels;
  60509. /**
  60510. * Checks if the given data starts with a KTX file identifier.
  60511. * @param data the data to check
  60512. * @returns true if the data is a KTX file or false otherwise
  60513. */
  60514. static IsValid(data: ArrayBufferView): boolean;
  60515. }
  60516. }
  60517. declare module "babylonjs/Misc/workerPool" {
  60518. import { IDisposable } from "babylonjs/scene";
  60519. /**
  60520. * Helper class to push actions to a pool of workers.
  60521. */
  60522. export class WorkerPool implements IDisposable {
  60523. private _workerInfos;
  60524. private _pendingActions;
  60525. /**
  60526. * Constructor
  60527. * @param workers Array of workers to use for actions
  60528. */
  60529. constructor(workers: Array<Worker>);
  60530. /**
  60531. * Terminates all workers and clears any pending actions.
  60532. */
  60533. dispose(): void;
  60534. /**
  60535. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60536. * pended until a worker has completed its action.
  60537. * @param action The action to perform. Call onComplete when the action is complete.
  60538. */
  60539. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60540. private _execute;
  60541. }
  60542. }
  60543. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60544. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60545. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60546. /**
  60547. * Class for loading KTX2 files
  60548. * @hidden
  60549. */
  60550. export class KhronosTextureContainer2 {
  60551. private static _WorkerPoolPromise?;
  60552. private static _Initialized;
  60553. private static _Ktx2Decoder;
  60554. /**
  60555. * URL to use when loading the KTX2 decoder module
  60556. */
  60557. static JSModuleURL: string;
  60558. /**
  60559. * Default number of workers used to handle data decoding
  60560. */
  60561. static DefaultNumWorkers: number;
  60562. private static GetDefaultNumWorkers;
  60563. private _engine;
  60564. private static _CreateWorkerPool;
  60565. /**
  60566. * Constructor
  60567. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60568. */
  60569. constructor(engine: ThinEngine, numWorkers?: number);
  60570. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60571. /**
  60572. * Stop all async operations and release resources.
  60573. */
  60574. dispose(): void;
  60575. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60576. /**
  60577. * Checks if the given data starts with a KTX2 file identifier.
  60578. * @param data the data to check
  60579. * @returns true if the data is a KTX2 file or false otherwise
  60580. */
  60581. static IsValid(data: ArrayBufferView): boolean;
  60582. }
  60583. export function workerFunc(): void;
  60584. }
  60585. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60586. import { Nullable } from "babylonjs/types";
  60587. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60588. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60589. /**
  60590. * Implementation of the KTX Texture Loader.
  60591. * @hidden
  60592. */
  60593. export class _KTXTextureLoader implements IInternalTextureLoader {
  60594. /**
  60595. * Defines wether the loader supports cascade loading the different faces.
  60596. */
  60597. readonly supportCascades: boolean;
  60598. /**
  60599. * This returns if the loader support the current file information.
  60600. * @param extension defines the file extension of the file being loaded
  60601. * @param mimeType defines the optional mime type of the file being loaded
  60602. * @returns true if the loader can load the specified file
  60603. */
  60604. canLoad(extension: string, mimeType?: string): boolean;
  60605. /**
  60606. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60607. * @param data contains the texture data
  60608. * @param texture defines the BabylonJS internal texture
  60609. * @param createPolynomials will be true if polynomials have been requested
  60610. * @param onLoad defines the callback to trigger once the texture is ready
  60611. * @param onError defines the callback to trigger in case of error
  60612. */
  60613. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60614. /**
  60615. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60616. * @param data contains the texture data
  60617. * @param texture defines the BabylonJS internal texture
  60618. * @param callback defines the method to call once ready to upload
  60619. */
  60620. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60621. }
  60622. }
  60623. declare module "babylonjs/Helpers/sceneHelpers" {
  60624. import { Nullable } from "babylonjs/types";
  60625. import { Mesh } from "babylonjs/Meshes/mesh";
  60626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60627. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60628. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60629. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60630. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60631. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60632. import "babylonjs/Meshes/Builders/boxBuilder";
  60633. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60634. /** @hidden */
  60635. export var _forceSceneHelpersToBundle: boolean;
  60636. module "babylonjs/scene" {
  60637. interface Scene {
  60638. /**
  60639. * Creates a default light for the scene.
  60640. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60641. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60642. */
  60643. createDefaultLight(replace?: boolean): void;
  60644. /**
  60645. * Creates a default camera for the scene.
  60646. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60647. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60648. * @param replace has default false, when true replaces the active camera in the scene
  60649. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60650. */
  60651. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60652. /**
  60653. * Creates a default camera and a default light.
  60654. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60655. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60656. * @param replace has the default false, when true replaces the active camera/light in the scene
  60657. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60658. */
  60659. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60660. /**
  60661. * Creates a new sky box
  60662. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60663. * @param environmentTexture defines the texture to use as environment texture
  60664. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60665. * @param scale defines the overall scale of the skybox
  60666. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60667. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60668. * @returns a new mesh holding the sky box
  60669. */
  60670. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60671. /**
  60672. * Creates a new environment
  60673. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60674. * @param options defines the options you can use to configure the environment
  60675. * @returns the new EnvironmentHelper
  60676. */
  60677. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60678. /**
  60679. * Creates a new VREXperienceHelper
  60680. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60681. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60682. * @returns a new VREXperienceHelper
  60683. */
  60684. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60685. /**
  60686. * Creates a new WebXRDefaultExperience
  60687. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60688. * @param options experience options
  60689. * @returns a promise for a new WebXRDefaultExperience
  60690. */
  60691. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60692. }
  60693. }
  60694. }
  60695. declare module "babylonjs/Helpers/videoDome" {
  60696. import { Scene } from "babylonjs/scene";
  60697. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60698. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60699. /**
  60700. * Display a 360/180 degree video 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 videos with different locations in the scene.
  60702. * This class achieves its effect with a VideoTexture 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 class VideoDome extends TextureDome<VideoTexture> {
  60706. /**
  60707. * Define the video source as a Monoscopic panoramic 360 video.
  60708. */
  60709. static readonly MODE_MONOSCOPIC: number;
  60710. /**
  60711. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60712. */
  60713. static readonly MODE_TOPBOTTOM: number;
  60714. /**
  60715. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60716. */
  60717. static readonly MODE_SIDEBYSIDE: number;
  60718. /**
  60719. * Get the video texture associated with this video dome
  60720. */
  60721. get videoTexture(): VideoTexture;
  60722. /**
  60723. * Get the video mode of this dome
  60724. */
  60725. get videoMode(): number;
  60726. /**
  60727. * Set the video mode of this dome.
  60728. * @see textureMode
  60729. */
  60730. set videoMode(value: number);
  60731. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60732. }
  60733. }
  60734. declare module "babylonjs/Helpers/index" {
  60735. export * from "babylonjs/Helpers/environmentHelper";
  60736. export * from "babylonjs/Helpers/photoDome";
  60737. export * from "babylonjs/Helpers/sceneHelpers";
  60738. export * from "babylonjs/Helpers/videoDome";
  60739. }
  60740. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60741. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60742. import { IDisposable } from "babylonjs/scene";
  60743. import { Engine } from "babylonjs/Engines/engine";
  60744. /**
  60745. * This class can be used to get instrumentation data from a Babylon engine
  60746. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60747. */
  60748. export class EngineInstrumentation implements IDisposable {
  60749. /**
  60750. * Define the instrumented engine.
  60751. */
  60752. engine: Engine;
  60753. private _captureGPUFrameTime;
  60754. private _gpuFrameTimeToken;
  60755. private _gpuFrameTime;
  60756. private _captureShaderCompilationTime;
  60757. private _shaderCompilationTime;
  60758. private _onBeginFrameObserver;
  60759. private _onEndFrameObserver;
  60760. private _onBeforeShaderCompilationObserver;
  60761. private _onAfterShaderCompilationObserver;
  60762. /**
  60763. * Gets the perf counter used for GPU frame time
  60764. */
  60765. get gpuFrameTimeCounter(): PerfCounter;
  60766. /**
  60767. * Gets the GPU frame time capture status
  60768. */
  60769. get captureGPUFrameTime(): boolean;
  60770. /**
  60771. * Enable or disable the GPU frame time capture
  60772. */
  60773. set captureGPUFrameTime(value: boolean);
  60774. /**
  60775. * Gets the perf counter used for shader compilation time
  60776. */
  60777. get shaderCompilationTimeCounter(): PerfCounter;
  60778. /**
  60779. * Gets the shader compilation time capture status
  60780. */
  60781. get captureShaderCompilationTime(): boolean;
  60782. /**
  60783. * Enable or disable the shader compilation time capture
  60784. */
  60785. set captureShaderCompilationTime(value: boolean);
  60786. /**
  60787. * Instantiates a new engine instrumentation.
  60788. * This class can be used to get instrumentation data from a Babylon engine
  60789. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60790. * @param engine Defines the engine to instrument
  60791. */
  60792. constructor(
  60793. /**
  60794. * Define the instrumented engine.
  60795. */
  60796. engine: Engine);
  60797. /**
  60798. * Dispose and release associated resources.
  60799. */
  60800. dispose(): void;
  60801. }
  60802. }
  60803. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60804. import { Scene, IDisposable } from "babylonjs/scene";
  60805. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60806. /**
  60807. * This class can be used to get instrumentation data from a Babylon engine
  60808. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60809. */
  60810. export class SceneInstrumentation implements IDisposable {
  60811. /**
  60812. * Defines the scene to instrument
  60813. */
  60814. scene: Scene;
  60815. private _captureActiveMeshesEvaluationTime;
  60816. private _activeMeshesEvaluationTime;
  60817. private _captureRenderTargetsRenderTime;
  60818. private _renderTargetsRenderTime;
  60819. private _captureFrameTime;
  60820. private _frameTime;
  60821. private _captureRenderTime;
  60822. private _renderTime;
  60823. private _captureInterFrameTime;
  60824. private _interFrameTime;
  60825. private _captureParticlesRenderTime;
  60826. private _particlesRenderTime;
  60827. private _captureSpritesRenderTime;
  60828. private _spritesRenderTime;
  60829. private _capturePhysicsTime;
  60830. private _physicsTime;
  60831. private _captureAnimationsTime;
  60832. private _animationsTime;
  60833. private _captureCameraRenderTime;
  60834. private _cameraRenderTime;
  60835. private _onBeforeActiveMeshesEvaluationObserver;
  60836. private _onAfterActiveMeshesEvaluationObserver;
  60837. private _onBeforeRenderTargetsRenderObserver;
  60838. private _onAfterRenderTargetsRenderObserver;
  60839. private _onAfterRenderObserver;
  60840. private _onBeforeDrawPhaseObserver;
  60841. private _onAfterDrawPhaseObserver;
  60842. private _onBeforeAnimationsObserver;
  60843. private _onBeforeParticlesRenderingObserver;
  60844. private _onAfterParticlesRenderingObserver;
  60845. private _onBeforeSpritesRenderingObserver;
  60846. private _onAfterSpritesRenderingObserver;
  60847. private _onBeforePhysicsObserver;
  60848. private _onAfterPhysicsObserver;
  60849. private _onAfterAnimationsObserver;
  60850. private _onBeforeCameraRenderObserver;
  60851. private _onAfterCameraRenderObserver;
  60852. /**
  60853. * Gets the perf counter used for active meshes evaluation time
  60854. */
  60855. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60856. /**
  60857. * Gets the active meshes evaluation time capture status
  60858. */
  60859. get captureActiveMeshesEvaluationTime(): boolean;
  60860. /**
  60861. * Enable or disable the active meshes evaluation time capture
  60862. */
  60863. set captureActiveMeshesEvaluationTime(value: boolean);
  60864. /**
  60865. * Gets the perf counter used for render targets render time
  60866. */
  60867. get renderTargetsRenderTimeCounter(): PerfCounter;
  60868. /**
  60869. * Gets the render targets render time capture status
  60870. */
  60871. get captureRenderTargetsRenderTime(): boolean;
  60872. /**
  60873. * Enable or disable the render targets render time capture
  60874. */
  60875. set captureRenderTargetsRenderTime(value: boolean);
  60876. /**
  60877. * Gets the perf counter used for particles render time
  60878. */
  60879. get particlesRenderTimeCounter(): PerfCounter;
  60880. /**
  60881. * Gets the particles render time capture status
  60882. */
  60883. get captureParticlesRenderTime(): boolean;
  60884. /**
  60885. * Enable or disable the particles render time capture
  60886. */
  60887. set captureParticlesRenderTime(value: boolean);
  60888. /**
  60889. * Gets the perf counter used for sprites render time
  60890. */
  60891. get spritesRenderTimeCounter(): PerfCounter;
  60892. /**
  60893. * Gets the sprites render time capture status
  60894. */
  60895. get captureSpritesRenderTime(): boolean;
  60896. /**
  60897. * Enable or disable the sprites render time capture
  60898. */
  60899. set captureSpritesRenderTime(value: boolean);
  60900. /**
  60901. * Gets the perf counter used for physics time
  60902. */
  60903. get physicsTimeCounter(): PerfCounter;
  60904. /**
  60905. * Gets the physics time capture status
  60906. */
  60907. get capturePhysicsTime(): boolean;
  60908. /**
  60909. * Enable or disable the physics time capture
  60910. */
  60911. set capturePhysicsTime(value: boolean);
  60912. /**
  60913. * Gets the perf counter used for animations time
  60914. */
  60915. get animationsTimeCounter(): PerfCounter;
  60916. /**
  60917. * Gets the animations time capture status
  60918. */
  60919. get captureAnimationsTime(): boolean;
  60920. /**
  60921. * Enable or disable the animations time capture
  60922. */
  60923. set captureAnimationsTime(value: boolean);
  60924. /**
  60925. * Gets the perf counter used for frame time capture
  60926. */
  60927. get frameTimeCounter(): PerfCounter;
  60928. /**
  60929. * Gets the frame time capture status
  60930. */
  60931. get captureFrameTime(): boolean;
  60932. /**
  60933. * Enable or disable the frame time capture
  60934. */
  60935. set captureFrameTime(value: boolean);
  60936. /**
  60937. * Gets the perf counter used for inter-frames time capture
  60938. */
  60939. get interFrameTimeCounter(): PerfCounter;
  60940. /**
  60941. * Gets the inter-frames time capture status
  60942. */
  60943. get captureInterFrameTime(): boolean;
  60944. /**
  60945. * Enable or disable the inter-frames time capture
  60946. */
  60947. set captureInterFrameTime(value: boolean);
  60948. /**
  60949. * Gets the perf counter used for render time capture
  60950. */
  60951. get renderTimeCounter(): PerfCounter;
  60952. /**
  60953. * Gets the render time capture status
  60954. */
  60955. get captureRenderTime(): boolean;
  60956. /**
  60957. * Enable or disable the render time capture
  60958. */
  60959. set captureRenderTime(value: boolean);
  60960. /**
  60961. * Gets the perf counter used for camera render time capture
  60962. */
  60963. get cameraRenderTimeCounter(): PerfCounter;
  60964. /**
  60965. * Gets the camera render time capture status
  60966. */
  60967. get captureCameraRenderTime(): boolean;
  60968. /**
  60969. * Enable or disable the camera render time capture
  60970. */
  60971. set captureCameraRenderTime(value: boolean);
  60972. /**
  60973. * Gets the perf counter used for draw calls
  60974. */
  60975. get drawCallsCounter(): PerfCounter;
  60976. /**
  60977. * Instantiates a new scene instrumentation.
  60978. * This class can be used to get instrumentation data from a Babylon engine
  60979. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60980. * @param scene Defines the scene to instrument
  60981. */
  60982. constructor(
  60983. /**
  60984. * Defines the scene to instrument
  60985. */
  60986. scene: Scene);
  60987. /**
  60988. * Dispose and release associated resources.
  60989. */
  60990. dispose(): void;
  60991. }
  60992. }
  60993. declare module "babylonjs/Instrumentation/index" {
  60994. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60995. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60996. export * from "babylonjs/Instrumentation/timeToken";
  60997. }
  60998. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60999. /** @hidden */
  61000. export var glowMapGenerationPixelShader: {
  61001. name: string;
  61002. shader: string;
  61003. };
  61004. }
  61005. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61006. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61007. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61008. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61009. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61010. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61011. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61012. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61013. /** @hidden */
  61014. export var glowMapGenerationVertexShader: {
  61015. name: string;
  61016. shader: string;
  61017. };
  61018. }
  61019. declare module "babylonjs/Layers/effectLayer" {
  61020. import { Observable } from "babylonjs/Misc/observable";
  61021. import { Nullable } from "babylonjs/types";
  61022. import { Camera } from "babylonjs/Cameras/camera";
  61023. import { Scene } from "babylonjs/scene";
  61024. import { ISize } from "babylonjs/Maths/math.size";
  61025. import { Color4 } from "babylonjs/Maths/math.color";
  61026. import { Engine } from "babylonjs/Engines/engine";
  61027. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61029. import { Mesh } from "babylonjs/Meshes/mesh";
  61030. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61031. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61032. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61033. import { Effect } from "babylonjs/Materials/effect";
  61034. import { Material } from "babylonjs/Materials/material";
  61035. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61036. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61037. /**
  61038. * Effect layer options. This helps customizing the behaviour
  61039. * of the effect layer.
  61040. */
  61041. export interface IEffectLayerOptions {
  61042. /**
  61043. * Multiplication factor apply to the canvas size to compute the render target size
  61044. * used to generated the objects (the smaller the faster).
  61045. */
  61046. mainTextureRatio: number;
  61047. /**
  61048. * Enforces a fixed size texture to ensure effect stability across devices.
  61049. */
  61050. mainTextureFixedSize?: number;
  61051. /**
  61052. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61053. */
  61054. alphaBlendingMode: number;
  61055. /**
  61056. * The camera attached to the layer.
  61057. */
  61058. camera: Nullable<Camera>;
  61059. /**
  61060. * The rendering group to draw the layer in.
  61061. */
  61062. renderingGroupId: number;
  61063. }
  61064. /**
  61065. * The effect layer Helps adding post process effect blended with the main pass.
  61066. *
  61067. * This can be for instance use to generate glow or higlight effects on the scene.
  61068. *
  61069. * The effect layer class can not be used directly and is intented to inherited from to be
  61070. * customized per effects.
  61071. */
  61072. export abstract class EffectLayer {
  61073. private _vertexBuffers;
  61074. private _indexBuffer;
  61075. private _cachedDefines;
  61076. private _effectLayerMapGenerationEffect;
  61077. private _effectLayerOptions;
  61078. private _mergeEffect;
  61079. protected _scene: Scene;
  61080. protected _engine: Engine;
  61081. protected _maxSize: number;
  61082. protected _mainTextureDesiredSize: ISize;
  61083. protected _mainTexture: RenderTargetTexture;
  61084. protected _shouldRender: boolean;
  61085. protected _postProcesses: PostProcess[];
  61086. protected _textures: BaseTexture[];
  61087. protected _emissiveTextureAndColor: {
  61088. texture: Nullable<BaseTexture>;
  61089. color: Color4;
  61090. };
  61091. /**
  61092. * The name of the layer
  61093. */
  61094. name: string;
  61095. /**
  61096. * The clear color of the texture used to generate the glow map.
  61097. */
  61098. neutralColor: Color4;
  61099. /**
  61100. * Specifies whether the highlight layer is enabled or not.
  61101. */
  61102. isEnabled: boolean;
  61103. /**
  61104. * Gets the camera attached to the layer.
  61105. */
  61106. get camera(): Nullable<Camera>;
  61107. /**
  61108. * Gets the rendering group id the layer should render in.
  61109. */
  61110. get renderingGroupId(): number;
  61111. set renderingGroupId(renderingGroupId: number);
  61112. /**
  61113. * An event triggered when the effect layer has been disposed.
  61114. */
  61115. onDisposeObservable: Observable<EffectLayer>;
  61116. /**
  61117. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61118. */
  61119. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61120. /**
  61121. * An event triggered when the generated texture is being merged in the scene.
  61122. */
  61123. onBeforeComposeObservable: Observable<EffectLayer>;
  61124. /**
  61125. * An event triggered when the mesh is rendered into the effect render target.
  61126. */
  61127. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61128. /**
  61129. * An event triggered after the mesh has been rendered into the effect render target.
  61130. */
  61131. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61132. /**
  61133. * An event triggered when the generated texture has been merged in the scene.
  61134. */
  61135. onAfterComposeObservable: Observable<EffectLayer>;
  61136. /**
  61137. * An event triggered when the efffect layer changes its size.
  61138. */
  61139. onSizeChangedObservable: Observable<EffectLayer>;
  61140. /** @hidden */
  61141. static _SceneComponentInitialization: (scene: Scene) => void;
  61142. /**
  61143. * Instantiates a new effect Layer and references it in the scene.
  61144. * @param name The name of the layer
  61145. * @param scene The scene to use the layer in
  61146. */
  61147. constructor(
  61148. /** The Friendly of the effect in the scene */
  61149. name: string, scene: Scene);
  61150. /**
  61151. * Get the effect name of the layer.
  61152. * @return The effect name
  61153. */
  61154. abstract getEffectName(): string;
  61155. /**
  61156. * Checks for the readiness of the element composing the layer.
  61157. * @param subMesh the mesh to check for
  61158. * @param useInstances specify whether or not to use instances to render the mesh
  61159. * @return true if ready otherwise, false
  61160. */
  61161. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61162. /**
  61163. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61164. * @returns true if the effect requires stencil during the main canvas render pass.
  61165. */
  61166. abstract needStencil(): boolean;
  61167. /**
  61168. * Create the merge effect. This is the shader use to blit the information back
  61169. * to the main canvas at the end of the scene rendering.
  61170. * @returns The effect containing the shader used to merge the effect on the main canvas
  61171. */
  61172. protected abstract _createMergeEffect(): Effect;
  61173. /**
  61174. * Creates the render target textures and post processes used in the effect layer.
  61175. */
  61176. protected abstract _createTextureAndPostProcesses(): void;
  61177. /**
  61178. * Implementation specific of rendering the generating effect on the main canvas.
  61179. * @param effect The effect used to render through
  61180. */
  61181. protected abstract _internalRender(effect: Effect): void;
  61182. /**
  61183. * Sets the required values for both the emissive texture and and the main color.
  61184. */
  61185. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61186. /**
  61187. * Free any resources and references associated to a mesh.
  61188. * Internal use
  61189. * @param mesh The mesh to free.
  61190. */
  61191. abstract _disposeMesh(mesh: Mesh): void;
  61192. /**
  61193. * Serializes this layer (Glow or Highlight for example)
  61194. * @returns a serialized layer object
  61195. */
  61196. abstract serialize?(): any;
  61197. /**
  61198. * Initializes the effect layer with the required options.
  61199. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61200. */
  61201. protected _init(options: Partial<IEffectLayerOptions>): void;
  61202. /**
  61203. * Generates the index buffer of the full screen quad blending to the main canvas.
  61204. */
  61205. private _generateIndexBuffer;
  61206. /**
  61207. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61208. */
  61209. private _generateVertexBuffer;
  61210. /**
  61211. * Sets the main texture desired size which is the closest power of two
  61212. * of the engine canvas size.
  61213. */
  61214. private _setMainTextureSize;
  61215. /**
  61216. * Creates the main texture for the effect layer.
  61217. */
  61218. protected _createMainTexture(): void;
  61219. /**
  61220. * Adds specific effects defines.
  61221. * @param defines The defines to add specifics to.
  61222. */
  61223. protected _addCustomEffectDefines(defines: string[]): void;
  61224. /**
  61225. * Checks for the readiness of the element composing the layer.
  61226. * @param subMesh the mesh to check for
  61227. * @param useInstances specify whether or not to use instances to render the mesh
  61228. * @param emissiveTexture the associated emissive texture used to generate the glow
  61229. * @return true if ready otherwise, false
  61230. */
  61231. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61232. /**
  61233. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61234. */
  61235. render(): void;
  61236. /**
  61237. * Determine if a given mesh will be used in the current effect.
  61238. * @param mesh mesh to test
  61239. * @returns true if the mesh will be used
  61240. */
  61241. hasMesh(mesh: AbstractMesh): boolean;
  61242. /**
  61243. * Returns true if the layer contains information to display, otherwise false.
  61244. * @returns true if the glow layer should be rendered
  61245. */
  61246. shouldRender(): boolean;
  61247. /**
  61248. * Returns true if the mesh should render, otherwise false.
  61249. * @param mesh The mesh to render
  61250. * @returns true if it should render otherwise false
  61251. */
  61252. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61253. /**
  61254. * Returns true if the mesh can be rendered, otherwise false.
  61255. * @param mesh The mesh to render
  61256. * @param material The material used on the mesh
  61257. * @returns true if it can be rendered otherwise false
  61258. */
  61259. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61260. /**
  61261. * Returns true if the mesh should render, otherwise false.
  61262. * @param mesh The mesh to render
  61263. * @returns true if it should render otherwise false
  61264. */
  61265. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61266. /**
  61267. * Renders the submesh passed in parameter to the generation map.
  61268. */
  61269. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61270. /**
  61271. * Defines whether the current material of the mesh should be use to render the effect.
  61272. * @param mesh defines the current mesh to render
  61273. */
  61274. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61275. /**
  61276. * Rebuild the required buffers.
  61277. * @hidden Internal use only.
  61278. */
  61279. _rebuild(): void;
  61280. /**
  61281. * Dispose only the render target textures and post process.
  61282. */
  61283. private _disposeTextureAndPostProcesses;
  61284. /**
  61285. * Dispose the highlight layer and free resources.
  61286. */
  61287. dispose(): void;
  61288. /**
  61289. * Gets the class name of the effect layer
  61290. * @returns the string with the class name of the effect layer
  61291. */
  61292. getClassName(): string;
  61293. /**
  61294. * Creates an effect layer from parsed effect layer data
  61295. * @param parsedEffectLayer defines effect layer data
  61296. * @param scene defines the current scene
  61297. * @param rootUrl defines the root URL containing the effect layer information
  61298. * @returns a parsed effect Layer
  61299. */
  61300. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61301. }
  61302. }
  61303. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61304. import { Scene } from "babylonjs/scene";
  61305. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61306. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61307. import { AbstractScene } from "babylonjs/abstractScene";
  61308. module "babylonjs/abstractScene" {
  61309. interface AbstractScene {
  61310. /**
  61311. * The list of effect layers (highlights/glow) added to the scene
  61312. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61313. * @see https://doc.babylonjs.com/how_to/glow_layer
  61314. */
  61315. effectLayers: Array<EffectLayer>;
  61316. /**
  61317. * Removes the given effect layer from this scene.
  61318. * @param toRemove defines the effect layer to remove
  61319. * @returns the index of the removed effect layer
  61320. */
  61321. removeEffectLayer(toRemove: EffectLayer): number;
  61322. /**
  61323. * Adds the given effect layer to this scene
  61324. * @param newEffectLayer defines the effect layer to add
  61325. */
  61326. addEffectLayer(newEffectLayer: EffectLayer): void;
  61327. }
  61328. }
  61329. /**
  61330. * Defines the layer scene component responsible to manage any effect layers
  61331. * in a given scene.
  61332. */
  61333. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61334. /**
  61335. * The component name helpfull to identify the component in the list of scene components.
  61336. */
  61337. readonly name: string;
  61338. /**
  61339. * The scene the component belongs to.
  61340. */
  61341. scene: Scene;
  61342. private _engine;
  61343. private _renderEffects;
  61344. private _needStencil;
  61345. private _previousStencilState;
  61346. /**
  61347. * Creates a new instance of the component for the given scene
  61348. * @param scene Defines the scene to register the component in
  61349. */
  61350. constructor(scene: Scene);
  61351. /**
  61352. * Registers the component in a given scene
  61353. */
  61354. register(): void;
  61355. /**
  61356. * Rebuilds the elements related to this component in case of
  61357. * context lost for instance.
  61358. */
  61359. rebuild(): void;
  61360. /**
  61361. * Serializes the component data to the specified json object
  61362. * @param serializationObject The object to serialize to
  61363. */
  61364. serialize(serializationObject: any): void;
  61365. /**
  61366. * Adds all the elements from the container to the scene
  61367. * @param container the container holding the elements
  61368. */
  61369. addFromContainer(container: AbstractScene): void;
  61370. /**
  61371. * Removes all the elements in the container from the scene
  61372. * @param container contains the elements to remove
  61373. * @param dispose if the removed element should be disposed (default: false)
  61374. */
  61375. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61376. /**
  61377. * Disposes the component and the associated ressources.
  61378. */
  61379. dispose(): void;
  61380. private _isReadyForMesh;
  61381. private _renderMainTexture;
  61382. private _setStencil;
  61383. private _setStencilBack;
  61384. private _draw;
  61385. private _drawCamera;
  61386. private _drawRenderingGroup;
  61387. }
  61388. }
  61389. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61390. /** @hidden */
  61391. export var glowMapMergePixelShader: {
  61392. name: string;
  61393. shader: string;
  61394. };
  61395. }
  61396. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61397. /** @hidden */
  61398. export var glowMapMergeVertexShader: {
  61399. name: string;
  61400. shader: string;
  61401. };
  61402. }
  61403. declare module "babylonjs/Layers/glowLayer" {
  61404. import { Nullable } from "babylonjs/types";
  61405. import { Camera } from "babylonjs/Cameras/camera";
  61406. import { Scene } from "babylonjs/scene";
  61407. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61409. import { Mesh } from "babylonjs/Meshes/mesh";
  61410. import { Texture } from "babylonjs/Materials/Textures/texture";
  61411. import { Effect } from "babylonjs/Materials/effect";
  61412. import { Material } from "babylonjs/Materials/material";
  61413. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61414. import { Color4 } from "babylonjs/Maths/math.color";
  61415. import "babylonjs/Shaders/glowMapMerge.fragment";
  61416. import "babylonjs/Shaders/glowMapMerge.vertex";
  61417. import "babylonjs/Layers/effectLayerSceneComponent";
  61418. module "babylonjs/abstractScene" {
  61419. interface AbstractScene {
  61420. /**
  61421. * Return a the first highlight layer of the scene with a given name.
  61422. * @param name The name of the highlight layer to look for.
  61423. * @return The highlight layer if found otherwise null.
  61424. */
  61425. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61426. }
  61427. }
  61428. /**
  61429. * Glow layer options. This helps customizing the behaviour
  61430. * of the glow layer.
  61431. */
  61432. export interface IGlowLayerOptions {
  61433. /**
  61434. * Multiplication factor apply to the canvas size to compute the render target size
  61435. * used to generated the glowing objects (the smaller the faster).
  61436. */
  61437. mainTextureRatio: number;
  61438. /**
  61439. * Enforces a fixed size texture to ensure resize independant blur.
  61440. */
  61441. mainTextureFixedSize?: number;
  61442. /**
  61443. * How big is the kernel of the blur texture.
  61444. */
  61445. blurKernelSize: number;
  61446. /**
  61447. * The camera attached to the layer.
  61448. */
  61449. camera: Nullable<Camera>;
  61450. /**
  61451. * Enable MSAA by chosing the number of samples.
  61452. */
  61453. mainTextureSamples?: number;
  61454. /**
  61455. * The rendering group to draw the layer in.
  61456. */
  61457. renderingGroupId: number;
  61458. }
  61459. /**
  61460. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61461. *
  61462. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61463. *
  61464. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61465. */
  61466. export class GlowLayer extends EffectLayer {
  61467. /**
  61468. * Effect Name of the layer.
  61469. */
  61470. static readonly EffectName: string;
  61471. /**
  61472. * The default blur kernel size used for the glow.
  61473. */
  61474. static DefaultBlurKernelSize: number;
  61475. /**
  61476. * The default texture size ratio used for the glow.
  61477. */
  61478. static DefaultTextureRatio: number;
  61479. /**
  61480. * Sets the kernel size of the blur.
  61481. */
  61482. set blurKernelSize(value: number);
  61483. /**
  61484. * Gets the kernel size of the blur.
  61485. */
  61486. get blurKernelSize(): number;
  61487. /**
  61488. * Sets the glow intensity.
  61489. */
  61490. set intensity(value: number);
  61491. /**
  61492. * Gets the glow intensity.
  61493. */
  61494. get intensity(): number;
  61495. private _options;
  61496. private _intensity;
  61497. private _horizontalBlurPostprocess1;
  61498. private _verticalBlurPostprocess1;
  61499. private _horizontalBlurPostprocess2;
  61500. private _verticalBlurPostprocess2;
  61501. private _blurTexture1;
  61502. private _blurTexture2;
  61503. private _postProcesses1;
  61504. private _postProcesses2;
  61505. private _includedOnlyMeshes;
  61506. private _excludedMeshes;
  61507. private _meshesUsingTheirOwnMaterials;
  61508. /**
  61509. * Callback used to let the user override the color selection on a per mesh basis
  61510. */
  61511. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61512. /**
  61513. * Callback used to let the user override the texture selection on a per mesh basis
  61514. */
  61515. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61516. /**
  61517. * Instantiates a new glow Layer and references it to the scene.
  61518. * @param name The name of the layer
  61519. * @param scene The scene to use the layer in
  61520. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61521. */
  61522. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61523. /**
  61524. * Get the effect name of the layer.
  61525. * @return The effect name
  61526. */
  61527. getEffectName(): string;
  61528. /**
  61529. * Create the merge effect. This is the shader use to blit the information back
  61530. * to the main canvas at the end of the scene rendering.
  61531. */
  61532. protected _createMergeEffect(): Effect;
  61533. /**
  61534. * Creates the render target textures and post processes used in the glow layer.
  61535. */
  61536. protected _createTextureAndPostProcesses(): void;
  61537. /**
  61538. * Checks for the readiness of the element composing the layer.
  61539. * @param subMesh the mesh to check for
  61540. * @param useInstances specify wether or not to use instances to render the mesh
  61541. * @param emissiveTexture the associated emissive texture used to generate the glow
  61542. * @return true if ready otherwise, false
  61543. */
  61544. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61545. /**
  61546. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61547. */
  61548. needStencil(): boolean;
  61549. /**
  61550. * Returns true if the mesh can be rendered, otherwise false.
  61551. * @param mesh The mesh to render
  61552. * @param material The material used on the mesh
  61553. * @returns true if it can be rendered otherwise false
  61554. */
  61555. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61556. /**
  61557. * Implementation specific of rendering the generating effect on the main canvas.
  61558. * @param effect The effect used to render through
  61559. */
  61560. protected _internalRender(effect: Effect): void;
  61561. /**
  61562. * Sets the required values for both the emissive texture and and the main color.
  61563. */
  61564. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61565. /**
  61566. * Returns true if the mesh should render, otherwise false.
  61567. * @param mesh The mesh to render
  61568. * @returns true if it should render otherwise false
  61569. */
  61570. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61571. /**
  61572. * Adds specific effects defines.
  61573. * @param defines The defines to add specifics to.
  61574. */
  61575. protected _addCustomEffectDefines(defines: string[]): void;
  61576. /**
  61577. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61578. * @param mesh The mesh to exclude from the glow layer
  61579. */
  61580. addExcludedMesh(mesh: Mesh): void;
  61581. /**
  61582. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61583. * @param mesh The mesh to remove
  61584. */
  61585. removeExcludedMesh(mesh: Mesh): void;
  61586. /**
  61587. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61588. * @param mesh The mesh to include in the glow layer
  61589. */
  61590. addIncludedOnlyMesh(mesh: Mesh): void;
  61591. /**
  61592. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61593. * @param mesh The mesh to remove
  61594. */
  61595. removeIncludedOnlyMesh(mesh: Mesh): void;
  61596. /**
  61597. * Determine if a given mesh will be used in the glow layer
  61598. * @param mesh The mesh to test
  61599. * @returns true if the mesh will be highlighted by the current glow layer
  61600. */
  61601. hasMesh(mesh: AbstractMesh): boolean;
  61602. /**
  61603. * Defines whether the current material of the mesh should be use to render the effect.
  61604. * @param mesh defines the current mesh to render
  61605. */
  61606. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61607. /**
  61608. * Add a mesh to be rendered through its own material and not with emissive only.
  61609. * @param mesh The mesh for which we need to use its material
  61610. */
  61611. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61612. /**
  61613. * Remove a mesh from being rendered through its own material and not with emissive only.
  61614. * @param mesh The mesh for which we need to not use its material
  61615. */
  61616. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61617. /**
  61618. * Free any resources and references associated to a mesh.
  61619. * Internal use
  61620. * @param mesh The mesh to free.
  61621. * @hidden
  61622. */
  61623. _disposeMesh(mesh: Mesh): void;
  61624. /**
  61625. * Gets the class name of the effect layer
  61626. * @returns the string with the class name of the effect layer
  61627. */
  61628. getClassName(): string;
  61629. /**
  61630. * Serializes this glow layer
  61631. * @returns a serialized glow layer object
  61632. */
  61633. serialize(): any;
  61634. /**
  61635. * Creates a Glow Layer from parsed glow layer data
  61636. * @param parsedGlowLayer defines glow layer data
  61637. * @param scene defines the current scene
  61638. * @param rootUrl defines the root URL containing the glow layer information
  61639. * @returns a parsed Glow Layer
  61640. */
  61641. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61642. }
  61643. }
  61644. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61645. /** @hidden */
  61646. export var glowBlurPostProcessPixelShader: {
  61647. name: string;
  61648. shader: string;
  61649. };
  61650. }
  61651. declare module "babylonjs/Layers/highlightLayer" {
  61652. import { Observable } from "babylonjs/Misc/observable";
  61653. import { Nullable } from "babylonjs/types";
  61654. import { Camera } from "babylonjs/Cameras/camera";
  61655. import { Scene } from "babylonjs/scene";
  61656. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61658. import { Mesh } from "babylonjs/Meshes/mesh";
  61659. import { Effect } from "babylonjs/Materials/effect";
  61660. import { Material } from "babylonjs/Materials/material";
  61661. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61662. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61663. import "babylonjs/Shaders/glowMapMerge.fragment";
  61664. import "babylonjs/Shaders/glowMapMerge.vertex";
  61665. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61666. module "babylonjs/abstractScene" {
  61667. interface AbstractScene {
  61668. /**
  61669. * Return a the first highlight layer of the scene with a given name.
  61670. * @param name The name of the highlight layer to look for.
  61671. * @return The highlight layer if found otherwise null.
  61672. */
  61673. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61674. }
  61675. }
  61676. /**
  61677. * Highlight layer options. This helps customizing the behaviour
  61678. * of the highlight layer.
  61679. */
  61680. export interface IHighlightLayerOptions {
  61681. /**
  61682. * Multiplication factor apply to the canvas size to compute the render target size
  61683. * used to generated the glowing objects (the smaller the faster).
  61684. */
  61685. mainTextureRatio: number;
  61686. /**
  61687. * Enforces a fixed size texture to ensure resize independant blur.
  61688. */
  61689. mainTextureFixedSize?: number;
  61690. /**
  61691. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61692. * of the picture to blur (the smaller the faster).
  61693. */
  61694. blurTextureSizeRatio: number;
  61695. /**
  61696. * How big in texel of the blur texture is the vertical blur.
  61697. */
  61698. blurVerticalSize: number;
  61699. /**
  61700. * How big in texel of the blur texture is the horizontal blur.
  61701. */
  61702. blurHorizontalSize: number;
  61703. /**
  61704. * Alpha blending mode used to apply the blur. Default is combine.
  61705. */
  61706. alphaBlendingMode: number;
  61707. /**
  61708. * The camera attached to the layer.
  61709. */
  61710. camera: Nullable<Camera>;
  61711. /**
  61712. * Should we display highlight as a solid stroke?
  61713. */
  61714. isStroke?: boolean;
  61715. /**
  61716. * The rendering group to draw the layer in.
  61717. */
  61718. renderingGroupId: number;
  61719. }
  61720. /**
  61721. * The highlight layer Helps adding a glow effect around a mesh.
  61722. *
  61723. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61724. * glowy meshes to your scene.
  61725. *
  61726. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61727. */
  61728. export class HighlightLayer extends EffectLayer {
  61729. name: string;
  61730. /**
  61731. * Effect Name of the highlight layer.
  61732. */
  61733. static readonly EffectName: string;
  61734. /**
  61735. * The neutral color used during the preparation of the glow effect.
  61736. * This is black by default as the blend operation is a blend operation.
  61737. */
  61738. static NeutralColor: Color4;
  61739. /**
  61740. * Stencil value used for glowing meshes.
  61741. */
  61742. static GlowingMeshStencilReference: number;
  61743. /**
  61744. * Stencil value used for the other meshes in the scene.
  61745. */
  61746. static NormalMeshStencilReference: number;
  61747. /**
  61748. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61749. */
  61750. innerGlow: boolean;
  61751. /**
  61752. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61753. */
  61754. outerGlow: boolean;
  61755. /**
  61756. * Specifies the horizontal size of the blur.
  61757. */
  61758. set blurHorizontalSize(value: number);
  61759. /**
  61760. * Specifies the vertical size of the blur.
  61761. */
  61762. set blurVerticalSize(value: number);
  61763. /**
  61764. * Gets the horizontal size of the blur.
  61765. */
  61766. get blurHorizontalSize(): number;
  61767. /**
  61768. * Gets the vertical size of the blur.
  61769. */
  61770. get blurVerticalSize(): number;
  61771. /**
  61772. * An event triggered when the highlight layer is being blurred.
  61773. */
  61774. onBeforeBlurObservable: Observable<HighlightLayer>;
  61775. /**
  61776. * An event triggered when the highlight layer has been blurred.
  61777. */
  61778. onAfterBlurObservable: Observable<HighlightLayer>;
  61779. private _instanceGlowingMeshStencilReference;
  61780. private _options;
  61781. private _downSamplePostprocess;
  61782. private _horizontalBlurPostprocess;
  61783. private _verticalBlurPostprocess;
  61784. private _blurTexture;
  61785. private _meshes;
  61786. private _excludedMeshes;
  61787. /**
  61788. * Instantiates a new highlight Layer and references it to the scene..
  61789. * @param name The name of the layer
  61790. * @param scene The scene to use the layer in
  61791. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61792. */
  61793. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61794. /**
  61795. * Get the effect name of the layer.
  61796. * @return The effect name
  61797. */
  61798. getEffectName(): string;
  61799. /**
  61800. * Create the merge effect. This is the shader use to blit the information back
  61801. * to the main canvas at the end of the scene rendering.
  61802. */
  61803. protected _createMergeEffect(): Effect;
  61804. /**
  61805. * Creates the render target textures and post processes used in the highlight layer.
  61806. */
  61807. protected _createTextureAndPostProcesses(): void;
  61808. /**
  61809. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61810. */
  61811. needStencil(): boolean;
  61812. /**
  61813. * Checks for the readiness of the element composing the layer.
  61814. * @param subMesh the mesh to check for
  61815. * @param useInstances specify wether or not to use instances to render the mesh
  61816. * @param emissiveTexture the associated emissive texture used to generate the glow
  61817. * @return true if ready otherwise, false
  61818. */
  61819. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61820. /**
  61821. * Implementation specific of rendering the generating effect on the main canvas.
  61822. * @param effect The effect used to render through
  61823. */
  61824. protected _internalRender(effect: Effect): void;
  61825. /**
  61826. * Returns true if the layer contains information to display, otherwise false.
  61827. */
  61828. shouldRender(): boolean;
  61829. /**
  61830. * Returns true if the mesh should render, otherwise false.
  61831. * @param mesh The mesh to render
  61832. * @returns true if it should render otherwise false
  61833. */
  61834. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61835. /**
  61836. * Returns true if the mesh can be rendered, otherwise false.
  61837. * @param mesh The mesh to render
  61838. * @param material The material used on the mesh
  61839. * @returns true if it can be rendered otherwise false
  61840. */
  61841. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61842. /**
  61843. * Adds specific effects defines.
  61844. * @param defines The defines to add specifics to.
  61845. */
  61846. protected _addCustomEffectDefines(defines: string[]): void;
  61847. /**
  61848. * Sets the required values for both the emissive texture and and the main color.
  61849. */
  61850. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61851. /**
  61852. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61853. * @param mesh The mesh to exclude from the highlight layer
  61854. */
  61855. addExcludedMesh(mesh: Mesh): void;
  61856. /**
  61857. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61858. * @param mesh The mesh to highlight
  61859. */
  61860. removeExcludedMesh(mesh: Mesh): void;
  61861. /**
  61862. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61863. * @param mesh mesh to test
  61864. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61865. */
  61866. hasMesh(mesh: AbstractMesh): boolean;
  61867. /**
  61868. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61869. * @param mesh The mesh to highlight
  61870. * @param color The color of the highlight
  61871. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61872. */
  61873. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61874. /**
  61875. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61876. * @param mesh The mesh to highlight
  61877. */
  61878. removeMesh(mesh: Mesh): void;
  61879. /**
  61880. * Remove all the meshes currently referenced in the highlight layer
  61881. */
  61882. removeAllMeshes(): void;
  61883. /**
  61884. * Force the stencil to the normal expected value for none glowing parts
  61885. */
  61886. private _defaultStencilReference;
  61887. /**
  61888. * Free any resources and references associated to a mesh.
  61889. * Internal use
  61890. * @param mesh The mesh to free.
  61891. * @hidden
  61892. */
  61893. _disposeMesh(mesh: Mesh): void;
  61894. /**
  61895. * Dispose the highlight layer and free resources.
  61896. */
  61897. dispose(): void;
  61898. /**
  61899. * Gets the class name of the effect layer
  61900. * @returns the string with the class name of the effect layer
  61901. */
  61902. getClassName(): string;
  61903. /**
  61904. * Serializes this Highlight layer
  61905. * @returns a serialized Highlight layer object
  61906. */
  61907. serialize(): any;
  61908. /**
  61909. * Creates a Highlight layer from parsed Highlight layer data
  61910. * @param parsedHightlightLayer defines the Highlight layer data
  61911. * @param scene defines the current scene
  61912. * @param rootUrl defines the root URL containing the Highlight layer information
  61913. * @returns a parsed Highlight layer
  61914. */
  61915. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61916. }
  61917. }
  61918. declare module "babylonjs/Layers/layerSceneComponent" {
  61919. import { Scene } from "babylonjs/scene";
  61920. import { ISceneComponent } from "babylonjs/sceneComponent";
  61921. import { Layer } from "babylonjs/Layers/layer";
  61922. import { AbstractScene } from "babylonjs/abstractScene";
  61923. module "babylonjs/abstractScene" {
  61924. interface AbstractScene {
  61925. /**
  61926. * The list of layers (background and foreground) of the scene
  61927. */
  61928. layers: Array<Layer>;
  61929. }
  61930. }
  61931. /**
  61932. * Defines the layer scene component responsible to manage any layers
  61933. * in a given scene.
  61934. */
  61935. export class LayerSceneComponent implements ISceneComponent {
  61936. /**
  61937. * The component name helpfull to identify the component in the list of scene components.
  61938. */
  61939. readonly name: string;
  61940. /**
  61941. * The scene the component belongs to.
  61942. */
  61943. scene: Scene;
  61944. private _engine;
  61945. /**
  61946. * Creates a new instance of the component for the given scene
  61947. * @param scene Defines the scene to register the component in
  61948. */
  61949. constructor(scene: Scene);
  61950. /**
  61951. * Registers the component in a given scene
  61952. */
  61953. register(): void;
  61954. /**
  61955. * Rebuilds the elements related to this component in case of
  61956. * context lost for instance.
  61957. */
  61958. rebuild(): void;
  61959. /**
  61960. * Disposes the component and the associated ressources.
  61961. */
  61962. dispose(): void;
  61963. private _draw;
  61964. private _drawCameraPredicate;
  61965. private _drawCameraBackground;
  61966. private _drawCameraForeground;
  61967. private _drawRenderTargetPredicate;
  61968. private _drawRenderTargetBackground;
  61969. private _drawRenderTargetForeground;
  61970. /**
  61971. * Adds all the elements from the container to the scene
  61972. * @param container the container holding the elements
  61973. */
  61974. addFromContainer(container: AbstractScene): void;
  61975. /**
  61976. * Removes all the elements in the container from the scene
  61977. * @param container contains the elements to remove
  61978. * @param dispose if the removed element should be disposed (default: false)
  61979. */
  61980. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61981. }
  61982. }
  61983. declare module "babylonjs/Shaders/layer.fragment" {
  61984. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61985. /** @hidden */
  61986. export var layerPixelShader: {
  61987. name: string;
  61988. shader: string;
  61989. };
  61990. }
  61991. declare module "babylonjs/Shaders/layer.vertex" {
  61992. /** @hidden */
  61993. export var layerVertexShader: {
  61994. name: string;
  61995. shader: string;
  61996. };
  61997. }
  61998. declare module "babylonjs/Layers/layer" {
  61999. import { Observable } from "babylonjs/Misc/observable";
  62000. import { Nullable } from "babylonjs/types";
  62001. import { Scene } from "babylonjs/scene";
  62002. import { Vector2 } from "babylonjs/Maths/math.vector";
  62003. import { Color4 } from "babylonjs/Maths/math.color";
  62004. import { Texture } from "babylonjs/Materials/Textures/texture";
  62005. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62006. import "babylonjs/Shaders/layer.fragment";
  62007. import "babylonjs/Shaders/layer.vertex";
  62008. /**
  62009. * This represents a full screen 2d layer.
  62010. * This can be useful to display a picture in the background of your scene for instance.
  62011. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62012. */
  62013. export class Layer {
  62014. /**
  62015. * Define the name of the layer.
  62016. */
  62017. name: string;
  62018. /**
  62019. * Define the texture the layer should display.
  62020. */
  62021. texture: Nullable<Texture>;
  62022. /**
  62023. * Is the layer in background or foreground.
  62024. */
  62025. isBackground: boolean;
  62026. /**
  62027. * Define the color of the layer (instead of texture).
  62028. */
  62029. color: Color4;
  62030. /**
  62031. * Define the scale of the layer in order to zoom in out of the texture.
  62032. */
  62033. scale: Vector2;
  62034. /**
  62035. * Define an offset for the layer in order to shift the texture.
  62036. */
  62037. offset: Vector2;
  62038. /**
  62039. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62040. */
  62041. alphaBlendingMode: number;
  62042. /**
  62043. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62044. * Alpha test will not mix with the background color in case of transparency.
  62045. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62046. */
  62047. alphaTest: boolean;
  62048. /**
  62049. * Define a mask to restrict the layer to only some of the scene cameras.
  62050. */
  62051. layerMask: number;
  62052. /**
  62053. * Define the list of render target the layer is visible into.
  62054. */
  62055. renderTargetTextures: RenderTargetTexture[];
  62056. /**
  62057. * Define if the layer is only used in renderTarget or if it also
  62058. * renders in the main frame buffer of the canvas.
  62059. */
  62060. renderOnlyInRenderTargetTextures: boolean;
  62061. private _scene;
  62062. private _vertexBuffers;
  62063. private _indexBuffer;
  62064. private _effect;
  62065. private _previousDefines;
  62066. /**
  62067. * An event triggered when the layer is disposed.
  62068. */
  62069. onDisposeObservable: Observable<Layer>;
  62070. private _onDisposeObserver;
  62071. /**
  62072. * Back compatibility with callback before the onDisposeObservable existed.
  62073. * The set callback will be triggered when the layer has been disposed.
  62074. */
  62075. set onDispose(callback: () => void);
  62076. /**
  62077. * An event triggered before rendering the scene
  62078. */
  62079. onBeforeRenderObservable: Observable<Layer>;
  62080. private _onBeforeRenderObserver;
  62081. /**
  62082. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62083. * The set callback will be triggered just before rendering the layer.
  62084. */
  62085. set onBeforeRender(callback: () => void);
  62086. /**
  62087. * An event triggered after rendering the scene
  62088. */
  62089. onAfterRenderObservable: Observable<Layer>;
  62090. private _onAfterRenderObserver;
  62091. /**
  62092. * Back compatibility with callback before the onAfterRenderObservable existed.
  62093. * The set callback will be triggered just after rendering the layer.
  62094. */
  62095. set onAfterRender(callback: () => void);
  62096. /**
  62097. * Instantiates a new layer.
  62098. * This represents a full screen 2d layer.
  62099. * This can be useful to display a picture in the background of your scene for instance.
  62100. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62101. * @param name Define the name of the layer in the scene
  62102. * @param imgUrl Define the url of the texture to display in the layer
  62103. * @param scene Define the scene the layer belongs to
  62104. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62105. * @param color Defines a color for the layer
  62106. */
  62107. constructor(
  62108. /**
  62109. * Define the name of the layer.
  62110. */
  62111. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62112. private _createIndexBuffer;
  62113. /** @hidden */
  62114. _rebuild(): void;
  62115. /**
  62116. * Renders the layer in the scene.
  62117. */
  62118. render(): void;
  62119. /**
  62120. * Disposes and releases the associated ressources.
  62121. */
  62122. dispose(): void;
  62123. }
  62124. }
  62125. declare module "babylonjs/Layers/index" {
  62126. export * from "babylonjs/Layers/effectLayer";
  62127. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62128. export * from "babylonjs/Layers/glowLayer";
  62129. export * from "babylonjs/Layers/highlightLayer";
  62130. export * from "babylonjs/Layers/layer";
  62131. export * from "babylonjs/Layers/layerSceneComponent";
  62132. }
  62133. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62134. /** @hidden */
  62135. export var lensFlarePixelShader: {
  62136. name: string;
  62137. shader: string;
  62138. };
  62139. }
  62140. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62141. /** @hidden */
  62142. export var lensFlareVertexShader: {
  62143. name: string;
  62144. shader: string;
  62145. };
  62146. }
  62147. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62148. import { Scene } from "babylonjs/scene";
  62149. import { Vector3 } from "babylonjs/Maths/math.vector";
  62150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62151. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62152. import "babylonjs/Shaders/lensFlare.fragment";
  62153. import "babylonjs/Shaders/lensFlare.vertex";
  62154. import { Viewport } from "babylonjs/Maths/math.viewport";
  62155. /**
  62156. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62157. * It is usually composed of several `lensFlare`.
  62158. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62159. */
  62160. export class LensFlareSystem {
  62161. /**
  62162. * Define the name of the lens flare system
  62163. */
  62164. name: string;
  62165. /**
  62166. * List of lens flares used in this system.
  62167. */
  62168. lensFlares: LensFlare[];
  62169. /**
  62170. * Define a limit from the border the lens flare can be visible.
  62171. */
  62172. borderLimit: number;
  62173. /**
  62174. * Define a viewport border we do not want to see the lens flare in.
  62175. */
  62176. viewportBorder: number;
  62177. /**
  62178. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62179. */
  62180. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62181. /**
  62182. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62183. */
  62184. layerMask: number;
  62185. /**
  62186. * Define the id of the lens flare system in the scene.
  62187. * (equal to name by default)
  62188. */
  62189. id: string;
  62190. private _scene;
  62191. private _emitter;
  62192. private _vertexBuffers;
  62193. private _indexBuffer;
  62194. private _effect;
  62195. private _positionX;
  62196. private _positionY;
  62197. private _isEnabled;
  62198. /** @hidden */
  62199. static _SceneComponentInitialization: (scene: Scene) => void;
  62200. /**
  62201. * Instantiates a lens flare system.
  62202. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62203. * It is usually composed of several `lensFlare`.
  62204. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62205. * @param name Define the name of the lens flare system in the scene
  62206. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62207. * @param scene Define the scene the lens flare system belongs to
  62208. */
  62209. constructor(
  62210. /**
  62211. * Define the name of the lens flare system
  62212. */
  62213. name: string, emitter: any, scene: Scene);
  62214. /**
  62215. * Define if the lens flare system is enabled.
  62216. */
  62217. get isEnabled(): boolean;
  62218. set isEnabled(value: boolean);
  62219. /**
  62220. * Get the scene the effects belongs to.
  62221. * @returns the scene holding the lens flare system
  62222. */
  62223. getScene(): Scene;
  62224. /**
  62225. * Get the emitter of the lens flare system.
  62226. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62227. * @returns the emitter of the lens flare system
  62228. */
  62229. getEmitter(): any;
  62230. /**
  62231. * Set the emitter of the lens flare system.
  62232. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62233. * @param newEmitter Define the new emitter of the system
  62234. */
  62235. setEmitter(newEmitter: any): void;
  62236. /**
  62237. * Get the lens flare system emitter position.
  62238. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62239. * @returns the position
  62240. */
  62241. getEmitterPosition(): Vector3;
  62242. /**
  62243. * @hidden
  62244. */
  62245. computeEffectivePosition(globalViewport: Viewport): boolean;
  62246. /** @hidden */
  62247. _isVisible(): boolean;
  62248. /**
  62249. * @hidden
  62250. */
  62251. render(): boolean;
  62252. /**
  62253. * Dispose and release the lens flare with its associated resources.
  62254. */
  62255. dispose(): void;
  62256. /**
  62257. * Parse a lens flare system from a JSON repressentation
  62258. * @param parsedLensFlareSystem Define the JSON to parse
  62259. * @param scene Define the scene the parsed system should be instantiated in
  62260. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62261. * @returns the parsed system
  62262. */
  62263. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62264. /**
  62265. * Serialize the current Lens Flare System into a JSON representation.
  62266. * @returns the serialized JSON
  62267. */
  62268. serialize(): any;
  62269. }
  62270. }
  62271. declare module "babylonjs/LensFlares/lensFlare" {
  62272. import { Nullable } from "babylonjs/types";
  62273. import { Color3 } from "babylonjs/Maths/math.color";
  62274. import { Texture } from "babylonjs/Materials/Textures/texture";
  62275. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62276. /**
  62277. * This represents one of the lens effect in a `lensFlareSystem`.
  62278. * It controls one of the indiviual texture used in the effect.
  62279. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62280. */
  62281. export class LensFlare {
  62282. /**
  62283. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62284. */
  62285. size: number;
  62286. /**
  62287. * 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.
  62288. */
  62289. position: number;
  62290. /**
  62291. * Define the lens color.
  62292. */
  62293. color: Color3;
  62294. /**
  62295. * Define the lens texture.
  62296. */
  62297. texture: Nullable<Texture>;
  62298. /**
  62299. * Define the alpha mode to render this particular lens.
  62300. */
  62301. alphaMode: number;
  62302. private _system;
  62303. /**
  62304. * Creates a new Lens Flare.
  62305. * This represents one of the lens effect in a `lensFlareSystem`.
  62306. * It controls one of the indiviual texture used in the effect.
  62307. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62308. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62309. * @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.
  62310. * @param color Define the lens color
  62311. * @param imgUrl Define the lens texture url
  62312. * @param system Define the `lensFlareSystem` this flare is part of
  62313. * @returns The newly created Lens Flare
  62314. */
  62315. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62316. /**
  62317. * Instantiates a new Lens Flare.
  62318. * This represents one of the lens effect in a `lensFlareSystem`.
  62319. * It controls one of the indiviual texture used in the effect.
  62320. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62321. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62322. * @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.
  62323. * @param color Define the lens color
  62324. * @param imgUrl Define the lens texture url
  62325. * @param system Define the `lensFlareSystem` this flare is part of
  62326. */
  62327. constructor(
  62328. /**
  62329. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62330. */
  62331. size: number,
  62332. /**
  62333. * 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.
  62334. */
  62335. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62336. /**
  62337. * Dispose and release the lens flare with its associated resources.
  62338. */
  62339. dispose(): void;
  62340. }
  62341. }
  62342. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62343. import { Nullable } from "babylonjs/types";
  62344. import { Scene } from "babylonjs/scene";
  62345. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62346. import { AbstractScene } from "babylonjs/abstractScene";
  62347. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62348. module "babylonjs/abstractScene" {
  62349. interface AbstractScene {
  62350. /**
  62351. * The list of lens flare system added to the scene
  62352. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62353. */
  62354. lensFlareSystems: Array<LensFlareSystem>;
  62355. /**
  62356. * Removes the given lens flare system from this scene.
  62357. * @param toRemove The lens flare system to remove
  62358. * @returns The index of the removed lens flare system
  62359. */
  62360. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62361. /**
  62362. * Adds the given lens flare system to this scene
  62363. * @param newLensFlareSystem The lens flare system to add
  62364. */
  62365. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62366. /**
  62367. * Gets a lens flare system using its name
  62368. * @param name defines the name to look for
  62369. * @returns the lens flare system or null if not found
  62370. */
  62371. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62372. /**
  62373. * Gets a lens flare system using its id
  62374. * @param id defines the id to look for
  62375. * @returns the lens flare system or null if not found
  62376. */
  62377. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62378. }
  62379. }
  62380. /**
  62381. * Defines the lens flare scene component responsible to manage any lens flares
  62382. * in a given scene.
  62383. */
  62384. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62385. /**
  62386. * The component name helpfull to identify the component in the list of scene components.
  62387. */
  62388. readonly name: string;
  62389. /**
  62390. * The scene the component belongs to.
  62391. */
  62392. scene: Scene;
  62393. /**
  62394. * Creates a new instance of the component for the given scene
  62395. * @param scene Defines the scene to register the component in
  62396. */
  62397. constructor(scene: Scene);
  62398. /**
  62399. * Registers the component in a given scene
  62400. */
  62401. register(): void;
  62402. /**
  62403. * Rebuilds the elements related to this component in case of
  62404. * context lost for instance.
  62405. */
  62406. rebuild(): void;
  62407. /**
  62408. * Adds all the elements from the container to the scene
  62409. * @param container the container holding the elements
  62410. */
  62411. addFromContainer(container: AbstractScene): void;
  62412. /**
  62413. * Removes all the elements in the container from the scene
  62414. * @param container contains the elements to remove
  62415. * @param dispose if the removed element should be disposed (default: false)
  62416. */
  62417. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62418. /**
  62419. * Serializes the component data to the specified json object
  62420. * @param serializationObject The object to serialize to
  62421. */
  62422. serialize(serializationObject: any): void;
  62423. /**
  62424. * Disposes the component and the associated ressources.
  62425. */
  62426. dispose(): void;
  62427. private _draw;
  62428. }
  62429. }
  62430. declare module "babylonjs/LensFlares/index" {
  62431. export * from "babylonjs/LensFlares/lensFlare";
  62432. export * from "babylonjs/LensFlares/lensFlareSystem";
  62433. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62434. }
  62435. declare module "babylonjs/Shaders/depth.fragment" {
  62436. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62437. /** @hidden */
  62438. export var depthPixelShader: {
  62439. name: string;
  62440. shader: string;
  62441. };
  62442. }
  62443. declare module "babylonjs/Shaders/depth.vertex" {
  62444. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62445. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62446. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62447. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62448. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62449. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62450. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62451. /** @hidden */
  62452. export var depthVertexShader: {
  62453. name: string;
  62454. shader: string;
  62455. };
  62456. }
  62457. declare module "babylonjs/Rendering/depthRenderer" {
  62458. import { Nullable } from "babylonjs/types";
  62459. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62460. import { Scene } from "babylonjs/scene";
  62461. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62462. import { Camera } from "babylonjs/Cameras/camera";
  62463. import "babylonjs/Shaders/depth.fragment";
  62464. import "babylonjs/Shaders/depth.vertex";
  62465. /**
  62466. * This represents a depth renderer in Babylon.
  62467. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62468. */
  62469. export class DepthRenderer {
  62470. private _scene;
  62471. private _depthMap;
  62472. private _effect;
  62473. private readonly _storeNonLinearDepth;
  62474. private readonly _clearColor;
  62475. /** Get if the depth renderer is using packed depth or not */
  62476. readonly isPacked: boolean;
  62477. private _cachedDefines;
  62478. private _camera;
  62479. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62480. enabled: boolean;
  62481. /**
  62482. * Specifiess that the depth renderer will only be used within
  62483. * the camera it is created for.
  62484. * This can help forcing its rendering during the camera processing.
  62485. */
  62486. useOnlyInActiveCamera: boolean;
  62487. /** @hidden */
  62488. static _SceneComponentInitialization: (scene: Scene) => void;
  62489. /**
  62490. * Instantiates a depth renderer
  62491. * @param scene The scene the renderer belongs to
  62492. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62493. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62494. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62495. */
  62496. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62497. /**
  62498. * Creates the depth rendering effect and checks if the effect is ready.
  62499. * @param subMesh The submesh to be used to render the depth map of
  62500. * @param useInstances If multiple world instances should be used
  62501. * @returns if the depth renderer is ready to render the depth map
  62502. */
  62503. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62504. /**
  62505. * Gets the texture which the depth map will be written to.
  62506. * @returns The depth map texture
  62507. */
  62508. getDepthMap(): RenderTargetTexture;
  62509. /**
  62510. * Disposes of the depth renderer.
  62511. */
  62512. dispose(): void;
  62513. }
  62514. }
  62515. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62516. /** @hidden */
  62517. export var minmaxReduxPixelShader: {
  62518. name: string;
  62519. shader: string;
  62520. };
  62521. }
  62522. declare module "babylonjs/Misc/minMaxReducer" {
  62523. import { Nullable } from "babylonjs/types";
  62524. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62525. import { Camera } from "babylonjs/Cameras/camera";
  62526. import { Observer } from "babylonjs/Misc/observable";
  62527. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62528. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62529. import { Observable } from "babylonjs/Misc/observable";
  62530. import "babylonjs/Shaders/minmaxRedux.fragment";
  62531. /**
  62532. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62533. * and maximum values from all values of the texture.
  62534. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62535. * The source values are read from the red channel of the texture.
  62536. */
  62537. export class MinMaxReducer {
  62538. /**
  62539. * Observable triggered when the computation has been performed
  62540. */
  62541. onAfterReductionPerformed: Observable<{
  62542. min: number;
  62543. max: number;
  62544. }>;
  62545. protected _camera: Camera;
  62546. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62547. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62548. protected _postProcessManager: PostProcessManager;
  62549. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62550. protected _forceFullscreenViewport: boolean;
  62551. /**
  62552. * Creates a min/max reducer
  62553. * @param camera The camera to use for the post processes
  62554. */
  62555. constructor(camera: Camera);
  62556. /**
  62557. * Gets the texture used to read the values from.
  62558. */
  62559. get sourceTexture(): Nullable<RenderTargetTexture>;
  62560. /**
  62561. * Sets the source texture to read the values from.
  62562. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62563. * because in such textures '1' value must not be taken into account to compute the maximum
  62564. * as this value is used to clear the texture.
  62565. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62566. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62567. * @param depthRedux Indicates if the texture is a depth texture or not
  62568. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62569. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62570. */
  62571. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62572. /**
  62573. * Defines the refresh rate of the computation.
  62574. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62575. */
  62576. get refreshRate(): number;
  62577. set refreshRate(value: number);
  62578. protected _activated: boolean;
  62579. /**
  62580. * Gets the activation status of the reducer
  62581. */
  62582. get activated(): boolean;
  62583. /**
  62584. * Activates the reduction computation.
  62585. * When activated, the observers registered in onAfterReductionPerformed are
  62586. * called after the compuation is performed
  62587. */
  62588. activate(): void;
  62589. /**
  62590. * Deactivates the reduction computation.
  62591. */
  62592. deactivate(): void;
  62593. /**
  62594. * Disposes the min/max reducer
  62595. * @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.
  62596. */
  62597. dispose(disposeAll?: boolean): void;
  62598. }
  62599. }
  62600. declare module "babylonjs/Misc/depthReducer" {
  62601. import { Nullable } from "babylonjs/types";
  62602. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62603. import { Camera } from "babylonjs/Cameras/camera";
  62604. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62605. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62606. /**
  62607. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62608. */
  62609. export class DepthReducer extends MinMaxReducer {
  62610. private _depthRenderer;
  62611. private _depthRendererId;
  62612. /**
  62613. * Gets the depth renderer used for the computation.
  62614. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62615. */
  62616. get depthRenderer(): Nullable<DepthRenderer>;
  62617. /**
  62618. * Creates a depth reducer
  62619. * @param camera The camera used to render the depth texture
  62620. */
  62621. constructor(camera: Camera);
  62622. /**
  62623. * Sets the depth renderer to use to generate the depth map
  62624. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62625. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62626. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62627. */
  62628. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62629. /** @hidden */
  62630. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62631. /**
  62632. * Activates the reduction computation.
  62633. * When activated, the observers registered in onAfterReductionPerformed are
  62634. * called after the compuation is performed
  62635. */
  62636. activate(): void;
  62637. /**
  62638. * Deactivates the reduction computation.
  62639. */
  62640. deactivate(): void;
  62641. /**
  62642. * Disposes the depth reducer
  62643. * @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.
  62644. */
  62645. dispose(disposeAll?: boolean): void;
  62646. }
  62647. }
  62648. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62649. import { Nullable } from "babylonjs/types";
  62650. import { Scene } from "babylonjs/scene";
  62651. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62652. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62654. import { Effect } from "babylonjs/Materials/effect";
  62655. import "babylonjs/Shaders/shadowMap.fragment";
  62656. import "babylonjs/Shaders/shadowMap.vertex";
  62657. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62658. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62659. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62660. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62661. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62662. /**
  62663. * A CSM implementation allowing casting shadows on large scenes.
  62664. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62665. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62666. */
  62667. export class CascadedShadowGenerator extends ShadowGenerator {
  62668. private static readonly frustumCornersNDCSpace;
  62669. /**
  62670. * Name of the CSM class
  62671. */
  62672. static CLASSNAME: string;
  62673. /**
  62674. * Defines the default number of cascades used by the CSM.
  62675. */
  62676. static readonly DEFAULT_CASCADES_COUNT: number;
  62677. /**
  62678. * Defines the minimum number of cascades used by the CSM.
  62679. */
  62680. static readonly MIN_CASCADES_COUNT: number;
  62681. /**
  62682. * Defines the maximum number of cascades used by the CSM.
  62683. */
  62684. static readonly MAX_CASCADES_COUNT: number;
  62685. protected _validateFilter(filter: number): number;
  62686. /**
  62687. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62688. */
  62689. penumbraDarkness: number;
  62690. private _numCascades;
  62691. /**
  62692. * Gets or set the number of cascades used by the CSM.
  62693. */
  62694. get numCascades(): number;
  62695. set numCascades(value: number);
  62696. /**
  62697. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62698. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62699. */
  62700. stabilizeCascades: boolean;
  62701. private _freezeShadowCastersBoundingInfo;
  62702. private _freezeShadowCastersBoundingInfoObservable;
  62703. /**
  62704. * Enables or disables the shadow casters bounding info computation.
  62705. * If your shadow casters don't move, you can disable this feature.
  62706. * If it is enabled, the bounding box computation is done every frame.
  62707. */
  62708. get freezeShadowCastersBoundingInfo(): boolean;
  62709. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62710. private _scbiMin;
  62711. private _scbiMax;
  62712. protected _computeShadowCastersBoundingInfo(): void;
  62713. protected _shadowCastersBoundingInfo: BoundingInfo;
  62714. /**
  62715. * Gets or sets the shadow casters bounding info.
  62716. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62717. * so that the system won't overwrite the bounds you provide
  62718. */
  62719. get shadowCastersBoundingInfo(): BoundingInfo;
  62720. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62721. protected _breaksAreDirty: boolean;
  62722. protected _minDistance: number;
  62723. protected _maxDistance: number;
  62724. /**
  62725. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62726. *
  62727. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62728. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62729. * @param min minimal distance for the breaks (default to 0.)
  62730. * @param max maximal distance for the breaks (default to 1.)
  62731. */
  62732. setMinMaxDistance(min: number, max: number): void;
  62733. /** Gets the minimal distance used in the cascade break computation */
  62734. get minDistance(): number;
  62735. /** Gets the maximal distance used in the cascade break computation */
  62736. get maxDistance(): number;
  62737. /**
  62738. * Gets the class name of that object
  62739. * @returns "CascadedShadowGenerator"
  62740. */
  62741. getClassName(): string;
  62742. private _cascadeMinExtents;
  62743. private _cascadeMaxExtents;
  62744. /**
  62745. * Gets a cascade minimum extents
  62746. * @param cascadeIndex index of the cascade
  62747. * @returns the minimum cascade extents
  62748. */
  62749. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62750. /**
  62751. * Gets a cascade maximum extents
  62752. * @param cascadeIndex index of the cascade
  62753. * @returns the maximum cascade extents
  62754. */
  62755. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62756. private _cascades;
  62757. private _currentLayer;
  62758. private _viewSpaceFrustumsZ;
  62759. private _viewMatrices;
  62760. private _projectionMatrices;
  62761. private _transformMatrices;
  62762. private _transformMatricesAsArray;
  62763. private _frustumLengths;
  62764. private _lightSizeUVCorrection;
  62765. private _depthCorrection;
  62766. private _frustumCornersWorldSpace;
  62767. private _frustumCenter;
  62768. private _shadowCameraPos;
  62769. private _shadowMaxZ;
  62770. /**
  62771. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62772. * It defaults to camera.maxZ
  62773. */
  62774. get shadowMaxZ(): number;
  62775. /**
  62776. * Sets the shadow max z distance.
  62777. */
  62778. set shadowMaxZ(value: number);
  62779. protected _debug: boolean;
  62780. /**
  62781. * Gets or sets the debug flag.
  62782. * When enabled, the cascades are materialized by different colors on the screen.
  62783. */
  62784. get debug(): boolean;
  62785. set debug(dbg: boolean);
  62786. private _depthClamp;
  62787. /**
  62788. * Gets or sets the depth clamping value.
  62789. *
  62790. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62791. * to account for the shadow casters far away.
  62792. *
  62793. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62794. */
  62795. get depthClamp(): boolean;
  62796. set depthClamp(value: boolean);
  62797. private _cascadeBlendPercentage;
  62798. /**
  62799. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62800. * It defaults to 0.1 (10% blending).
  62801. */
  62802. get cascadeBlendPercentage(): number;
  62803. set cascadeBlendPercentage(value: number);
  62804. private _lambda;
  62805. /**
  62806. * Gets or set the lambda parameter.
  62807. * This parameter is used to split the camera frustum and create the cascades.
  62808. * 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.
  62809. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62810. */
  62811. get lambda(): number;
  62812. set lambda(value: number);
  62813. /**
  62814. * Gets the view matrix corresponding to a given cascade
  62815. * @param cascadeNum cascade to retrieve the view matrix from
  62816. * @returns the cascade view matrix
  62817. */
  62818. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62819. /**
  62820. * Gets the projection matrix corresponding to a given cascade
  62821. * @param cascadeNum cascade to retrieve the projection matrix from
  62822. * @returns the cascade projection matrix
  62823. */
  62824. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62825. /**
  62826. * Gets the transformation matrix corresponding to a given cascade
  62827. * @param cascadeNum cascade to retrieve the transformation matrix from
  62828. * @returns the cascade transformation matrix
  62829. */
  62830. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62831. private _depthRenderer;
  62832. /**
  62833. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62834. *
  62835. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62836. *
  62837. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62838. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62839. * @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
  62840. */
  62841. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62842. private _depthReducer;
  62843. private _autoCalcDepthBounds;
  62844. /**
  62845. * Gets or sets the autoCalcDepthBounds property.
  62846. *
  62847. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62848. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62849. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62850. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62851. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62852. */
  62853. get autoCalcDepthBounds(): boolean;
  62854. set autoCalcDepthBounds(value: boolean);
  62855. /**
  62856. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62857. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62858. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62859. * for setting the refresh rate on the renderer yourself!
  62860. */
  62861. get autoCalcDepthBoundsRefreshRate(): number;
  62862. set autoCalcDepthBoundsRefreshRate(value: number);
  62863. /**
  62864. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62865. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62866. * you change the camera near/far planes!
  62867. */
  62868. splitFrustum(): void;
  62869. private _splitFrustum;
  62870. private _computeMatrices;
  62871. private _computeFrustumInWorldSpace;
  62872. private _computeCascadeFrustum;
  62873. /**
  62874. * Support test.
  62875. */
  62876. static get IsSupported(): boolean;
  62877. /** @hidden */
  62878. static _SceneComponentInitialization: (scene: Scene) => void;
  62879. /**
  62880. * Creates a Cascaded Shadow Generator object.
  62881. * A ShadowGenerator is the required tool to use the shadows.
  62882. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62883. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62884. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62885. * @param light The directional light object generating the shadows.
  62886. * @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.
  62887. */
  62888. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62889. protected _initializeGenerator(): void;
  62890. protected _createTargetRenderTexture(): void;
  62891. protected _initializeShadowMap(): void;
  62892. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62893. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62894. /**
  62895. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62896. * @param defines Defines of the material we want to update
  62897. * @param lightIndex Index of the light in the enabled light list of the material
  62898. */
  62899. prepareDefines(defines: any, lightIndex: number): void;
  62900. /**
  62901. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62902. * defined in the generator but impacting the effect).
  62903. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62904. * @param effect The effect we are binfing the information for
  62905. */
  62906. bindShadowLight(lightIndex: string, effect: Effect): void;
  62907. /**
  62908. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62909. * (eq to view projection * shadow projection matrices)
  62910. * @returns The transform matrix used to create the shadow map
  62911. */
  62912. getTransformMatrix(): Matrix;
  62913. /**
  62914. * Disposes the ShadowGenerator.
  62915. * Returns nothing.
  62916. */
  62917. dispose(): void;
  62918. /**
  62919. * Serializes the shadow generator setup to a json object.
  62920. * @returns The serialized JSON object
  62921. */
  62922. serialize(): any;
  62923. /**
  62924. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62925. * @param parsedShadowGenerator The JSON object to parse
  62926. * @param scene The scene to create the shadow map for
  62927. * @returns The parsed shadow generator
  62928. */
  62929. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62930. }
  62931. }
  62932. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62933. import { Scene } from "babylonjs/scene";
  62934. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62935. import { AbstractScene } from "babylonjs/abstractScene";
  62936. /**
  62937. * Defines the shadow generator component responsible to manage any shadow generators
  62938. * in a given scene.
  62939. */
  62940. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62941. /**
  62942. * The component name helpfull to identify the component in the list of scene components.
  62943. */
  62944. readonly name: string;
  62945. /**
  62946. * The scene the component belongs to.
  62947. */
  62948. scene: Scene;
  62949. /**
  62950. * Creates a new instance of the component for the given scene
  62951. * @param scene Defines the scene to register the component in
  62952. */
  62953. constructor(scene: Scene);
  62954. /**
  62955. * Registers the component in a given scene
  62956. */
  62957. register(): void;
  62958. /**
  62959. * Rebuilds the elements related to this component in case of
  62960. * context lost for instance.
  62961. */
  62962. rebuild(): void;
  62963. /**
  62964. * Serializes the component data to the specified json object
  62965. * @param serializationObject The object to serialize to
  62966. */
  62967. serialize(serializationObject: any): void;
  62968. /**
  62969. * Adds all the elements from the container to the scene
  62970. * @param container the container holding the elements
  62971. */
  62972. addFromContainer(container: AbstractScene): void;
  62973. /**
  62974. * Removes all the elements in the container from the scene
  62975. * @param container contains the elements to remove
  62976. * @param dispose if the removed element should be disposed (default: false)
  62977. */
  62978. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62979. /**
  62980. * Rebuilds the elements related to this component in case of
  62981. * context lost for instance.
  62982. */
  62983. dispose(): void;
  62984. private _gatherRenderTargets;
  62985. }
  62986. }
  62987. declare module "babylonjs/Lights/Shadows/index" {
  62988. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62989. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62990. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62991. }
  62992. declare module "babylonjs/Lights/pointLight" {
  62993. import { Scene } from "babylonjs/scene";
  62994. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62996. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62997. import { Effect } from "babylonjs/Materials/effect";
  62998. /**
  62999. * A point light is a light defined by an unique point in world space.
  63000. * The light is emitted in every direction from this point.
  63001. * A good example of a point light is a standard light bulb.
  63002. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63003. */
  63004. export class PointLight extends ShadowLight {
  63005. private _shadowAngle;
  63006. /**
  63007. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63008. * This specifies what angle the shadow will use to be created.
  63009. *
  63010. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63011. */
  63012. get shadowAngle(): number;
  63013. /**
  63014. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63015. * This specifies what angle the shadow will use to be created.
  63016. *
  63017. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63018. */
  63019. set shadowAngle(value: number);
  63020. /**
  63021. * Gets the direction if it has been set.
  63022. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63023. */
  63024. get direction(): Vector3;
  63025. /**
  63026. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63027. */
  63028. set direction(value: Vector3);
  63029. /**
  63030. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63031. * A PointLight emits the light in every direction.
  63032. * It can cast shadows.
  63033. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63034. * ```javascript
  63035. * var pointLight = new PointLight("pl", camera.position, scene);
  63036. * ```
  63037. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63038. * @param name The light friendly name
  63039. * @param position The position of the point light in the scene
  63040. * @param scene The scene the lights belongs to
  63041. */
  63042. constructor(name: string, position: Vector3, scene: Scene);
  63043. /**
  63044. * Returns the string "PointLight"
  63045. * @returns the class name
  63046. */
  63047. getClassName(): string;
  63048. /**
  63049. * Returns the integer 0.
  63050. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63051. */
  63052. getTypeID(): number;
  63053. /**
  63054. * Specifies wether or not the shadowmap should be a cube texture.
  63055. * @returns true if the shadowmap needs to be a cube texture.
  63056. */
  63057. needCube(): boolean;
  63058. /**
  63059. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63060. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63061. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63062. */
  63063. getShadowDirection(faceIndex?: number): Vector3;
  63064. /**
  63065. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63066. * - fov = PI / 2
  63067. * - aspect ratio : 1.0
  63068. * - z-near and far equal to the active camera minZ and maxZ.
  63069. * Returns the PointLight.
  63070. */
  63071. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63072. protected _buildUniformLayout(): void;
  63073. /**
  63074. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63075. * @param effect The effect to update
  63076. * @param lightIndex The index of the light in the effect to update
  63077. * @returns The point light
  63078. */
  63079. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63080. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63081. /**
  63082. * Prepares the list of defines specific to the light type.
  63083. * @param defines the list of defines
  63084. * @param lightIndex defines the index of the light for the effect
  63085. */
  63086. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63087. }
  63088. }
  63089. declare module "babylonjs/Lights/index" {
  63090. export * from "babylonjs/Lights/light";
  63091. export * from "babylonjs/Lights/shadowLight";
  63092. export * from "babylonjs/Lights/Shadows/index";
  63093. export * from "babylonjs/Lights/directionalLight";
  63094. export * from "babylonjs/Lights/hemisphericLight";
  63095. export * from "babylonjs/Lights/pointLight";
  63096. export * from "babylonjs/Lights/spotLight";
  63097. }
  63098. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63099. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63100. /**
  63101. * Header information of HDR texture files.
  63102. */
  63103. export interface HDRInfo {
  63104. /**
  63105. * The height of the texture in pixels.
  63106. */
  63107. height: number;
  63108. /**
  63109. * The width of the texture in pixels.
  63110. */
  63111. width: number;
  63112. /**
  63113. * The index of the beginning of the data in the binary file.
  63114. */
  63115. dataPosition: number;
  63116. }
  63117. /**
  63118. * This groups tools to convert HDR texture to native colors array.
  63119. */
  63120. export class HDRTools {
  63121. private static Ldexp;
  63122. private static Rgbe2float;
  63123. private static readStringLine;
  63124. /**
  63125. * Reads header information from an RGBE texture stored in a native array.
  63126. * More information on this format are available here:
  63127. * https://en.wikipedia.org/wiki/RGBE_image_format
  63128. *
  63129. * @param uint8array The binary file stored in native array.
  63130. * @return The header information.
  63131. */
  63132. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63133. /**
  63134. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63135. * This RGBE texture needs to store the information as a panorama.
  63136. *
  63137. * More information on this format are available here:
  63138. * https://en.wikipedia.org/wiki/RGBE_image_format
  63139. *
  63140. * @param buffer The binary file stored in an array buffer.
  63141. * @param size The expected size of the extracted cubemap.
  63142. * @return The Cube Map information.
  63143. */
  63144. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63145. /**
  63146. * Returns the pixels data extracted from an RGBE texture.
  63147. * This pixels will be stored left to right up to down in the R G B order in one array.
  63148. *
  63149. * More information on this format are available here:
  63150. * https://en.wikipedia.org/wiki/RGBE_image_format
  63151. *
  63152. * @param uint8array The binary file stored in an array buffer.
  63153. * @param hdrInfo The header information of the file.
  63154. * @return The pixels data in RGB right to left up to down order.
  63155. */
  63156. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63157. private static RGBE_ReadPixels_RLE;
  63158. private static RGBE_ReadPixels_NOT_RLE;
  63159. }
  63160. }
  63161. declare module "babylonjs/Materials/effectRenderer" {
  63162. import { Nullable } from "babylonjs/types";
  63163. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63164. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63165. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63166. import { Viewport } from "babylonjs/Maths/math.viewport";
  63167. import { Observable } from "babylonjs/Misc/observable";
  63168. import { Effect } from "babylonjs/Materials/effect";
  63169. import "babylonjs/Shaders/postprocess.vertex";
  63170. /**
  63171. * Effect Render Options
  63172. */
  63173. export interface IEffectRendererOptions {
  63174. /**
  63175. * Defines the vertices positions.
  63176. */
  63177. positions?: number[];
  63178. /**
  63179. * Defines the indices.
  63180. */
  63181. indices?: number[];
  63182. }
  63183. /**
  63184. * Helper class to render one or more effects.
  63185. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63186. */
  63187. export class EffectRenderer {
  63188. private engine;
  63189. private static _DefaultOptions;
  63190. private _vertexBuffers;
  63191. private _indexBuffer;
  63192. private _fullscreenViewport;
  63193. /**
  63194. * Creates an effect renderer
  63195. * @param engine the engine to use for rendering
  63196. * @param options defines the options of the effect renderer
  63197. */
  63198. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63199. /**
  63200. * Sets the current viewport in normalized coordinates 0-1
  63201. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63202. */
  63203. setViewport(viewport?: Viewport): void;
  63204. /**
  63205. * Binds the embedded attributes buffer to the effect.
  63206. * @param effect Defines the effect to bind the attributes for
  63207. */
  63208. bindBuffers(effect: Effect): void;
  63209. /**
  63210. * Sets the current effect wrapper to use during draw.
  63211. * The effect needs to be ready before calling this api.
  63212. * This also sets the default full screen position attribute.
  63213. * @param effectWrapper Defines the effect to draw with
  63214. */
  63215. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63216. /**
  63217. * Restores engine states
  63218. */
  63219. restoreStates(): void;
  63220. /**
  63221. * Draws a full screen quad.
  63222. */
  63223. draw(): void;
  63224. private isRenderTargetTexture;
  63225. /**
  63226. * renders one or more effects to a specified texture
  63227. * @param effectWrapper the effect to renderer
  63228. * @param outputTexture texture to draw to, if null it will render to the screen.
  63229. */
  63230. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63231. /**
  63232. * Disposes of the effect renderer
  63233. */
  63234. dispose(): void;
  63235. }
  63236. /**
  63237. * Options to create an EffectWrapper
  63238. */
  63239. interface EffectWrapperCreationOptions {
  63240. /**
  63241. * Engine to use to create the effect
  63242. */
  63243. engine: ThinEngine;
  63244. /**
  63245. * Fragment shader for the effect
  63246. */
  63247. fragmentShader: string;
  63248. /**
  63249. * Use the shader store instead of direct source code
  63250. */
  63251. useShaderStore?: boolean;
  63252. /**
  63253. * Vertex shader for the effect
  63254. */
  63255. vertexShader?: string;
  63256. /**
  63257. * Attributes to use in the shader
  63258. */
  63259. attributeNames?: Array<string>;
  63260. /**
  63261. * Uniforms to use in the shader
  63262. */
  63263. uniformNames?: Array<string>;
  63264. /**
  63265. * Texture sampler names to use in the shader
  63266. */
  63267. samplerNames?: Array<string>;
  63268. /**
  63269. * Defines to use in the shader
  63270. */
  63271. defines?: Array<string>;
  63272. /**
  63273. * Callback when effect is compiled
  63274. */
  63275. onCompiled?: Nullable<(effect: Effect) => void>;
  63276. /**
  63277. * The friendly name of the effect displayed in Spector.
  63278. */
  63279. name?: string;
  63280. }
  63281. /**
  63282. * Wraps an effect to be used for rendering
  63283. */
  63284. export class EffectWrapper {
  63285. /**
  63286. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63287. */
  63288. onApplyObservable: Observable<{}>;
  63289. /**
  63290. * The underlying effect
  63291. */
  63292. effect: Effect;
  63293. /**
  63294. * Creates an effect to be renderer
  63295. * @param creationOptions options to create the effect
  63296. */
  63297. constructor(creationOptions: EffectWrapperCreationOptions);
  63298. /**
  63299. * Disposes of the effect wrapper
  63300. */
  63301. dispose(): void;
  63302. }
  63303. }
  63304. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63305. /** @hidden */
  63306. export var hdrFilteringVertexShader: {
  63307. name: string;
  63308. shader: string;
  63309. };
  63310. }
  63311. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63312. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63313. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63314. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63315. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63316. /** @hidden */
  63317. export var hdrFilteringPixelShader: {
  63318. name: string;
  63319. shader: string;
  63320. };
  63321. }
  63322. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63324. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63325. import { Nullable } from "babylonjs/types";
  63326. import "babylonjs/Shaders/hdrFiltering.vertex";
  63327. import "babylonjs/Shaders/hdrFiltering.fragment";
  63328. /**
  63329. * Options for texture filtering
  63330. */
  63331. interface IHDRFilteringOptions {
  63332. /**
  63333. * Scales pixel intensity for the input HDR map.
  63334. */
  63335. hdrScale?: number;
  63336. /**
  63337. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63338. */
  63339. quality?: number;
  63340. }
  63341. /**
  63342. * Filters HDR maps to get correct renderings of PBR reflections
  63343. */
  63344. export class HDRFiltering {
  63345. private _engine;
  63346. private _effectRenderer;
  63347. private _effectWrapper;
  63348. private _lodGenerationOffset;
  63349. private _lodGenerationScale;
  63350. /**
  63351. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63352. * you care about baking speed.
  63353. */
  63354. quality: number;
  63355. /**
  63356. * Scales pixel intensity for the input HDR map.
  63357. */
  63358. hdrScale: number;
  63359. /**
  63360. * Instantiates HDR filter for reflection maps
  63361. *
  63362. * @param engine Thin engine
  63363. * @param options Options
  63364. */
  63365. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63366. private _createRenderTarget;
  63367. private _prefilterInternal;
  63368. private _createEffect;
  63369. /**
  63370. * Get a value indicating if the filter is ready to be used
  63371. * @param texture Texture to filter
  63372. * @returns true if the filter is ready
  63373. */
  63374. isReady(texture: BaseTexture): boolean;
  63375. /**
  63376. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63377. * Prefiltering will be invoked at the end of next rendering pass.
  63378. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63379. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63380. * @param texture Texture to filter
  63381. * @param onFinished Callback when filtering is done
  63382. * @return Promise called when prefiltering is done
  63383. */
  63384. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63385. }
  63386. }
  63387. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63388. import { Nullable } from "babylonjs/types";
  63389. import { Scene } from "babylonjs/scene";
  63390. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63391. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63392. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63393. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63394. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63395. /**
  63396. * This represents a texture coming from an HDR input.
  63397. *
  63398. * The only supported format is currently panorama picture stored in RGBE format.
  63399. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63400. */
  63401. export class HDRCubeTexture extends BaseTexture {
  63402. private static _facesMapping;
  63403. private _generateHarmonics;
  63404. private _noMipmap;
  63405. private _prefilterOnLoad;
  63406. private _textureMatrix;
  63407. private _size;
  63408. private _onLoad;
  63409. private _onError;
  63410. /**
  63411. * The texture URL.
  63412. */
  63413. url: string;
  63414. protected _isBlocking: boolean;
  63415. /**
  63416. * Sets wether or not the texture is blocking during loading.
  63417. */
  63418. set isBlocking(value: boolean);
  63419. /**
  63420. * Gets wether or not the texture is blocking during loading.
  63421. */
  63422. get isBlocking(): boolean;
  63423. protected _rotationY: number;
  63424. /**
  63425. * Sets texture matrix rotation angle around Y axis in radians.
  63426. */
  63427. set rotationY(value: number);
  63428. /**
  63429. * Gets texture matrix rotation angle around Y axis radians.
  63430. */
  63431. get rotationY(): number;
  63432. /**
  63433. * Gets or sets the center of the bounding box associated with the cube texture
  63434. * It must define where the camera used to render the texture was set
  63435. */
  63436. boundingBoxPosition: Vector3;
  63437. private _boundingBoxSize;
  63438. /**
  63439. * Gets or sets the size of the bounding box associated with the cube texture
  63440. * When defined, the cubemap will switch to local mode
  63441. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63442. * @example https://www.babylonjs-playground.com/#RNASML
  63443. */
  63444. set boundingBoxSize(value: Vector3);
  63445. get boundingBoxSize(): Vector3;
  63446. /**
  63447. * Instantiates an HDRTexture from the following parameters.
  63448. *
  63449. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63450. * @param sceneOrEngine The scene or engine the texture will be used in
  63451. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63452. * @param noMipmap Forces to not generate the mipmap if true
  63453. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63454. * @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)
  63455. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63456. */
  63457. 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>);
  63458. /**
  63459. * Get the current class name of the texture useful for serialization or dynamic coding.
  63460. * @returns "HDRCubeTexture"
  63461. */
  63462. getClassName(): string;
  63463. /**
  63464. * Occurs when the file is raw .hdr file.
  63465. */
  63466. private loadTexture;
  63467. clone(): HDRCubeTexture;
  63468. delayLoad(): void;
  63469. /**
  63470. * Get the texture reflection matrix used to rotate/transform the reflection.
  63471. * @returns the reflection matrix
  63472. */
  63473. getReflectionTextureMatrix(): Matrix;
  63474. /**
  63475. * Set the texture reflection matrix used to rotate/transform the reflection.
  63476. * @param value Define the reflection matrix to set
  63477. */
  63478. setReflectionTextureMatrix(value: Matrix): void;
  63479. /**
  63480. * Parses a JSON representation of an HDR Texture in order to create the texture
  63481. * @param parsedTexture Define the JSON representation
  63482. * @param scene Define the scene the texture should be created in
  63483. * @param rootUrl Define the root url in case we need to load relative dependencies
  63484. * @returns the newly created texture after parsing
  63485. */
  63486. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63487. serialize(): any;
  63488. }
  63489. }
  63490. declare module "babylonjs/Physics/physicsEngine" {
  63491. import { Nullable } from "babylonjs/types";
  63492. import { Vector3 } from "babylonjs/Maths/math.vector";
  63493. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63494. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63495. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63496. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63497. /**
  63498. * Class used to control physics engine
  63499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63500. */
  63501. export class PhysicsEngine implements IPhysicsEngine {
  63502. private _physicsPlugin;
  63503. /**
  63504. * Global value used to control the smallest number supported by the simulation
  63505. */
  63506. static Epsilon: number;
  63507. private _impostors;
  63508. private _joints;
  63509. private _subTimeStep;
  63510. /**
  63511. * Gets the gravity vector used by the simulation
  63512. */
  63513. gravity: Vector3;
  63514. /**
  63515. * Factory used to create the default physics plugin.
  63516. * @returns The default physics plugin
  63517. */
  63518. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63519. /**
  63520. * Creates a new Physics Engine
  63521. * @param gravity defines the gravity vector used by the simulation
  63522. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63523. */
  63524. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63525. /**
  63526. * Sets the gravity vector used by the simulation
  63527. * @param gravity defines the gravity vector to use
  63528. */
  63529. setGravity(gravity: Vector3): void;
  63530. /**
  63531. * Set the time step of the physics engine.
  63532. * Default is 1/60.
  63533. * To slow it down, enter 1/600 for example.
  63534. * To speed it up, 1/30
  63535. * @param newTimeStep defines the new timestep to apply to this world.
  63536. */
  63537. setTimeStep(newTimeStep?: number): void;
  63538. /**
  63539. * Get the time step of the physics engine.
  63540. * @returns the current time step
  63541. */
  63542. getTimeStep(): number;
  63543. /**
  63544. * Set the sub time step of the physics engine.
  63545. * Default is 0 meaning there is no sub steps
  63546. * To increase physics resolution precision, set a small value (like 1 ms)
  63547. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63548. */
  63549. setSubTimeStep(subTimeStep?: number): void;
  63550. /**
  63551. * Get the sub time step of the physics engine.
  63552. * @returns the current sub time step
  63553. */
  63554. getSubTimeStep(): number;
  63555. /**
  63556. * Release all resources
  63557. */
  63558. dispose(): void;
  63559. /**
  63560. * Gets the name of the current physics plugin
  63561. * @returns the name of the plugin
  63562. */
  63563. getPhysicsPluginName(): string;
  63564. /**
  63565. * Adding a new impostor for the impostor tracking.
  63566. * This will be done by the impostor itself.
  63567. * @param impostor the impostor to add
  63568. */
  63569. addImpostor(impostor: PhysicsImpostor): void;
  63570. /**
  63571. * Remove an impostor from the engine.
  63572. * This impostor and its mesh will not longer be updated by the physics engine.
  63573. * @param impostor the impostor to remove
  63574. */
  63575. removeImpostor(impostor: PhysicsImpostor): void;
  63576. /**
  63577. * Add a joint to the physics engine
  63578. * @param mainImpostor defines the main impostor to which the joint is added.
  63579. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63580. * @param joint defines the joint that will connect both impostors.
  63581. */
  63582. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63583. /**
  63584. * Removes a joint from the simulation
  63585. * @param mainImpostor defines the impostor used with the joint
  63586. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63587. * @param joint defines the joint to remove
  63588. */
  63589. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63590. /**
  63591. * Called by the scene. No need to call it.
  63592. * @param delta defines the timespam between frames
  63593. */
  63594. _step(delta: number): void;
  63595. /**
  63596. * Gets the current plugin used to run the simulation
  63597. * @returns current plugin
  63598. */
  63599. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63600. /**
  63601. * Gets the list of physic impostors
  63602. * @returns an array of PhysicsImpostor
  63603. */
  63604. getImpostors(): Array<PhysicsImpostor>;
  63605. /**
  63606. * Gets the impostor for a physics enabled object
  63607. * @param object defines the object impersonated by the impostor
  63608. * @returns the PhysicsImpostor or null if not found
  63609. */
  63610. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63611. /**
  63612. * Gets the impostor for a physics body object
  63613. * @param body defines physics body used by the impostor
  63614. * @returns the PhysicsImpostor or null if not found
  63615. */
  63616. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63617. /**
  63618. * Does a raycast in the physics world
  63619. * @param from when should the ray start?
  63620. * @param to when should the ray end?
  63621. * @returns PhysicsRaycastResult
  63622. */
  63623. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63624. }
  63625. }
  63626. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63627. import { Nullable } from "babylonjs/types";
  63628. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63630. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63631. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63632. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63633. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63634. /** @hidden */
  63635. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63636. private _useDeltaForWorldStep;
  63637. world: any;
  63638. name: string;
  63639. private _physicsMaterials;
  63640. private _fixedTimeStep;
  63641. private _cannonRaycastResult;
  63642. private _raycastResult;
  63643. private _physicsBodysToRemoveAfterStep;
  63644. private _firstFrame;
  63645. BJSCANNON: any;
  63646. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63647. setGravity(gravity: Vector3): void;
  63648. setTimeStep(timeStep: number): void;
  63649. getTimeStep(): number;
  63650. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63651. private _removeMarkedPhysicsBodiesFromWorld;
  63652. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63653. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63654. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63655. private _processChildMeshes;
  63656. removePhysicsBody(impostor: PhysicsImpostor): void;
  63657. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63658. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63659. private _addMaterial;
  63660. private _checkWithEpsilon;
  63661. private _createShape;
  63662. private _createHeightmap;
  63663. private _minus90X;
  63664. private _plus90X;
  63665. private _tmpPosition;
  63666. private _tmpDeltaPosition;
  63667. private _tmpUnityRotation;
  63668. private _updatePhysicsBodyTransformation;
  63669. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63670. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63671. isSupported(): boolean;
  63672. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63673. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63674. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63675. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63676. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63677. getBodyMass(impostor: PhysicsImpostor): number;
  63678. getBodyFriction(impostor: PhysicsImpostor): number;
  63679. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63680. getBodyRestitution(impostor: PhysicsImpostor): number;
  63681. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63682. sleepBody(impostor: PhysicsImpostor): void;
  63683. wakeUpBody(impostor: PhysicsImpostor): void;
  63684. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63685. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63686. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63687. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63688. getRadius(impostor: PhysicsImpostor): number;
  63689. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63690. dispose(): void;
  63691. private _extendNamespace;
  63692. /**
  63693. * Does a raycast in the physics world
  63694. * @param from when should the ray start?
  63695. * @param to when should the ray end?
  63696. * @returns PhysicsRaycastResult
  63697. */
  63698. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63699. }
  63700. }
  63701. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63702. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63703. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63704. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63706. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63707. import { Nullable } from "babylonjs/types";
  63708. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63709. /** @hidden */
  63710. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63711. private _useDeltaForWorldStep;
  63712. world: any;
  63713. name: string;
  63714. BJSOIMO: any;
  63715. private _raycastResult;
  63716. private _fixedTimeStep;
  63717. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63718. setGravity(gravity: Vector3): void;
  63719. setTimeStep(timeStep: number): void;
  63720. getTimeStep(): number;
  63721. private _tmpImpostorsArray;
  63722. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63723. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63724. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63725. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63726. private _tmpPositionVector;
  63727. removePhysicsBody(impostor: PhysicsImpostor): void;
  63728. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63729. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63730. isSupported(): boolean;
  63731. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63732. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63733. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63734. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63735. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63736. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63737. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63738. getBodyMass(impostor: PhysicsImpostor): number;
  63739. getBodyFriction(impostor: PhysicsImpostor): number;
  63740. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63741. getBodyRestitution(impostor: PhysicsImpostor): number;
  63742. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63743. sleepBody(impostor: PhysicsImpostor): void;
  63744. wakeUpBody(impostor: PhysicsImpostor): void;
  63745. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63746. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63747. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63748. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63749. getRadius(impostor: PhysicsImpostor): number;
  63750. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63751. dispose(): void;
  63752. /**
  63753. * Does a raycast in the physics world
  63754. * @param from when should the ray start?
  63755. * @param to when should the ray end?
  63756. * @returns PhysicsRaycastResult
  63757. */
  63758. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63759. }
  63760. }
  63761. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63762. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63763. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63764. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63765. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63766. import { Nullable } from "babylonjs/types";
  63767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63768. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63769. /**
  63770. * AmmoJS Physics plugin
  63771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63772. * @see https://github.com/kripken/ammo.js/
  63773. */
  63774. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63775. private _useDeltaForWorldStep;
  63776. /**
  63777. * Reference to the Ammo library
  63778. */
  63779. bjsAMMO: any;
  63780. /**
  63781. * Created ammoJS world which physics bodies are added to
  63782. */
  63783. world: any;
  63784. /**
  63785. * Name of the plugin
  63786. */
  63787. name: string;
  63788. private _timeStep;
  63789. private _fixedTimeStep;
  63790. private _maxSteps;
  63791. private _tmpQuaternion;
  63792. private _tmpAmmoTransform;
  63793. private _tmpAmmoQuaternion;
  63794. private _tmpAmmoConcreteContactResultCallback;
  63795. private _collisionConfiguration;
  63796. private _dispatcher;
  63797. private _overlappingPairCache;
  63798. private _solver;
  63799. private _softBodySolver;
  63800. private _tmpAmmoVectorA;
  63801. private _tmpAmmoVectorB;
  63802. private _tmpAmmoVectorC;
  63803. private _tmpAmmoVectorD;
  63804. private _tmpContactCallbackResult;
  63805. private _tmpAmmoVectorRCA;
  63806. private _tmpAmmoVectorRCB;
  63807. private _raycastResult;
  63808. private static readonly DISABLE_COLLISION_FLAG;
  63809. private static readonly KINEMATIC_FLAG;
  63810. private static readonly DISABLE_DEACTIVATION_FLAG;
  63811. /**
  63812. * Initializes the ammoJS plugin
  63813. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63814. * @param ammoInjection can be used to inject your own ammo reference
  63815. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63816. */
  63817. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63818. /**
  63819. * Sets the gravity of the physics world (m/(s^2))
  63820. * @param gravity Gravity to set
  63821. */
  63822. setGravity(gravity: Vector3): void;
  63823. /**
  63824. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63825. * @param timeStep timestep to use in seconds
  63826. */
  63827. setTimeStep(timeStep: number): void;
  63828. /**
  63829. * 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)
  63830. * @param fixedTimeStep fixedTimeStep to use in seconds
  63831. */
  63832. setFixedTimeStep(fixedTimeStep: number): void;
  63833. /**
  63834. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63835. * @param maxSteps the maximum number of steps by the physics engine per frame
  63836. */
  63837. setMaxSteps(maxSteps: number): void;
  63838. /**
  63839. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63840. * @returns the current timestep in seconds
  63841. */
  63842. getTimeStep(): number;
  63843. /**
  63844. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63845. */
  63846. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63847. private _isImpostorInContact;
  63848. private _isImpostorPairInContact;
  63849. private _stepSimulation;
  63850. /**
  63851. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63852. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63853. * After the step the babylon meshes are set to the position of the physics imposters
  63854. * @param delta amount of time to step forward
  63855. * @param impostors array of imposters to update before/after the step
  63856. */
  63857. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63858. /**
  63859. * Update babylon mesh to match physics world object
  63860. * @param impostor imposter to match
  63861. */
  63862. private _afterSoftStep;
  63863. /**
  63864. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63865. * @param impostor imposter to match
  63866. */
  63867. private _ropeStep;
  63868. /**
  63869. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63870. * @param impostor imposter to match
  63871. */
  63872. private _softbodyOrClothStep;
  63873. private _tmpMatrix;
  63874. /**
  63875. * Applies an impulse on the imposter
  63876. * @param impostor imposter to apply impulse to
  63877. * @param force amount of force to be applied to the imposter
  63878. * @param contactPoint the location to apply the impulse on the imposter
  63879. */
  63880. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63881. /**
  63882. * Applies a force on the imposter
  63883. * @param impostor imposter to apply force
  63884. * @param force amount of force to be applied to the imposter
  63885. * @param contactPoint the location to apply the force on the imposter
  63886. */
  63887. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63888. /**
  63889. * Creates a physics body using the plugin
  63890. * @param impostor the imposter to create the physics body on
  63891. */
  63892. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63893. /**
  63894. * Removes the physics body from the imposter and disposes of the body's memory
  63895. * @param impostor imposter to remove the physics body from
  63896. */
  63897. removePhysicsBody(impostor: PhysicsImpostor): void;
  63898. /**
  63899. * Generates a joint
  63900. * @param impostorJoint the imposter joint to create the joint with
  63901. */
  63902. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63903. /**
  63904. * Removes a joint
  63905. * @param impostorJoint the imposter joint to remove the joint from
  63906. */
  63907. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63908. private _addMeshVerts;
  63909. /**
  63910. * Initialise the soft body vertices to match its object's (mesh) vertices
  63911. * Softbody vertices (nodes) are in world space and to match this
  63912. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63913. * @param impostor to create the softbody for
  63914. */
  63915. private _softVertexData;
  63916. /**
  63917. * Create an impostor's soft body
  63918. * @param impostor to create the softbody for
  63919. */
  63920. private _createSoftbody;
  63921. /**
  63922. * Create cloth for an impostor
  63923. * @param impostor to create the softbody for
  63924. */
  63925. private _createCloth;
  63926. /**
  63927. * Create rope for an impostor
  63928. * @param impostor to create the softbody for
  63929. */
  63930. private _createRope;
  63931. /**
  63932. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63933. * @param impostor to create the custom physics shape for
  63934. */
  63935. private _createCustom;
  63936. private _addHullVerts;
  63937. private _createShape;
  63938. /**
  63939. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63940. * @param impostor imposter containing the physics body and babylon object
  63941. */
  63942. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63943. /**
  63944. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63945. * @param impostor imposter containing the physics body and babylon object
  63946. * @param newPosition new position
  63947. * @param newRotation new rotation
  63948. */
  63949. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63950. /**
  63951. * If this plugin is supported
  63952. * @returns true if its supported
  63953. */
  63954. isSupported(): boolean;
  63955. /**
  63956. * Sets the linear velocity of the physics body
  63957. * @param impostor imposter to set the velocity on
  63958. * @param velocity velocity to set
  63959. */
  63960. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63961. /**
  63962. * Sets the angular velocity of the physics body
  63963. * @param impostor imposter to set the velocity on
  63964. * @param velocity velocity to set
  63965. */
  63966. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63967. /**
  63968. * gets the linear velocity
  63969. * @param impostor imposter to get linear velocity from
  63970. * @returns linear velocity
  63971. */
  63972. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63973. /**
  63974. * gets the angular velocity
  63975. * @param impostor imposter to get angular velocity from
  63976. * @returns angular velocity
  63977. */
  63978. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63979. /**
  63980. * Sets the mass of physics body
  63981. * @param impostor imposter to set the mass on
  63982. * @param mass mass to set
  63983. */
  63984. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63985. /**
  63986. * Gets the mass of the physics body
  63987. * @param impostor imposter to get the mass from
  63988. * @returns mass
  63989. */
  63990. getBodyMass(impostor: PhysicsImpostor): number;
  63991. /**
  63992. * Gets friction of the impostor
  63993. * @param impostor impostor to get friction from
  63994. * @returns friction value
  63995. */
  63996. getBodyFriction(impostor: PhysicsImpostor): number;
  63997. /**
  63998. * Sets friction of the impostor
  63999. * @param impostor impostor to set friction on
  64000. * @param friction friction value
  64001. */
  64002. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64003. /**
  64004. * Gets restitution of the impostor
  64005. * @param impostor impostor to get restitution from
  64006. * @returns restitution value
  64007. */
  64008. getBodyRestitution(impostor: PhysicsImpostor): number;
  64009. /**
  64010. * Sets resitution of the impostor
  64011. * @param impostor impostor to set resitution on
  64012. * @param restitution resitution value
  64013. */
  64014. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64015. /**
  64016. * Gets pressure inside the impostor
  64017. * @param impostor impostor to get pressure from
  64018. * @returns pressure value
  64019. */
  64020. getBodyPressure(impostor: PhysicsImpostor): number;
  64021. /**
  64022. * Sets pressure inside a soft body impostor
  64023. * Cloth and rope must remain 0 pressure
  64024. * @param impostor impostor to set pressure on
  64025. * @param pressure pressure value
  64026. */
  64027. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64028. /**
  64029. * Gets stiffness of the impostor
  64030. * @param impostor impostor to get stiffness from
  64031. * @returns pressure value
  64032. */
  64033. getBodyStiffness(impostor: PhysicsImpostor): number;
  64034. /**
  64035. * Sets stiffness of the impostor
  64036. * @param impostor impostor to set stiffness on
  64037. * @param stiffness stiffness value from 0 to 1
  64038. */
  64039. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64040. /**
  64041. * Gets velocityIterations of the impostor
  64042. * @param impostor impostor to get velocity iterations from
  64043. * @returns velocityIterations value
  64044. */
  64045. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64046. /**
  64047. * Sets velocityIterations of the impostor
  64048. * @param impostor impostor to set velocity iterations on
  64049. * @param velocityIterations velocityIterations value
  64050. */
  64051. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64052. /**
  64053. * Gets positionIterations of the impostor
  64054. * @param impostor impostor to get position iterations from
  64055. * @returns positionIterations value
  64056. */
  64057. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64058. /**
  64059. * Sets positionIterations of the impostor
  64060. * @param impostor impostor to set position on
  64061. * @param positionIterations positionIterations value
  64062. */
  64063. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64064. /**
  64065. * Append an anchor to a cloth object
  64066. * @param impostor is the cloth impostor to add anchor to
  64067. * @param otherImpostor is the rigid impostor to anchor to
  64068. * @param width ratio across width from 0 to 1
  64069. * @param height ratio up height from 0 to 1
  64070. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64071. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64072. */
  64073. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64074. /**
  64075. * Append an hook to a rope object
  64076. * @param impostor is the rope impostor to add hook to
  64077. * @param otherImpostor is the rigid impostor to hook to
  64078. * @param length ratio along the rope from 0 to 1
  64079. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64080. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64081. */
  64082. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64083. /**
  64084. * Sleeps the physics body and stops it from being active
  64085. * @param impostor impostor to sleep
  64086. */
  64087. sleepBody(impostor: PhysicsImpostor): void;
  64088. /**
  64089. * Activates the physics body
  64090. * @param impostor impostor to activate
  64091. */
  64092. wakeUpBody(impostor: PhysicsImpostor): void;
  64093. /**
  64094. * Updates the distance parameters of the joint
  64095. * @param joint joint to update
  64096. * @param maxDistance maximum distance of the joint
  64097. * @param minDistance minimum distance of the joint
  64098. */
  64099. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64100. /**
  64101. * Sets a motor on the joint
  64102. * @param joint joint to set motor on
  64103. * @param speed speed of the motor
  64104. * @param maxForce maximum force of the motor
  64105. * @param motorIndex index of the motor
  64106. */
  64107. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64108. /**
  64109. * Sets the motors limit
  64110. * @param joint joint to set limit on
  64111. * @param upperLimit upper limit
  64112. * @param lowerLimit lower limit
  64113. */
  64114. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64115. /**
  64116. * Syncs the position and rotation of a mesh with the impostor
  64117. * @param mesh mesh to sync
  64118. * @param impostor impostor to update the mesh with
  64119. */
  64120. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64121. /**
  64122. * Gets the radius of the impostor
  64123. * @param impostor impostor to get radius from
  64124. * @returns the radius
  64125. */
  64126. getRadius(impostor: PhysicsImpostor): number;
  64127. /**
  64128. * Gets the box size of the impostor
  64129. * @param impostor impostor to get box size from
  64130. * @param result the resulting box size
  64131. */
  64132. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64133. /**
  64134. * Disposes of the impostor
  64135. */
  64136. dispose(): void;
  64137. /**
  64138. * Does a raycast in the physics world
  64139. * @param from when should the ray start?
  64140. * @param to when should the ray end?
  64141. * @returns PhysicsRaycastResult
  64142. */
  64143. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64144. }
  64145. }
  64146. declare module "babylonjs/Probes/reflectionProbe" {
  64147. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64148. import { Vector3 } from "babylonjs/Maths/math.vector";
  64149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64150. import { Nullable } from "babylonjs/types";
  64151. import { Scene } from "babylonjs/scene";
  64152. module "babylonjs/abstractScene" {
  64153. interface AbstractScene {
  64154. /**
  64155. * The list of reflection probes added to the scene
  64156. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64157. */
  64158. reflectionProbes: Array<ReflectionProbe>;
  64159. /**
  64160. * Removes the given reflection probe from this scene.
  64161. * @param toRemove The reflection probe to remove
  64162. * @returns The index of the removed reflection probe
  64163. */
  64164. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64165. /**
  64166. * Adds the given reflection probe to this scene.
  64167. * @param newReflectionProbe The reflection probe to add
  64168. */
  64169. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64170. }
  64171. }
  64172. /**
  64173. * Class used to generate realtime reflection / refraction cube textures
  64174. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64175. */
  64176. export class ReflectionProbe {
  64177. /** defines the name of the probe */
  64178. name: string;
  64179. private _scene;
  64180. private _renderTargetTexture;
  64181. private _projectionMatrix;
  64182. private _viewMatrix;
  64183. private _target;
  64184. private _add;
  64185. private _attachedMesh;
  64186. private _invertYAxis;
  64187. /** Gets or sets probe position (center of the cube map) */
  64188. position: Vector3;
  64189. /**
  64190. * Creates a new reflection probe
  64191. * @param name defines the name of the probe
  64192. * @param size defines the texture resolution (for each face)
  64193. * @param scene defines the hosting scene
  64194. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64195. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64196. */
  64197. constructor(
  64198. /** defines the name of the probe */
  64199. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64200. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64201. get samples(): number;
  64202. set samples(value: number);
  64203. /** Gets or sets the refresh rate to use (on every frame by default) */
  64204. get refreshRate(): number;
  64205. set refreshRate(value: number);
  64206. /**
  64207. * Gets the hosting scene
  64208. * @returns a Scene
  64209. */
  64210. getScene(): Scene;
  64211. /** Gets the internal CubeTexture used to render to */
  64212. get cubeTexture(): RenderTargetTexture;
  64213. /** Gets the list of meshes to render */
  64214. get renderList(): Nullable<AbstractMesh[]>;
  64215. /**
  64216. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64217. * @param mesh defines the mesh to attach to
  64218. */
  64219. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64220. /**
  64221. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64222. * @param renderingGroupId The rendering group id corresponding to its index
  64223. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64224. */
  64225. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64226. /**
  64227. * Clean all associated resources
  64228. */
  64229. dispose(): void;
  64230. /**
  64231. * Converts the reflection probe information to a readable string for debug purpose.
  64232. * @param fullDetails Supports for multiple levels of logging within scene loading
  64233. * @returns the human readable reflection probe info
  64234. */
  64235. toString(fullDetails?: boolean): string;
  64236. /**
  64237. * Get the class name of the relfection probe.
  64238. * @returns "ReflectionProbe"
  64239. */
  64240. getClassName(): string;
  64241. /**
  64242. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64243. * @returns The JSON representation of the texture
  64244. */
  64245. serialize(): any;
  64246. /**
  64247. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64248. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64249. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64250. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64251. * @returns The parsed reflection probe if successful
  64252. */
  64253. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64254. }
  64255. }
  64256. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64257. /** @hidden */
  64258. export var _BabylonLoaderRegistered: boolean;
  64259. /**
  64260. * Helps setting up some configuration for the babylon file loader.
  64261. */
  64262. export class BabylonFileLoaderConfiguration {
  64263. /**
  64264. * The loader does not allow injecting custom physix engine into the plugins.
  64265. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64266. * So you could set this variable to your engine import to make it work.
  64267. */
  64268. static LoaderInjectedPhysicsEngine: any;
  64269. }
  64270. }
  64271. declare module "babylonjs/Loading/Plugins/index" {
  64272. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64273. }
  64274. declare module "babylonjs/Loading/index" {
  64275. export * from "babylonjs/Loading/loadingScreen";
  64276. export * from "babylonjs/Loading/Plugins/index";
  64277. export * from "babylonjs/Loading/sceneLoader";
  64278. export * from "babylonjs/Loading/sceneLoaderFlags";
  64279. }
  64280. declare module "babylonjs/Materials/Background/index" {
  64281. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64282. }
  64283. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64284. import { Scene } from "babylonjs/scene";
  64285. import { Color3 } from "babylonjs/Maths/math.color";
  64286. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64287. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64288. /**
  64289. * The Physically based simple base material of BJS.
  64290. *
  64291. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64292. * It is used as the base class for both the specGloss and metalRough conventions.
  64293. */
  64294. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64295. /**
  64296. * Number of Simultaneous lights allowed on the material.
  64297. */
  64298. maxSimultaneousLights: number;
  64299. /**
  64300. * If sets to true, disables all the lights affecting the material.
  64301. */
  64302. disableLighting: boolean;
  64303. /**
  64304. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64305. */
  64306. environmentTexture: BaseTexture;
  64307. /**
  64308. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64309. */
  64310. invertNormalMapX: boolean;
  64311. /**
  64312. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64313. */
  64314. invertNormalMapY: boolean;
  64315. /**
  64316. * Normal map used in the model.
  64317. */
  64318. normalTexture: BaseTexture;
  64319. /**
  64320. * Emissivie color used to self-illuminate the model.
  64321. */
  64322. emissiveColor: Color3;
  64323. /**
  64324. * Emissivie texture used to self-illuminate the model.
  64325. */
  64326. emissiveTexture: BaseTexture;
  64327. /**
  64328. * Occlusion Channel Strenght.
  64329. */
  64330. occlusionStrength: number;
  64331. /**
  64332. * Occlusion Texture of the material (adding extra occlusion effects).
  64333. */
  64334. occlusionTexture: BaseTexture;
  64335. /**
  64336. * Defines the alpha limits in alpha test mode.
  64337. */
  64338. alphaCutOff: number;
  64339. /**
  64340. * Gets the current double sided mode.
  64341. */
  64342. get doubleSided(): boolean;
  64343. /**
  64344. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64345. */
  64346. set doubleSided(value: boolean);
  64347. /**
  64348. * Stores the pre-calculated light information of a mesh in a texture.
  64349. */
  64350. lightmapTexture: BaseTexture;
  64351. /**
  64352. * If true, the light map contains occlusion information instead of lighting info.
  64353. */
  64354. useLightmapAsShadowmap: boolean;
  64355. /**
  64356. * Instantiates a new PBRMaterial instance.
  64357. *
  64358. * @param name The material name
  64359. * @param scene The scene the material will be use in.
  64360. */
  64361. constructor(name: string, scene: Scene);
  64362. getClassName(): string;
  64363. }
  64364. }
  64365. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64366. import { Scene } from "babylonjs/scene";
  64367. import { Color3 } from "babylonjs/Maths/math.color";
  64368. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64369. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64370. /**
  64371. * The PBR material of BJS following the metal roughness convention.
  64372. *
  64373. * This fits to the PBR convention in the GLTF definition:
  64374. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64375. */
  64376. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64377. /**
  64378. * The base color has two different interpretations depending on the value of metalness.
  64379. * When the material is a metal, the base color is the specific measured reflectance value
  64380. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64381. * of the material.
  64382. */
  64383. baseColor: Color3;
  64384. /**
  64385. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64386. * well as opacity information in the alpha channel.
  64387. */
  64388. baseTexture: BaseTexture;
  64389. /**
  64390. * Specifies the metallic scalar value of the material.
  64391. * Can also be used to scale the metalness values of the metallic texture.
  64392. */
  64393. metallic: number;
  64394. /**
  64395. * Specifies the roughness scalar value of the material.
  64396. * Can also be used to scale the roughness values of the metallic texture.
  64397. */
  64398. roughness: number;
  64399. /**
  64400. * Texture containing both the metallic value in the B channel and the
  64401. * roughness value in the G channel to keep better precision.
  64402. */
  64403. metallicRoughnessTexture: BaseTexture;
  64404. /**
  64405. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64406. *
  64407. * @param name The material name
  64408. * @param scene The scene the material will be use in.
  64409. */
  64410. constructor(name: string, scene: Scene);
  64411. /**
  64412. * Return the currrent class name of the material.
  64413. */
  64414. getClassName(): string;
  64415. /**
  64416. * Makes a duplicate of the current material.
  64417. * @param name - name to use for the new material.
  64418. */
  64419. clone(name: string): PBRMetallicRoughnessMaterial;
  64420. /**
  64421. * Serialize the material to a parsable JSON object.
  64422. */
  64423. serialize(): any;
  64424. /**
  64425. * Parses a JSON object correponding to the serialize function.
  64426. */
  64427. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64428. }
  64429. }
  64430. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64431. import { Scene } from "babylonjs/scene";
  64432. import { Color3 } from "babylonjs/Maths/math.color";
  64433. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64434. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64435. /**
  64436. * The PBR material of BJS following the specular glossiness convention.
  64437. *
  64438. * This fits to the PBR convention in the GLTF definition:
  64439. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64440. */
  64441. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64442. /**
  64443. * Specifies the diffuse color of the material.
  64444. */
  64445. diffuseColor: Color3;
  64446. /**
  64447. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64448. * channel.
  64449. */
  64450. diffuseTexture: BaseTexture;
  64451. /**
  64452. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64453. */
  64454. specularColor: Color3;
  64455. /**
  64456. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64457. */
  64458. glossiness: number;
  64459. /**
  64460. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64461. */
  64462. specularGlossinessTexture: BaseTexture;
  64463. /**
  64464. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64465. *
  64466. * @param name The material name
  64467. * @param scene The scene the material will be use in.
  64468. */
  64469. constructor(name: string, scene: Scene);
  64470. /**
  64471. * Return the currrent class name of the material.
  64472. */
  64473. getClassName(): string;
  64474. /**
  64475. * Makes a duplicate of the current material.
  64476. * @param name - name to use for the new material.
  64477. */
  64478. clone(name: string): PBRSpecularGlossinessMaterial;
  64479. /**
  64480. * Serialize the material to a parsable JSON object.
  64481. */
  64482. serialize(): any;
  64483. /**
  64484. * Parses a JSON object correponding to the serialize function.
  64485. */
  64486. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64487. }
  64488. }
  64489. declare module "babylonjs/Materials/PBR/index" {
  64490. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64491. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64492. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64493. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64494. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64495. }
  64496. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64497. import { Nullable } from "babylonjs/types";
  64498. import { Scene } from "babylonjs/scene";
  64499. import { Matrix } from "babylonjs/Maths/math.vector";
  64500. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64501. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64502. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64503. /**
  64504. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64505. * It can help converting any input color in a desired output one. This can then be used to create effects
  64506. * from sepia, black and white to sixties or futuristic rendering...
  64507. *
  64508. * The only supported format is currently 3dl.
  64509. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64510. */
  64511. export class ColorGradingTexture extends BaseTexture {
  64512. /**
  64513. * The texture URL.
  64514. */
  64515. url: string;
  64516. /**
  64517. * Empty line regex stored for GC.
  64518. */
  64519. private static _noneEmptyLineRegex;
  64520. private _textureMatrix;
  64521. private _onLoad;
  64522. /**
  64523. * Instantiates a ColorGradingTexture from the following parameters.
  64524. *
  64525. * @param url The location of the color gradind data (currently only supporting 3dl)
  64526. * @param sceneOrEngine The scene or engine the texture will be used in
  64527. * @param onLoad defines a callback triggered when the texture has been loaded
  64528. */
  64529. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64530. /**
  64531. * Fires the onload event from the constructor if requested.
  64532. */
  64533. private _triggerOnLoad;
  64534. /**
  64535. * Returns the texture matrix used in most of the material.
  64536. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64537. */
  64538. getTextureMatrix(): Matrix;
  64539. /**
  64540. * Occurs when the file being loaded is a .3dl LUT file.
  64541. */
  64542. private load3dlTexture;
  64543. /**
  64544. * Starts the loading process of the texture.
  64545. */
  64546. private loadTexture;
  64547. /**
  64548. * Clones the color gradind texture.
  64549. */
  64550. clone(): ColorGradingTexture;
  64551. /**
  64552. * Called during delayed load for textures.
  64553. */
  64554. delayLoad(): void;
  64555. /**
  64556. * Parses a color grading texture serialized by Babylon.
  64557. * @param parsedTexture The texture information being parsedTexture
  64558. * @param scene The scene to load the texture in
  64559. * @param rootUrl The root url of the data assets to load
  64560. * @return A color gradind texture
  64561. */
  64562. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64563. /**
  64564. * Serializes the LUT texture to json format.
  64565. */
  64566. serialize(): any;
  64567. }
  64568. }
  64569. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64570. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64571. import { Scene } from "babylonjs/scene";
  64572. import { Nullable } from "babylonjs/types";
  64573. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64574. /**
  64575. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64576. */
  64577. export class EquiRectangularCubeTexture extends BaseTexture {
  64578. /** The six faces of the cube. */
  64579. private static _FacesMapping;
  64580. private _noMipmap;
  64581. private _onLoad;
  64582. private _onError;
  64583. /** The size of the cubemap. */
  64584. private _size;
  64585. /** The buffer of the image. */
  64586. private _buffer;
  64587. /** The width of the input image. */
  64588. private _width;
  64589. /** The height of the input image. */
  64590. private _height;
  64591. /** The URL to the image. */
  64592. url: string;
  64593. /**
  64594. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64595. * @param url The location of the image
  64596. * @param scene The scene the texture will be used in
  64597. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64598. * @param noMipmap Forces to not generate the mipmap if true
  64599. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64600. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64601. * @param onLoad — defines a callback called when texture is loaded
  64602. * @param onError — defines a callback called if there is an error
  64603. */
  64604. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64605. /**
  64606. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64607. */
  64608. private loadImage;
  64609. /**
  64610. * Convert the image buffer into a cubemap and create a CubeTexture.
  64611. */
  64612. private loadTexture;
  64613. /**
  64614. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64615. * @param buffer The ArrayBuffer that should be converted.
  64616. * @returns The buffer as Float32Array.
  64617. */
  64618. private getFloat32ArrayFromArrayBuffer;
  64619. /**
  64620. * Get the current class name of the texture useful for serialization or dynamic coding.
  64621. * @returns "EquiRectangularCubeTexture"
  64622. */
  64623. getClassName(): string;
  64624. /**
  64625. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64626. * @returns A clone of the current EquiRectangularCubeTexture.
  64627. */
  64628. clone(): EquiRectangularCubeTexture;
  64629. }
  64630. }
  64631. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64632. import { Nullable } from "babylonjs/types";
  64633. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64634. import { Matrix } from "babylonjs/Maths/math.vector";
  64635. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64636. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64637. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64638. import { Scene } from "babylonjs/scene";
  64639. /**
  64640. * Defines the options related to the creation of an HtmlElementTexture
  64641. */
  64642. export interface IHtmlElementTextureOptions {
  64643. /**
  64644. * Defines wether mip maps should be created or not.
  64645. */
  64646. generateMipMaps?: boolean;
  64647. /**
  64648. * Defines the sampling mode of the texture.
  64649. */
  64650. samplingMode?: number;
  64651. /**
  64652. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64653. */
  64654. engine: Nullable<ThinEngine>;
  64655. /**
  64656. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64657. */
  64658. scene: Nullable<Scene>;
  64659. }
  64660. /**
  64661. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64662. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64663. * is automatically managed.
  64664. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64665. * in your application.
  64666. *
  64667. * As the update is not automatic, you need to call them manually.
  64668. */
  64669. export class HtmlElementTexture extends BaseTexture {
  64670. /**
  64671. * The texture URL.
  64672. */
  64673. element: HTMLVideoElement | HTMLCanvasElement;
  64674. private static readonly DefaultOptions;
  64675. private _textureMatrix;
  64676. private _isVideo;
  64677. private _generateMipMaps;
  64678. private _samplingMode;
  64679. /**
  64680. * Instantiates a HtmlElementTexture from the following parameters.
  64681. *
  64682. * @param name Defines the name of the texture
  64683. * @param element Defines the video or canvas the texture is filled with
  64684. * @param options Defines the other none mandatory texture creation options
  64685. */
  64686. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64687. private _createInternalTexture;
  64688. /**
  64689. * Returns the texture matrix used in most of the material.
  64690. */
  64691. getTextureMatrix(): Matrix;
  64692. /**
  64693. * Updates the content of the texture.
  64694. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64695. */
  64696. update(invertY?: Nullable<boolean>): void;
  64697. }
  64698. }
  64699. declare module "babylonjs/Misc/tga" {
  64700. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64701. /**
  64702. * Based on jsTGALoader - Javascript loader for TGA file
  64703. * By Vincent Thibault
  64704. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64705. */
  64706. export class TGATools {
  64707. private static _TYPE_INDEXED;
  64708. private static _TYPE_RGB;
  64709. private static _TYPE_GREY;
  64710. private static _TYPE_RLE_INDEXED;
  64711. private static _TYPE_RLE_RGB;
  64712. private static _TYPE_RLE_GREY;
  64713. private static _ORIGIN_MASK;
  64714. private static _ORIGIN_SHIFT;
  64715. private static _ORIGIN_BL;
  64716. private static _ORIGIN_BR;
  64717. private static _ORIGIN_UL;
  64718. private static _ORIGIN_UR;
  64719. /**
  64720. * Gets the header of a TGA file
  64721. * @param data defines the TGA data
  64722. * @returns the header
  64723. */
  64724. static GetTGAHeader(data: Uint8Array): any;
  64725. /**
  64726. * Uploads TGA content to a Babylon Texture
  64727. * @hidden
  64728. */
  64729. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64730. /** @hidden */
  64731. 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;
  64732. /** @hidden */
  64733. 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;
  64734. /** @hidden */
  64735. 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;
  64736. /** @hidden */
  64737. 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;
  64738. /** @hidden */
  64739. 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;
  64740. /** @hidden */
  64741. 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;
  64742. }
  64743. }
  64744. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64745. import { Nullable } from "babylonjs/types";
  64746. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64747. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64748. /**
  64749. * Implementation of the TGA Texture Loader.
  64750. * @hidden
  64751. */
  64752. export class _TGATextureLoader implements IInternalTextureLoader {
  64753. /**
  64754. * Defines wether the loader supports cascade loading the different faces.
  64755. */
  64756. readonly supportCascades: boolean;
  64757. /**
  64758. * This returns if the loader support the current file information.
  64759. * @param extension defines the file extension of the file being loaded
  64760. * @returns true if the loader can load the specified file
  64761. */
  64762. canLoad(extension: string): boolean;
  64763. /**
  64764. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64765. * @param data contains the texture data
  64766. * @param texture defines the BabylonJS internal texture
  64767. * @param createPolynomials will be true if polynomials have been requested
  64768. * @param onLoad defines the callback to trigger once the texture is ready
  64769. * @param onError defines the callback to trigger in case of error
  64770. */
  64771. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64772. /**
  64773. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64774. * @param data contains the texture data
  64775. * @param texture defines the BabylonJS internal texture
  64776. * @param callback defines the method to call once ready to upload
  64777. */
  64778. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64779. }
  64780. }
  64781. declare module "babylonjs/Misc/basis" {
  64782. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64783. /**
  64784. * Info about the .basis files
  64785. */
  64786. class BasisFileInfo {
  64787. /**
  64788. * If the file has alpha
  64789. */
  64790. hasAlpha: boolean;
  64791. /**
  64792. * Info about each image of the basis file
  64793. */
  64794. images: Array<{
  64795. levels: Array<{
  64796. width: number;
  64797. height: number;
  64798. transcodedPixels: ArrayBufferView;
  64799. }>;
  64800. }>;
  64801. }
  64802. /**
  64803. * Result of transcoding a basis file
  64804. */
  64805. class TranscodeResult {
  64806. /**
  64807. * Info about the .basis file
  64808. */
  64809. fileInfo: BasisFileInfo;
  64810. /**
  64811. * Format to use when loading the file
  64812. */
  64813. format: number;
  64814. }
  64815. /**
  64816. * Configuration options for the Basis transcoder
  64817. */
  64818. export class BasisTranscodeConfiguration {
  64819. /**
  64820. * Supported compression formats used to determine the supported output format of the transcoder
  64821. */
  64822. supportedCompressionFormats?: {
  64823. /**
  64824. * etc1 compression format
  64825. */
  64826. etc1?: boolean;
  64827. /**
  64828. * s3tc compression format
  64829. */
  64830. s3tc?: boolean;
  64831. /**
  64832. * pvrtc compression format
  64833. */
  64834. pvrtc?: boolean;
  64835. /**
  64836. * etc2 compression format
  64837. */
  64838. etc2?: boolean;
  64839. };
  64840. /**
  64841. * If mipmap levels should be loaded for transcoded images (Default: true)
  64842. */
  64843. loadMipmapLevels?: boolean;
  64844. /**
  64845. * Index of a single image to load (Default: all images)
  64846. */
  64847. loadSingleImage?: number;
  64848. }
  64849. /**
  64850. * Used to load .Basis files
  64851. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64852. */
  64853. export class BasisTools {
  64854. private static _IgnoreSupportedFormats;
  64855. /**
  64856. * URL to use when loading the basis transcoder
  64857. */
  64858. static JSModuleURL: string;
  64859. /**
  64860. * URL to use when loading the wasm module for the transcoder
  64861. */
  64862. static WasmModuleURL: string;
  64863. /**
  64864. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64865. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64866. * @returns internal format corresponding to the Basis format
  64867. */
  64868. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64869. private static _WorkerPromise;
  64870. private static _Worker;
  64871. private static _actionId;
  64872. private static _CreateWorkerAsync;
  64873. /**
  64874. * Transcodes a loaded image file to compressed pixel data
  64875. * @param data image data to transcode
  64876. * @param config configuration options for the transcoding
  64877. * @returns a promise resulting in the transcoded image
  64878. */
  64879. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64880. /**
  64881. * Loads a texture from the transcode result
  64882. * @param texture texture load to
  64883. * @param transcodeResult the result of transcoding the basis file to load from
  64884. */
  64885. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64886. }
  64887. }
  64888. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64889. import { Nullable } from "babylonjs/types";
  64890. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64891. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64892. /**
  64893. * Loader for .basis file format
  64894. */
  64895. export class _BasisTextureLoader implements IInternalTextureLoader {
  64896. /**
  64897. * Defines whether the loader supports cascade loading the different faces.
  64898. */
  64899. readonly supportCascades: boolean;
  64900. /**
  64901. * This returns if the loader support the current file information.
  64902. * @param extension defines the file extension of the file being loaded
  64903. * @returns true if the loader can load the specified file
  64904. */
  64905. canLoad(extension: string): boolean;
  64906. /**
  64907. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64908. * @param data contains the texture data
  64909. * @param texture defines the BabylonJS internal texture
  64910. * @param createPolynomials will be true if polynomials have been requested
  64911. * @param onLoad defines the callback to trigger once the texture is ready
  64912. * @param onError defines the callback to trigger in case of error
  64913. */
  64914. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64915. /**
  64916. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64917. * @param data contains the texture data
  64918. * @param texture defines the BabylonJS internal texture
  64919. * @param callback defines the method to call once ready to upload
  64920. */
  64921. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64922. }
  64923. }
  64924. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64925. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64926. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64927. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64928. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64929. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64930. }
  64931. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64932. import { Vector2 } from "babylonjs/Maths/math.vector";
  64933. /**
  64934. * Defines the basic options interface of a TexturePacker Frame
  64935. */
  64936. export interface ITexturePackerFrame {
  64937. /**
  64938. * The frame ID
  64939. */
  64940. id: number;
  64941. /**
  64942. * The frames Scale
  64943. */
  64944. scale: Vector2;
  64945. /**
  64946. * The Frames offset
  64947. */
  64948. offset: Vector2;
  64949. }
  64950. /**
  64951. * This is a support class for frame Data on texture packer sets.
  64952. */
  64953. export class TexturePackerFrame implements ITexturePackerFrame {
  64954. /**
  64955. * The frame ID
  64956. */
  64957. id: number;
  64958. /**
  64959. * The frames Scale
  64960. */
  64961. scale: Vector2;
  64962. /**
  64963. * The Frames offset
  64964. */
  64965. offset: Vector2;
  64966. /**
  64967. * Initializes a texture package frame.
  64968. * @param id The numerical frame identifier
  64969. * @param scale Scalar Vector2 for UV frame
  64970. * @param offset Vector2 for the frame position in UV units.
  64971. * @returns TexturePackerFrame
  64972. */
  64973. constructor(id: number, scale: Vector2, offset: Vector2);
  64974. }
  64975. }
  64976. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64978. import { Scene } from "babylonjs/scene";
  64979. import { Nullable } from "babylonjs/types";
  64980. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64981. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64982. /**
  64983. * Defines the basic options interface of a TexturePacker
  64984. */
  64985. export interface ITexturePackerOptions {
  64986. /**
  64987. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64988. */
  64989. map?: string[];
  64990. /**
  64991. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64992. */
  64993. uvsIn?: string;
  64994. /**
  64995. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64996. */
  64997. uvsOut?: string;
  64998. /**
  64999. * number representing the layout style. Defaults to LAYOUT_STRIP
  65000. */
  65001. layout?: number;
  65002. /**
  65003. * number of columns if using custom column count layout(2). This defaults to 4.
  65004. */
  65005. colnum?: number;
  65006. /**
  65007. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65008. */
  65009. updateInputMeshes?: boolean;
  65010. /**
  65011. * boolean flag to dispose all the source textures. Defaults to true.
  65012. */
  65013. disposeSources?: boolean;
  65014. /**
  65015. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65016. */
  65017. fillBlanks?: boolean;
  65018. /**
  65019. * string value representing the context fill style color. Defaults to 'black'.
  65020. */
  65021. customFillColor?: string;
  65022. /**
  65023. * Width and Height Value of each Frame in the TexturePacker Sets
  65024. */
  65025. frameSize?: number;
  65026. /**
  65027. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65028. */
  65029. paddingRatio?: number;
  65030. /**
  65031. * Number that declares the fill method for the padding gutter.
  65032. */
  65033. paddingMode?: number;
  65034. /**
  65035. * If in SUBUV_COLOR padding mode what color to use.
  65036. */
  65037. paddingColor?: Color3 | Color4;
  65038. }
  65039. /**
  65040. * Defines the basic interface of a TexturePacker JSON File
  65041. */
  65042. export interface ITexturePackerJSON {
  65043. /**
  65044. * The frame ID
  65045. */
  65046. name: string;
  65047. /**
  65048. * The base64 channel data
  65049. */
  65050. sets: any;
  65051. /**
  65052. * The options of the Packer
  65053. */
  65054. options: ITexturePackerOptions;
  65055. /**
  65056. * The frame data of the Packer
  65057. */
  65058. frames: Array<number>;
  65059. }
  65060. /**
  65061. * This is a support class that generates a series of packed texture sets.
  65062. * @see https://doc.babylonjs.com/babylon101/materials
  65063. */
  65064. export class TexturePacker {
  65065. /** Packer Layout Constant 0 */
  65066. static readonly LAYOUT_STRIP: number;
  65067. /** Packer Layout Constant 1 */
  65068. static readonly LAYOUT_POWER2: number;
  65069. /** Packer Layout Constant 2 */
  65070. static readonly LAYOUT_COLNUM: number;
  65071. /** Packer Layout Constant 0 */
  65072. static readonly SUBUV_WRAP: number;
  65073. /** Packer Layout Constant 1 */
  65074. static readonly SUBUV_EXTEND: number;
  65075. /** Packer Layout Constant 2 */
  65076. static readonly SUBUV_COLOR: number;
  65077. /** The Name of the Texture Package */
  65078. name: string;
  65079. /** The scene scope of the TexturePacker */
  65080. scene: Scene;
  65081. /** The Meshes to target */
  65082. meshes: AbstractMesh[];
  65083. /** Arguments passed with the Constructor */
  65084. options: ITexturePackerOptions;
  65085. /** The promise that is started upon initialization */
  65086. promise: Nullable<Promise<TexturePacker | string>>;
  65087. /** The Container object for the channel sets that are generated */
  65088. sets: object;
  65089. /** The Container array for the frames that are generated */
  65090. frames: TexturePackerFrame[];
  65091. /** The expected number of textures the system is parsing. */
  65092. private _expecting;
  65093. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65094. private _paddingValue;
  65095. /**
  65096. * Initializes a texture package series from an array of meshes or a single mesh.
  65097. * @param name The name of the package
  65098. * @param meshes The target meshes to compose the package from
  65099. * @param options The arguments that texture packer should follow while building.
  65100. * @param scene The scene which the textures are scoped to.
  65101. * @returns TexturePacker
  65102. */
  65103. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65104. /**
  65105. * Starts the package process
  65106. * @param resolve The promises resolution function
  65107. * @returns TexturePacker
  65108. */
  65109. private _createFrames;
  65110. /**
  65111. * Calculates the Size of the Channel Sets
  65112. * @returns Vector2
  65113. */
  65114. private _calculateSize;
  65115. /**
  65116. * Calculates the UV data for the frames.
  65117. * @param baseSize the base frameSize
  65118. * @param padding the base frame padding
  65119. * @param dtSize size of the Dynamic Texture for that channel
  65120. * @param dtUnits is 1/dtSize
  65121. * @param update flag to update the input meshes
  65122. */
  65123. private _calculateMeshUVFrames;
  65124. /**
  65125. * Calculates the frames Offset.
  65126. * @param index of the frame
  65127. * @returns Vector2
  65128. */
  65129. private _getFrameOffset;
  65130. /**
  65131. * Updates a Mesh to the frame data
  65132. * @param mesh that is the target
  65133. * @param frameID or the frame index
  65134. */
  65135. private _updateMeshUV;
  65136. /**
  65137. * Updates a Meshes materials to use the texture packer channels
  65138. * @param m is the mesh to target
  65139. * @param force all channels on the packer to be set.
  65140. */
  65141. private _updateTextureReferences;
  65142. /**
  65143. * Public method to set a Mesh to a frame
  65144. * @param m that is the target
  65145. * @param frameID or the frame index
  65146. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65147. */
  65148. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65149. /**
  65150. * Starts the async promise to compile the texture packer.
  65151. * @returns Promise<void>
  65152. */
  65153. processAsync(): Promise<void>;
  65154. /**
  65155. * Disposes all textures associated with this packer
  65156. */
  65157. dispose(): void;
  65158. /**
  65159. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65160. * @param imageType is the image type to use.
  65161. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65162. */
  65163. download(imageType?: string, quality?: number): void;
  65164. /**
  65165. * Public method to load a texturePacker JSON file.
  65166. * @param data of the JSON file in string format.
  65167. */
  65168. updateFromJSON(data: string): void;
  65169. }
  65170. }
  65171. declare module "babylonjs/Materials/Textures/Packer/index" {
  65172. export * from "babylonjs/Materials/Textures/Packer/packer";
  65173. export * from "babylonjs/Materials/Textures/Packer/frame";
  65174. }
  65175. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65176. import { Scene } from "babylonjs/scene";
  65177. import { Texture } from "babylonjs/Materials/Textures/texture";
  65178. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65179. /**
  65180. * 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.
  65181. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65182. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65183. */
  65184. export class CustomProceduralTexture extends ProceduralTexture {
  65185. private _animate;
  65186. private _time;
  65187. private _config;
  65188. private _texturePath;
  65189. /**
  65190. * Instantiates a new Custom Procedural Texture.
  65191. * 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.
  65192. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65193. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65194. * @param name Define the name of the texture
  65195. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65196. * @param size Define the size of the texture to create
  65197. * @param scene Define the scene the texture belongs to
  65198. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65199. * @param generateMipMaps Define if the texture should creates mip maps or not
  65200. */
  65201. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65202. private _loadJson;
  65203. /**
  65204. * Is the texture ready to be used ? (rendered at least once)
  65205. * @returns true if ready, otherwise, false.
  65206. */
  65207. isReady(): boolean;
  65208. /**
  65209. * Render the texture to its associated render target.
  65210. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65211. */
  65212. render(useCameraPostProcess?: boolean): void;
  65213. /**
  65214. * Update the list of dependant textures samplers in the shader.
  65215. */
  65216. updateTextures(): void;
  65217. /**
  65218. * Update the uniform values of the procedural texture in the shader.
  65219. */
  65220. updateShaderUniforms(): void;
  65221. /**
  65222. * Define if the texture animates or not.
  65223. */
  65224. get animate(): boolean;
  65225. set animate(value: boolean);
  65226. }
  65227. }
  65228. declare module "babylonjs/Shaders/noise.fragment" {
  65229. /** @hidden */
  65230. export var noisePixelShader: {
  65231. name: string;
  65232. shader: string;
  65233. };
  65234. }
  65235. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65236. import { Nullable } from "babylonjs/types";
  65237. import { Scene } from "babylonjs/scene";
  65238. import { Texture } from "babylonjs/Materials/Textures/texture";
  65239. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65240. import "babylonjs/Shaders/noise.fragment";
  65241. /**
  65242. * Class used to generate noise procedural textures
  65243. */
  65244. export class NoiseProceduralTexture extends ProceduralTexture {
  65245. /** Gets or sets the start time (default is 0) */
  65246. time: number;
  65247. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65248. brightness: number;
  65249. /** Defines the number of octaves to process */
  65250. octaves: number;
  65251. /** Defines the level of persistence (0.8 by default) */
  65252. persistence: number;
  65253. /** Gets or sets animation speed factor (default is 1) */
  65254. animationSpeedFactor: number;
  65255. /**
  65256. * Creates a new NoiseProceduralTexture
  65257. * @param name defines the name fo the texture
  65258. * @param size defines the size of the texture (default is 256)
  65259. * @param scene defines the hosting scene
  65260. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65261. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65262. */
  65263. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65264. private _updateShaderUniforms;
  65265. protected _getDefines(): string;
  65266. /** Generate the current state of the procedural texture */
  65267. render(useCameraPostProcess?: boolean): void;
  65268. /**
  65269. * Serializes this noise procedural texture
  65270. * @returns a serialized noise procedural texture object
  65271. */
  65272. serialize(): any;
  65273. /**
  65274. * Clone the texture.
  65275. * @returns the cloned texture
  65276. */
  65277. clone(): NoiseProceduralTexture;
  65278. /**
  65279. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65280. * @param parsedTexture defines parsed texture data
  65281. * @param scene defines the current scene
  65282. * @param rootUrl defines the root URL containing noise procedural texture information
  65283. * @returns a parsed NoiseProceduralTexture
  65284. */
  65285. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65286. }
  65287. }
  65288. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65289. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65290. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65291. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65292. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65293. }
  65294. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65295. import { Nullable } from "babylonjs/types";
  65296. import { Scene } from "babylonjs/scene";
  65297. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65298. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65299. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65300. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65301. /**
  65302. * Raw cube texture where the raw buffers are passed in
  65303. */
  65304. export class RawCubeTexture extends CubeTexture {
  65305. /**
  65306. * Creates a cube texture where the raw buffers are passed in.
  65307. * @param scene defines the scene the texture is attached to
  65308. * @param data defines the array of data to use to create each face
  65309. * @param size defines the size of the textures
  65310. * @param format defines the format of the data
  65311. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65312. * @param generateMipMaps defines if the engine should generate the mip levels
  65313. * @param invertY defines if data must be stored with Y axis inverted
  65314. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65315. * @param compression defines the compression used (null by default)
  65316. */
  65317. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65318. /**
  65319. * Updates the raw cube texture.
  65320. * @param data defines the data to store
  65321. * @param format defines the data format
  65322. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65323. * @param invertY defines if data must be stored with Y axis inverted
  65324. * @param compression defines the compression used (null by default)
  65325. * @param level defines which level of the texture to update
  65326. */
  65327. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65328. /**
  65329. * Updates a raw cube texture with RGBD encoded data.
  65330. * @param data defines the array of data [mipmap][face] to use to create each face
  65331. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65332. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65333. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65334. * @returns a promsie that resolves when the operation is complete
  65335. */
  65336. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65337. /**
  65338. * Clones the raw cube texture.
  65339. * @return a new cube texture
  65340. */
  65341. clone(): CubeTexture;
  65342. /** @hidden */
  65343. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65344. }
  65345. }
  65346. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65347. import { Scene } from "babylonjs/scene";
  65348. import { Texture } from "babylonjs/Materials/Textures/texture";
  65349. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65350. /**
  65351. * Class used to store 2D array textures containing user data
  65352. */
  65353. export class RawTexture2DArray extends Texture {
  65354. /** Gets or sets the texture format to use */
  65355. format: number;
  65356. /**
  65357. * Create a new RawTexture2DArray
  65358. * @param data defines the data of the texture
  65359. * @param width defines the width of the texture
  65360. * @param height defines the height of the texture
  65361. * @param depth defines the number of layers of the texture
  65362. * @param format defines the texture format to use
  65363. * @param scene defines the hosting scene
  65364. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65365. * @param invertY defines if texture must be stored with Y axis inverted
  65366. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65367. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65368. */
  65369. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65370. /** Gets or sets the texture format to use */
  65371. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65372. /**
  65373. * Update the texture with new data
  65374. * @param data defines the data to store in the texture
  65375. */
  65376. update(data: ArrayBufferView): void;
  65377. }
  65378. }
  65379. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65380. import { Scene } from "babylonjs/scene";
  65381. import { Texture } from "babylonjs/Materials/Textures/texture";
  65382. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65383. /**
  65384. * Class used to store 3D textures containing user data
  65385. */
  65386. export class RawTexture3D extends Texture {
  65387. /** Gets or sets the texture format to use */
  65388. format: number;
  65389. /**
  65390. * Create a new RawTexture3D
  65391. * @param data defines the data of the texture
  65392. * @param width defines the width of the texture
  65393. * @param height defines the height of the texture
  65394. * @param depth defines the depth of the texture
  65395. * @param format defines the texture format to use
  65396. * @param scene defines the hosting scene
  65397. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65398. * @param invertY defines if texture must be stored with Y axis inverted
  65399. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65400. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65401. */
  65402. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65403. /** Gets or sets the texture format to use */
  65404. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65405. /**
  65406. * Update the texture with new data
  65407. * @param data defines the data to store in the texture
  65408. */
  65409. update(data: ArrayBufferView): void;
  65410. }
  65411. }
  65412. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65413. import { Scene } from "babylonjs/scene";
  65414. import { Plane } from "babylonjs/Maths/math.plane";
  65415. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65416. /**
  65417. * Creates a refraction texture used by refraction channel of the standard material.
  65418. * It is like a mirror but to see through a material.
  65419. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65420. */
  65421. export class RefractionTexture extends RenderTargetTexture {
  65422. /**
  65423. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65424. * 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.
  65425. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65426. */
  65427. refractionPlane: Plane;
  65428. /**
  65429. * Define how deep under the surface we should see.
  65430. */
  65431. depth: number;
  65432. /**
  65433. * Creates a refraction texture used by refraction channel of the standard material.
  65434. * It is like a mirror but to see through a material.
  65435. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65436. * @param name Define the texture name
  65437. * @param size Define the size of the underlying texture
  65438. * @param scene Define the scene the refraction belongs to
  65439. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65440. */
  65441. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65442. /**
  65443. * Clone the refraction texture.
  65444. * @returns the cloned texture
  65445. */
  65446. clone(): RefractionTexture;
  65447. /**
  65448. * Serialize the texture to a JSON representation you could use in Parse later on
  65449. * @returns the serialized JSON representation
  65450. */
  65451. serialize(): any;
  65452. }
  65453. }
  65454. declare module "babylonjs/Materials/Textures/index" {
  65455. export * from "babylonjs/Materials/Textures/baseTexture";
  65456. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65457. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65458. export * from "babylonjs/Materials/Textures/cubeTexture";
  65459. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65460. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65461. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65462. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65463. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65464. export * from "babylonjs/Materials/Textures/internalTexture";
  65465. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65466. export * from "babylonjs/Materials/Textures/Loaders/index";
  65467. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65468. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65469. export * from "babylonjs/Materials/Textures/Packer/index";
  65470. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65471. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65472. export * from "babylonjs/Materials/Textures/rawTexture";
  65473. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65474. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65475. export * from "babylonjs/Materials/Textures/refractionTexture";
  65476. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65477. export * from "babylonjs/Materials/Textures/texture";
  65478. export * from "babylonjs/Materials/Textures/videoTexture";
  65479. }
  65480. declare module "babylonjs/Materials/Node/Enums/index" {
  65481. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65482. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65483. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65484. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65485. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65486. }
  65487. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65491. import { Mesh } from "babylonjs/Meshes/mesh";
  65492. import { Effect } from "babylonjs/Materials/effect";
  65493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65494. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65495. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65496. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65497. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65498. /**
  65499. * Block used to add support for vertex skinning (bones)
  65500. */
  65501. export class BonesBlock extends NodeMaterialBlock {
  65502. /**
  65503. * Creates a new BonesBlock
  65504. * @param name defines the block name
  65505. */
  65506. constructor(name: string);
  65507. /**
  65508. * Initialize the block and prepare the context for build
  65509. * @param state defines the state that will be used for the build
  65510. */
  65511. initialize(state: NodeMaterialBuildState): void;
  65512. /**
  65513. * Gets the current class name
  65514. * @returns the class name
  65515. */
  65516. getClassName(): string;
  65517. /**
  65518. * Gets the matrix indices input component
  65519. */
  65520. get matricesIndices(): NodeMaterialConnectionPoint;
  65521. /**
  65522. * Gets the matrix weights input component
  65523. */
  65524. get matricesWeights(): NodeMaterialConnectionPoint;
  65525. /**
  65526. * Gets the extra matrix indices input component
  65527. */
  65528. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65529. /**
  65530. * Gets the extra matrix weights input component
  65531. */
  65532. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65533. /**
  65534. * Gets the world input component
  65535. */
  65536. get world(): NodeMaterialConnectionPoint;
  65537. /**
  65538. * Gets the output component
  65539. */
  65540. get output(): NodeMaterialConnectionPoint;
  65541. autoConfigure(material: NodeMaterial): void;
  65542. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65543. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65544. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65545. protected _buildBlock(state: NodeMaterialBuildState): this;
  65546. }
  65547. }
  65548. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65549. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65551. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65553. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65554. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65555. /**
  65556. * Block used to add support for instances
  65557. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65558. */
  65559. export class InstancesBlock extends NodeMaterialBlock {
  65560. /**
  65561. * Creates a new InstancesBlock
  65562. * @param name defines the block name
  65563. */
  65564. constructor(name: string);
  65565. /**
  65566. * Gets the current class name
  65567. * @returns the class name
  65568. */
  65569. getClassName(): string;
  65570. /**
  65571. * Gets the first world row input component
  65572. */
  65573. get world0(): NodeMaterialConnectionPoint;
  65574. /**
  65575. * Gets the second world row input component
  65576. */
  65577. get world1(): NodeMaterialConnectionPoint;
  65578. /**
  65579. * Gets the third world row input component
  65580. */
  65581. get world2(): NodeMaterialConnectionPoint;
  65582. /**
  65583. * Gets the forth world row input component
  65584. */
  65585. get world3(): NodeMaterialConnectionPoint;
  65586. /**
  65587. * Gets the world input component
  65588. */
  65589. get world(): NodeMaterialConnectionPoint;
  65590. /**
  65591. * Gets the output component
  65592. */
  65593. get output(): NodeMaterialConnectionPoint;
  65594. /**
  65595. * Gets the isntanceID component
  65596. */
  65597. get instanceID(): NodeMaterialConnectionPoint;
  65598. autoConfigure(material: NodeMaterial): void;
  65599. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65600. protected _buildBlock(state: NodeMaterialBuildState): this;
  65601. }
  65602. }
  65603. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65608. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65609. import { Effect } from "babylonjs/Materials/effect";
  65610. import { Mesh } from "babylonjs/Meshes/mesh";
  65611. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65612. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65613. /**
  65614. * Block used to add morph targets support to vertex shader
  65615. */
  65616. export class MorphTargetsBlock extends NodeMaterialBlock {
  65617. private _repeatableContentAnchor;
  65618. /**
  65619. * Create a new MorphTargetsBlock
  65620. * @param name defines the block name
  65621. */
  65622. constructor(name: string);
  65623. /**
  65624. * Gets the current class name
  65625. * @returns the class name
  65626. */
  65627. getClassName(): string;
  65628. /**
  65629. * Gets the position input component
  65630. */
  65631. get position(): NodeMaterialConnectionPoint;
  65632. /**
  65633. * Gets the normal input component
  65634. */
  65635. get normal(): NodeMaterialConnectionPoint;
  65636. /**
  65637. * Gets the tangent input component
  65638. */
  65639. get tangent(): NodeMaterialConnectionPoint;
  65640. /**
  65641. * Gets the tangent input component
  65642. */
  65643. get uv(): NodeMaterialConnectionPoint;
  65644. /**
  65645. * Gets the position output component
  65646. */
  65647. get positionOutput(): NodeMaterialConnectionPoint;
  65648. /**
  65649. * Gets the normal output component
  65650. */
  65651. get normalOutput(): NodeMaterialConnectionPoint;
  65652. /**
  65653. * Gets the tangent output component
  65654. */
  65655. get tangentOutput(): NodeMaterialConnectionPoint;
  65656. /**
  65657. * Gets the tangent output component
  65658. */
  65659. get uvOutput(): NodeMaterialConnectionPoint;
  65660. initialize(state: NodeMaterialBuildState): void;
  65661. autoConfigure(material: NodeMaterial): void;
  65662. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65663. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65664. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65665. protected _buildBlock(state: NodeMaterialBuildState): this;
  65666. }
  65667. }
  65668. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65672. import { Nullable } from "babylonjs/types";
  65673. import { Scene } from "babylonjs/scene";
  65674. import { Effect } from "babylonjs/Materials/effect";
  65675. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65676. import { Mesh } from "babylonjs/Meshes/mesh";
  65677. import { Light } from "babylonjs/Lights/light";
  65678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65679. /**
  65680. * Block used to get data information from a light
  65681. */
  65682. export class LightInformationBlock extends NodeMaterialBlock {
  65683. private _lightDataUniformName;
  65684. private _lightColorUniformName;
  65685. private _lightTypeDefineName;
  65686. /**
  65687. * Gets or sets the light associated with this block
  65688. */
  65689. light: Nullable<Light>;
  65690. /**
  65691. * Creates a new LightInformationBlock
  65692. * @param name defines the block name
  65693. */
  65694. constructor(name: string);
  65695. /**
  65696. * Gets the current class name
  65697. * @returns the class name
  65698. */
  65699. getClassName(): string;
  65700. /**
  65701. * Gets the world position input component
  65702. */
  65703. get worldPosition(): NodeMaterialConnectionPoint;
  65704. /**
  65705. * Gets the direction output component
  65706. */
  65707. get direction(): NodeMaterialConnectionPoint;
  65708. /**
  65709. * Gets the direction output component
  65710. */
  65711. get color(): NodeMaterialConnectionPoint;
  65712. /**
  65713. * Gets the direction output component
  65714. */
  65715. get intensity(): NodeMaterialConnectionPoint;
  65716. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65717. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65718. protected _buildBlock(state: NodeMaterialBuildState): this;
  65719. serialize(): any;
  65720. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65721. }
  65722. }
  65723. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65724. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65725. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65726. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65727. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65728. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65729. }
  65730. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65731. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65732. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65733. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65735. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65736. import { Effect } from "babylonjs/Materials/effect";
  65737. import { Mesh } from "babylonjs/Meshes/mesh";
  65738. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65739. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65740. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65741. /**
  65742. * Block used to add image processing support to fragment shader
  65743. */
  65744. export class ImageProcessingBlock extends NodeMaterialBlock {
  65745. /**
  65746. * Create a new ImageProcessingBlock
  65747. * @param name defines the block name
  65748. */
  65749. constructor(name: string);
  65750. /**
  65751. * Gets the current class name
  65752. * @returns the class name
  65753. */
  65754. getClassName(): string;
  65755. /**
  65756. * Gets the color input component
  65757. */
  65758. get color(): NodeMaterialConnectionPoint;
  65759. /**
  65760. * Gets the output component
  65761. */
  65762. get output(): NodeMaterialConnectionPoint;
  65763. /**
  65764. * Initialize the block and prepare the context for build
  65765. * @param state defines the state that will be used for the build
  65766. */
  65767. initialize(state: NodeMaterialBuildState): void;
  65768. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65769. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65770. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65771. protected _buildBlock(state: NodeMaterialBuildState): this;
  65772. }
  65773. }
  65774. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65775. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65776. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65777. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65778. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65780. import { Effect } from "babylonjs/Materials/effect";
  65781. import { Mesh } from "babylonjs/Meshes/mesh";
  65782. import { Scene } from "babylonjs/scene";
  65783. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65784. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65785. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65786. /**
  65787. * Block used to pertub normals based on a normal map
  65788. */
  65789. export class PerturbNormalBlock extends NodeMaterialBlock {
  65790. private _tangentSpaceParameterName;
  65791. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65792. invertX: boolean;
  65793. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65794. invertY: boolean;
  65795. /**
  65796. * Create a new PerturbNormalBlock
  65797. * @param name defines the block name
  65798. */
  65799. constructor(name: string);
  65800. /**
  65801. * Gets the current class name
  65802. * @returns the class name
  65803. */
  65804. getClassName(): string;
  65805. /**
  65806. * Gets the world position input component
  65807. */
  65808. get worldPosition(): NodeMaterialConnectionPoint;
  65809. /**
  65810. * Gets the world normal input component
  65811. */
  65812. get worldNormal(): NodeMaterialConnectionPoint;
  65813. /**
  65814. * Gets the world tangent input component
  65815. */
  65816. get worldTangent(): NodeMaterialConnectionPoint;
  65817. /**
  65818. * Gets the uv input component
  65819. */
  65820. get uv(): NodeMaterialConnectionPoint;
  65821. /**
  65822. * Gets the normal map color input component
  65823. */
  65824. get normalMapColor(): NodeMaterialConnectionPoint;
  65825. /**
  65826. * Gets the strength input component
  65827. */
  65828. get strength(): NodeMaterialConnectionPoint;
  65829. /**
  65830. * Gets the output component
  65831. */
  65832. get output(): NodeMaterialConnectionPoint;
  65833. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65834. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65835. autoConfigure(material: NodeMaterial): void;
  65836. protected _buildBlock(state: NodeMaterialBuildState): this;
  65837. protected _dumpPropertiesCode(): string;
  65838. serialize(): any;
  65839. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65840. }
  65841. }
  65842. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65843. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65844. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65845. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65846. /**
  65847. * Block used to discard a pixel if a value is smaller than a cutoff
  65848. */
  65849. export class DiscardBlock extends NodeMaterialBlock {
  65850. /**
  65851. * Create a new DiscardBlock
  65852. * @param name defines the block name
  65853. */
  65854. constructor(name: string);
  65855. /**
  65856. * Gets the current class name
  65857. * @returns the class name
  65858. */
  65859. getClassName(): string;
  65860. /**
  65861. * Gets the color input component
  65862. */
  65863. get value(): NodeMaterialConnectionPoint;
  65864. /**
  65865. * Gets the cutoff input component
  65866. */
  65867. get cutoff(): NodeMaterialConnectionPoint;
  65868. protected _buildBlock(state: NodeMaterialBuildState): this;
  65869. }
  65870. }
  65871. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65872. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65873. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65874. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65875. /**
  65876. * Block used to test if the fragment shader is front facing
  65877. */
  65878. export class FrontFacingBlock extends NodeMaterialBlock {
  65879. /**
  65880. * Creates a new FrontFacingBlock
  65881. * @param name defines the block name
  65882. */
  65883. constructor(name: string);
  65884. /**
  65885. * Gets the current class name
  65886. * @returns the class name
  65887. */
  65888. getClassName(): string;
  65889. /**
  65890. * Gets the output component
  65891. */
  65892. get output(): NodeMaterialConnectionPoint;
  65893. protected _buildBlock(state: NodeMaterialBuildState): this;
  65894. }
  65895. }
  65896. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65897. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65898. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65899. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65900. /**
  65901. * Block used to get the derivative value on x and y of a given input
  65902. */
  65903. export class DerivativeBlock extends NodeMaterialBlock {
  65904. /**
  65905. * Create a new DerivativeBlock
  65906. * @param name defines the block name
  65907. */
  65908. constructor(name: string);
  65909. /**
  65910. * Gets the current class name
  65911. * @returns the class name
  65912. */
  65913. getClassName(): string;
  65914. /**
  65915. * Gets the input component
  65916. */
  65917. get input(): NodeMaterialConnectionPoint;
  65918. /**
  65919. * Gets the derivative output on x
  65920. */
  65921. get dx(): NodeMaterialConnectionPoint;
  65922. /**
  65923. * Gets the derivative output on y
  65924. */
  65925. get dy(): NodeMaterialConnectionPoint;
  65926. protected _buildBlock(state: NodeMaterialBuildState): this;
  65927. }
  65928. }
  65929. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65932. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65933. /**
  65934. * Block used to make gl_FragCoord available
  65935. */
  65936. export class FragCoordBlock extends NodeMaterialBlock {
  65937. /**
  65938. * Creates a new FragCoordBlock
  65939. * @param name defines the block name
  65940. */
  65941. constructor(name: string);
  65942. /**
  65943. * Gets the current class name
  65944. * @returns the class name
  65945. */
  65946. getClassName(): string;
  65947. /**
  65948. * Gets the xy component
  65949. */
  65950. get xy(): NodeMaterialConnectionPoint;
  65951. /**
  65952. * Gets the xyz component
  65953. */
  65954. get xyz(): NodeMaterialConnectionPoint;
  65955. /**
  65956. * Gets the xyzw component
  65957. */
  65958. get xyzw(): NodeMaterialConnectionPoint;
  65959. /**
  65960. * Gets the x component
  65961. */
  65962. get x(): NodeMaterialConnectionPoint;
  65963. /**
  65964. * Gets the y component
  65965. */
  65966. get y(): NodeMaterialConnectionPoint;
  65967. /**
  65968. * Gets the z component
  65969. */
  65970. get z(): NodeMaterialConnectionPoint;
  65971. /**
  65972. * Gets the w component
  65973. */
  65974. get output(): NodeMaterialConnectionPoint;
  65975. protected writeOutputs(state: NodeMaterialBuildState): string;
  65976. protected _buildBlock(state: NodeMaterialBuildState): this;
  65977. }
  65978. }
  65979. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65983. import { Effect } from "babylonjs/Materials/effect";
  65984. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65985. import { Mesh } from "babylonjs/Meshes/mesh";
  65986. /**
  65987. * Block used to get the screen sizes
  65988. */
  65989. export class ScreenSizeBlock extends NodeMaterialBlock {
  65990. private _varName;
  65991. private _scene;
  65992. /**
  65993. * Creates a new ScreenSizeBlock
  65994. * @param name defines the block name
  65995. */
  65996. constructor(name: string);
  65997. /**
  65998. * Gets the current class name
  65999. * @returns the class name
  66000. */
  66001. getClassName(): string;
  66002. /**
  66003. * Gets the xy component
  66004. */
  66005. get xy(): NodeMaterialConnectionPoint;
  66006. /**
  66007. * Gets the x component
  66008. */
  66009. get x(): NodeMaterialConnectionPoint;
  66010. /**
  66011. * Gets the y component
  66012. */
  66013. get y(): NodeMaterialConnectionPoint;
  66014. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66015. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66016. protected _buildBlock(state: NodeMaterialBuildState): this;
  66017. }
  66018. }
  66019. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66020. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66021. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66022. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66023. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66024. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66025. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66026. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66027. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66028. }
  66029. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66032. import { Mesh } from "babylonjs/Meshes/mesh";
  66033. import { Effect } from "babylonjs/Materials/effect";
  66034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66036. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66037. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66038. /**
  66039. * Block used to add support for scene fog
  66040. */
  66041. export class FogBlock extends NodeMaterialBlock {
  66042. private _fogDistanceName;
  66043. private _fogParameters;
  66044. /**
  66045. * Create a new FogBlock
  66046. * @param name defines the block name
  66047. */
  66048. constructor(name: string);
  66049. /**
  66050. * Gets the current class name
  66051. * @returns the class name
  66052. */
  66053. getClassName(): string;
  66054. /**
  66055. * Gets the world position input component
  66056. */
  66057. get worldPosition(): NodeMaterialConnectionPoint;
  66058. /**
  66059. * Gets the view input component
  66060. */
  66061. get view(): NodeMaterialConnectionPoint;
  66062. /**
  66063. * Gets the color input component
  66064. */
  66065. get input(): NodeMaterialConnectionPoint;
  66066. /**
  66067. * Gets the fog color input component
  66068. */
  66069. get fogColor(): NodeMaterialConnectionPoint;
  66070. /**
  66071. * Gets the output component
  66072. */
  66073. get output(): NodeMaterialConnectionPoint;
  66074. autoConfigure(material: NodeMaterial): void;
  66075. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66076. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66077. protected _buildBlock(state: NodeMaterialBuildState): this;
  66078. }
  66079. }
  66080. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66085. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66086. import { Effect } from "babylonjs/Materials/effect";
  66087. import { Mesh } from "babylonjs/Meshes/mesh";
  66088. import { Light } from "babylonjs/Lights/light";
  66089. import { Nullable } from "babylonjs/types";
  66090. import { Scene } from "babylonjs/scene";
  66091. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66092. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66093. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66094. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66095. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66096. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66097. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66098. /**
  66099. * Block used to add light in the fragment shader
  66100. */
  66101. export class LightBlock extends NodeMaterialBlock {
  66102. private _lightId;
  66103. /**
  66104. * Gets or sets the light associated with this block
  66105. */
  66106. light: Nullable<Light>;
  66107. /**
  66108. * Create a new LightBlock
  66109. * @param name defines the block name
  66110. */
  66111. constructor(name: string);
  66112. /**
  66113. * Gets the current class name
  66114. * @returns the class name
  66115. */
  66116. getClassName(): string;
  66117. /**
  66118. * Gets the world position input component
  66119. */
  66120. get worldPosition(): NodeMaterialConnectionPoint;
  66121. /**
  66122. * Gets the world normal input component
  66123. */
  66124. get worldNormal(): NodeMaterialConnectionPoint;
  66125. /**
  66126. * Gets the camera (or eye) position component
  66127. */
  66128. get cameraPosition(): NodeMaterialConnectionPoint;
  66129. /**
  66130. * Gets the glossiness component
  66131. */
  66132. get glossiness(): NodeMaterialConnectionPoint;
  66133. /**
  66134. * Gets the glossinness power component
  66135. */
  66136. get glossPower(): NodeMaterialConnectionPoint;
  66137. /**
  66138. * Gets the diffuse color component
  66139. */
  66140. get diffuseColor(): NodeMaterialConnectionPoint;
  66141. /**
  66142. * Gets the specular color component
  66143. */
  66144. get specularColor(): NodeMaterialConnectionPoint;
  66145. /**
  66146. * Gets the diffuse output component
  66147. */
  66148. get diffuseOutput(): NodeMaterialConnectionPoint;
  66149. /**
  66150. * Gets the specular output component
  66151. */
  66152. get specularOutput(): NodeMaterialConnectionPoint;
  66153. /**
  66154. * Gets the shadow output component
  66155. */
  66156. get shadow(): NodeMaterialConnectionPoint;
  66157. autoConfigure(material: NodeMaterial): void;
  66158. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66159. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66160. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66161. private _injectVertexCode;
  66162. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66163. serialize(): any;
  66164. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66165. }
  66166. }
  66167. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66169. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66170. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66171. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66172. /**
  66173. * Block used to read a reflection texture from a sampler
  66174. */
  66175. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66176. /**
  66177. * Create a new ReflectionTextureBlock
  66178. * @param name defines the block name
  66179. */
  66180. constructor(name: string);
  66181. /**
  66182. * Gets the current class name
  66183. * @returns the class name
  66184. */
  66185. getClassName(): string;
  66186. /**
  66187. * Gets the world position input component
  66188. */
  66189. get position(): NodeMaterialConnectionPoint;
  66190. /**
  66191. * Gets the world position input component
  66192. */
  66193. get worldPosition(): NodeMaterialConnectionPoint;
  66194. /**
  66195. * Gets the world normal input component
  66196. */
  66197. get worldNormal(): NodeMaterialConnectionPoint;
  66198. /**
  66199. * Gets the world input component
  66200. */
  66201. get world(): NodeMaterialConnectionPoint;
  66202. /**
  66203. * Gets the camera (or eye) position component
  66204. */
  66205. get cameraPosition(): NodeMaterialConnectionPoint;
  66206. /**
  66207. * Gets the view input component
  66208. */
  66209. get view(): NodeMaterialConnectionPoint;
  66210. /**
  66211. * Gets the rgb output component
  66212. */
  66213. get rgb(): NodeMaterialConnectionPoint;
  66214. /**
  66215. * Gets the rgba output component
  66216. */
  66217. get rgba(): NodeMaterialConnectionPoint;
  66218. /**
  66219. * Gets the r output component
  66220. */
  66221. get r(): NodeMaterialConnectionPoint;
  66222. /**
  66223. * Gets the g output component
  66224. */
  66225. get g(): NodeMaterialConnectionPoint;
  66226. /**
  66227. * Gets the b output component
  66228. */
  66229. get b(): NodeMaterialConnectionPoint;
  66230. /**
  66231. * Gets the a output component
  66232. */
  66233. get a(): NodeMaterialConnectionPoint;
  66234. autoConfigure(material: NodeMaterial): void;
  66235. protected _buildBlock(state: NodeMaterialBuildState): this;
  66236. }
  66237. }
  66238. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66239. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66240. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66241. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66242. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66243. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66244. }
  66245. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66246. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66247. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66248. }
  66249. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66250. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66251. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66252. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66253. /**
  66254. * Block used to add 2 vectors
  66255. */
  66256. export class AddBlock extends NodeMaterialBlock {
  66257. /**
  66258. * Creates a new AddBlock
  66259. * @param name defines the block name
  66260. */
  66261. constructor(name: string);
  66262. /**
  66263. * Gets the current class name
  66264. * @returns the class name
  66265. */
  66266. getClassName(): string;
  66267. /**
  66268. * Gets the left operand input component
  66269. */
  66270. get left(): NodeMaterialConnectionPoint;
  66271. /**
  66272. * Gets the right operand input component
  66273. */
  66274. get right(): NodeMaterialConnectionPoint;
  66275. /**
  66276. * Gets the output component
  66277. */
  66278. get output(): NodeMaterialConnectionPoint;
  66279. protected _buildBlock(state: NodeMaterialBuildState): this;
  66280. }
  66281. }
  66282. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66286. /**
  66287. * Block used to scale a vector by a float
  66288. */
  66289. export class ScaleBlock extends NodeMaterialBlock {
  66290. /**
  66291. * Creates a new ScaleBlock
  66292. * @param name defines the block name
  66293. */
  66294. constructor(name: string);
  66295. /**
  66296. * Gets the current class name
  66297. * @returns the class name
  66298. */
  66299. getClassName(): string;
  66300. /**
  66301. * Gets the input component
  66302. */
  66303. get input(): NodeMaterialConnectionPoint;
  66304. /**
  66305. * Gets the factor input component
  66306. */
  66307. get factor(): NodeMaterialConnectionPoint;
  66308. /**
  66309. * Gets the output component
  66310. */
  66311. get output(): NodeMaterialConnectionPoint;
  66312. protected _buildBlock(state: NodeMaterialBuildState): this;
  66313. }
  66314. }
  66315. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66316. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66317. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66318. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66319. import { Scene } from "babylonjs/scene";
  66320. /**
  66321. * Block used to clamp a float
  66322. */
  66323. export class ClampBlock extends NodeMaterialBlock {
  66324. /** Gets or sets the minimum range */
  66325. minimum: number;
  66326. /** Gets or sets the maximum range */
  66327. maximum: number;
  66328. /**
  66329. * Creates a new ClampBlock
  66330. * @param name defines the block name
  66331. */
  66332. constructor(name: string);
  66333. /**
  66334. * Gets the current class name
  66335. * @returns the class name
  66336. */
  66337. getClassName(): string;
  66338. /**
  66339. * Gets the value input component
  66340. */
  66341. get value(): NodeMaterialConnectionPoint;
  66342. /**
  66343. * Gets the output component
  66344. */
  66345. get output(): NodeMaterialConnectionPoint;
  66346. protected _buildBlock(state: NodeMaterialBuildState): this;
  66347. protected _dumpPropertiesCode(): string;
  66348. serialize(): any;
  66349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66350. }
  66351. }
  66352. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66353. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66354. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66355. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66356. /**
  66357. * Block used to apply a cross product between 2 vectors
  66358. */
  66359. export class CrossBlock extends NodeMaterialBlock {
  66360. /**
  66361. * Creates a new CrossBlock
  66362. * @param name defines the block name
  66363. */
  66364. constructor(name: string);
  66365. /**
  66366. * Gets the current class name
  66367. * @returns the class name
  66368. */
  66369. getClassName(): string;
  66370. /**
  66371. * Gets the left operand input component
  66372. */
  66373. get left(): NodeMaterialConnectionPoint;
  66374. /**
  66375. * Gets the right operand input component
  66376. */
  66377. get right(): NodeMaterialConnectionPoint;
  66378. /**
  66379. * Gets the output component
  66380. */
  66381. get output(): NodeMaterialConnectionPoint;
  66382. protected _buildBlock(state: NodeMaterialBuildState): this;
  66383. }
  66384. }
  66385. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66386. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66387. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66388. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66389. /**
  66390. * Block used to apply a dot product between 2 vectors
  66391. */
  66392. export class DotBlock extends NodeMaterialBlock {
  66393. /**
  66394. * Creates a new DotBlock
  66395. * @param name defines the block name
  66396. */
  66397. constructor(name: string);
  66398. /**
  66399. * Gets the current class name
  66400. * @returns the class name
  66401. */
  66402. getClassName(): string;
  66403. /**
  66404. * Gets the left operand input component
  66405. */
  66406. get left(): NodeMaterialConnectionPoint;
  66407. /**
  66408. * Gets the right operand input component
  66409. */
  66410. get right(): NodeMaterialConnectionPoint;
  66411. /**
  66412. * Gets the output component
  66413. */
  66414. get output(): NodeMaterialConnectionPoint;
  66415. protected _buildBlock(state: NodeMaterialBuildState): this;
  66416. }
  66417. }
  66418. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66422. /**
  66423. * Block used to normalize a vector
  66424. */
  66425. export class NormalizeBlock extends NodeMaterialBlock {
  66426. /**
  66427. * Creates a new NormalizeBlock
  66428. * @param name defines the block name
  66429. */
  66430. constructor(name: string);
  66431. /**
  66432. * Gets the current class name
  66433. * @returns the class name
  66434. */
  66435. getClassName(): string;
  66436. /**
  66437. * Gets the input component
  66438. */
  66439. get input(): NodeMaterialConnectionPoint;
  66440. /**
  66441. * Gets the output component
  66442. */
  66443. get output(): NodeMaterialConnectionPoint;
  66444. protected _buildBlock(state: NodeMaterialBuildState): this;
  66445. }
  66446. }
  66447. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66451. /**
  66452. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66453. */
  66454. export class ColorMergerBlock extends NodeMaterialBlock {
  66455. /**
  66456. * Create a new ColorMergerBlock
  66457. * @param name defines the block name
  66458. */
  66459. constructor(name: string);
  66460. /**
  66461. * Gets the current class name
  66462. * @returns the class name
  66463. */
  66464. getClassName(): string;
  66465. /**
  66466. * Gets the rgb component (input)
  66467. */
  66468. get rgbIn(): NodeMaterialConnectionPoint;
  66469. /**
  66470. * Gets the r component (input)
  66471. */
  66472. get r(): NodeMaterialConnectionPoint;
  66473. /**
  66474. * Gets the g component (input)
  66475. */
  66476. get g(): NodeMaterialConnectionPoint;
  66477. /**
  66478. * Gets the b component (input)
  66479. */
  66480. get b(): NodeMaterialConnectionPoint;
  66481. /**
  66482. * Gets the a component (input)
  66483. */
  66484. get a(): NodeMaterialConnectionPoint;
  66485. /**
  66486. * Gets the rgba component (output)
  66487. */
  66488. get rgba(): NodeMaterialConnectionPoint;
  66489. /**
  66490. * Gets the rgb component (output)
  66491. */
  66492. get rgbOut(): NodeMaterialConnectionPoint;
  66493. /**
  66494. * Gets the rgb component (output)
  66495. * @deprecated Please use rgbOut instead.
  66496. */
  66497. get rgb(): NodeMaterialConnectionPoint;
  66498. protected _buildBlock(state: NodeMaterialBuildState): this;
  66499. }
  66500. }
  66501. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66505. /**
  66506. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66507. */
  66508. export class VectorSplitterBlock extends NodeMaterialBlock {
  66509. /**
  66510. * Create a new VectorSplitterBlock
  66511. * @param name defines the block name
  66512. */
  66513. constructor(name: string);
  66514. /**
  66515. * Gets the current class name
  66516. * @returns the class name
  66517. */
  66518. getClassName(): string;
  66519. /**
  66520. * Gets the xyzw component (input)
  66521. */
  66522. get xyzw(): NodeMaterialConnectionPoint;
  66523. /**
  66524. * Gets the xyz component (input)
  66525. */
  66526. get xyzIn(): NodeMaterialConnectionPoint;
  66527. /**
  66528. * Gets the xy component (input)
  66529. */
  66530. get xyIn(): NodeMaterialConnectionPoint;
  66531. /**
  66532. * Gets the xyz component (output)
  66533. */
  66534. get xyzOut(): NodeMaterialConnectionPoint;
  66535. /**
  66536. * Gets the xy component (output)
  66537. */
  66538. get xyOut(): NodeMaterialConnectionPoint;
  66539. /**
  66540. * Gets the x component (output)
  66541. */
  66542. get x(): NodeMaterialConnectionPoint;
  66543. /**
  66544. * Gets the y component (output)
  66545. */
  66546. get y(): NodeMaterialConnectionPoint;
  66547. /**
  66548. * Gets the z component (output)
  66549. */
  66550. get z(): NodeMaterialConnectionPoint;
  66551. /**
  66552. * Gets the w component (output)
  66553. */
  66554. get w(): NodeMaterialConnectionPoint;
  66555. protected _inputRename(name: string): string;
  66556. protected _outputRename(name: string): string;
  66557. protected _buildBlock(state: NodeMaterialBuildState): this;
  66558. }
  66559. }
  66560. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66564. /**
  66565. * Block used to lerp between 2 values
  66566. */
  66567. export class LerpBlock extends NodeMaterialBlock {
  66568. /**
  66569. * Creates a new LerpBlock
  66570. * @param name defines the block name
  66571. */
  66572. constructor(name: string);
  66573. /**
  66574. * Gets the current class name
  66575. * @returns the class name
  66576. */
  66577. getClassName(): string;
  66578. /**
  66579. * Gets the left operand input component
  66580. */
  66581. get left(): NodeMaterialConnectionPoint;
  66582. /**
  66583. * Gets the right operand input component
  66584. */
  66585. get right(): NodeMaterialConnectionPoint;
  66586. /**
  66587. * Gets the gradient operand input component
  66588. */
  66589. get gradient(): NodeMaterialConnectionPoint;
  66590. /**
  66591. * Gets the output component
  66592. */
  66593. get output(): NodeMaterialConnectionPoint;
  66594. protected _buildBlock(state: NodeMaterialBuildState): this;
  66595. }
  66596. }
  66597. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66601. /**
  66602. * Block used to divide 2 vectors
  66603. */
  66604. export class DivideBlock extends NodeMaterialBlock {
  66605. /**
  66606. * Creates a new DivideBlock
  66607. * @param name defines the block name
  66608. */
  66609. constructor(name: string);
  66610. /**
  66611. * Gets the current class name
  66612. * @returns the class name
  66613. */
  66614. getClassName(): string;
  66615. /**
  66616. * Gets the left operand input component
  66617. */
  66618. get left(): NodeMaterialConnectionPoint;
  66619. /**
  66620. * Gets the right operand input component
  66621. */
  66622. get right(): NodeMaterialConnectionPoint;
  66623. /**
  66624. * Gets the output component
  66625. */
  66626. get output(): NodeMaterialConnectionPoint;
  66627. protected _buildBlock(state: NodeMaterialBuildState): this;
  66628. }
  66629. }
  66630. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66633. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66634. /**
  66635. * Block used to subtract 2 vectors
  66636. */
  66637. export class SubtractBlock extends NodeMaterialBlock {
  66638. /**
  66639. * Creates a new SubtractBlock
  66640. * @param name defines the block name
  66641. */
  66642. constructor(name: string);
  66643. /**
  66644. * Gets the current class name
  66645. * @returns the class name
  66646. */
  66647. getClassName(): string;
  66648. /**
  66649. * Gets the left operand input component
  66650. */
  66651. get left(): NodeMaterialConnectionPoint;
  66652. /**
  66653. * Gets the right operand input component
  66654. */
  66655. get right(): NodeMaterialConnectionPoint;
  66656. /**
  66657. * Gets the output component
  66658. */
  66659. get output(): NodeMaterialConnectionPoint;
  66660. protected _buildBlock(state: NodeMaterialBuildState): this;
  66661. }
  66662. }
  66663. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66667. /**
  66668. * Block used to step a value
  66669. */
  66670. export class StepBlock extends NodeMaterialBlock {
  66671. /**
  66672. * Creates a new StepBlock
  66673. * @param name defines the block name
  66674. */
  66675. constructor(name: string);
  66676. /**
  66677. * Gets the current class name
  66678. * @returns the class name
  66679. */
  66680. getClassName(): string;
  66681. /**
  66682. * Gets the value operand input component
  66683. */
  66684. get value(): NodeMaterialConnectionPoint;
  66685. /**
  66686. * Gets the edge operand input component
  66687. */
  66688. get edge(): NodeMaterialConnectionPoint;
  66689. /**
  66690. * Gets the output component
  66691. */
  66692. get output(): NodeMaterialConnectionPoint;
  66693. protected _buildBlock(state: NodeMaterialBuildState): this;
  66694. }
  66695. }
  66696. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66700. /**
  66701. * Block used to get the opposite (1 - x) of a value
  66702. */
  66703. export class OneMinusBlock extends NodeMaterialBlock {
  66704. /**
  66705. * Creates a new OneMinusBlock
  66706. * @param name defines the block name
  66707. */
  66708. constructor(name: string);
  66709. /**
  66710. * Gets the current class name
  66711. * @returns the class name
  66712. */
  66713. getClassName(): string;
  66714. /**
  66715. * Gets the input component
  66716. */
  66717. get input(): NodeMaterialConnectionPoint;
  66718. /**
  66719. * Gets the output component
  66720. */
  66721. get output(): NodeMaterialConnectionPoint;
  66722. protected _buildBlock(state: NodeMaterialBuildState): this;
  66723. }
  66724. }
  66725. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66726. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66727. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66728. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66729. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66730. /**
  66731. * Block used to get the view direction
  66732. */
  66733. export class ViewDirectionBlock extends NodeMaterialBlock {
  66734. /**
  66735. * Creates a new ViewDirectionBlock
  66736. * @param name defines the block name
  66737. */
  66738. constructor(name: string);
  66739. /**
  66740. * Gets the current class name
  66741. * @returns the class name
  66742. */
  66743. getClassName(): string;
  66744. /**
  66745. * Gets the world position component
  66746. */
  66747. get worldPosition(): NodeMaterialConnectionPoint;
  66748. /**
  66749. * Gets the camera position component
  66750. */
  66751. get cameraPosition(): NodeMaterialConnectionPoint;
  66752. /**
  66753. * Gets the output component
  66754. */
  66755. get output(): NodeMaterialConnectionPoint;
  66756. autoConfigure(material: NodeMaterial): void;
  66757. protected _buildBlock(state: NodeMaterialBuildState): this;
  66758. }
  66759. }
  66760. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66764. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66765. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66766. /**
  66767. * Block used to compute fresnel value
  66768. */
  66769. export class FresnelBlock extends NodeMaterialBlock {
  66770. /**
  66771. * Create a new FresnelBlock
  66772. * @param name defines the block name
  66773. */
  66774. constructor(name: string);
  66775. /**
  66776. * Gets the current class name
  66777. * @returns the class name
  66778. */
  66779. getClassName(): string;
  66780. /**
  66781. * Gets the world normal input component
  66782. */
  66783. get worldNormal(): NodeMaterialConnectionPoint;
  66784. /**
  66785. * Gets the view direction input component
  66786. */
  66787. get viewDirection(): NodeMaterialConnectionPoint;
  66788. /**
  66789. * Gets the bias input component
  66790. */
  66791. get bias(): NodeMaterialConnectionPoint;
  66792. /**
  66793. * Gets the camera (or eye) position component
  66794. */
  66795. get power(): NodeMaterialConnectionPoint;
  66796. /**
  66797. * Gets the fresnel output component
  66798. */
  66799. get fresnel(): NodeMaterialConnectionPoint;
  66800. autoConfigure(material: NodeMaterial): void;
  66801. protected _buildBlock(state: NodeMaterialBuildState): this;
  66802. }
  66803. }
  66804. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66808. /**
  66809. * Block used to get the max of 2 values
  66810. */
  66811. export class MaxBlock extends NodeMaterialBlock {
  66812. /**
  66813. * Creates a new MaxBlock
  66814. * @param name defines the block name
  66815. */
  66816. constructor(name: string);
  66817. /**
  66818. * Gets the current class name
  66819. * @returns the class name
  66820. */
  66821. getClassName(): string;
  66822. /**
  66823. * Gets the left operand input component
  66824. */
  66825. get left(): NodeMaterialConnectionPoint;
  66826. /**
  66827. * Gets the right operand input component
  66828. */
  66829. get right(): NodeMaterialConnectionPoint;
  66830. /**
  66831. * Gets the output component
  66832. */
  66833. get output(): NodeMaterialConnectionPoint;
  66834. protected _buildBlock(state: NodeMaterialBuildState): this;
  66835. }
  66836. }
  66837. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66841. /**
  66842. * Block used to get the min of 2 values
  66843. */
  66844. export class MinBlock extends NodeMaterialBlock {
  66845. /**
  66846. * Creates a new MinBlock
  66847. * @param name defines the block name
  66848. */
  66849. constructor(name: string);
  66850. /**
  66851. * Gets the current class name
  66852. * @returns the class name
  66853. */
  66854. getClassName(): string;
  66855. /**
  66856. * Gets the left operand input component
  66857. */
  66858. get left(): NodeMaterialConnectionPoint;
  66859. /**
  66860. * Gets the right operand input component
  66861. */
  66862. get right(): NodeMaterialConnectionPoint;
  66863. /**
  66864. * Gets the output component
  66865. */
  66866. get output(): NodeMaterialConnectionPoint;
  66867. protected _buildBlock(state: NodeMaterialBuildState): this;
  66868. }
  66869. }
  66870. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66871. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66872. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66873. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66874. /**
  66875. * Block used to get the distance between 2 values
  66876. */
  66877. export class DistanceBlock extends NodeMaterialBlock {
  66878. /**
  66879. * Creates a new DistanceBlock
  66880. * @param name defines the block name
  66881. */
  66882. constructor(name: string);
  66883. /**
  66884. * Gets the current class name
  66885. * @returns the class name
  66886. */
  66887. getClassName(): string;
  66888. /**
  66889. * Gets the left operand input component
  66890. */
  66891. get left(): NodeMaterialConnectionPoint;
  66892. /**
  66893. * Gets the right operand input component
  66894. */
  66895. get right(): NodeMaterialConnectionPoint;
  66896. /**
  66897. * Gets the output component
  66898. */
  66899. get output(): NodeMaterialConnectionPoint;
  66900. protected _buildBlock(state: NodeMaterialBuildState): this;
  66901. }
  66902. }
  66903. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66904. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66905. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66906. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66907. /**
  66908. * Block used to get the length of a vector
  66909. */
  66910. export class LengthBlock extends NodeMaterialBlock {
  66911. /**
  66912. * Creates a new LengthBlock
  66913. * @param name defines the block name
  66914. */
  66915. constructor(name: string);
  66916. /**
  66917. * Gets the current class name
  66918. * @returns the class name
  66919. */
  66920. getClassName(): string;
  66921. /**
  66922. * Gets the value input component
  66923. */
  66924. get value(): NodeMaterialConnectionPoint;
  66925. /**
  66926. * Gets the output component
  66927. */
  66928. get output(): NodeMaterialConnectionPoint;
  66929. protected _buildBlock(state: NodeMaterialBuildState): this;
  66930. }
  66931. }
  66932. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66933. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66936. /**
  66937. * Block used to get negative version of a value (i.e. x * -1)
  66938. */
  66939. export class NegateBlock extends NodeMaterialBlock {
  66940. /**
  66941. * Creates a new NegateBlock
  66942. * @param name defines the block name
  66943. */
  66944. constructor(name: string);
  66945. /**
  66946. * Gets the current class name
  66947. * @returns the class name
  66948. */
  66949. getClassName(): string;
  66950. /**
  66951. * Gets the value input component
  66952. */
  66953. get value(): NodeMaterialConnectionPoint;
  66954. /**
  66955. * Gets the output component
  66956. */
  66957. get output(): NodeMaterialConnectionPoint;
  66958. protected _buildBlock(state: NodeMaterialBuildState): this;
  66959. }
  66960. }
  66961. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66963. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66964. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66965. /**
  66966. * Block used to get the value of the first parameter raised to the power of the second
  66967. */
  66968. export class PowBlock extends NodeMaterialBlock {
  66969. /**
  66970. * Creates a new PowBlock
  66971. * @param name defines the block name
  66972. */
  66973. constructor(name: string);
  66974. /**
  66975. * Gets the current class name
  66976. * @returns the class name
  66977. */
  66978. getClassName(): string;
  66979. /**
  66980. * Gets the value operand input component
  66981. */
  66982. get value(): NodeMaterialConnectionPoint;
  66983. /**
  66984. * Gets the power operand input component
  66985. */
  66986. get power(): NodeMaterialConnectionPoint;
  66987. /**
  66988. * Gets the output component
  66989. */
  66990. get output(): NodeMaterialConnectionPoint;
  66991. protected _buildBlock(state: NodeMaterialBuildState): this;
  66992. }
  66993. }
  66994. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66998. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66999. /**
  67000. * Block used to get a random number
  67001. */
  67002. export class RandomNumberBlock extends NodeMaterialBlock {
  67003. /**
  67004. * Creates a new RandomNumberBlock
  67005. * @param name defines the block name
  67006. */
  67007. constructor(name: string);
  67008. /**
  67009. * Gets the current class name
  67010. * @returns the class name
  67011. */
  67012. getClassName(): string;
  67013. /**
  67014. * Gets the seed input component
  67015. */
  67016. get seed(): NodeMaterialConnectionPoint;
  67017. /**
  67018. * Gets the output component
  67019. */
  67020. get output(): NodeMaterialConnectionPoint;
  67021. protected _buildBlock(state: NodeMaterialBuildState): this;
  67022. }
  67023. }
  67024. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67027. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67028. /**
  67029. * Block used to compute arc tangent of 2 values
  67030. */
  67031. export class ArcTan2Block extends NodeMaterialBlock {
  67032. /**
  67033. * Creates a new ArcTan2Block
  67034. * @param name defines the block name
  67035. */
  67036. constructor(name: string);
  67037. /**
  67038. * Gets the current class name
  67039. * @returns the class name
  67040. */
  67041. getClassName(): string;
  67042. /**
  67043. * Gets the x operand input component
  67044. */
  67045. get x(): NodeMaterialConnectionPoint;
  67046. /**
  67047. * Gets the y operand input component
  67048. */
  67049. get y(): NodeMaterialConnectionPoint;
  67050. /**
  67051. * Gets the output component
  67052. */
  67053. get output(): NodeMaterialConnectionPoint;
  67054. protected _buildBlock(state: NodeMaterialBuildState): this;
  67055. }
  67056. }
  67057. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67059. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67061. /**
  67062. * Block used to smooth step a value
  67063. */
  67064. export class SmoothStepBlock extends NodeMaterialBlock {
  67065. /**
  67066. * Creates a new SmoothStepBlock
  67067. * @param name defines the block name
  67068. */
  67069. constructor(name: string);
  67070. /**
  67071. * Gets the current class name
  67072. * @returns the class name
  67073. */
  67074. getClassName(): string;
  67075. /**
  67076. * Gets the value operand input component
  67077. */
  67078. get value(): NodeMaterialConnectionPoint;
  67079. /**
  67080. * Gets the first edge operand input component
  67081. */
  67082. get edge0(): NodeMaterialConnectionPoint;
  67083. /**
  67084. * Gets the second edge operand input component
  67085. */
  67086. get edge1(): NodeMaterialConnectionPoint;
  67087. /**
  67088. * Gets the output component
  67089. */
  67090. get output(): NodeMaterialConnectionPoint;
  67091. protected _buildBlock(state: NodeMaterialBuildState): this;
  67092. }
  67093. }
  67094. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67096. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67097. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67098. /**
  67099. * Block used to get the reciprocal (1 / x) of a value
  67100. */
  67101. export class ReciprocalBlock extends NodeMaterialBlock {
  67102. /**
  67103. * Creates a new ReciprocalBlock
  67104. * @param name defines the block name
  67105. */
  67106. constructor(name: string);
  67107. /**
  67108. * Gets the current class name
  67109. * @returns the class name
  67110. */
  67111. getClassName(): string;
  67112. /**
  67113. * Gets the input component
  67114. */
  67115. get input(): NodeMaterialConnectionPoint;
  67116. /**
  67117. * Gets the output component
  67118. */
  67119. get output(): NodeMaterialConnectionPoint;
  67120. protected _buildBlock(state: NodeMaterialBuildState): this;
  67121. }
  67122. }
  67123. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67126. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67127. /**
  67128. * Block used to replace a color by another one
  67129. */
  67130. export class ReplaceColorBlock extends NodeMaterialBlock {
  67131. /**
  67132. * Creates a new ReplaceColorBlock
  67133. * @param name defines the block name
  67134. */
  67135. constructor(name: string);
  67136. /**
  67137. * Gets the current class name
  67138. * @returns the class name
  67139. */
  67140. getClassName(): string;
  67141. /**
  67142. * Gets the value input component
  67143. */
  67144. get value(): NodeMaterialConnectionPoint;
  67145. /**
  67146. * Gets the reference input component
  67147. */
  67148. get reference(): NodeMaterialConnectionPoint;
  67149. /**
  67150. * Gets the distance input component
  67151. */
  67152. get distance(): NodeMaterialConnectionPoint;
  67153. /**
  67154. * Gets the replacement input component
  67155. */
  67156. get replacement(): NodeMaterialConnectionPoint;
  67157. /**
  67158. * Gets the output component
  67159. */
  67160. get output(): NodeMaterialConnectionPoint;
  67161. protected _buildBlock(state: NodeMaterialBuildState): this;
  67162. }
  67163. }
  67164. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67166. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67167. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67168. /**
  67169. * Block used to posterize a value
  67170. * @see https://en.wikipedia.org/wiki/Posterization
  67171. */
  67172. export class PosterizeBlock extends NodeMaterialBlock {
  67173. /**
  67174. * Creates a new PosterizeBlock
  67175. * @param name defines the block name
  67176. */
  67177. constructor(name: string);
  67178. /**
  67179. * Gets the current class name
  67180. * @returns the class name
  67181. */
  67182. getClassName(): string;
  67183. /**
  67184. * Gets the value input component
  67185. */
  67186. get value(): NodeMaterialConnectionPoint;
  67187. /**
  67188. * Gets the steps input component
  67189. */
  67190. get steps(): NodeMaterialConnectionPoint;
  67191. /**
  67192. * Gets the output component
  67193. */
  67194. get output(): NodeMaterialConnectionPoint;
  67195. protected _buildBlock(state: NodeMaterialBuildState): this;
  67196. }
  67197. }
  67198. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67199. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67200. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67201. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67202. import { Scene } from "babylonjs/scene";
  67203. /**
  67204. * Operations supported by the Wave block
  67205. */
  67206. export enum WaveBlockKind {
  67207. /** SawTooth */
  67208. SawTooth = 0,
  67209. /** Square */
  67210. Square = 1,
  67211. /** Triangle */
  67212. Triangle = 2
  67213. }
  67214. /**
  67215. * Block used to apply wave operation to floats
  67216. */
  67217. export class WaveBlock extends NodeMaterialBlock {
  67218. /**
  67219. * Gets or sets the kibnd of wave to be applied by the block
  67220. */
  67221. kind: WaveBlockKind;
  67222. /**
  67223. * Creates a new WaveBlock
  67224. * @param name defines the block name
  67225. */
  67226. constructor(name: string);
  67227. /**
  67228. * Gets the current class name
  67229. * @returns the class name
  67230. */
  67231. getClassName(): string;
  67232. /**
  67233. * Gets the input component
  67234. */
  67235. get input(): NodeMaterialConnectionPoint;
  67236. /**
  67237. * Gets the output component
  67238. */
  67239. get output(): NodeMaterialConnectionPoint;
  67240. protected _buildBlock(state: NodeMaterialBuildState): this;
  67241. serialize(): any;
  67242. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67243. }
  67244. }
  67245. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67249. import { Color3 } from "babylonjs/Maths/math.color";
  67250. import { Scene } from "babylonjs/scene";
  67251. import { Observable } from "babylonjs/Misc/observable";
  67252. /**
  67253. * Class used to store a color step for the GradientBlock
  67254. */
  67255. export class GradientBlockColorStep {
  67256. private _step;
  67257. /**
  67258. * Gets value indicating which step this color is associated with (between 0 and 1)
  67259. */
  67260. get step(): number;
  67261. /**
  67262. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67263. */
  67264. set step(val: number);
  67265. private _color;
  67266. /**
  67267. * Gets the color associated with this step
  67268. */
  67269. get color(): Color3;
  67270. /**
  67271. * Sets the color associated with this step
  67272. */
  67273. set color(val: Color3);
  67274. /**
  67275. * Creates a new GradientBlockColorStep
  67276. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67277. * @param color defines the color associated with this step
  67278. */
  67279. constructor(step: number, color: Color3);
  67280. }
  67281. /**
  67282. * Block used to return a color from a gradient based on an input value between 0 and 1
  67283. */
  67284. export class GradientBlock extends NodeMaterialBlock {
  67285. /**
  67286. * Gets or sets the list of color steps
  67287. */
  67288. colorSteps: GradientBlockColorStep[];
  67289. /** Gets an observable raised when the value is changed */
  67290. onValueChangedObservable: Observable<GradientBlock>;
  67291. /** calls observable when the value is changed*/
  67292. colorStepsUpdated(): void;
  67293. /**
  67294. * Creates a new GradientBlock
  67295. * @param name defines the block name
  67296. */
  67297. constructor(name: string);
  67298. /**
  67299. * Gets the current class name
  67300. * @returns the class name
  67301. */
  67302. getClassName(): string;
  67303. /**
  67304. * Gets the gradient input component
  67305. */
  67306. get gradient(): NodeMaterialConnectionPoint;
  67307. /**
  67308. * Gets the output component
  67309. */
  67310. get output(): NodeMaterialConnectionPoint;
  67311. private _writeColorConstant;
  67312. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67313. serialize(): any;
  67314. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67315. protected _dumpPropertiesCode(): string;
  67316. }
  67317. }
  67318. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67322. /**
  67323. * Block used to normalize lerp between 2 values
  67324. */
  67325. export class NLerpBlock extends NodeMaterialBlock {
  67326. /**
  67327. * Creates a new NLerpBlock
  67328. * @param name defines the block name
  67329. */
  67330. constructor(name: string);
  67331. /**
  67332. * Gets the current class name
  67333. * @returns the class name
  67334. */
  67335. getClassName(): string;
  67336. /**
  67337. * Gets the left operand input component
  67338. */
  67339. get left(): NodeMaterialConnectionPoint;
  67340. /**
  67341. * Gets the right operand input component
  67342. */
  67343. get right(): NodeMaterialConnectionPoint;
  67344. /**
  67345. * Gets the gradient operand input component
  67346. */
  67347. get gradient(): NodeMaterialConnectionPoint;
  67348. /**
  67349. * Gets the output component
  67350. */
  67351. get output(): NodeMaterialConnectionPoint;
  67352. protected _buildBlock(state: NodeMaterialBuildState): this;
  67353. }
  67354. }
  67355. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67359. import { Scene } from "babylonjs/scene";
  67360. /**
  67361. * block used to Generate a Worley Noise 3D Noise Pattern
  67362. */
  67363. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67364. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67365. manhattanDistance: boolean;
  67366. /**
  67367. * Creates a new WorleyNoise3DBlock
  67368. * @param name defines the block name
  67369. */
  67370. constructor(name: string);
  67371. /**
  67372. * Gets the current class name
  67373. * @returns the class name
  67374. */
  67375. getClassName(): string;
  67376. /**
  67377. * Gets the seed input component
  67378. */
  67379. get seed(): NodeMaterialConnectionPoint;
  67380. /**
  67381. * Gets the jitter input component
  67382. */
  67383. get jitter(): NodeMaterialConnectionPoint;
  67384. /**
  67385. * Gets the output component
  67386. */
  67387. get output(): NodeMaterialConnectionPoint;
  67388. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67389. /**
  67390. * Exposes the properties to the UI?
  67391. */
  67392. protected _dumpPropertiesCode(): string;
  67393. /**
  67394. * Exposes the properties to the Seralize?
  67395. */
  67396. serialize(): any;
  67397. /**
  67398. * Exposes the properties to the deseralize?
  67399. */
  67400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67401. }
  67402. }
  67403. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67407. /**
  67408. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67409. */
  67410. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67411. /**
  67412. * Creates a new SimplexPerlin3DBlock
  67413. * @param name defines the block name
  67414. */
  67415. constructor(name: string);
  67416. /**
  67417. * Gets the current class name
  67418. * @returns the class name
  67419. */
  67420. getClassName(): string;
  67421. /**
  67422. * Gets the seed operand input component
  67423. */
  67424. get seed(): NodeMaterialConnectionPoint;
  67425. /**
  67426. * Gets the output component
  67427. */
  67428. get output(): NodeMaterialConnectionPoint;
  67429. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67430. }
  67431. }
  67432. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67436. /**
  67437. * Block used to blend normals
  67438. */
  67439. export class NormalBlendBlock extends NodeMaterialBlock {
  67440. /**
  67441. * Creates a new NormalBlendBlock
  67442. * @param name defines the block name
  67443. */
  67444. constructor(name: string);
  67445. /**
  67446. * Gets the current class name
  67447. * @returns the class name
  67448. */
  67449. getClassName(): string;
  67450. /**
  67451. * Gets the first input component
  67452. */
  67453. get normalMap0(): NodeMaterialConnectionPoint;
  67454. /**
  67455. * Gets the second input component
  67456. */
  67457. get normalMap1(): NodeMaterialConnectionPoint;
  67458. /**
  67459. * Gets the output component
  67460. */
  67461. get output(): NodeMaterialConnectionPoint;
  67462. protected _buildBlock(state: NodeMaterialBuildState): this;
  67463. }
  67464. }
  67465. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  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. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67470. /**
  67471. * Block used to rotate a 2d vector by a given angle
  67472. */
  67473. export class Rotate2dBlock extends NodeMaterialBlock {
  67474. /**
  67475. * Creates a new Rotate2dBlock
  67476. * @param name defines the block name
  67477. */
  67478. constructor(name: string);
  67479. /**
  67480. * Gets the current class name
  67481. * @returns the class name
  67482. */
  67483. getClassName(): string;
  67484. /**
  67485. * Gets the input vector
  67486. */
  67487. get input(): NodeMaterialConnectionPoint;
  67488. /**
  67489. * Gets the input angle
  67490. */
  67491. get angle(): NodeMaterialConnectionPoint;
  67492. /**
  67493. * Gets the output component
  67494. */
  67495. get output(): NodeMaterialConnectionPoint;
  67496. autoConfigure(material: NodeMaterial): void;
  67497. protected _buildBlock(state: NodeMaterialBuildState): this;
  67498. }
  67499. }
  67500. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67501. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67502. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67503. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67504. /**
  67505. * Block used to get the reflected vector from a direction and a normal
  67506. */
  67507. export class ReflectBlock extends NodeMaterialBlock {
  67508. /**
  67509. * Creates a new ReflectBlock
  67510. * @param name defines the block name
  67511. */
  67512. constructor(name: string);
  67513. /**
  67514. * Gets the current class name
  67515. * @returns the class name
  67516. */
  67517. getClassName(): string;
  67518. /**
  67519. * Gets the incident component
  67520. */
  67521. get incident(): NodeMaterialConnectionPoint;
  67522. /**
  67523. * Gets the normal component
  67524. */
  67525. get normal(): NodeMaterialConnectionPoint;
  67526. /**
  67527. * Gets the output component
  67528. */
  67529. get output(): NodeMaterialConnectionPoint;
  67530. protected _buildBlock(state: NodeMaterialBuildState): this;
  67531. }
  67532. }
  67533. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67534. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67535. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67536. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67537. /**
  67538. * Block used to get the refracted vector from a direction and a normal
  67539. */
  67540. export class RefractBlock extends NodeMaterialBlock {
  67541. /**
  67542. * Creates a new RefractBlock
  67543. * @param name defines the block name
  67544. */
  67545. constructor(name: string);
  67546. /**
  67547. * Gets the current class name
  67548. * @returns the class name
  67549. */
  67550. getClassName(): string;
  67551. /**
  67552. * Gets the incident component
  67553. */
  67554. get incident(): NodeMaterialConnectionPoint;
  67555. /**
  67556. * Gets the normal component
  67557. */
  67558. get normal(): NodeMaterialConnectionPoint;
  67559. /**
  67560. * Gets the index of refraction component
  67561. */
  67562. get ior(): NodeMaterialConnectionPoint;
  67563. /**
  67564. * Gets the output component
  67565. */
  67566. get output(): NodeMaterialConnectionPoint;
  67567. protected _buildBlock(state: NodeMaterialBuildState): this;
  67568. }
  67569. }
  67570. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67574. /**
  67575. * Block used to desaturate a color
  67576. */
  67577. export class DesaturateBlock extends NodeMaterialBlock {
  67578. /**
  67579. * Creates a new DesaturateBlock
  67580. * @param name defines the block name
  67581. */
  67582. constructor(name: string);
  67583. /**
  67584. * Gets the current class name
  67585. * @returns the class name
  67586. */
  67587. getClassName(): string;
  67588. /**
  67589. * Gets the color operand input component
  67590. */
  67591. get color(): NodeMaterialConnectionPoint;
  67592. /**
  67593. * Gets the level operand input component
  67594. */
  67595. get level(): NodeMaterialConnectionPoint;
  67596. /**
  67597. * Gets the output component
  67598. */
  67599. get output(): NodeMaterialConnectionPoint;
  67600. protected _buildBlock(state: NodeMaterialBuildState): this;
  67601. }
  67602. }
  67603. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67607. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67608. import { Nullable } from "babylonjs/types";
  67609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67610. import { Scene } from "babylonjs/scene";
  67611. /**
  67612. * Block used to implement the ambient occlusion module of the PBR material
  67613. */
  67614. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67615. /**
  67616. * Create a new AmbientOcclusionBlock
  67617. * @param name defines the block name
  67618. */
  67619. constructor(name: string);
  67620. /**
  67621. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67622. */
  67623. useAmbientInGrayScale: boolean;
  67624. /**
  67625. * Initialize the block and prepare the context for build
  67626. * @param state defines the state that will be used for the build
  67627. */
  67628. initialize(state: NodeMaterialBuildState): void;
  67629. /**
  67630. * Gets the current class name
  67631. * @returns the class name
  67632. */
  67633. getClassName(): string;
  67634. /**
  67635. * Gets the texture input component
  67636. */
  67637. get texture(): NodeMaterialConnectionPoint;
  67638. /**
  67639. * Gets the texture intensity component
  67640. */
  67641. get intensity(): NodeMaterialConnectionPoint;
  67642. /**
  67643. * Gets the direct light intensity input component
  67644. */
  67645. get directLightIntensity(): NodeMaterialConnectionPoint;
  67646. /**
  67647. * Gets the ambient occlusion object output component
  67648. */
  67649. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67650. /**
  67651. * Gets the main code of the block (fragment side)
  67652. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67653. * @returns the shader code
  67654. */
  67655. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67656. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67657. protected _buildBlock(state: NodeMaterialBuildState): this;
  67658. protected _dumpPropertiesCode(): string;
  67659. serialize(): any;
  67660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67661. }
  67662. }
  67663. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67666. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67667. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67669. import { Nullable } from "babylonjs/types";
  67670. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67671. import { Mesh } from "babylonjs/Meshes/mesh";
  67672. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67673. import { Effect } from "babylonjs/Materials/effect";
  67674. import { Scene } from "babylonjs/scene";
  67675. /**
  67676. * Block used to implement the reflection module of the PBR material
  67677. */
  67678. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67679. /** @hidden */
  67680. _defineLODReflectionAlpha: string;
  67681. /** @hidden */
  67682. _defineLinearSpecularReflection: string;
  67683. private _vEnvironmentIrradianceName;
  67684. /** @hidden */
  67685. _vReflectionMicrosurfaceInfosName: string;
  67686. /** @hidden */
  67687. _vReflectionInfosName: string;
  67688. /** @hidden */
  67689. _vReflectionFilteringInfoName: string;
  67690. private _scene;
  67691. /**
  67692. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67693. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67694. * It's less burden on the user side in the editor part.
  67695. */
  67696. /** @hidden */
  67697. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67698. /** @hidden */
  67699. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67700. /** @hidden */
  67701. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67702. /**
  67703. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67704. * diffuse part of the IBL.
  67705. */
  67706. useSphericalHarmonics: boolean;
  67707. /**
  67708. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67709. */
  67710. forceIrradianceInFragment: boolean;
  67711. /**
  67712. * Create a new ReflectionBlock
  67713. * @param name defines the block name
  67714. */
  67715. constructor(name: string);
  67716. /**
  67717. * Gets the current class name
  67718. * @returns the class name
  67719. */
  67720. getClassName(): string;
  67721. /**
  67722. * Gets the position input component
  67723. */
  67724. get position(): NodeMaterialConnectionPoint;
  67725. /**
  67726. * Gets the world position input component
  67727. */
  67728. get worldPosition(): NodeMaterialConnectionPoint;
  67729. /**
  67730. * Gets the world normal input component
  67731. */
  67732. get worldNormal(): NodeMaterialConnectionPoint;
  67733. /**
  67734. * Gets the world input component
  67735. */
  67736. get world(): NodeMaterialConnectionPoint;
  67737. /**
  67738. * Gets the camera (or eye) position component
  67739. */
  67740. get cameraPosition(): NodeMaterialConnectionPoint;
  67741. /**
  67742. * Gets the view input component
  67743. */
  67744. get view(): NodeMaterialConnectionPoint;
  67745. /**
  67746. * Gets the color input component
  67747. */
  67748. get color(): NodeMaterialConnectionPoint;
  67749. /**
  67750. * Gets the reflection object output component
  67751. */
  67752. get reflection(): NodeMaterialConnectionPoint;
  67753. /**
  67754. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67755. */
  67756. get hasTexture(): boolean;
  67757. /**
  67758. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67759. */
  67760. get reflectionColor(): string;
  67761. protected _getTexture(): Nullable<BaseTexture>;
  67762. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67763. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67764. /**
  67765. * Gets the code to inject in the vertex shader
  67766. * @param state current state of the node material building
  67767. * @returns the shader code
  67768. */
  67769. handleVertexSide(state: NodeMaterialBuildState): string;
  67770. /**
  67771. * Gets the main code of the block (fragment side)
  67772. * @param state current state of the node material building
  67773. * @param normalVarName name of the existing variable corresponding to the normal
  67774. * @returns the shader code
  67775. */
  67776. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67777. protected _buildBlock(state: NodeMaterialBuildState): this;
  67778. protected _dumpPropertiesCode(): string;
  67779. serialize(): any;
  67780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67781. }
  67782. }
  67783. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67784. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67785. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67786. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67787. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67789. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67790. import { Scene } from "babylonjs/scene";
  67791. import { Nullable } from "babylonjs/types";
  67792. /**
  67793. * Block used to implement the sheen module of the PBR material
  67794. */
  67795. export class SheenBlock extends NodeMaterialBlock {
  67796. /**
  67797. * Create a new SheenBlock
  67798. * @param name defines the block name
  67799. */
  67800. constructor(name: string);
  67801. /**
  67802. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67803. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67804. * making it easier to setup and tweak the effect
  67805. */
  67806. albedoScaling: boolean;
  67807. /**
  67808. * Defines if the sheen is linked to the sheen color.
  67809. */
  67810. linkSheenWithAlbedo: boolean;
  67811. /**
  67812. * Initialize the block and prepare the context for build
  67813. * @param state defines the state that will be used for the build
  67814. */
  67815. initialize(state: NodeMaterialBuildState): void;
  67816. /**
  67817. * Gets the current class name
  67818. * @returns the class name
  67819. */
  67820. getClassName(): string;
  67821. /**
  67822. * Gets the intensity input component
  67823. */
  67824. get intensity(): NodeMaterialConnectionPoint;
  67825. /**
  67826. * Gets the color input component
  67827. */
  67828. get color(): NodeMaterialConnectionPoint;
  67829. /**
  67830. * Gets the roughness input component
  67831. */
  67832. get roughness(): NodeMaterialConnectionPoint;
  67833. /**
  67834. * Gets the sheen object output component
  67835. */
  67836. get sheen(): NodeMaterialConnectionPoint;
  67837. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67838. /**
  67839. * Gets the main code of the block (fragment side)
  67840. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67841. * @returns the shader code
  67842. */
  67843. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67844. protected _buildBlock(state: NodeMaterialBuildState): this;
  67845. protected _dumpPropertiesCode(): string;
  67846. serialize(): any;
  67847. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67848. }
  67849. }
  67850. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67851. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67853. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67855. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67856. import { Scene } from "babylonjs/scene";
  67857. import { Nullable } from "babylonjs/types";
  67858. import { Mesh } from "babylonjs/Meshes/mesh";
  67859. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67860. import { Effect } from "babylonjs/Materials/effect";
  67861. /**
  67862. * Block used to implement the reflectivity module of the PBR material
  67863. */
  67864. export class ReflectivityBlock extends NodeMaterialBlock {
  67865. private _metallicReflectanceColor;
  67866. private _metallicF0Factor;
  67867. /** @hidden */
  67868. _vMetallicReflectanceFactorsName: string;
  67869. /**
  67870. * The property below is set by the main PBR block prior to calling methods of this class.
  67871. */
  67872. /** @hidden */
  67873. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67874. /**
  67875. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67876. */
  67877. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67878. /**
  67879. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67880. */
  67881. useMetallnessFromMetallicTextureBlue: boolean;
  67882. /**
  67883. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67884. */
  67885. useRoughnessFromMetallicTextureAlpha: boolean;
  67886. /**
  67887. * Specifies if the metallic texture contains the roughness information in its green channel.
  67888. */
  67889. useRoughnessFromMetallicTextureGreen: boolean;
  67890. /**
  67891. * Create a new ReflectivityBlock
  67892. * @param name defines the block name
  67893. */
  67894. constructor(name: string);
  67895. /**
  67896. * Initialize the block and prepare the context for build
  67897. * @param state defines the state that will be used for the build
  67898. */
  67899. initialize(state: NodeMaterialBuildState): void;
  67900. /**
  67901. * Gets the current class name
  67902. * @returns the class name
  67903. */
  67904. getClassName(): string;
  67905. /**
  67906. * Gets the metallic input component
  67907. */
  67908. get metallic(): NodeMaterialConnectionPoint;
  67909. /**
  67910. * Gets the roughness input component
  67911. */
  67912. get roughness(): NodeMaterialConnectionPoint;
  67913. /**
  67914. * Gets the texture input component
  67915. */
  67916. get texture(): NodeMaterialConnectionPoint;
  67917. /**
  67918. * Gets the reflectivity object output component
  67919. */
  67920. get reflectivity(): NodeMaterialConnectionPoint;
  67921. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67922. /**
  67923. * Gets the main code of the block (fragment side)
  67924. * @param state current state of the node material building
  67925. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67926. * @returns the shader code
  67927. */
  67928. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67930. protected _buildBlock(state: NodeMaterialBuildState): this;
  67931. protected _dumpPropertiesCode(): string;
  67932. serialize(): any;
  67933. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67934. }
  67935. }
  67936. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67937. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67938. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67939. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67940. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67942. /**
  67943. * Block used to implement the anisotropy module of the PBR material
  67944. */
  67945. export class AnisotropyBlock extends NodeMaterialBlock {
  67946. /**
  67947. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67948. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67949. * It's less burden on the user side in the editor part.
  67950. */
  67951. /** @hidden */
  67952. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67953. /** @hidden */
  67954. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67955. /**
  67956. * Create a new AnisotropyBlock
  67957. * @param name defines the block name
  67958. */
  67959. constructor(name: string);
  67960. /**
  67961. * Initialize the block and prepare the context for build
  67962. * @param state defines the state that will be used for the build
  67963. */
  67964. initialize(state: NodeMaterialBuildState): void;
  67965. /**
  67966. * Gets the current class name
  67967. * @returns the class name
  67968. */
  67969. getClassName(): string;
  67970. /**
  67971. * Gets the intensity input component
  67972. */
  67973. get intensity(): NodeMaterialConnectionPoint;
  67974. /**
  67975. * Gets the direction input component
  67976. */
  67977. get direction(): NodeMaterialConnectionPoint;
  67978. /**
  67979. * Gets the texture input component
  67980. */
  67981. get texture(): NodeMaterialConnectionPoint;
  67982. /**
  67983. * Gets the uv input component
  67984. */
  67985. get uv(): NodeMaterialConnectionPoint;
  67986. /**
  67987. * Gets the worldTangent input component
  67988. */
  67989. get worldTangent(): NodeMaterialConnectionPoint;
  67990. /**
  67991. * Gets the anisotropy object output component
  67992. */
  67993. get anisotropy(): NodeMaterialConnectionPoint;
  67994. private _generateTBNSpace;
  67995. /**
  67996. * Gets the main code of the block (fragment side)
  67997. * @param state current state of the node material building
  67998. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67999. * @returns the shader code
  68000. */
  68001. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68002. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68003. protected _buildBlock(state: NodeMaterialBuildState): this;
  68004. }
  68005. }
  68006. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68008. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68009. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68010. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68012. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68013. import { Nullable } from "babylonjs/types";
  68014. import { Mesh } from "babylonjs/Meshes/mesh";
  68015. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68016. import { Effect } from "babylonjs/Materials/effect";
  68017. /**
  68018. * Block used to implement the clear coat module of the PBR material
  68019. */
  68020. export class ClearCoatBlock extends NodeMaterialBlock {
  68021. private _scene;
  68022. /**
  68023. * Create a new ClearCoatBlock
  68024. * @param name defines the block name
  68025. */
  68026. constructor(name: string);
  68027. /**
  68028. * Initialize the block and prepare the context for build
  68029. * @param state defines the state that will be used for the build
  68030. */
  68031. initialize(state: NodeMaterialBuildState): void;
  68032. /**
  68033. * Gets the current class name
  68034. * @returns the class name
  68035. */
  68036. getClassName(): string;
  68037. /**
  68038. * Gets the intensity input component
  68039. */
  68040. get intensity(): NodeMaterialConnectionPoint;
  68041. /**
  68042. * Gets the roughness input component
  68043. */
  68044. get roughness(): NodeMaterialConnectionPoint;
  68045. /**
  68046. * Gets the ior input component
  68047. */
  68048. get ior(): NodeMaterialConnectionPoint;
  68049. /**
  68050. * Gets the texture input component
  68051. */
  68052. get texture(): NodeMaterialConnectionPoint;
  68053. /**
  68054. * Gets the bump texture input component
  68055. */
  68056. get bumpTexture(): NodeMaterialConnectionPoint;
  68057. /**
  68058. * Gets the uv input component
  68059. */
  68060. get uv(): NodeMaterialConnectionPoint;
  68061. /**
  68062. * Gets the tint color input component
  68063. */
  68064. get tintColor(): NodeMaterialConnectionPoint;
  68065. /**
  68066. * Gets the tint "at distance" input component
  68067. */
  68068. get tintAtDistance(): NodeMaterialConnectionPoint;
  68069. /**
  68070. * Gets the tint thickness input component
  68071. */
  68072. get tintThickness(): NodeMaterialConnectionPoint;
  68073. /**
  68074. * Gets the world tangent input component
  68075. */
  68076. get worldTangent(): NodeMaterialConnectionPoint;
  68077. /**
  68078. * Gets the clear coat object output component
  68079. */
  68080. get clearcoat(): NodeMaterialConnectionPoint;
  68081. autoConfigure(material: NodeMaterial): void;
  68082. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68083. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68084. private _generateTBNSpace;
  68085. /**
  68086. * Gets the main code of the block (fragment side)
  68087. * @param state current state of the node material building
  68088. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68089. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68090. * @param worldPosVarName name of the variable holding the world position
  68091. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68092. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68093. * @param worldNormalVarName name of the variable holding the world normal
  68094. * @returns the shader code
  68095. */
  68096. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68097. protected _buildBlock(state: NodeMaterialBuildState): this;
  68098. }
  68099. }
  68100. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68104. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68106. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68107. import { Nullable } from "babylonjs/types";
  68108. /**
  68109. * Block used to implement the sub surface module of the PBR material
  68110. */
  68111. export class SubSurfaceBlock extends NodeMaterialBlock {
  68112. /**
  68113. * Create a new SubSurfaceBlock
  68114. * @param name defines the block name
  68115. */
  68116. constructor(name: string);
  68117. /**
  68118. * Stores the intensity of the different subsurface effects in the thickness texture.
  68119. * * the green channel is the translucency intensity.
  68120. * * the blue channel is the scattering intensity.
  68121. * * the alpha channel is the refraction intensity.
  68122. */
  68123. useMaskFromThicknessTexture: boolean;
  68124. /**
  68125. * Initialize the block and prepare the context for build
  68126. * @param state defines the state that will be used for the build
  68127. */
  68128. initialize(state: NodeMaterialBuildState): void;
  68129. /**
  68130. * Gets the current class name
  68131. * @returns the class name
  68132. */
  68133. getClassName(): string;
  68134. /**
  68135. * Gets the min thickness input component
  68136. */
  68137. get minThickness(): NodeMaterialConnectionPoint;
  68138. /**
  68139. * Gets the max thickness input component
  68140. */
  68141. get maxThickness(): NodeMaterialConnectionPoint;
  68142. /**
  68143. * Gets the thickness texture component
  68144. */
  68145. get thicknessTexture(): NodeMaterialConnectionPoint;
  68146. /**
  68147. * Gets the tint color input component
  68148. */
  68149. get tintColor(): NodeMaterialConnectionPoint;
  68150. /**
  68151. * Gets the translucency intensity input component
  68152. */
  68153. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68154. /**
  68155. * Gets the translucency diffusion distance input component
  68156. */
  68157. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68158. /**
  68159. * Gets the refraction object parameters
  68160. */
  68161. get refraction(): NodeMaterialConnectionPoint;
  68162. /**
  68163. * Gets the sub surface object output component
  68164. */
  68165. get subsurface(): NodeMaterialConnectionPoint;
  68166. autoConfigure(material: NodeMaterial): void;
  68167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68168. /**
  68169. * Gets the main code of the block (fragment side)
  68170. * @param state current state of the node material building
  68171. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68172. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68173. * @param worldPosVarName name of the variable holding the world position
  68174. * @returns the shader code
  68175. */
  68176. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68177. protected _buildBlock(state: NodeMaterialBuildState): this;
  68178. }
  68179. }
  68180. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68181. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68182. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68183. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68184. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68185. import { Light } from "babylonjs/Lights/light";
  68186. import { Nullable } from "babylonjs/types";
  68187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68188. import { Effect } from "babylonjs/Materials/effect";
  68189. import { Mesh } from "babylonjs/Meshes/mesh";
  68190. import { Scene } from "babylonjs/scene";
  68191. /**
  68192. * Block used to implement the PBR metallic/roughness model
  68193. */
  68194. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68195. /**
  68196. * Gets or sets the light associated with this block
  68197. */
  68198. light: Nullable<Light>;
  68199. private _lightId;
  68200. private _scene;
  68201. private _environmentBRDFTexture;
  68202. private _environmentBrdfSamplerName;
  68203. private _vNormalWName;
  68204. private _invertNormalName;
  68205. /**
  68206. * Create a new ReflectionBlock
  68207. * @param name defines the block name
  68208. */
  68209. constructor(name: string);
  68210. /**
  68211. * Intensity of the direct lights e.g. the four lights available in your scene.
  68212. * This impacts both the direct diffuse and specular highlights.
  68213. */
  68214. directIntensity: number;
  68215. /**
  68216. * Intensity of the environment e.g. how much the environment will light the object
  68217. * either through harmonics for rough material or through the refelction for shiny ones.
  68218. */
  68219. environmentIntensity: number;
  68220. /**
  68221. * This is a special control allowing the reduction of the specular highlights coming from the
  68222. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68223. */
  68224. specularIntensity: number;
  68225. /**
  68226. * Defines the falloff type used in this material.
  68227. * It by default is Physical.
  68228. */
  68229. lightFalloff: number;
  68230. /**
  68231. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68232. */
  68233. useAlphaFromAlbedoTexture: boolean;
  68234. /**
  68235. * Specifies that alpha test should be used
  68236. */
  68237. useAlphaTest: boolean;
  68238. /**
  68239. * Defines the alpha limits in alpha test mode.
  68240. */
  68241. alphaTestCutoff: number;
  68242. /**
  68243. * Specifies that alpha blending should be used
  68244. */
  68245. useAlphaBlending: boolean;
  68246. /**
  68247. * Defines if the alpha value should be determined via the rgb values.
  68248. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68249. */
  68250. opacityRGB: boolean;
  68251. /**
  68252. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68253. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68254. */
  68255. useRadianceOverAlpha: boolean;
  68256. /**
  68257. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68258. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68259. */
  68260. useSpecularOverAlpha: boolean;
  68261. /**
  68262. * Enables specular anti aliasing in the PBR shader.
  68263. * It will both interacts on the Geometry for analytical and IBL lighting.
  68264. * It also prefilter the roughness map based on the bump values.
  68265. */
  68266. enableSpecularAntiAliasing: boolean;
  68267. /**
  68268. * Enables realtime filtering on the texture.
  68269. */
  68270. realTimeFiltering: boolean;
  68271. /**
  68272. * Quality switch for realtime filtering
  68273. */
  68274. realTimeFilteringQuality: number;
  68275. /**
  68276. * Defines if the material uses energy conservation.
  68277. */
  68278. useEnergyConservation: boolean;
  68279. /**
  68280. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68281. * too much the area relying on ambient texture to define their ambient occlusion.
  68282. */
  68283. useRadianceOcclusion: boolean;
  68284. /**
  68285. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68286. * makes the reflect vector face the model (under horizon).
  68287. */
  68288. useHorizonOcclusion: boolean;
  68289. /**
  68290. * If set to true, no lighting calculations will be applied.
  68291. */
  68292. unlit: boolean;
  68293. /**
  68294. * Force normal to face away from face.
  68295. */
  68296. forceNormalForward: boolean;
  68297. /**
  68298. * Defines the material debug mode.
  68299. * It helps seeing only some components of the material while troubleshooting.
  68300. */
  68301. debugMode: number;
  68302. /**
  68303. * Specify from where on screen the debug mode should start.
  68304. * The value goes from -1 (full screen) to 1 (not visible)
  68305. * It helps with side by side comparison against the final render
  68306. * This defaults to 0
  68307. */
  68308. debugLimit: number;
  68309. /**
  68310. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68311. * You can use the factor to better multiply the final value.
  68312. */
  68313. debugFactor: number;
  68314. /**
  68315. * Initialize the block and prepare the context for build
  68316. * @param state defines the state that will be used for the build
  68317. */
  68318. initialize(state: NodeMaterialBuildState): void;
  68319. /**
  68320. * Gets the current class name
  68321. * @returns the class name
  68322. */
  68323. getClassName(): string;
  68324. /**
  68325. * Gets the world position input component
  68326. */
  68327. get worldPosition(): NodeMaterialConnectionPoint;
  68328. /**
  68329. * Gets the world normal input component
  68330. */
  68331. get worldNormal(): NodeMaterialConnectionPoint;
  68332. /**
  68333. * Gets the perturbed normal input component
  68334. */
  68335. get perturbedNormal(): NodeMaterialConnectionPoint;
  68336. /**
  68337. * Gets the camera position input component
  68338. */
  68339. get cameraPosition(): NodeMaterialConnectionPoint;
  68340. /**
  68341. * Gets the base color input component
  68342. */
  68343. get baseColor(): NodeMaterialConnectionPoint;
  68344. /**
  68345. * Gets the opacity texture input component
  68346. */
  68347. get opacityTexture(): NodeMaterialConnectionPoint;
  68348. /**
  68349. * Gets the ambient color input component
  68350. */
  68351. get ambientColor(): NodeMaterialConnectionPoint;
  68352. /**
  68353. * Gets the reflectivity object parameters
  68354. */
  68355. get reflectivity(): NodeMaterialConnectionPoint;
  68356. /**
  68357. * Gets the ambient occlusion object parameters
  68358. */
  68359. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68360. /**
  68361. * Gets the reflection object parameters
  68362. */
  68363. get reflection(): NodeMaterialConnectionPoint;
  68364. /**
  68365. * Gets the sheen object parameters
  68366. */
  68367. get sheen(): NodeMaterialConnectionPoint;
  68368. /**
  68369. * Gets the clear coat object parameters
  68370. */
  68371. get clearcoat(): NodeMaterialConnectionPoint;
  68372. /**
  68373. * Gets the sub surface object parameters
  68374. */
  68375. get subsurface(): NodeMaterialConnectionPoint;
  68376. /**
  68377. * Gets the anisotropy object parameters
  68378. */
  68379. get anisotropy(): NodeMaterialConnectionPoint;
  68380. /**
  68381. * Gets the ambient output component
  68382. */
  68383. get ambient(): NodeMaterialConnectionPoint;
  68384. /**
  68385. * Gets the diffuse output component
  68386. */
  68387. get diffuse(): NodeMaterialConnectionPoint;
  68388. /**
  68389. * Gets the specular output component
  68390. */
  68391. get specular(): NodeMaterialConnectionPoint;
  68392. /**
  68393. * Gets the sheen output component
  68394. */
  68395. get sheenDir(): NodeMaterialConnectionPoint;
  68396. /**
  68397. * Gets the clear coat output component
  68398. */
  68399. get clearcoatDir(): NodeMaterialConnectionPoint;
  68400. /**
  68401. * Gets the indirect diffuse output component
  68402. */
  68403. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68404. /**
  68405. * Gets the indirect specular output component
  68406. */
  68407. get specularIndirect(): NodeMaterialConnectionPoint;
  68408. /**
  68409. * Gets the indirect sheen output component
  68410. */
  68411. get sheenIndirect(): NodeMaterialConnectionPoint;
  68412. /**
  68413. * Gets the indirect clear coat output component
  68414. */
  68415. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68416. /**
  68417. * Gets the refraction output component
  68418. */
  68419. get refraction(): NodeMaterialConnectionPoint;
  68420. /**
  68421. * Gets the global lighting output component
  68422. */
  68423. get lighting(): NodeMaterialConnectionPoint;
  68424. /**
  68425. * Gets the shadow output component
  68426. */
  68427. get shadow(): NodeMaterialConnectionPoint;
  68428. /**
  68429. * Gets the alpha output component
  68430. */
  68431. get alpha(): NodeMaterialConnectionPoint;
  68432. autoConfigure(material: NodeMaterial): void;
  68433. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68434. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68435. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68436. private _injectVertexCode;
  68437. /**
  68438. * Gets the code corresponding to the albedo/opacity module
  68439. * @returns the shader code
  68440. */
  68441. getAlbedoOpacityCode(): string;
  68442. protected _buildBlock(state: NodeMaterialBuildState): this;
  68443. protected _dumpPropertiesCode(): string;
  68444. serialize(): any;
  68445. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68446. }
  68447. }
  68448. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68449. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68450. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68451. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68452. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68453. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68454. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68455. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68456. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68457. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68458. }
  68459. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68460. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68461. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68462. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68463. }
  68464. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68468. /**
  68469. * Block used to compute value of one parameter modulo another
  68470. */
  68471. export class ModBlock extends NodeMaterialBlock {
  68472. /**
  68473. * Creates a new ModBlock
  68474. * @param name defines the block name
  68475. */
  68476. constructor(name: string);
  68477. /**
  68478. * Gets the current class name
  68479. * @returns the class name
  68480. */
  68481. getClassName(): string;
  68482. /**
  68483. * Gets the left operand input component
  68484. */
  68485. get left(): NodeMaterialConnectionPoint;
  68486. /**
  68487. * Gets the right operand input component
  68488. */
  68489. get right(): NodeMaterialConnectionPoint;
  68490. /**
  68491. * Gets the output component
  68492. */
  68493. get output(): NodeMaterialConnectionPoint;
  68494. protected _buildBlock(state: NodeMaterialBuildState): this;
  68495. }
  68496. }
  68497. declare module "babylonjs/Materials/Node/Blocks/index" {
  68498. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68499. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68500. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68501. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68502. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68503. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68504. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68505. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68506. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68507. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68508. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68509. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68510. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68511. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68512. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68513. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68514. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68515. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68516. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68517. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68518. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68519. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68520. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68521. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68522. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68523. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68524. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68525. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68526. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68527. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68528. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68529. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68530. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68531. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68532. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68533. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68534. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68535. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68536. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68537. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68538. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68539. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68540. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68541. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68542. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68543. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68544. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68545. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68546. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68547. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68548. }
  68549. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68550. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68551. }
  68552. declare module "babylonjs/Materials/Node/index" {
  68553. export * from "babylonjs/Materials/Node/Enums/index";
  68554. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68555. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68556. export * from "babylonjs/Materials/Node/nodeMaterial";
  68557. export * from "babylonjs/Materials/Node/Blocks/index";
  68558. export * from "babylonjs/Materials/Node/Optimizers/index";
  68559. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68560. }
  68561. declare module "babylonjs/Materials/index" {
  68562. export * from "babylonjs/Materials/Background/index";
  68563. export * from "babylonjs/Materials/colorCurves";
  68564. export * from "babylonjs/Materials/iEffectFallbacks";
  68565. export * from "babylonjs/Materials/effectFallbacks";
  68566. export * from "babylonjs/Materials/effect";
  68567. export * from "babylonjs/Materials/fresnelParameters";
  68568. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68569. export * from "babylonjs/Materials/material";
  68570. export * from "babylonjs/Materials/materialDefines";
  68571. export * from "babylonjs/Materials/thinMaterialHelper";
  68572. export * from "babylonjs/Materials/materialHelper";
  68573. export * from "babylonjs/Materials/multiMaterial";
  68574. export * from "babylonjs/Materials/PBR/index";
  68575. export * from "babylonjs/Materials/pushMaterial";
  68576. export * from "babylonjs/Materials/shaderMaterial";
  68577. export * from "babylonjs/Materials/standardMaterial";
  68578. export * from "babylonjs/Materials/Textures/index";
  68579. export * from "babylonjs/Materials/uniformBuffer";
  68580. export * from "babylonjs/Materials/materialFlags";
  68581. export * from "babylonjs/Materials/Node/index";
  68582. export * from "babylonjs/Materials/effectRenderer";
  68583. export * from "babylonjs/Materials/shadowDepthWrapper";
  68584. }
  68585. declare module "babylonjs/Maths/index" {
  68586. export * from "babylonjs/Maths/math.scalar";
  68587. export * from "babylonjs/Maths/math";
  68588. export * from "babylonjs/Maths/sphericalPolynomial";
  68589. }
  68590. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68591. import { IDisposable } from "babylonjs/scene";
  68592. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68593. /**
  68594. * Configuration for Draco compression
  68595. */
  68596. export interface IDracoCompressionConfiguration {
  68597. /**
  68598. * Configuration for the decoder.
  68599. */
  68600. decoder: {
  68601. /**
  68602. * The url to the WebAssembly module.
  68603. */
  68604. wasmUrl?: string;
  68605. /**
  68606. * The url to the WebAssembly binary.
  68607. */
  68608. wasmBinaryUrl?: string;
  68609. /**
  68610. * The url to the fallback JavaScript module.
  68611. */
  68612. fallbackUrl?: string;
  68613. };
  68614. }
  68615. /**
  68616. * Draco compression (https://google.github.io/draco/)
  68617. *
  68618. * This class wraps the Draco module.
  68619. *
  68620. * **Encoder**
  68621. *
  68622. * The encoder is not currently implemented.
  68623. *
  68624. * **Decoder**
  68625. *
  68626. * 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.
  68627. *
  68628. * To update the configuration, use the following code:
  68629. * ```javascript
  68630. * DracoCompression.Configuration = {
  68631. * decoder: {
  68632. * wasmUrl: "<url to the WebAssembly library>",
  68633. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68634. * fallbackUrl: "<url to the fallback JavaScript library>",
  68635. * }
  68636. * };
  68637. * ```
  68638. *
  68639. * 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.
  68640. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68641. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68642. *
  68643. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68644. * ```javascript
  68645. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68646. * ```
  68647. *
  68648. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68649. */
  68650. export class DracoCompression implements IDisposable {
  68651. private _workerPoolPromise?;
  68652. private _decoderModulePromise?;
  68653. /**
  68654. * The configuration. Defaults to the following urls:
  68655. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68656. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68657. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68658. */
  68659. static Configuration: IDracoCompressionConfiguration;
  68660. /**
  68661. * Returns true if the decoder configuration is available.
  68662. */
  68663. static get DecoderAvailable(): boolean;
  68664. /**
  68665. * Default number of workers to create when creating the draco compression object.
  68666. */
  68667. static DefaultNumWorkers: number;
  68668. private static GetDefaultNumWorkers;
  68669. private static _Default;
  68670. /**
  68671. * Default instance for the draco compression object.
  68672. */
  68673. static get Default(): DracoCompression;
  68674. /**
  68675. * Constructor
  68676. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68677. */
  68678. constructor(numWorkers?: number);
  68679. /**
  68680. * Stop all async operations and release resources.
  68681. */
  68682. dispose(): void;
  68683. /**
  68684. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68685. * @returns a promise that resolves when ready
  68686. */
  68687. whenReadyAsync(): Promise<void>;
  68688. /**
  68689. * Decode Draco compressed mesh data to vertex data.
  68690. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68691. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68692. * @returns A promise that resolves with the decoded vertex data
  68693. */
  68694. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68695. [kind: string]: number;
  68696. }): Promise<VertexData>;
  68697. }
  68698. }
  68699. declare module "babylonjs/Meshes/Compression/index" {
  68700. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68701. }
  68702. declare module "babylonjs/Meshes/csg" {
  68703. import { Nullable } from "babylonjs/types";
  68704. import { Scene } from "babylonjs/scene";
  68705. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68706. import { Mesh } from "babylonjs/Meshes/mesh";
  68707. import { Material } from "babylonjs/Materials/material";
  68708. /**
  68709. * Class for building Constructive Solid Geometry
  68710. */
  68711. export class CSG {
  68712. private polygons;
  68713. /**
  68714. * The world matrix
  68715. */
  68716. matrix: Matrix;
  68717. /**
  68718. * Stores the position
  68719. */
  68720. position: Vector3;
  68721. /**
  68722. * Stores the rotation
  68723. */
  68724. rotation: Vector3;
  68725. /**
  68726. * Stores the rotation quaternion
  68727. */
  68728. rotationQuaternion: Nullable<Quaternion>;
  68729. /**
  68730. * Stores the scaling vector
  68731. */
  68732. scaling: Vector3;
  68733. /**
  68734. * Convert the Mesh to CSG
  68735. * @param mesh The Mesh to convert to CSG
  68736. * @returns A new CSG from the Mesh
  68737. */
  68738. static FromMesh(mesh: Mesh): CSG;
  68739. /**
  68740. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68741. * @param polygons Polygons used to construct a CSG solid
  68742. */
  68743. private static FromPolygons;
  68744. /**
  68745. * Clones, or makes a deep copy, of the CSG
  68746. * @returns A new CSG
  68747. */
  68748. clone(): CSG;
  68749. /**
  68750. * Unions this CSG with another CSG
  68751. * @param csg The CSG to union against this CSG
  68752. * @returns The unioned CSG
  68753. */
  68754. union(csg: CSG): CSG;
  68755. /**
  68756. * Unions this CSG with another CSG in place
  68757. * @param csg The CSG to union against this CSG
  68758. */
  68759. unionInPlace(csg: CSG): void;
  68760. /**
  68761. * Subtracts this CSG with another CSG
  68762. * @param csg The CSG to subtract against this CSG
  68763. * @returns A new CSG
  68764. */
  68765. subtract(csg: CSG): CSG;
  68766. /**
  68767. * Subtracts this CSG with another CSG in place
  68768. * @param csg The CSG to subtact against this CSG
  68769. */
  68770. subtractInPlace(csg: CSG): void;
  68771. /**
  68772. * Intersect this CSG with another CSG
  68773. * @param csg The CSG to intersect against this CSG
  68774. * @returns A new CSG
  68775. */
  68776. intersect(csg: CSG): CSG;
  68777. /**
  68778. * Intersects this CSG with another CSG in place
  68779. * @param csg The CSG to intersect against this CSG
  68780. */
  68781. intersectInPlace(csg: CSG): void;
  68782. /**
  68783. * Return a new CSG solid with solid and empty space switched. This solid is
  68784. * not modified.
  68785. * @returns A new CSG solid with solid and empty space switched
  68786. */
  68787. inverse(): CSG;
  68788. /**
  68789. * Inverses the CSG in place
  68790. */
  68791. inverseInPlace(): void;
  68792. /**
  68793. * This is used to keep meshes transformations so they can be restored
  68794. * when we build back a Babylon Mesh
  68795. * NB : All CSG operations are performed in world coordinates
  68796. * @param csg The CSG to copy the transform attributes from
  68797. * @returns This CSG
  68798. */
  68799. copyTransformAttributes(csg: CSG): CSG;
  68800. /**
  68801. * Build Raw mesh from CSG
  68802. * Coordinates here are in world space
  68803. * @param name The name of the mesh geometry
  68804. * @param scene The Scene
  68805. * @param keepSubMeshes Specifies if the submeshes should be kept
  68806. * @returns A new Mesh
  68807. */
  68808. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68809. /**
  68810. * Build Mesh from CSG taking material and transforms into account
  68811. * @param name The name of the Mesh
  68812. * @param material The material of the Mesh
  68813. * @param scene The Scene
  68814. * @param keepSubMeshes Specifies if submeshes should be kept
  68815. * @returns The new Mesh
  68816. */
  68817. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68818. }
  68819. }
  68820. declare module "babylonjs/Meshes/trailMesh" {
  68821. import { Mesh } from "babylonjs/Meshes/mesh";
  68822. import { Scene } from "babylonjs/scene";
  68823. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68824. /**
  68825. * Class used to create a trail following a mesh
  68826. */
  68827. export class TrailMesh extends Mesh {
  68828. private _generator;
  68829. private _autoStart;
  68830. private _running;
  68831. private _diameter;
  68832. private _length;
  68833. private _sectionPolygonPointsCount;
  68834. private _sectionVectors;
  68835. private _sectionNormalVectors;
  68836. private _beforeRenderObserver;
  68837. /**
  68838. * @constructor
  68839. * @param name The value used by scene.getMeshByName() to do a lookup.
  68840. * @param generator The mesh or transform node to generate a trail.
  68841. * @param scene The scene to add this mesh to.
  68842. * @param diameter Diameter of trailing mesh. Default is 1.
  68843. * @param length Length of trailing mesh. Default is 60.
  68844. * @param autoStart Automatically start trailing mesh. Default true.
  68845. */
  68846. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68847. /**
  68848. * "TrailMesh"
  68849. * @returns "TrailMesh"
  68850. */
  68851. getClassName(): string;
  68852. private _createMesh;
  68853. /**
  68854. * Start trailing mesh.
  68855. */
  68856. start(): void;
  68857. /**
  68858. * Stop trailing mesh.
  68859. */
  68860. stop(): void;
  68861. /**
  68862. * Update trailing mesh geometry.
  68863. */
  68864. update(): void;
  68865. /**
  68866. * Returns a new TrailMesh object.
  68867. * @param name is a string, the name given to the new mesh
  68868. * @param newGenerator use new generator object for cloned trail mesh
  68869. * @returns a new mesh
  68870. */
  68871. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68872. /**
  68873. * Serializes this trail mesh
  68874. * @param serializationObject object to write serialization to
  68875. */
  68876. serialize(serializationObject: any): void;
  68877. /**
  68878. * Parses a serialized trail mesh
  68879. * @param parsedMesh the serialized mesh
  68880. * @param scene the scene to create the trail mesh in
  68881. * @returns the created trail mesh
  68882. */
  68883. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68884. }
  68885. }
  68886. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68887. import { Nullable } from "babylonjs/types";
  68888. import { Scene } from "babylonjs/scene";
  68889. import { Vector4 } from "babylonjs/Maths/math.vector";
  68890. import { Color4 } from "babylonjs/Maths/math.color";
  68891. import { Mesh } from "babylonjs/Meshes/mesh";
  68892. /**
  68893. * Class containing static functions to help procedurally build meshes
  68894. */
  68895. export class TiledBoxBuilder {
  68896. /**
  68897. * Creates a box mesh
  68898. * 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)
  68899. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68903. * @param name defines the name of the mesh
  68904. * @param options defines the options used to create the mesh
  68905. * @param scene defines the hosting scene
  68906. * @returns the box mesh
  68907. */
  68908. static CreateTiledBox(name: string, options: {
  68909. pattern?: number;
  68910. width?: number;
  68911. height?: number;
  68912. depth?: number;
  68913. tileSize?: number;
  68914. tileWidth?: number;
  68915. tileHeight?: number;
  68916. alignHorizontal?: number;
  68917. alignVertical?: number;
  68918. faceUV?: Vector4[];
  68919. faceColors?: Color4[];
  68920. sideOrientation?: number;
  68921. updatable?: boolean;
  68922. }, scene?: Nullable<Scene>): Mesh;
  68923. }
  68924. }
  68925. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68926. import { Vector4 } from "babylonjs/Maths/math.vector";
  68927. import { Mesh } from "babylonjs/Meshes/mesh";
  68928. /**
  68929. * Class containing static functions to help procedurally build meshes
  68930. */
  68931. export class TorusKnotBuilder {
  68932. /**
  68933. * Creates a torus knot mesh
  68934. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68935. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68936. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68937. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68941. * @param name defines the name of the mesh
  68942. * @param options defines the options used to create the mesh
  68943. * @param scene defines the hosting scene
  68944. * @returns the torus knot mesh
  68945. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68946. */
  68947. static CreateTorusKnot(name: string, options: {
  68948. radius?: number;
  68949. tube?: number;
  68950. radialSegments?: number;
  68951. tubularSegments?: number;
  68952. p?: number;
  68953. q?: number;
  68954. updatable?: boolean;
  68955. sideOrientation?: number;
  68956. frontUVs?: Vector4;
  68957. backUVs?: Vector4;
  68958. }, scene: any): Mesh;
  68959. }
  68960. }
  68961. declare module "babylonjs/Meshes/polygonMesh" {
  68962. import { Scene } from "babylonjs/scene";
  68963. import { Vector2 } from "babylonjs/Maths/math.vector";
  68964. import { Mesh } from "babylonjs/Meshes/mesh";
  68965. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68966. import { Path2 } from "babylonjs/Maths/math.path";
  68967. /**
  68968. * Polygon
  68969. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68970. */
  68971. export class Polygon {
  68972. /**
  68973. * Creates a rectangle
  68974. * @param xmin bottom X coord
  68975. * @param ymin bottom Y coord
  68976. * @param xmax top X coord
  68977. * @param ymax top Y coord
  68978. * @returns points that make the resulting rectation
  68979. */
  68980. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68981. /**
  68982. * Creates a circle
  68983. * @param radius radius of circle
  68984. * @param cx scale in x
  68985. * @param cy scale in y
  68986. * @param numberOfSides number of sides that make up the circle
  68987. * @returns points that make the resulting circle
  68988. */
  68989. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68990. /**
  68991. * Creates a polygon from input string
  68992. * @param input Input polygon data
  68993. * @returns the parsed points
  68994. */
  68995. static Parse(input: string): Vector2[];
  68996. /**
  68997. * Starts building a polygon from x and y coordinates
  68998. * @param x x coordinate
  68999. * @param y y coordinate
  69000. * @returns the started path2
  69001. */
  69002. static StartingAt(x: number, y: number): Path2;
  69003. }
  69004. /**
  69005. * Builds a polygon
  69006. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69007. */
  69008. export class PolygonMeshBuilder {
  69009. private _points;
  69010. private _outlinepoints;
  69011. private _holes;
  69012. private _name;
  69013. private _scene;
  69014. private _epoints;
  69015. private _eholes;
  69016. private _addToepoint;
  69017. /**
  69018. * Babylon reference to the earcut plugin.
  69019. */
  69020. bjsEarcut: any;
  69021. /**
  69022. * Creates a PolygonMeshBuilder
  69023. * @param name name of the builder
  69024. * @param contours Path of the polygon
  69025. * @param scene scene to add to when creating the mesh
  69026. * @param earcutInjection can be used to inject your own earcut reference
  69027. */
  69028. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69029. /**
  69030. * Adds a whole within the polygon
  69031. * @param hole Array of points defining the hole
  69032. * @returns this
  69033. */
  69034. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69035. /**
  69036. * Creates the polygon
  69037. * @param updatable If the mesh should be updatable
  69038. * @param depth The depth of the mesh created
  69039. * @returns the created mesh
  69040. */
  69041. build(updatable?: boolean, depth?: number): Mesh;
  69042. /**
  69043. * Creates the polygon
  69044. * @param depth The depth of the mesh created
  69045. * @returns the created VertexData
  69046. */
  69047. buildVertexData(depth?: number): VertexData;
  69048. /**
  69049. * Adds a side to the polygon
  69050. * @param positions points that make the polygon
  69051. * @param normals normals of the polygon
  69052. * @param uvs uvs of the polygon
  69053. * @param indices indices of the polygon
  69054. * @param bounds bounds of the polygon
  69055. * @param points points of the polygon
  69056. * @param depth depth of the polygon
  69057. * @param flip flip of the polygon
  69058. */
  69059. private addSide;
  69060. }
  69061. }
  69062. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69063. import { Scene } from "babylonjs/scene";
  69064. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69065. import { Color4 } from "babylonjs/Maths/math.color";
  69066. import { Mesh } from "babylonjs/Meshes/mesh";
  69067. import { Nullable } from "babylonjs/types";
  69068. /**
  69069. * Class containing static functions to help procedurally build meshes
  69070. */
  69071. export class PolygonBuilder {
  69072. /**
  69073. * Creates a polygon mesh
  69074. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69075. * * 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
  69076. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69079. * * Remember you can only change the shape positions, not their number when updating a polygon
  69080. * @param name defines the name of the mesh
  69081. * @param options defines the options used to create the mesh
  69082. * @param scene defines the hosting scene
  69083. * @param earcutInjection can be used to inject your own earcut reference
  69084. * @returns the polygon mesh
  69085. */
  69086. static CreatePolygon(name: string, options: {
  69087. shape: Vector3[];
  69088. holes?: Vector3[][];
  69089. depth?: number;
  69090. faceUV?: Vector4[];
  69091. faceColors?: Color4[];
  69092. updatable?: boolean;
  69093. sideOrientation?: number;
  69094. frontUVs?: Vector4;
  69095. backUVs?: Vector4;
  69096. wrap?: boolean;
  69097. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69098. /**
  69099. * Creates an extruded polygon mesh, with depth in the Y direction.
  69100. * * 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)
  69101. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69102. * @param name defines the name of the mesh
  69103. * @param options defines the options used to create the mesh
  69104. * @param scene defines the hosting scene
  69105. * @param earcutInjection can be used to inject your own earcut reference
  69106. * @returns the polygon mesh
  69107. */
  69108. static ExtrudePolygon(name: string, options: {
  69109. shape: Vector3[];
  69110. holes?: Vector3[][];
  69111. depth?: number;
  69112. faceUV?: Vector4[];
  69113. faceColors?: Color4[];
  69114. updatable?: boolean;
  69115. sideOrientation?: number;
  69116. frontUVs?: Vector4;
  69117. backUVs?: Vector4;
  69118. wrap?: boolean;
  69119. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69120. }
  69121. }
  69122. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69123. import { Scene } from "babylonjs/scene";
  69124. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69125. import { Mesh } from "babylonjs/Meshes/mesh";
  69126. import { Nullable } from "babylonjs/types";
  69127. /**
  69128. * Class containing static functions to help procedurally build meshes
  69129. */
  69130. export class LatheBuilder {
  69131. /**
  69132. * Creates lathe mesh.
  69133. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69134. * * 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
  69135. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69136. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69137. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69138. * * 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
  69139. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69140. * * 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
  69141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69143. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69145. * @param name defines the name of the mesh
  69146. * @param options defines the options used to create the mesh
  69147. * @param scene defines the hosting scene
  69148. * @returns the lathe mesh
  69149. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69150. */
  69151. static CreateLathe(name: string, options: {
  69152. shape: Vector3[];
  69153. radius?: number;
  69154. tessellation?: number;
  69155. clip?: number;
  69156. arc?: number;
  69157. closed?: boolean;
  69158. updatable?: boolean;
  69159. sideOrientation?: number;
  69160. frontUVs?: Vector4;
  69161. backUVs?: Vector4;
  69162. cap?: number;
  69163. invertUV?: boolean;
  69164. }, scene?: Nullable<Scene>): Mesh;
  69165. }
  69166. }
  69167. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69168. import { Nullable } from "babylonjs/types";
  69169. import { Scene } from "babylonjs/scene";
  69170. import { Vector4 } from "babylonjs/Maths/math.vector";
  69171. import { Mesh } from "babylonjs/Meshes/mesh";
  69172. /**
  69173. * Class containing static functions to help procedurally build meshes
  69174. */
  69175. export class TiledPlaneBuilder {
  69176. /**
  69177. * Creates a tiled plane mesh
  69178. * * The parameter `pattern` will, depending on value, do nothing or
  69179. * * * flip (reflect about central vertical) alternate tiles across and up
  69180. * * * flip every tile on alternate rows
  69181. * * * rotate (180 degs) alternate tiles across and up
  69182. * * * rotate every tile on alternate rows
  69183. * * * flip and rotate alternate tiles across and up
  69184. * * * flip and rotate every tile on alternate rows
  69185. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69186. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69189. * * 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)
  69190. * * 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)
  69191. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69192. * @param name defines the name of the mesh
  69193. * @param options defines the options used to create the mesh
  69194. * @param scene defines the hosting scene
  69195. * @returns the box mesh
  69196. */
  69197. static CreateTiledPlane(name: string, options: {
  69198. pattern?: number;
  69199. tileSize?: number;
  69200. tileWidth?: number;
  69201. tileHeight?: number;
  69202. size?: number;
  69203. width?: number;
  69204. height?: number;
  69205. alignHorizontal?: number;
  69206. alignVertical?: number;
  69207. sideOrientation?: number;
  69208. frontUVs?: Vector4;
  69209. backUVs?: Vector4;
  69210. updatable?: boolean;
  69211. }, scene?: Nullable<Scene>): Mesh;
  69212. }
  69213. }
  69214. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69215. import { Nullable } from "babylonjs/types";
  69216. import { Scene } from "babylonjs/scene";
  69217. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69218. import { Mesh } from "babylonjs/Meshes/mesh";
  69219. /**
  69220. * Class containing static functions to help procedurally build meshes
  69221. */
  69222. export class TubeBuilder {
  69223. /**
  69224. * Creates a tube mesh.
  69225. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69226. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69227. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69228. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69229. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69230. * * 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)
  69231. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69232. * * 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
  69233. * * 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
  69234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69238. * @param name defines the name of the mesh
  69239. * @param options defines the options used to create the mesh
  69240. * @param scene defines the hosting scene
  69241. * @returns the tube mesh
  69242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69243. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69244. */
  69245. static CreateTube(name: string, options: {
  69246. path: Vector3[];
  69247. radius?: number;
  69248. tessellation?: number;
  69249. radiusFunction?: {
  69250. (i: number, distance: number): number;
  69251. };
  69252. cap?: number;
  69253. arc?: number;
  69254. updatable?: boolean;
  69255. sideOrientation?: number;
  69256. frontUVs?: Vector4;
  69257. backUVs?: Vector4;
  69258. instance?: Mesh;
  69259. invertUV?: boolean;
  69260. }, scene?: Nullable<Scene>): Mesh;
  69261. }
  69262. }
  69263. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69264. import { Scene } from "babylonjs/scene";
  69265. import { Vector4 } from "babylonjs/Maths/math.vector";
  69266. import { Mesh } from "babylonjs/Meshes/mesh";
  69267. import { Nullable } from "babylonjs/types";
  69268. /**
  69269. * Class containing static functions to help procedurally build meshes
  69270. */
  69271. export class IcoSphereBuilder {
  69272. /**
  69273. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69274. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69275. * * 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`)
  69276. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69277. * * 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
  69278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69281. * @param name defines the name of the mesh
  69282. * @param options defines the options used to create the mesh
  69283. * @param scene defines the hosting scene
  69284. * @returns the icosahedron mesh
  69285. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69286. */
  69287. static CreateIcoSphere(name: string, options: {
  69288. radius?: number;
  69289. radiusX?: number;
  69290. radiusY?: number;
  69291. radiusZ?: number;
  69292. flat?: boolean;
  69293. subdivisions?: number;
  69294. sideOrientation?: number;
  69295. frontUVs?: Vector4;
  69296. backUVs?: Vector4;
  69297. updatable?: boolean;
  69298. }, scene?: Nullable<Scene>): Mesh;
  69299. }
  69300. }
  69301. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69302. import { Vector3 } from "babylonjs/Maths/math.vector";
  69303. import { Mesh } from "babylonjs/Meshes/mesh";
  69304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69305. /**
  69306. * Class containing static functions to help procedurally build meshes
  69307. */
  69308. export class DecalBuilder {
  69309. /**
  69310. * Creates a decal mesh.
  69311. * 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
  69312. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69313. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69314. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69315. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69316. * @param name defines the name of the mesh
  69317. * @param sourceMesh defines the mesh where the decal must be applied
  69318. * @param options defines the options used to create the mesh
  69319. * @param scene defines the hosting scene
  69320. * @returns the decal mesh
  69321. * @see https://doc.babylonjs.com/how_to/decals
  69322. */
  69323. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69324. position?: Vector3;
  69325. normal?: Vector3;
  69326. size?: Vector3;
  69327. angle?: number;
  69328. }): Mesh;
  69329. }
  69330. }
  69331. declare module "babylonjs/Meshes/meshBuilder" {
  69332. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69333. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69334. import { Nullable } from "babylonjs/types";
  69335. import { Scene } from "babylonjs/scene";
  69336. import { Mesh } from "babylonjs/Meshes/mesh";
  69337. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69338. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69340. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69341. import { Plane } from "babylonjs/Maths/math.plane";
  69342. /**
  69343. * Class containing static functions to help procedurally build meshes
  69344. */
  69345. export class MeshBuilder {
  69346. /**
  69347. * Creates a box mesh
  69348. * * The parameter `size` sets the size (float) of each box side (default 1)
  69349. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69350. * * 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)
  69351. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69355. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69356. * @param name defines the name of the mesh
  69357. * @param options defines the options used to create the mesh
  69358. * @param scene defines the hosting scene
  69359. * @returns the box mesh
  69360. */
  69361. static CreateBox(name: string, options: {
  69362. size?: number;
  69363. width?: number;
  69364. height?: number;
  69365. depth?: number;
  69366. faceUV?: Vector4[];
  69367. faceColors?: Color4[];
  69368. sideOrientation?: number;
  69369. frontUVs?: Vector4;
  69370. backUVs?: Vector4;
  69371. wrap?: boolean;
  69372. topBaseAt?: number;
  69373. bottomBaseAt?: number;
  69374. updatable?: boolean;
  69375. }, scene?: Nullable<Scene>): Mesh;
  69376. /**
  69377. * Creates a tiled box mesh
  69378. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69380. * @param name defines the name of the mesh
  69381. * @param options defines the options used to create the mesh
  69382. * @param scene defines the hosting scene
  69383. * @returns the tiled box mesh
  69384. */
  69385. static CreateTiledBox(name: string, options: {
  69386. pattern?: number;
  69387. size?: number;
  69388. width?: number;
  69389. height?: number;
  69390. depth: number;
  69391. tileSize?: number;
  69392. tileWidth?: number;
  69393. tileHeight?: number;
  69394. faceUV?: Vector4[];
  69395. faceColors?: Color4[];
  69396. alignHorizontal?: number;
  69397. alignVertical?: number;
  69398. sideOrientation?: number;
  69399. updatable?: boolean;
  69400. }, scene?: Nullable<Scene>): Mesh;
  69401. /**
  69402. * Creates a sphere mesh
  69403. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69404. * * 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`)
  69405. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69406. * * 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
  69407. * * 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)
  69408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69411. * @param name defines the name of the mesh
  69412. * @param options defines the options used to create the mesh
  69413. * @param scene defines the hosting scene
  69414. * @returns the sphere mesh
  69415. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69416. */
  69417. static CreateSphere(name: string, options: {
  69418. segments?: number;
  69419. diameter?: number;
  69420. diameterX?: number;
  69421. diameterY?: number;
  69422. diameterZ?: number;
  69423. arc?: number;
  69424. slice?: number;
  69425. sideOrientation?: number;
  69426. frontUVs?: Vector4;
  69427. backUVs?: Vector4;
  69428. updatable?: boolean;
  69429. }, scene?: Nullable<Scene>): Mesh;
  69430. /**
  69431. * Creates a plane polygonal mesh. By default, this is a disc
  69432. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69433. * * 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
  69434. * * 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
  69435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69438. * @param name defines the name of the mesh
  69439. * @param options defines the options used to create the mesh
  69440. * @param scene defines the hosting scene
  69441. * @returns the plane polygonal mesh
  69442. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69443. */
  69444. static CreateDisc(name: string, options: {
  69445. radius?: number;
  69446. tessellation?: number;
  69447. arc?: number;
  69448. updatable?: boolean;
  69449. sideOrientation?: number;
  69450. frontUVs?: Vector4;
  69451. backUVs?: Vector4;
  69452. }, scene?: Nullable<Scene>): Mesh;
  69453. /**
  69454. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69455. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69456. * * 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`)
  69457. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69458. * * 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
  69459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69462. * @param name defines the name of the mesh
  69463. * @param options defines the options used to create the mesh
  69464. * @param scene defines the hosting scene
  69465. * @returns the icosahedron mesh
  69466. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69467. */
  69468. static CreateIcoSphere(name: string, options: {
  69469. radius?: number;
  69470. radiusX?: number;
  69471. radiusY?: number;
  69472. radiusZ?: number;
  69473. flat?: boolean;
  69474. subdivisions?: number;
  69475. sideOrientation?: number;
  69476. frontUVs?: Vector4;
  69477. backUVs?: Vector4;
  69478. updatable?: boolean;
  69479. }, scene?: Nullable<Scene>): Mesh;
  69480. /**
  69481. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69482. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69483. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69484. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69485. * * 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
  69486. * * 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
  69487. * * 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
  69488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69490. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69491. * * 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
  69492. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69493. * * 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
  69494. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69496. * @param name defines the name of the mesh
  69497. * @param options defines the options used to create the mesh
  69498. * @param scene defines the hosting scene
  69499. * @returns the ribbon mesh
  69500. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69502. */
  69503. static CreateRibbon(name: string, options: {
  69504. pathArray: Vector3[][];
  69505. closeArray?: boolean;
  69506. closePath?: boolean;
  69507. offset?: number;
  69508. updatable?: boolean;
  69509. sideOrientation?: number;
  69510. frontUVs?: Vector4;
  69511. backUVs?: Vector4;
  69512. instance?: Mesh;
  69513. invertUV?: boolean;
  69514. uvs?: Vector2[];
  69515. colors?: Color4[];
  69516. }, scene?: Nullable<Scene>): Mesh;
  69517. /**
  69518. * Creates a cylinder or a cone mesh
  69519. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69520. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69521. * * 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.
  69522. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69523. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69524. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69525. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69526. * * 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).
  69527. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69528. * * 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).
  69529. * * 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
  69530. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69531. * * 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
  69532. * * 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.
  69533. * * If `enclose` is false, a ring surface is one element.
  69534. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69535. * * 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
  69536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69539. * @param name defines the name of the mesh
  69540. * @param options defines the options used to create the mesh
  69541. * @param scene defines the hosting scene
  69542. * @returns the cylinder mesh
  69543. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69544. */
  69545. static CreateCylinder(name: string, options: {
  69546. height?: number;
  69547. diameterTop?: number;
  69548. diameterBottom?: number;
  69549. diameter?: number;
  69550. tessellation?: number;
  69551. subdivisions?: number;
  69552. arc?: number;
  69553. faceColors?: Color4[];
  69554. faceUV?: Vector4[];
  69555. updatable?: boolean;
  69556. hasRings?: boolean;
  69557. enclose?: boolean;
  69558. cap?: number;
  69559. sideOrientation?: number;
  69560. frontUVs?: Vector4;
  69561. backUVs?: Vector4;
  69562. }, scene?: Nullable<Scene>): Mesh;
  69563. /**
  69564. * Creates a torus mesh
  69565. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69566. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69567. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69571. * @param name defines the name of the mesh
  69572. * @param options defines the options used to create the mesh
  69573. * @param scene defines the hosting scene
  69574. * @returns the torus mesh
  69575. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69576. */
  69577. static CreateTorus(name: string, options: {
  69578. diameter?: number;
  69579. thickness?: number;
  69580. tessellation?: number;
  69581. updatable?: boolean;
  69582. sideOrientation?: number;
  69583. frontUVs?: Vector4;
  69584. backUVs?: Vector4;
  69585. }, scene?: Nullable<Scene>): Mesh;
  69586. /**
  69587. * Creates a torus knot mesh
  69588. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69589. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69590. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69591. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69595. * @param name defines the name of the mesh
  69596. * @param options defines the options used to create the mesh
  69597. * @param scene defines the hosting scene
  69598. * @returns the torus knot mesh
  69599. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69600. */
  69601. static CreateTorusKnot(name: string, options: {
  69602. radius?: number;
  69603. tube?: number;
  69604. radialSegments?: number;
  69605. tubularSegments?: number;
  69606. p?: number;
  69607. q?: number;
  69608. updatable?: boolean;
  69609. sideOrientation?: number;
  69610. frontUVs?: Vector4;
  69611. backUVs?: Vector4;
  69612. }, scene?: Nullable<Scene>): Mesh;
  69613. /**
  69614. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69615. * * 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
  69616. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69617. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69618. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69619. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69620. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69621. * * 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
  69622. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69625. * @param name defines the name of the new line system
  69626. * @param options defines the options used to create the line system
  69627. * @param scene defines the hosting scene
  69628. * @returns a new line system mesh
  69629. */
  69630. static CreateLineSystem(name: string, options: {
  69631. lines: Vector3[][];
  69632. updatable?: boolean;
  69633. instance?: Nullable<LinesMesh>;
  69634. colors?: Nullable<Color4[][]>;
  69635. useVertexAlpha?: boolean;
  69636. }, scene: Nullable<Scene>): LinesMesh;
  69637. /**
  69638. * Creates a line mesh
  69639. * 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
  69640. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69641. * * The parameter `points` is an array successive Vector3
  69642. * * 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
  69643. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69644. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69645. * * When updating an instance, remember that only point positions can change, not the number of points
  69646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69648. * @param name defines the name of the new line system
  69649. * @param options defines the options used to create the line system
  69650. * @param scene defines the hosting scene
  69651. * @returns a new line mesh
  69652. */
  69653. static CreateLines(name: string, options: {
  69654. points: Vector3[];
  69655. updatable?: boolean;
  69656. instance?: Nullable<LinesMesh>;
  69657. colors?: Color4[];
  69658. useVertexAlpha?: boolean;
  69659. }, scene?: Nullable<Scene>): LinesMesh;
  69660. /**
  69661. * Creates a dashed line mesh
  69662. * * 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
  69663. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69664. * * The parameter `points` is an array successive Vector3
  69665. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69666. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69667. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69668. * * 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
  69669. * * When updating an instance, remember that only point positions can change, not the number of points
  69670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69671. * @param name defines the name of the mesh
  69672. * @param options defines the options used to create the mesh
  69673. * @param scene defines the hosting scene
  69674. * @returns the dashed line mesh
  69675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69676. */
  69677. static CreateDashedLines(name: string, options: {
  69678. points: Vector3[];
  69679. dashSize?: number;
  69680. gapSize?: number;
  69681. dashNb?: number;
  69682. updatable?: boolean;
  69683. instance?: LinesMesh;
  69684. }, scene?: Nullable<Scene>): LinesMesh;
  69685. /**
  69686. * 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.
  69687. * * 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.
  69688. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69689. * * 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.
  69690. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69691. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  69692. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  69693. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69695. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69696. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69698. * @param name defines the name of the mesh
  69699. * @param options defines the options used to create the mesh
  69700. * @param scene defines the hosting scene
  69701. * @returns the extruded shape mesh
  69702. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69704. */
  69705. static ExtrudeShape(name: string, options: {
  69706. shape: Vector3[];
  69707. path: Vector3[];
  69708. scale?: number;
  69709. rotation?: number;
  69710. cap?: number;
  69711. updatable?: boolean;
  69712. sideOrientation?: number;
  69713. frontUVs?: Vector4;
  69714. backUVs?: Vector4;
  69715. instance?: Mesh;
  69716. invertUV?: boolean;
  69717. }, scene?: Nullable<Scene>): Mesh;
  69718. /**
  69719. * Creates an custom extruded shape mesh.
  69720. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69721. * * 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.
  69722. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69723. * * 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
  69724. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69725. * * 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
  69726. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69727. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69728. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69729. * * 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
  69730. * * 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
  69731. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69736. * @param name defines the name of the mesh
  69737. * @param options defines the options used to create the mesh
  69738. * @param scene defines the hosting scene
  69739. * @returns the custom extruded shape mesh
  69740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69741. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69742. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69743. */
  69744. static ExtrudeShapeCustom(name: string, options: {
  69745. shape: Vector3[];
  69746. path: Vector3[];
  69747. scaleFunction?: any;
  69748. rotationFunction?: any;
  69749. ribbonCloseArray?: boolean;
  69750. ribbonClosePath?: boolean;
  69751. cap?: number;
  69752. updatable?: boolean;
  69753. sideOrientation?: number;
  69754. frontUVs?: Vector4;
  69755. backUVs?: Vector4;
  69756. instance?: Mesh;
  69757. invertUV?: boolean;
  69758. }, scene?: Nullable<Scene>): Mesh;
  69759. /**
  69760. * Creates lathe mesh.
  69761. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69762. * * 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
  69763. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69764. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69765. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69766. * * 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
  69767. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69768. * * 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
  69769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69771. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69773. * @param name defines the name of the mesh
  69774. * @param options defines the options used to create the mesh
  69775. * @param scene defines the hosting scene
  69776. * @returns the lathe mesh
  69777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69778. */
  69779. static CreateLathe(name: string, options: {
  69780. shape: Vector3[];
  69781. radius?: number;
  69782. tessellation?: number;
  69783. clip?: number;
  69784. arc?: number;
  69785. closed?: boolean;
  69786. updatable?: boolean;
  69787. sideOrientation?: number;
  69788. frontUVs?: Vector4;
  69789. backUVs?: Vector4;
  69790. cap?: number;
  69791. invertUV?: boolean;
  69792. }, scene?: Nullable<Scene>): Mesh;
  69793. /**
  69794. * Creates a tiled plane mesh
  69795. * * You can set a limited pattern arrangement with the tiles
  69796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69799. * @param name defines the name of the mesh
  69800. * @param options defines the options used to create the mesh
  69801. * @param scene defines the hosting scene
  69802. * @returns the plane mesh
  69803. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69804. */
  69805. static CreateTiledPlane(name: string, options: {
  69806. pattern?: number;
  69807. tileSize?: number;
  69808. tileWidth?: number;
  69809. tileHeight?: number;
  69810. size?: number;
  69811. width?: number;
  69812. height?: number;
  69813. alignHorizontal?: number;
  69814. alignVertical?: number;
  69815. sideOrientation?: number;
  69816. frontUVs?: Vector4;
  69817. backUVs?: Vector4;
  69818. updatable?: boolean;
  69819. }, scene?: Nullable<Scene>): Mesh;
  69820. /**
  69821. * Creates a plane mesh
  69822. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69823. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69824. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69828. * @param name defines the name of the mesh
  69829. * @param options defines the options used to create the mesh
  69830. * @param scene defines the hosting scene
  69831. * @returns the plane mesh
  69832. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69833. */
  69834. static CreatePlane(name: string, options: {
  69835. size?: number;
  69836. width?: number;
  69837. height?: number;
  69838. sideOrientation?: number;
  69839. frontUVs?: Vector4;
  69840. backUVs?: Vector4;
  69841. updatable?: boolean;
  69842. sourcePlane?: Plane;
  69843. }, scene?: Nullable<Scene>): Mesh;
  69844. /**
  69845. * Creates a ground mesh
  69846. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69847. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69849. * @param name defines the name of the mesh
  69850. * @param options defines the options used to create the mesh
  69851. * @param scene defines the hosting scene
  69852. * @returns the ground mesh
  69853. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69854. */
  69855. static CreateGround(name: string, options: {
  69856. width?: number;
  69857. height?: number;
  69858. subdivisions?: number;
  69859. subdivisionsX?: number;
  69860. subdivisionsY?: number;
  69861. updatable?: boolean;
  69862. }, scene?: Nullable<Scene>): Mesh;
  69863. /**
  69864. * Creates a tiled ground mesh
  69865. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69866. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69867. * * 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
  69868. * * 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
  69869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69870. * @param name defines the name of the mesh
  69871. * @param options defines the options used to create the mesh
  69872. * @param scene defines the hosting scene
  69873. * @returns the tiled ground mesh
  69874. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69875. */
  69876. static CreateTiledGround(name: string, options: {
  69877. xmin: number;
  69878. zmin: number;
  69879. xmax: number;
  69880. zmax: number;
  69881. subdivisions?: {
  69882. w: number;
  69883. h: number;
  69884. };
  69885. precision?: {
  69886. w: number;
  69887. h: number;
  69888. };
  69889. updatable?: boolean;
  69890. }, scene?: Nullable<Scene>): Mesh;
  69891. /**
  69892. * Creates a ground mesh from a height map
  69893. * * The parameter `url` sets the URL of the height map image resource.
  69894. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69895. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69896. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69897. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69898. * * 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.
  69899. * * 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).
  69900. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69902. * @param name defines the name of the mesh
  69903. * @param url defines the url to the height map
  69904. * @param options defines the options used to create the mesh
  69905. * @param scene defines the hosting scene
  69906. * @returns the ground mesh
  69907. * @see https://doc.babylonjs.com/babylon101/height_map
  69908. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69909. */
  69910. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69911. width?: number;
  69912. height?: number;
  69913. subdivisions?: number;
  69914. minHeight?: number;
  69915. maxHeight?: number;
  69916. colorFilter?: Color3;
  69917. alphaFilter?: number;
  69918. updatable?: boolean;
  69919. onReady?: (mesh: GroundMesh) => void;
  69920. }, scene?: Nullable<Scene>): GroundMesh;
  69921. /**
  69922. * Creates a polygon mesh
  69923. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69924. * * 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
  69925. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69928. * * Remember you can only change the shape positions, not their number when updating a polygon
  69929. * @param name defines the name of the mesh
  69930. * @param options defines the options used to create the mesh
  69931. * @param scene defines the hosting scene
  69932. * @param earcutInjection can be used to inject your own earcut reference
  69933. * @returns the polygon mesh
  69934. */
  69935. static CreatePolygon(name: string, options: {
  69936. shape: Vector3[];
  69937. holes?: Vector3[][];
  69938. depth?: number;
  69939. faceUV?: Vector4[];
  69940. faceColors?: Color4[];
  69941. updatable?: boolean;
  69942. sideOrientation?: number;
  69943. frontUVs?: Vector4;
  69944. backUVs?: Vector4;
  69945. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69946. /**
  69947. * Creates an extruded polygon mesh, with depth in the Y direction.
  69948. * * 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)
  69949. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69950. * @param name defines the name of the mesh
  69951. * @param options defines the options used to create the mesh
  69952. * @param scene defines the hosting scene
  69953. * @param earcutInjection can be used to inject your own earcut reference
  69954. * @returns the polygon mesh
  69955. */
  69956. static ExtrudePolygon(name: string, options: {
  69957. shape: Vector3[];
  69958. holes?: Vector3[][];
  69959. depth?: number;
  69960. faceUV?: Vector4[];
  69961. faceColors?: Color4[];
  69962. updatable?: boolean;
  69963. sideOrientation?: number;
  69964. frontUVs?: Vector4;
  69965. backUVs?: Vector4;
  69966. wrap?: boolean;
  69967. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69968. /**
  69969. * Creates a tube mesh.
  69970. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69971. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69972. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69973. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69974. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69975. * * 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)
  69976. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69977. * * 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
  69978. * * 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
  69979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69980. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69981. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69983. * @param name defines the name of the mesh
  69984. * @param options defines the options used to create the mesh
  69985. * @param scene defines the hosting scene
  69986. * @returns the tube mesh
  69987. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69988. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69989. */
  69990. static CreateTube(name: string, options: {
  69991. path: Vector3[];
  69992. radius?: number;
  69993. tessellation?: number;
  69994. radiusFunction?: {
  69995. (i: number, distance: number): number;
  69996. };
  69997. cap?: number;
  69998. arc?: number;
  69999. updatable?: boolean;
  70000. sideOrientation?: number;
  70001. frontUVs?: Vector4;
  70002. backUVs?: Vector4;
  70003. instance?: Mesh;
  70004. invertUV?: boolean;
  70005. }, scene?: Nullable<Scene>): Mesh;
  70006. /**
  70007. * Creates a polyhedron mesh
  70008. * * 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
  70009. * * The parameter `size` (positive float, default 1) sets the polygon size
  70010. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70011. * * 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`
  70012. * * 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
  70013. * * 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)`)
  70014. * * 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
  70015. * * 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
  70016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70017. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70019. * @param name defines the name of the mesh
  70020. * @param options defines the options used to create the mesh
  70021. * @param scene defines the hosting scene
  70022. * @returns the polyhedron mesh
  70023. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70024. */
  70025. static CreatePolyhedron(name: string, options: {
  70026. type?: number;
  70027. size?: number;
  70028. sizeX?: number;
  70029. sizeY?: number;
  70030. sizeZ?: number;
  70031. custom?: any;
  70032. faceUV?: Vector4[];
  70033. faceColors?: Color4[];
  70034. flat?: boolean;
  70035. updatable?: boolean;
  70036. sideOrientation?: number;
  70037. frontUVs?: Vector4;
  70038. backUVs?: Vector4;
  70039. }, scene?: Nullable<Scene>): Mesh;
  70040. /**
  70041. * Creates a decal mesh.
  70042. * 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
  70043. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70044. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70045. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70046. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70047. * @param name defines the name of the mesh
  70048. * @param sourceMesh defines the mesh where the decal must be applied
  70049. * @param options defines the options used to create the mesh
  70050. * @param scene defines the hosting scene
  70051. * @returns the decal mesh
  70052. * @see https://doc.babylonjs.com/how_to/decals
  70053. */
  70054. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70055. position?: Vector3;
  70056. normal?: Vector3;
  70057. size?: Vector3;
  70058. angle?: number;
  70059. }): Mesh;
  70060. /**
  70061. * Creates a Capsule Mesh
  70062. * @param name defines the name of the mesh.
  70063. * @param options the constructors options used to shape the mesh.
  70064. * @param scene defines the scene the mesh is scoped to.
  70065. * @returns the capsule mesh
  70066. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70067. */
  70068. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70069. }
  70070. }
  70071. declare module "babylonjs/Meshes/meshSimplification" {
  70072. import { Mesh } from "babylonjs/Meshes/mesh";
  70073. /**
  70074. * A simplifier interface for future simplification implementations
  70075. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70076. */
  70077. export interface ISimplifier {
  70078. /**
  70079. * Simplification of a given mesh according to the given settings.
  70080. * Since this requires computation, it is assumed that the function runs async.
  70081. * @param settings The settings of the simplification, including quality and distance
  70082. * @param successCallback A callback that will be called after the mesh was simplified.
  70083. * @param errorCallback in case of an error, this callback will be called. optional.
  70084. */
  70085. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70086. }
  70087. /**
  70088. * Expected simplification settings.
  70089. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70090. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70091. */
  70092. export interface ISimplificationSettings {
  70093. /**
  70094. * Gets or sets the expected quality
  70095. */
  70096. quality: number;
  70097. /**
  70098. * Gets or sets the distance when this optimized version should be used
  70099. */
  70100. distance: number;
  70101. /**
  70102. * Gets an already optimized mesh
  70103. */
  70104. optimizeMesh?: boolean;
  70105. }
  70106. /**
  70107. * Class used to specify simplification options
  70108. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70109. */
  70110. export class SimplificationSettings implements ISimplificationSettings {
  70111. /** expected quality */
  70112. quality: number;
  70113. /** distance when this optimized version should be used */
  70114. distance: number;
  70115. /** already optimized mesh */
  70116. optimizeMesh?: boolean | undefined;
  70117. /**
  70118. * Creates a SimplificationSettings
  70119. * @param quality expected quality
  70120. * @param distance distance when this optimized version should be used
  70121. * @param optimizeMesh already optimized mesh
  70122. */
  70123. constructor(
  70124. /** expected quality */
  70125. quality: number,
  70126. /** distance when this optimized version should be used */
  70127. distance: number,
  70128. /** already optimized mesh */
  70129. optimizeMesh?: boolean | undefined);
  70130. }
  70131. /**
  70132. * Interface used to define a simplification task
  70133. */
  70134. export interface ISimplificationTask {
  70135. /**
  70136. * Array of settings
  70137. */
  70138. settings: Array<ISimplificationSettings>;
  70139. /**
  70140. * Simplification type
  70141. */
  70142. simplificationType: SimplificationType;
  70143. /**
  70144. * Mesh to simplify
  70145. */
  70146. mesh: Mesh;
  70147. /**
  70148. * Callback called on success
  70149. */
  70150. successCallback?: () => void;
  70151. /**
  70152. * Defines if parallel processing can be used
  70153. */
  70154. parallelProcessing: boolean;
  70155. }
  70156. /**
  70157. * Queue used to order the simplification tasks
  70158. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70159. */
  70160. export class SimplificationQueue {
  70161. private _simplificationArray;
  70162. /**
  70163. * Gets a boolean indicating that the process is still running
  70164. */
  70165. running: boolean;
  70166. /**
  70167. * Creates a new queue
  70168. */
  70169. constructor();
  70170. /**
  70171. * Adds a new simplification task
  70172. * @param task defines a task to add
  70173. */
  70174. addTask(task: ISimplificationTask): void;
  70175. /**
  70176. * Execute next task
  70177. */
  70178. executeNext(): void;
  70179. /**
  70180. * Execute a simplification task
  70181. * @param task defines the task to run
  70182. */
  70183. runSimplification(task: ISimplificationTask): void;
  70184. private getSimplifier;
  70185. }
  70186. /**
  70187. * The implemented types of simplification
  70188. * At the moment only Quadratic Error Decimation is implemented
  70189. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70190. */
  70191. export enum SimplificationType {
  70192. /** Quadratic error decimation */
  70193. QUADRATIC = 0
  70194. }
  70195. /**
  70196. * An implementation of the Quadratic Error simplification algorithm.
  70197. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70198. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70199. * @author RaananW
  70200. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70201. */
  70202. export class QuadraticErrorSimplification implements ISimplifier {
  70203. private _mesh;
  70204. private triangles;
  70205. private vertices;
  70206. private references;
  70207. private _reconstructedMesh;
  70208. /** Gets or sets the number pf sync interations */
  70209. syncIterations: number;
  70210. /** Gets or sets the aggressiveness of the simplifier */
  70211. aggressiveness: number;
  70212. /** Gets or sets the number of allowed iterations for decimation */
  70213. decimationIterations: number;
  70214. /** Gets or sets the espilon to use for bounding box computation */
  70215. boundingBoxEpsilon: number;
  70216. /**
  70217. * Creates a new QuadraticErrorSimplification
  70218. * @param _mesh defines the target mesh
  70219. */
  70220. constructor(_mesh: Mesh);
  70221. /**
  70222. * Simplification of a given mesh according to the given settings.
  70223. * Since this requires computation, it is assumed that the function runs async.
  70224. * @param settings The settings of the simplification, including quality and distance
  70225. * @param successCallback A callback that will be called after the mesh was simplified.
  70226. */
  70227. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70228. private runDecimation;
  70229. private initWithMesh;
  70230. private init;
  70231. private reconstructMesh;
  70232. private initDecimatedMesh;
  70233. private isFlipped;
  70234. private updateTriangles;
  70235. private identifyBorder;
  70236. private updateMesh;
  70237. private vertexError;
  70238. private calculateError;
  70239. }
  70240. }
  70241. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70242. import { Scene } from "babylonjs/scene";
  70243. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70244. import { ISceneComponent } from "babylonjs/sceneComponent";
  70245. module "babylonjs/scene" {
  70246. interface Scene {
  70247. /** @hidden (Backing field) */
  70248. _simplificationQueue: SimplificationQueue;
  70249. /**
  70250. * Gets or sets the simplification queue attached to the scene
  70251. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70252. */
  70253. simplificationQueue: SimplificationQueue;
  70254. }
  70255. }
  70256. module "babylonjs/Meshes/mesh" {
  70257. interface Mesh {
  70258. /**
  70259. * Simplify the mesh according to the given array of settings.
  70260. * Function will return immediately and will simplify async
  70261. * @param settings a collection of simplification settings
  70262. * @param parallelProcessing should all levels calculate parallel or one after the other
  70263. * @param simplificationType the type of simplification to run
  70264. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70265. * @returns the current mesh
  70266. */
  70267. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70268. }
  70269. }
  70270. /**
  70271. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70272. * created in a scene
  70273. */
  70274. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70275. /**
  70276. * The component name helpfull to identify the component in the list of scene components.
  70277. */
  70278. readonly name: string;
  70279. /**
  70280. * The scene the component belongs to.
  70281. */
  70282. scene: Scene;
  70283. /**
  70284. * Creates a new instance of the component for the given scene
  70285. * @param scene Defines the scene to register the component in
  70286. */
  70287. constructor(scene: Scene);
  70288. /**
  70289. * Registers the component in a given scene
  70290. */
  70291. register(): void;
  70292. /**
  70293. * Rebuilds the elements related to this component in case of
  70294. * context lost for instance.
  70295. */
  70296. rebuild(): void;
  70297. /**
  70298. * Disposes the component and the associated ressources
  70299. */
  70300. dispose(): void;
  70301. private _beforeCameraUpdate;
  70302. }
  70303. }
  70304. declare module "babylonjs/Meshes/Builders/index" {
  70305. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70306. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70307. export * from "babylonjs/Meshes/Builders/discBuilder";
  70308. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70309. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70310. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70311. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70312. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70313. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70314. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70315. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70316. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70317. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70318. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70319. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70320. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70321. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70322. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70323. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70324. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70325. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70326. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70327. }
  70328. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70329. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70330. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70331. import { Matrix } from "babylonjs/Maths/math.vector";
  70332. module "babylonjs/Meshes/mesh" {
  70333. interface Mesh {
  70334. /**
  70335. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70336. */
  70337. thinInstanceEnablePicking: boolean;
  70338. /**
  70339. * Creates a new thin instance
  70340. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70341. * @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
  70342. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70343. */
  70344. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70345. /**
  70346. * Adds the transformation (matrix) of the current mesh as a thin instance
  70347. * @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
  70348. * @returns the thin instance index number
  70349. */
  70350. thinInstanceAddSelf(refresh: boolean): number;
  70351. /**
  70352. * Registers a custom attribute to be used with thin instances
  70353. * @param kind name of the attribute
  70354. * @param stride size in floats of the attribute
  70355. */
  70356. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70357. /**
  70358. * Sets the matrix of a thin instance
  70359. * @param index index of the thin instance
  70360. * @param matrix matrix to set
  70361. * @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
  70362. */
  70363. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70364. /**
  70365. * Sets the value of a custom attribute for a thin instance
  70366. * @param kind name of the attribute
  70367. * @param index index of the thin instance
  70368. * @param value value to set
  70369. * @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
  70370. */
  70371. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70372. /**
  70373. * 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.
  70374. */
  70375. thinInstanceCount: number;
  70376. /**
  70377. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70378. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70379. * @param buffer buffer to set
  70380. * @param stride size in floats of each value of the buffer
  70381. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70382. */
  70383. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70384. /**
  70385. * Gets the list of world matrices
  70386. * @return an array containing all the world matrices from the thin instances
  70387. */
  70388. thinInstanceGetWorldMatrices(): Matrix[];
  70389. /**
  70390. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70391. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70392. */
  70393. thinInstanceBufferUpdated(kind: string): void;
  70394. /**
  70395. * Applies a partial update to a buffer directly on the GPU
  70396. * 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
  70397. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70398. * @param data the data to set in the GPU buffer
  70399. * @param offset the offset in the GPU buffer where to update the data
  70400. */
  70401. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70402. /**
  70403. * Refreshes the bounding info, taking into account all the thin instances defined
  70404. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70405. */
  70406. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70407. /** @hidden */
  70408. _thinInstanceInitializeUserStorage(): void;
  70409. /** @hidden */
  70410. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70411. /** @hidden */
  70412. _userThinInstanceBuffersStorage: {
  70413. data: {
  70414. [key: string]: Float32Array;
  70415. };
  70416. sizes: {
  70417. [key: string]: number;
  70418. };
  70419. vertexBuffers: {
  70420. [key: string]: Nullable<VertexBuffer>;
  70421. };
  70422. strides: {
  70423. [key: string]: number;
  70424. };
  70425. };
  70426. }
  70427. }
  70428. }
  70429. declare module "babylonjs/Meshes/index" {
  70430. export * from "babylonjs/Meshes/abstractMesh";
  70431. export * from "babylonjs/Meshes/buffer";
  70432. export * from "babylonjs/Meshes/Compression/index";
  70433. export * from "babylonjs/Meshes/csg";
  70434. export * from "babylonjs/Meshes/geometry";
  70435. export * from "babylonjs/Meshes/groundMesh";
  70436. export * from "babylonjs/Meshes/trailMesh";
  70437. export * from "babylonjs/Meshes/instancedMesh";
  70438. export * from "babylonjs/Meshes/linesMesh";
  70439. export * from "babylonjs/Meshes/mesh";
  70440. export * from "babylonjs/Meshes/mesh.vertexData";
  70441. export * from "babylonjs/Meshes/meshBuilder";
  70442. export * from "babylonjs/Meshes/meshSimplification";
  70443. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70444. export * from "babylonjs/Meshes/polygonMesh";
  70445. export * from "babylonjs/Meshes/subMesh";
  70446. export * from "babylonjs/Meshes/meshLODLevel";
  70447. export * from "babylonjs/Meshes/transformNode";
  70448. export * from "babylonjs/Meshes/Builders/index";
  70449. export * from "babylonjs/Meshes/dataBuffer";
  70450. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70451. import "babylonjs/Meshes/thinInstanceMesh";
  70452. export * from "babylonjs/Meshes/thinInstanceMesh";
  70453. }
  70454. declare module "babylonjs/Morph/index" {
  70455. export * from "babylonjs/Morph/morphTarget";
  70456. export * from "babylonjs/Morph/morphTargetManager";
  70457. }
  70458. declare module "babylonjs/Navigation/INavigationEngine" {
  70459. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70460. import { Vector3 } from "babylonjs/Maths/math";
  70461. import { Mesh } from "babylonjs/Meshes/mesh";
  70462. import { Scene } from "babylonjs/scene";
  70463. /**
  70464. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70465. */
  70466. export interface INavigationEnginePlugin {
  70467. /**
  70468. * plugin name
  70469. */
  70470. name: string;
  70471. /**
  70472. * Creates a navigation mesh
  70473. * @param meshes array of all the geometry used to compute the navigatio mesh
  70474. * @param parameters bunch of parameters used to filter geometry
  70475. */
  70476. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70477. /**
  70478. * Create a navigation mesh debug mesh
  70479. * @param scene is where the mesh will be added
  70480. * @returns debug display mesh
  70481. */
  70482. createDebugNavMesh(scene: Scene): Mesh;
  70483. /**
  70484. * Get a navigation mesh constrained position, closest to the parameter position
  70485. * @param position world position
  70486. * @returns the closest point to position constrained by the navigation mesh
  70487. */
  70488. getClosestPoint(position: Vector3): Vector3;
  70489. /**
  70490. * Get a navigation mesh constrained position, closest to the parameter position
  70491. * @param position world position
  70492. * @param result output the closest point to position constrained by the navigation mesh
  70493. */
  70494. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70495. /**
  70496. * Get a navigation mesh constrained position, within a particular radius
  70497. * @param position world position
  70498. * @param maxRadius the maximum distance to the constrained world position
  70499. * @returns the closest point to position constrained by the navigation mesh
  70500. */
  70501. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70502. /**
  70503. * Get a navigation mesh constrained position, within a particular radius
  70504. * @param position world position
  70505. * @param maxRadius the maximum distance to the constrained world position
  70506. * @param result output the closest point to position constrained by the navigation mesh
  70507. */
  70508. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70509. /**
  70510. * Compute the final position from a segment made of destination-position
  70511. * @param position world position
  70512. * @param destination world position
  70513. * @returns the resulting point along the navmesh
  70514. */
  70515. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70516. /**
  70517. * Compute the final position from a segment made of destination-position
  70518. * @param position world position
  70519. * @param destination world position
  70520. * @param result output the resulting point along the navmesh
  70521. */
  70522. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70523. /**
  70524. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70525. * @param start world position
  70526. * @param end world position
  70527. * @returns array containing world position composing the path
  70528. */
  70529. computePath(start: Vector3, end: Vector3): Vector3[];
  70530. /**
  70531. * If this plugin is supported
  70532. * @returns true if plugin is supported
  70533. */
  70534. isSupported(): boolean;
  70535. /**
  70536. * Create a new Crowd so you can add agents
  70537. * @param maxAgents the maximum agent count in the crowd
  70538. * @param maxAgentRadius the maximum radius an agent can have
  70539. * @param scene to attach the crowd to
  70540. * @returns the crowd you can add agents to
  70541. */
  70542. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70543. /**
  70544. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70545. * The queries will try to find a solution within those bounds
  70546. * default is (1,1,1)
  70547. * @param extent x,y,z value that define the extent around the queries point of reference
  70548. */
  70549. setDefaultQueryExtent(extent: Vector3): void;
  70550. /**
  70551. * Get the Bounding box extent specified by setDefaultQueryExtent
  70552. * @returns the box extent values
  70553. */
  70554. getDefaultQueryExtent(): Vector3;
  70555. /**
  70556. * build the navmesh from a previously saved state using getNavmeshData
  70557. * @param data the Uint8Array returned by getNavmeshData
  70558. */
  70559. buildFromNavmeshData(data: Uint8Array): void;
  70560. /**
  70561. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70562. * @returns data the Uint8Array that can be saved and reused
  70563. */
  70564. getNavmeshData(): Uint8Array;
  70565. /**
  70566. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70567. * @param result output the box extent values
  70568. */
  70569. getDefaultQueryExtentToRef(result: Vector3): void;
  70570. /**
  70571. * Release all resources
  70572. */
  70573. dispose(): void;
  70574. }
  70575. /**
  70576. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70577. */
  70578. export interface ICrowd {
  70579. /**
  70580. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70581. * You can attach anything to that node. The node position is updated in the scene update tick.
  70582. * @param pos world position that will be constrained by the navigation mesh
  70583. * @param parameters agent parameters
  70584. * @param transform hooked to the agent that will be update by the scene
  70585. * @returns agent index
  70586. */
  70587. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70588. /**
  70589. * Returns the agent position in world space
  70590. * @param index agent index returned by addAgent
  70591. * @returns world space position
  70592. */
  70593. getAgentPosition(index: number): Vector3;
  70594. /**
  70595. * Gets the agent position result in world space
  70596. * @param index agent index returned by addAgent
  70597. * @param result output world space position
  70598. */
  70599. getAgentPositionToRef(index: number, result: Vector3): void;
  70600. /**
  70601. * Gets the agent velocity in world space
  70602. * @param index agent index returned by addAgent
  70603. * @returns world space velocity
  70604. */
  70605. getAgentVelocity(index: number): Vector3;
  70606. /**
  70607. * Gets the agent velocity result in world space
  70608. * @param index agent index returned by addAgent
  70609. * @param result output world space velocity
  70610. */
  70611. getAgentVelocityToRef(index: number, result: Vector3): void;
  70612. /**
  70613. * remove a particular agent previously created
  70614. * @param index agent index returned by addAgent
  70615. */
  70616. removeAgent(index: number): void;
  70617. /**
  70618. * get the list of all agents attached to this crowd
  70619. * @returns list of agent indices
  70620. */
  70621. getAgents(): number[];
  70622. /**
  70623. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70624. * @param deltaTime in seconds
  70625. */
  70626. update(deltaTime: number): void;
  70627. /**
  70628. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70629. * @param index agent index returned by addAgent
  70630. * @param destination targeted world position
  70631. */
  70632. agentGoto(index: number, destination: Vector3): void;
  70633. /**
  70634. * Teleport the agent to a new position
  70635. * @param index agent index returned by addAgent
  70636. * @param destination targeted world position
  70637. */
  70638. agentTeleport(index: number, destination: Vector3): void;
  70639. /**
  70640. * Update agent parameters
  70641. * @param index agent index returned by addAgent
  70642. * @param parameters agent parameters
  70643. */
  70644. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70645. /**
  70646. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70647. * The queries will try to find a solution within those bounds
  70648. * default is (1,1,1)
  70649. * @param extent x,y,z value that define the extent around the queries point of reference
  70650. */
  70651. setDefaultQueryExtent(extent: Vector3): void;
  70652. /**
  70653. * Get the Bounding box extent specified by setDefaultQueryExtent
  70654. * @returns the box extent values
  70655. */
  70656. getDefaultQueryExtent(): Vector3;
  70657. /**
  70658. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70659. * @param result output the box extent values
  70660. */
  70661. getDefaultQueryExtentToRef(result: Vector3): void;
  70662. /**
  70663. * Release all resources
  70664. */
  70665. dispose(): void;
  70666. }
  70667. /**
  70668. * Configures an agent
  70669. */
  70670. export interface IAgentParameters {
  70671. /**
  70672. * Agent radius. [Limit: >= 0]
  70673. */
  70674. radius: number;
  70675. /**
  70676. * Agent height. [Limit: > 0]
  70677. */
  70678. height: number;
  70679. /**
  70680. * Maximum allowed acceleration. [Limit: >= 0]
  70681. */
  70682. maxAcceleration: number;
  70683. /**
  70684. * Maximum allowed speed. [Limit: >= 0]
  70685. */
  70686. maxSpeed: number;
  70687. /**
  70688. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70689. */
  70690. collisionQueryRange: number;
  70691. /**
  70692. * The path visibility optimization range. [Limit: > 0]
  70693. */
  70694. pathOptimizationRange: number;
  70695. /**
  70696. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70697. */
  70698. separationWeight: number;
  70699. }
  70700. /**
  70701. * Configures the navigation mesh creation
  70702. */
  70703. export interface INavMeshParameters {
  70704. /**
  70705. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70706. */
  70707. cs: number;
  70708. /**
  70709. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70710. */
  70711. ch: number;
  70712. /**
  70713. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70714. */
  70715. walkableSlopeAngle: number;
  70716. /**
  70717. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70718. * be considered walkable. [Limit: >= 3] [Units: vx]
  70719. */
  70720. walkableHeight: number;
  70721. /**
  70722. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70723. */
  70724. walkableClimb: number;
  70725. /**
  70726. * The distance to erode/shrink the walkable area of the heightfield away from
  70727. * obstructions. [Limit: >=0] [Units: vx]
  70728. */
  70729. walkableRadius: number;
  70730. /**
  70731. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70732. */
  70733. maxEdgeLen: number;
  70734. /**
  70735. * The maximum distance a simplfied contour's border edges should deviate
  70736. * the original raw contour. [Limit: >=0] [Units: vx]
  70737. */
  70738. maxSimplificationError: number;
  70739. /**
  70740. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70741. */
  70742. minRegionArea: number;
  70743. /**
  70744. * Any regions with a span count smaller than this value will, if possible,
  70745. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70746. */
  70747. mergeRegionArea: number;
  70748. /**
  70749. * The maximum number of vertices allowed for polygons generated during the
  70750. * contour to polygon conversion process. [Limit: >= 3]
  70751. */
  70752. maxVertsPerPoly: number;
  70753. /**
  70754. * Sets the sampling distance to use when generating the detail mesh.
  70755. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70756. */
  70757. detailSampleDist: number;
  70758. /**
  70759. * The maximum distance the detail mesh surface should deviate from heightfield
  70760. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70761. */
  70762. detailSampleMaxError: number;
  70763. }
  70764. }
  70765. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70766. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70767. import { Mesh } from "babylonjs/Meshes/mesh";
  70768. import { Scene } from "babylonjs/scene";
  70769. import { Vector3 } from "babylonjs/Maths/math";
  70770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70771. /**
  70772. * RecastJS navigation plugin
  70773. */
  70774. export class RecastJSPlugin implements INavigationEnginePlugin {
  70775. /**
  70776. * Reference to the Recast library
  70777. */
  70778. bjsRECAST: any;
  70779. /**
  70780. * plugin name
  70781. */
  70782. name: string;
  70783. /**
  70784. * the first navmesh created. We might extend this to support multiple navmeshes
  70785. */
  70786. navMesh: any;
  70787. /**
  70788. * Initializes the recastJS plugin
  70789. * @param recastInjection can be used to inject your own recast reference
  70790. */
  70791. constructor(recastInjection?: any);
  70792. /**
  70793. * Creates a navigation mesh
  70794. * @param meshes array of all the geometry used to compute the navigatio mesh
  70795. * @param parameters bunch of parameters used to filter geometry
  70796. */
  70797. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70798. /**
  70799. * Create a navigation mesh debug mesh
  70800. * @param scene is where the mesh will be added
  70801. * @returns debug display mesh
  70802. */
  70803. createDebugNavMesh(scene: Scene): Mesh;
  70804. /**
  70805. * Get a navigation mesh constrained position, closest to the parameter position
  70806. * @param position world position
  70807. * @returns the closest point to position constrained by the navigation mesh
  70808. */
  70809. getClosestPoint(position: Vector3): Vector3;
  70810. /**
  70811. * Get a navigation mesh constrained position, closest to the parameter position
  70812. * @param position world position
  70813. * @param result output the closest point to position constrained by the navigation mesh
  70814. */
  70815. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70816. /**
  70817. * Get a navigation mesh constrained position, within a particular radius
  70818. * @param position world position
  70819. * @param maxRadius the maximum distance to the constrained world position
  70820. * @returns the closest point to position constrained by the navigation mesh
  70821. */
  70822. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70823. /**
  70824. * Get a navigation mesh constrained position, within a particular radius
  70825. * @param position world position
  70826. * @param maxRadius the maximum distance to the constrained world position
  70827. * @param result output the closest point to position constrained by the navigation mesh
  70828. */
  70829. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70830. /**
  70831. * Compute the final position from a segment made of destination-position
  70832. * @param position world position
  70833. * @param destination world position
  70834. * @returns the resulting point along the navmesh
  70835. */
  70836. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70837. /**
  70838. * Compute the final position from a segment made of destination-position
  70839. * @param position world position
  70840. * @param destination world position
  70841. * @param result output the resulting point along the navmesh
  70842. */
  70843. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70844. /**
  70845. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70846. * @param start world position
  70847. * @param end world position
  70848. * @returns array containing world position composing the path
  70849. */
  70850. computePath(start: Vector3, end: Vector3): Vector3[];
  70851. /**
  70852. * Create a new Crowd so you can add agents
  70853. * @param maxAgents the maximum agent count in the crowd
  70854. * @param maxAgentRadius the maximum radius an agent can have
  70855. * @param scene to attach the crowd to
  70856. * @returns the crowd you can add agents to
  70857. */
  70858. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70859. /**
  70860. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70861. * The queries will try to find a solution within those bounds
  70862. * default is (1,1,1)
  70863. * @param extent x,y,z value that define the extent around the queries point of reference
  70864. */
  70865. setDefaultQueryExtent(extent: Vector3): void;
  70866. /**
  70867. * Get the Bounding box extent specified by setDefaultQueryExtent
  70868. * @returns the box extent values
  70869. */
  70870. getDefaultQueryExtent(): Vector3;
  70871. /**
  70872. * build the navmesh from a previously saved state using getNavmeshData
  70873. * @param data the Uint8Array returned by getNavmeshData
  70874. */
  70875. buildFromNavmeshData(data: Uint8Array): void;
  70876. /**
  70877. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70878. * @returns data the Uint8Array that can be saved and reused
  70879. */
  70880. getNavmeshData(): Uint8Array;
  70881. /**
  70882. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70883. * @param result output the box extent values
  70884. */
  70885. getDefaultQueryExtentToRef(result: Vector3): void;
  70886. /**
  70887. * Disposes
  70888. */
  70889. dispose(): void;
  70890. /**
  70891. * If this plugin is supported
  70892. * @returns true if plugin is supported
  70893. */
  70894. isSupported(): boolean;
  70895. }
  70896. /**
  70897. * Recast detour crowd implementation
  70898. */
  70899. export class RecastJSCrowd implements ICrowd {
  70900. /**
  70901. * Recast/detour plugin
  70902. */
  70903. bjsRECASTPlugin: RecastJSPlugin;
  70904. /**
  70905. * Link to the detour crowd
  70906. */
  70907. recastCrowd: any;
  70908. /**
  70909. * One transform per agent
  70910. */
  70911. transforms: TransformNode[];
  70912. /**
  70913. * All agents created
  70914. */
  70915. agents: number[];
  70916. /**
  70917. * Link to the scene is kept to unregister the crowd from the scene
  70918. */
  70919. private _scene;
  70920. /**
  70921. * Observer for crowd updates
  70922. */
  70923. private _onBeforeAnimationsObserver;
  70924. /**
  70925. * Constructor
  70926. * @param plugin recastJS plugin
  70927. * @param maxAgents the maximum agent count in the crowd
  70928. * @param maxAgentRadius the maximum radius an agent can have
  70929. * @param scene to attach the crowd to
  70930. * @returns the crowd you can add agents to
  70931. */
  70932. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70933. /**
  70934. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70935. * You can attach anything to that node. The node position is updated in the scene update tick.
  70936. * @param pos world position that will be constrained by the navigation mesh
  70937. * @param parameters agent parameters
  70938. * @param transform hooked to the agent that will be update by the scene
  70939. * @returns agent index
  70940. */
  70941. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70942. /**
  70943. * Returns the agent position in world space
  70944. * @param index agent index returned by addAgent
  70945. * @returns world space position
  70946. */
  70947. getAgentPosition(index: number): Vector3;
  70948. /**
  70949. * Returns the agent position result in world space
  70950. * @param index agent index returned by addAgent
  70951. * @param result output world space position
  70952. */
  70953. getAgentPositionToRef(index: number, result: Vector3): void;
  70954. /**
  70955. * Returns the agent velocity in world space
  70956. * @param index agent index returned by addAgent
  70957. * @returns world space velocity
  70958. */
  70959. getAgentVelocity(index: number): Vector3;
  70960. /**
  70961. * Returns the agent velocity result in world space
  70962. * @param index agent index returned by addAgent
  70963. * @param result output world space velocity
  70964. */
  70965. getAgentVelocityToRef(index: number, result: Vector3): void;
  70966. /**
  70967. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70968. * @param index agent index returned by addAgent
  70969. * @param destination targeted world position
  70970. */
  70971. agentGoto(index: number, destination: Vector3): void;
  70972. /**
  70973. * Teleport the agent to a new position
  70974. * @param index agent index returned by addAgent
  70975. * @param destination targeted world position
  70976. */
  70977. agentTeleport(index: number, destination: Vector3): void;
  70978. /**
  70979. * Update agent parameters
  70980. * @param index agent index returned by addAgent
  70981. * @param parameters agent parameters
  70982. */
  70983. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70984. /**
  70985. * remove a particular agent previously created
  70986. * @param index agent index returned by addAgent
  70987. */
  70988. removeAgent(index: number): void;
  70989. /**
  70990. * get the list of all agents attached to this crowd
  70991. * @returns list of agent indices
  70992. */
  70993. getAgents(): number[];
  70994. /**
  70995. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70996. * @param deltaTime in seconds
  70997. */
  70998. update(deltaTime: number): void;
  70999. /**
  71000. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71001. * The queries will try to find a solution within those bounds
  71002. * default is (1,1,1)
  71003. * @param extent x,y,z value that define the extent around the queries point of reference
  71004. */
  71005. setDefaultQueryExtent(extent: Vector3): void;
  71006. /**
  71007. * Get the Bounding box extent specified by setDefaultQueryExtent
  71008. * @returns the box extent values
  71009. */
  71010. getDefaultQueryExtent(): Vector3;
  71011. /**
  71012. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71013. * @param result output the box extent values
  71014. */
  71015. getDefaultQueryExtentToRef(result: Vector3): void;
  71016. /**
  71017. * Release all resources
  71018. */
  71019. dispose(): void;
  71020. }
  71021. }
  71022. declare module "babylonjs/Navigation/Plugins/index" {
  71023. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71024. }
  71025. declare module "babylonjs/Navigation/index" {
  71026. export * from "babylonjs/Navigation/INavigationEngine";
  71027. export * from "babylonjs/Navigation/Plugins/index";
  71028. }
  71029. declare module "babylonjs/Offline/database" {
  71030. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71031. /**
  71032. * Class used to enable access to IndexedDB
  71033. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71034. */
  71035. export class Database implements IOfflineProvider {
  71036. private _callbackManifestChecked;
  71037. private _currentSceneUrl;
  71038. private _db;
  71039. private _enableSceneOffline;
  71040. private _enableTexturesOffline;
  71041. private _manifestVersionFound;
  71042. private _mustUpdateRessources;
  71043. private _hasReachedQuota;
  71044. private _isSupported;
  71045. private _idbFactory;
  71046. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71047. private static IsUASupportingBlobStorage;
  71048. /**
  71049. * Gets a boolean indicating if Database storate is enabled (off by default)
  71050. */
  71051. static IDBStorageEnabled: boolean;
  71052. /**
  71053. * Gets a boolean indicating if scene must be saved in the database
  71054. */
  71055. get enableSceneOffline(): boolean;
  71056. /**
  71057. * Gets a boolean indicating if textures must be saved in the database
  71058. */
  71059. get enableTexturesOffline(): boolean;
  71060. /**
  71061. * Creates a new Database
  71062. * @param urlToScene defines the url to load the scene
  71063. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71064. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71065. */
  71066. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71067. private static _ParseURL;
  71068. private static _ReturnFullUrlLocation;
  71069. private _checkManifestFile;
  71070. /**
  71071. * Open the database and make it available
  71072. * @param successCallback defines the callback to call on success
  71073. * @param errorCallback defines the callback to call on error
  71074. */
  71075. open(successCallback: () => void, errorCallback: () => void): void;
  71076. /**
  71077. * Loads an image from the database
  71078. * @param url defines the url to load from
  71079. * @param image defines the target DOM image
  71080. */
  71081. loadImage(url: string, image: HTMLImageElement): void;
  71082. private _loadImageFromDBAsync;
  71083. private _saveImageIntoDBAsync;
  71084. private _checkVersionFromDB;
  71085. private _loadVersionFromDBAsync;
  71086. private _saveVersionIntoDBAsync;
  71087. /**
  71088. * Loads a file from database
  71089. * @param url defines the URL to load from
  71090. * @param sceneLoaded defines a callback to call on success
  71091. * @param progressCallBack defines a callback to call when progress changed
  71092. * @param errorCallback defines a callback to call on error
  71093. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71094. */
  71095. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71096. private _loadFileAsync;
  71097. private _saveFileAsync;
  71098. /**
  71099. * Validates if xhr data is correct
  71100. * @param xhr defines the request to validate
  71101. * @param dataType defines the expected data type
  71102. * @returns true if data is correct
  71103. */
  71104. private static _ValidateXHRData;
  71105. }
  71106. }
  71107. declare module "babylonjs/Offline/index" {
  71108. export * from "babylonjs/Offline/database";
  71109. export * from "babylonjs/Offline/IOfflineProvider";
  71110. }
  71111. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71112. /** @hidden */
  71113. export var gpuUpdateParticlesPixelShader: {
  71114. name: string;
  71115. shader: string;
  71116. };
  71117. }
  71118. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71119. /** @hidden */
  71120. export var gpuUpdateParticlesVertexShader: {
  71121. name: string;
  71122. shader: string;
  71123. };
  71124. }
  71125. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71126. /** @hidden */
  71127. export var clipPlaneFragmentDeclaration2: {
  71128. name: string;
  71129. shader: string;
  71130. };
  71131. }
  71132. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71133. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71134. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71135. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71136. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71137. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71138. /** @hidden */
  71139. export var gpuRenderParticlesPixelShader: {
  71140. name: string;
  71141. shader: string;
  71142. };
  71143. }
  71144. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71145. /** @hidden */
  71146. export var clipPlaneVertexDeclaration2: {
  71147. name: string;
  71148. shader: string;
  71149. };
  71150. }
  71151. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71152. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71153. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71154. /** @hidden */
  71155. export var gpuRenderParticlesVertexShader: {
  71156. name: string;
  71157. shader: string;
  71158. };
  71159. }
  71160. declare module "babylonjs/Particles/gpuParticleSystem" {
  71161. import { Nullable } from "babylonjs/types";
  71162. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71163. import { Observable } from "babylonjs/Misc/observable";
  71164. import { Matrix } from "babylonjs/Maths/math.vector";
  71165. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71166. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71167. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71168. import { IDisposable } from "babylonjs/scene";
  71169. import { Effect } from "babylonjs/Materials/effect";
  71170. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71171. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71172. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71173. import { Scene } from "babylonjs/scene";
  71174. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71175. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71176. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71177. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71178. /**
  71179. * This represents a GPU particle system in Babylon
  71180. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71181. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71182. */
  71183. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71184. /**
  71185. * The layer mask we are rendering the particles through.
  71186. */
  71187. layerMask: number;
  71188. private _capacity;
  71189. private _activeCount;
  71190. private _currentActiveCount;
  71191. private _accumulatedCount;
  71192. private _renderEffect;
  71193. private _updateEffect;
  71194. private _buffer0;
  71195. private _buffer1;
  71196. private _spriteBuffer;
  71197. private _updateVAO;
  71198. private _renderVAO;
  71199. private _targetIndex;
  71200. private _sourceBuffer;
  71201. private _targetBuffer;
  71202. private _currentRenderId;
  71203. private _started;
  71204. private _stopped;
  71205. private _timeDelta;
  71206. private _randomTexture;
  71207. private _randomTexture2;
  71208. private _attributesStrideSize;
  71209. private _updateEffectOptions;
  71210. private _randomTextureSize;
  71211. private _actualFrame;
  71212. private _customEffect;
  71213. private readonly _rawTextureWidth;
  71214. /**
  71215. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71216. */
  71217. static get IsSupported(): boolean;
  71218. /**
  71219. * An event triggered when the system is disposed.
  71220. */
  71221. onDisposeObservable: Observable<IParticleSystem>;
  71222. /**
  71223. * Gets the maximum number of particles active at the same time.
  71224. * @returns The max number of active particles.
  71225. */
  71226. getCapacity(): number;
  71227. /**
  71228. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71229. * to override the particles.
  71230. */
  71231. forceDepthWrite: boolean;
  71232. /**
  71233. * Gets or set the number of active particles
  71234. */
  71235. get activeParticleCount(): number;
  71236. set activeParticleCount(value: number);
  71237. private _preWarmDone;
  71238. /**
  71239. * Specifies if the particles are updated in emitter local space or world space.
  71240. */
  71241. isLocal: boolean;
  71242. /** Gets or sets a matrix to use to compute projection */
  71243. defaultProjectionMatrix: Matrix;
  71244. /**
  71245. * Is this system ready to be used/rendered
  71246. * @return true if the system is ready
  71247. */
  71248. isReady(): boolean;
  71249. /**
  71250. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71251. * @returns True if it has been started, otherwise false.
  71252. */
  71253. isStarted(): boolean;
  71254. /**
  71255. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71256. * @returns True if it has been stopped, otherwise false.
  71257. */
  71258. isStopped(): boolean;
  71259. /**
  71260. * Gets a boolean indicating that the system is stopping
  71261. * @returns true if the system is currently stopping
  71262. */
  71263. isStopping(): boolean;
  71264. /**
  71265. * Gets the number of particles active at the same time.
  71266. * @returns The number of active particles.
  71267. */
  71268. getActiveCount(): number;
  71269. /**
  71270. * Starts the particle system and begins to emit
  71271. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71272. */
  71273. start(delay?: number): void;
  71274. /**
  71275. * Stops the particle system.
  71276. */
  71277. stop(): void;
  71278. /**
  71279. * Remove all active particles
  71280. */
  71281. reset(): void;
  71282. /**
  71283. * Returns the string "GPUParticleSystem"
  71284. * @returns a string containing the class name
  71285. */
  71286. getClassName(): string;
  71287. /**
  71288. * Gets the custom effect used to render the particles
  71289. * @param blendMode Blend mode for which the effect should be retrieved
  71290. * @returns The effect
  71291. */
  71292. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71293. /**
  71294. * Sets the custom effect used to render the particles
  71295. * @param effect The effect to set
  71296. * @param blendMode Blend mode for which the effect should be set
  71297. */
  71298. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71299. /** @hidden */
  71300. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71301. /**
  71302. * Observable that will be called just before the particles are drawn
  71303. */
  71304. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71305. /**
  71306. * Gets the name of the particle vertex shader
  71307. */
  71308. get vertexShaderName(): string;
  71309. private _colorGradientsTexture;
  71310. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71311. /**
  71312. * Adds a new color gradient
  71313. * @param gradient defines the gradient to use (between 0 and 1)
  71314. * @param color1 defines the color to affect to the specified gradient
  71315. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71316. * @returns the current particle system
  71317. */
  71318. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71319. private _refreshColorGradient;
  71320. /** Force the system to rebuild all gradients that need to be resync */
  71321. forceRefreshGradients(): void;
  71322. /**
  71323. * Remove a specific color gradient
  71324. * @param gradient defines the gradient to remove
  71325. * @returns the current particle system
  71326. */
  71327. removeColorGradient(gradient: number): GPUParticleSystem;
  71328. private _angularSpeedGradientsTexture;
  71329. private _sizeGradientsTexture;
  71330. private _velocityGradientsTexture;
  71331. private _limitVelocityGradientsTexture;
  71332. private _dragGradientsTexture;
  71333. private _addFactorGradient;
  71334. /**
  71335. * Adds a new size gradient
  71336. * @param gradient defines the gradient to use (between 0 and 1)
  71337. * @param factor defines the size factor to affect to the specified gradient
  71338. * @returns the current particle system
  71339. */
  71340. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71341. /**
  71342. * Remove a specific size gradient
  71343. * @param gradient defines the gradient to remove
  71344. * @returns the current particle system
  71345. */
  71346. removeSizeGradient(gradient: number): GPUParticleSystem;
  71347. private _refreshFactorGradient;
  71348. /**
  71349. * Adds a new angular speed gradient
  71350. * @param gradient defines the gradient to use (between 0 and 1)
  71351. * @param factor defines the angular speed to affect to the specified gradient
  71352. * @returns the current particle system
  71353. */
  71354. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71355. /**
  71356. * Remove a specific angular speed gradient
  71357. * @param gradient defines the gradient to remove
  71358. * @returns the current particle system
  71359. */
  71360. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71361. /**
  71362. * Adds a new velocity gradient
  71363. * @param gradient defines the gradient to use (between 0 and 1)
  71364. * @param factor defines the velocity to affect to the specified gradient
  71365. * @returns the current particle system
  71366. */
  71367. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71368. /**
  71369. * Remove a specific velocity gradient
  71370. * @param gradient defines the gradient to remove
  71371. * @returns the current particle system
  71372. */
  71373. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71374. /**
  71375. * Adds a new limit velocity gradient
  71376. * @param gradient defines the gradient to use (between 0 and 1)
  71377. * @param factor defines the limit velocity value to affect to the specified gradient
  71378. * @returns the current particle system
  71379. */
  71380. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71381. /**
  71382. * Remove a specific limit velocity gradient
  71383. * @param gradient defines the gradient to remove
  71384. * @returns the current particle system
  71385. */
  71386. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71387. /**
  71388. * Adds a new drag gradient
  71389. * @param gradient defines the gradient to use (between 0 and 1)
  71390. * @param factor defines the drag value to affect to the specified gradient
  71391. * @returns the current particle system
  71392. */
  71393. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71394. /**
  71395. * Remove a specific drag gradient
  71396. * @param gradient defines the gradient to remove
  71397. * @returns the current particle system
  71398. */
  71399. removeDragGradient(gradient: number): GPUParticleSystem;
  71400. /**
  71401. * Not supported by GPUParticleSystem
  71402. * @param gradient defines the gradient to use (between 0 and 1)
  71403. * @param factor defines the emit rate value to affect to the specified gradient
  71404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71405. * @returns the current particle system
  71406. */
  71407. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71408. /**
  71409. * Not supported by GPUParticleSystem
  71410. * @param gradient defines the gradient to remove
  71411. * @returns the current particle system
  71412. */
  71413. removeEmitRateGradient(gradient: number): IParticleSystem;
  71414. /**
  71415. * Not supported by GPUParticleSystem
  71416. * @param gradient defines the gradient to use (between 0 and 1)
  71417. * @param factor defines the start size value to affect to the specified gradient
  71418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71419. * @returns the current particle system
  71420. */
  71421. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71422. /**
  71423. * Not supported by GPUParticleSystem
  71424. * @param gradient defines the gradient to remove
  71425. * @returns the current particle system
  71426. */
  71427. removeStartSizeGradient(gradient: number): IParticleSystem;
  71428. /**
  71429. * Not supported by GPUParticleSystem
  71430. * @param gradient defines the gradient to use (between 0 and 1)
  71431. * @param min defines the color remap minimal range
  71432. * @param max defines the color remap maximal range
  71433. * @returns the current particle system
  71434. */
  71435. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71436. /**
  71437. * Not supported by GPUParticleSystem
  71438. * @param gradient defines the gradient to remove
  71439. * @returns the current particle system
  71440. */
  71441. removeColorRemapGradient(): IParticleSystem;
  71442. /**
  71443. * Not supported by GPUParticleSystem
  71444. * @param gradient defines the gradient to use (between 0 and 1)
  71445. * @param min defines the alpha remap minimal range
  71446. * @param max defines the alpha remap maximal range
  71447. * @returns the current particle system
  71448. */
  71449. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71450. /**
  71451. * Not supported by GPUParticleSystem
  71452. * @param gradient defines the gradient to remove
  71453. * @returns the current particle system
  71454. */
  71455. removeAlphaRemapGradient(): IParticleSystem;
  71456. /**
  71457. * Not supported by GPUParticleSystem
  71458. * @param gradient defines the gradient to use (between 0 and 1)
  71459. * @param color defines the color to affect to the specified gradient
  71460. * @returns the current particle system
  71461. */
  71462. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71463. /**
  71464. * Not supported by GPUParticleSystem
  71465. * @param gradient defines the gradient to remove
  71466. * @returns the current particle system
  71467. */
  71468. removeRampGradient(): IParticleSystem;
  71469. /**
  71470. * Not supported by GPUParticleSystem
  71471. * @returns the list of ramp gradients
  71472. */
  71473. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71474. /**
  71475. * Not supported by GPUParticleSystem
  71476. * Gets or sets a boolean indicating that ramp gradients must be used
  71477. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71478. */
  71479. get useRampGradients(): boolean;
  71480. set useRampGradients(value: boolean);
  71481. /**
  71482. * Not supported by GPUParticleSystem
  71483. * @param gradient defines the gradient to use (between 0 and 1)
  71484. * @param factor defines the life time factor to affect to the specified gradient
  71485. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71486. * @returns the current particle system
  71487. */
  71488. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71489. /**
  71490. * Not supported by GPUParticleSystem
  71491. * @param gradient defines the gradient to remove
  71492. * @returns the current particle system
  71493. */
  71494. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71495. /**
  71496. * Instantiates a GPU particle system.
  71497. * 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.
  71498. * @param name The name of the particle system
  71499. * @param options The options used to create the system
  71500. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71501. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71502. * @param customEffect a custom effect used to change the way particles are rendered by default
  71503. */
  71504. constructor(name: string, options: Partial<{
  71505. capacity: number;
  71506. randomTextureSize: number;
  71507. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71508. protected _reset(): void;
  71509. private _createUpdateVAO;
  71510. private _createRenderVAO;
  71511. private _initialize;
  71512. /** @hidden */
  71513. _recreateUpdateEffect(): void;
  71514. private _getEffect;
  71515. /**
  71516. * Fill the defines array according to the current settings of the particle system
  71517. * @param defines Array to be updated
  71518. * @param blendMode blend mode to take into account when updating the array
  71519. */
  71520. fillDefines(defines: Array<string>, blendMode?: number): void;
  71521. /**
  71522. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71523. * @param uniforms Uniforms array to fill
  71524. * @param attributes Attributes array to fill
  71525. * @param samplers Samplers array to fill
  71526. */
  71527. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71528. /** @hidden */
  71529. _recreateRenderEffect(): Effect;
  71530. /**
  71531. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71532. * @param preWarm defines if we are in the pre-warmimg phase
  71533. */
  71534. animate(preWarm?: boolean): void;
  71535. private _createFactorGradientTexture;
  71536. private _createSizeGradientTexture;
  71537. private _createAngularSpeedGradientTexture;
  71538. private _createVelocityGradientTexture;
  71539. private _createLimitVelocityGradientTexture;
  71540. private _createDragGradientTexture;
  71541. private _createColorGradientTexture;
  71542. /**
  71543. * Renders the particle system in its current state
  71544. * @param preWarm defines if the system should only update the particles but not render them
  71545. * @returns the current number of particles
  71546. */
  71547. render(preWarm?: boolean): number;
  71548. /**
  71549. * Rebuilds the particle system
  71550. */
  71551. rebuild(): void;
  71552. private _releaseBuffers;
  71553. private _releaseVAOs;
  71554. /**
  71555. * Disposes the particle system and free the associated resources
  71556. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71557. */
  71558. dispose(disposeTexture?: boolean): void;
  71559. /**
  71560. * Clones the particle system.
  71561. * @param name The name of the cloned object
  71562. * @param newEmitter The new emitter to use
  71563. * @returns the cloned particle system
  71564. */
  71565. clone(name: string, newEmitter: any): GPUParticleSystem;
  71566. /**
  71567. * Serializes the particle system to a JSON object
  71568. * @param serializeTexture defines if the texture must be serialized as well
  71569. * @returns the JSON object
  71570. */
  71571. serialize(serializeTexture?: boolean): any;
  71572. /**
  71573. * Parses a JSON object to create a GPU particle system.
  71574. * @param parsedParticleSystem The JSON object to parse
  71575. * @param sceneOrEngine The scene or the engine to create the particle system in
  71576. * @param rootUrl The root url to use to load external dependencies like texture
  71577. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71578. * @returns the parsed GPU particle system
  71579. */
  71580. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71581. }
  71582. }
  71583. declare module "babylonjs/Particles/particleSystemSet" {
  71584. import { Nullable } from "babylonjs/types";
  71585. import { Color3 } from "babylonjs/Maths/math.color";
  71586. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71588. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71589. import { Scene, IDisposable } from "babylonjs/scene";
  71590. /**
  71591. * Represents a set of particle systems working together to create a specific effect
  71592. */
  71593. export class ParticleSystemSet implements IDisposable {
  71594. /**
  71595. * Gets or sets base Assets URL
  71596. */
  71597. static BaseAssetsUrl: string;
  71598. private _emitterCreationOptions;
  71599. private _emitterNode;
  71600. /**
  71601. * Gets the particle system list
  71602. */
  71603. systems: IParticleSystem[];
  71604. /**
  71605. * Gets the emitter node used with this set
  71606. */
  71607. get emitterNode(): Nullable<TransformNode>;
  71608. /**
  71609. * Creates a new emitter mesh as a sphere
  71610. * @param options defines the options used to create the sphere
  71611. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71612. * @param scene defines the hosting scene
  71613. */
  71614. setEmitterAsSphere(options: {
  71615. diameter: number;
  71616. segments: number;
  71617. color: Color3;
  71618. }, renderingGroupId: number, scene: Scene): void;
  71619. /**
  71620. * Starts all particle systems of the set
  71621. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71622. */
  71623. start(emitter?: AbstractMesh): void;
  71624. /**
  71625. * Release all associated resources
  71626. */
  71627. dispose(): void;
  71628. /**
  71629. * Serialize the set into a JSON compatible object
  71630. * @param serializeTexture defines if the texture must be serialized as well
  71631. * @returns a JSON compatible representation of the set
  71632. */
  71633. serialize(serializeTexture?: boolean): any;
  71634. /**
  71635. * Parse a new ParticleSystemSet from a serialized source
  71636. * @param data defines a JSON compatible representation of the set
  71637. * @param scene defines the hosting scene
  71638. * @param gpu defines if we want GPU particles or CPU particles
  71639. * @returns a new ParticleSystemSet
  71640. */
  71641. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71642. }
  71643. }
  71644. declare module "babylonjs/Particles/particleHelper" {
  71645. import { Nullable } from "babylonjs/types";
  71646. import { Scene } from "babylonjs/scene";
  71647. import { Vector3 } from "babylonjs/Maths/math.vector";
  71648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71649. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71650. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71651. /**
  71652. * This class is made for on one-liner static method to help creating particle system set.
  71653. */
  71654. export class ParticleHelper {
  71655. /**
  71656. * Gets or sets base Assets URL
  71657. */
  71658. static BaseAssetsUrl: string;
  71659. /** Define the Url to load snippets */
  71660. static SnippetUrl: string;
  71661. /**
  71662. * Create a default particle system that you can tweak
  71663. * @param emitter defines the emitter to use
  71664. * @param capacity defines the system capacity (default is 500 particles)
  71665. * @param scene defines the hosting scene
  71666. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71667. * @returns the new Particle system
  71668. */
  71669. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71670. /**
  71671. * This is the main static method (one-liner) of this helper to create different particle systems
  71672. * @param type This string represents the type to the particle system to create
  71673. * @param scene The scene where the particle system should live
  71674. * @param gpu If the system will use gpu
  71675. * @returns the ParticleSystemSet created
  71676. */
  71677. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71678. /**
  71679. * Static function used to export a particle system to a ParticleSystemSet variable.
  71680. * Please note that the emitter shape is not exported
  71681. * @param systems defines the particle systems to export
  71682. * @returns the created particle system set
  71683. */
  71684. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71685. /**
  71686. * Creates a particle system from a snippet saved in a remote file
  71687. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71688. * @param url defines the url to load from
  71689. * @param scene defines the hosting scene
  71690. * @param gpu If the system will use gpu
  71691. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71692. * @returns a promise that will resolve to the new particle system
  71693. */
  71694. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71695. /**
  71696. * Creates a particle system from a snippet saved by the particle system editor
  71697. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71698. * @param scene defines the hosting scene
  71699. * @param gpu If the system will use gpu
  71700. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71701. * @returns a promise that will resolve to the new particle system
  71702. */
  71703. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71704. }
  71705. }
  71706. declare module "babylonjs/Particles/particleSystemComponent" {
  71707. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71708. import { Effect } from "babylonjs/Materials/effect";
  71709. import "babylonjs/Shaders/particles.vertex";
  71710. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71711. module "babylonjs/Engines/engine" {
  71712. interface Engine {
  71713. /**
  71714. * Create an effect to use with particle systems.
  71715. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71716. * the particle system for which you want to create a custom effect in the last parameter
  71717. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71718. * @param uniformsNames defines a list of attribute names
  71719. * @param samplers defines an array of string used to represent textures
  71720. * @param defines defines the string containing the defines to use to compile the shaders
  71721. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71722. * @param onCompiled defines a function to call when the effect creation is successful
  71723. * @param onError defines a function to call when the effect creation has failed
  71724. * @param particleSystem the particle system you want to create the effect for
  71725. * @returns the new Effect
  71726. */
  71727. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71728. }
  71729. }
  71730. module "babylonjs/Meshes/mesh" {
  71731. interface Mesh {
  71732. /**
  71733. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71734. * @returns an array of IParticleSystem
  71735. */
  71736. getEmittedParticleSystems(): IParticleSystem[];
  71737. /**
  71738. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71739. * @returns an array of IParticleSystem
  71740. */
  71741. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71742. }
  71743. }
  71744. }
  71745. declare module "babylonjs/Particles/pointsCloudSystem" {
  71746. import { Color4 } from "babylonjs/Maths/math";
  71747. import { Mesh } from "babylonjs/Meshes/mesh";
  71748. import { Scene, IDisposable } from "babylonjs/scene";
  71749. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71750. /** Defines the 4 color options */
  71751. export enum PointColor {
  71752. /** color value */
  71753. Color = 2,
  71754. /** uv value */
  71755. UV = 1,
  71756. /** random value */
  71757. Random = 0,
  71758. /** stated value */
  71759. Stated = 3
  71760. }
  71761. /**
  71762. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71763. * 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.
  71764. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71765. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71766. *
  71767. * Full documentation here : TO BE ENTERED
  71768. */
  71769. export class PointsCloudSystem implements IDisposable {
  71770. /**
  71771. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71772. * Example : var p = SPS.particles[i];
  71773. */
  71774. particles: CloudPoint[];
  71775. /**
  71776. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71777. */
  71778. nbParticles: number;
  71779. /**
  71780. * This a counter for your own usage. It's not set by any SPS functions.
  71781. */
  71782. counter: number;
  71783. /**
  71784. * The PCS name. This name is also given to the underlying mesh.
  71785. */
  71786. name: string;
  71787. /**
  71788. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71789. */
  71790. mesh: Mesh;
  71791. /**
  71792. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71793. * Please read :
  71794. */
  71795. vars: any;
  71796. /**
  71797. * @hidden
  71798. */
  71799. _size: number;
  71800. private _scene;
  71801. private _promises;
  71802. private _positions;
  71803. private _indices;
  71804. private _normals;
  71805. private _colors;
  71806. private _uvs;
  71807. private _indices32;
  71808. private _positions32;
  71809. private _colors32;
  71810. private _uvs32;
  71811. private _updatable;
  71812. private _isVisibilityBoxLocked;
  71813. private _alwaysVisible;
  71814. private _groups;
  71815. private _groupCounter;
  71816. private _computeParticleColor;
  71817. private _computeParticleTexture;
  71818. private _computeParticleRotation;
  71819. private _computeBoundingBox;
  71820. private _isReady;
  71821. /**
  71822. * Creates a PCS (Points Cloud System) object
  71823. * @param name (String) is the PCS name, this will be the underlying mesh name
  71824. * @param pointSize (number) is the size for each point
  71825. * @param scene (Scene) is the scene in which the PCS is added
  71826. * @param options defines the options of the PCS e.g.
  71827. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71828. */
  71829. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71830. updatable?: boolean;
  71831. });
  71832. /**
  71833. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71834. * If no points were added to the PCS, the returned mesh is just a single point.
  71835. * @returns a promise for the created mesh
  71836. */
  71837. buildMeshAsync(): Promise<Mesh>;
  71838. /**
  71839. * @hidden
  71840. */
  71841. private _buildMesh;
  71842. private _addParticle;
  71843. private _randomUnitVector;
  71844. private _getColorIndicesForCoord;
  71845. private _setPointsColorOrUV;
  71846. private _colorFromTexture;
  71847. private _calculateDensity;
  71848. /**
  71849. * Adds points to the PCS in random positions within a unit sphere
  71850. * @param nb (positive integer) the number of particles to be created from this model
  71851. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71852. * @returns the number of groups in the system
  71853. */
  71854. addPoints(nb: number, pointFunction?: any): number;
  71855. /**
  71856. * Adds points to the PCS from the surface of the model shape
  71857. * @param mesh is any Mesh object that will be used as a surface model for the points
  71858. * @param nb (positive integer) the number of particles to be created from this model
  71859. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71860. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71861. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71862. * @returns the number of groups in the system
  71863. */
  71864. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71865. /**
  71866. * Adds points to the PCS inside the model shape
  71867. * @param mesh is any Mesh object that will be used as a surface model for the points
  71868. * @param nb (positive integer) the number of particles to be created from this model
  71869. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71870. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71871. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71872. * @returns the number of groups in the system
  71873. */
  71874. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71875. /**
  71876. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71877. * This method calls `updateParticle()` for each particle of the SPS.
  71878. * For an animated SPS, it is usually called within the render loop.
  71879. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71880. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71881. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71882. * @returns the PCS.
  71883. */
  71884. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71885. /**
  71886. * Disposes the PCS.
  71887. */
  71888. dispose(): void;
  71889. /**
  71890. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71891. * doc :
  71892. * @returns the PCS.
  71893. */
  71894. refreshVisibleSize(): PointsCloudSystem;
  71895. /**
  71896. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71897. * @param size the size (float) of the visibility box
  71898. * note : this doesn't lock the PCS mesh bounding box.
  71899. * doc :
  71900. */
  71901. setVisibilityBox(size: number): void;
  71902. /**
  71903. * Gets whether the PCS is always visible or not
  71904. * doc :
  71905. */
  71906. get isAlwaysVisible(): boolean;
  71907. /**
  71908. * Sets the PCS as always visible or not
  71909. * doc :
  71910. */
  71911. set isAlwaysVisible(val: boolean);
  71912. /**
  71913. * Tells to `setParticles()` to compute the particle rotations or not
  71914. * Default value : false. The PCS is faster when it's set to false
  71915. * Note : particle rotations are only applied to parent particles
  71916. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71917. */
  71918. set computeParticleRotation(val: boolean);
  71919. /**
  71920. * Tells to `setParticles()` to compute the particle colors or not.
  71921. * Default value : true. The PCS is faster when it's set to false.
  71922. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71923. */
  71924. set computeParticleColor(val: boolean);
  71925. set computeParticleTexture(val: boolean);
  71926. /**
  71927. * Gets if `setParticles()` computes the particle colors or not.
  71928. * Default value : false. The PCS is faster when it's set to false.
  71929. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71930. */
  71931. get computeParticleColor(): boolean;
  71932. /**
  71933. * Gets if `setParticles()` computes the particle textures or not.
  71934. * Default value : false. The PCS is faster when it's set to false.
  71935. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71936. */
  71937. get computeParticleTexture(): boolean;
  71938. /**
  71939. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71940. */
  71941. set computeBoundingBox(val: boolean);
  71942. /**
  71943. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71944. */
  71945. get computeBoundingBox(): boolean;
  71946. /**
  71947. * This function does nothing. It may be overwritten to set all the particle first values.
  71948. * The PCS doesn't call this function, you may have to call it by your own.
  71949. * doc :
  71950. */
  71951. initParticles(): void;
  71952. /**
  71953. * This function does nothing. It may be overwritten to recycle a particle
  71954. * The PCS doesn't call this function, you can to call it
  71955. * doc :
  71956. * @param particle The particle to recycle
  71957. * @returns the recycled particle
  71958. */
  71959. recycleParticle(particle: CloudPoint): CloudPoint;
  71960. /**
  71961. * Updates a particle : this function should be overwritten by the user.
  71962. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71963. * doc :
  71964. * @example : just set a particle position or velocity and recycle conditions
  71965. * @param particle The particle to update
  71966. * @returns the updated particle
  71967. */
  71968. updateParticle(particle: CloudPoint): CloudPoint;
  71969. /**
  71970. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71971. * This does nothing and may be overwritten by the user.
  71972. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71973. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71974. * @param update the boolean update value actually passed to setParticles()
  71975. */
  71976. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71977. /**
  71978. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71979. * This will be passed three parameters.
  71980. * This does nothing and may be overwritten by the user.
  71981. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71982. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71983. * @param update the boolean update value actually passed to setParticles()
  71984. */
  71985. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71986. }
  71987. }
  71988. declare module "babylonjs/Particles/cloudPoint" {
  71989. import { Nullable } from "babylonjs/types";
  71990. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71991. import { Mesh } from "babylonjs/Meshes/mesh";
  71992. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71993. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71994. /**
  71995. * Represents one particle of a points cloud system.
  71996. */
  71997. export class CloudPoint {
  71998. /**
  71999. * particle global index
  72000. */
  72001. idx: number;
  72002. /**
  72003. * The color of the particle
  72004. */
  72005. color: Nullable<Color4>;
  72006. /**
  72007. * The world space position of the particle.
  72008. */
  72009. position: Vector3;
  72010. /**
  72011. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72012. */
  72013. rotation: Vector3;
  72014. /**
  72015. * The world space rotation quaternion of the particle.
  72016. */
  72017. rotationQuaternion: Nullable<Quaternion>;
  72018. /**
  72019. * The uv of the particle.
  72020. */
  72021. uv: Nullable<Vector2>;
  72022. /**
  72023. * The current speed of the particle.
  72024. */
  72025. velocity: Vector3;
  72026. /**
  72027. * The pivot point in the particle local space.
  72028. */
  72029. pivot: Vector3;
  72030. /**
  72031. * Must the particle be translated from its pivot point in its local space ?
  72032. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72033. * Default : false
  72034. */
  72035. translateFromPivot: boolean;
  72036. /**
  72037. * Index of this particle in the global "positions" array (Internal use)
  72038. * @hidden
  72039. */
  72040. _pos: number;
  72041. /**
  72042. * @hidden Index of this particle in the global "indices" array (Internal use)
  72043. */
  72044. _ind: number;
  72045. /**
  72046. * Group this particle belongs to
  72047. */
  72048. _group: PointsGroup;
  72049. /**
  72050. * Group id of this particle
  72051. */
  72052. groupId: number;
  72053. /**
  72054. * Index of the particle in its group id (Internal use)
  72055. */
  72056. idxInGroup: number;
  72057. /**
  72058. * @hidden Particle BoundingInfo object (Internal use)
  72059. */
  72060. _boundingInfo: BoundingInfo;
  72061. /**
  72062. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72063. */
  72064. _pcs: PointsCloudSystem;
  72065. /**
  72066. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72067. */
  72068. _stillInvisible: boolean;
  72069. /**
  72070. * @hidden Last computed particle rotation matrix
  72071. */
  72072. _rotationMatrix: number[];
  72073. /**
  72074. * Parent particle Id, if any.
  72075. * Default null.
  72076. */
  72077. parentId: Nullable<number>;
  72078. /**
  72079. * @hidden Internal global position in the PCS.
  72080. */
  72081. _globalPosition: Vector3;
  72082. /**
  72083. * Creates a Point Cloud object.
  72084. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72085. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72086. * @param group (PointsGroup) is the group the particle belongs to
  72087. * @param groupId (integer) is the group identifier in the PCS.
  72088. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72089. * @param pcs defines the PCS it is associated to
  72090. */
  72091. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72092. /**
  72093. * get point size
  72094. */
  72095. get size(): Vector3;
  72096. /**
  72097. * Set point size
  72098. */
  72099. set size(scale: Vector3);
  72100. /**
  72101. * Legacy support, changed quaternion to rotationQuaternion
  72102. */
  72103. get quaternion(): Nullable<Quaternion>;
  72104. /**
  72105. * Legacy support, changed quaternion to rotationQuaternion
  72106. */
  72107. set quaternion(q: Nullable<Quaternion>);
  72108. /**
  72109. * Returns a boolean. True if the particle intersects a mesh, else false
  72110. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72111. * @param target is the object (point or mesh) what the intersection is computed against
  72112. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72113. * @returns true if it intersects
  72114. */
  72115. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72116. /**
  72117. * get the rotation matrix of the particle
  72118. * @hidden
  72119. */
  72120. getRotationMatrix(m: Matrix): void;
  72121. }
  72122. /**
  72123. * Represents a group of points in a points cloud system
  72124. * * PCS internal tool, don't use it manually.
  72125. */
  72126. export class PointsGroup {
  72127. /**
  72128. * The group id
  72129. * @hidden
  72130. */
  72131. groupID: number;
  72132. /**
  72133. * image data for group (internal use)
  72134. * @hidden
  72135. */
  72136. _groupImageData: Nullable<ArrayBufferView>;
  72137. /**
  72138. * Image Width (internal use)
  72139. * @hidden
  72140. */
  72141. _groupImgWidth: number;
  72142. /**
  72143. * Image Height (internal use)
  72144. * @hidden
  72145. */
  72146. _groupImgHeight: number;
  72147. /**
  72148. * Custom position function (internal use)
  72149. * @hidden
  72150. */
  72151. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72152. /**
  72153. * density per facet for surface points
  72154. * @hidden
  72155. */
  72156. _groupDensity: number[];
  72157. /**
  72158. * Only when points are colored by texture carries pointer to texture list array
  72159. * @hidden
  72160. */
  72161. _textureNb: number;
  72162. /**
  72163. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72164. * PCS internal tool, don't use it manually.
  72165. * @hidden
  72166. */
  72167. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72168. }
  72169. }
  72170. declare module "babylonjs/Particles/index" {
  72171. export * from "babylonjs/Particles/baseParticleSystem";
  72172. export * from "babylonjs/Particles/EmitterTypes/index";
  72173. export * from "babylonjs/Particles/gpuParticleSystem";
  72174. export * from "babylonjs/Particles/IParticleSystem";
  72175. export * from "babylonjs/Particles/particle";
  72176. export * from "babylonjs/Particles/particleHelper";
  72177. export * from "babylonjs/Particles/particleSystem";
  72178. import "babylonjs/Particles/particleSystemComponent";
  72179. export * from "babylonjs/Particles/particleSystemComponent";
  72180. export * from "babylonjs/Particles/particleSystemSet";
  72181. export * from "babylonjs/Particles/solidParticle";
  72182. export * from "babylonjs/Particles/solidParticleSystem";
  72183. export * from "babylonjs/Particles/cloudPoint";
  72184. export * from "babylonjs/Particles/pointsCloudSystem";
  72185. export * from "babylonjs/Particles/subEmitter";
  72186. }
  72187. declare module "babylonjs/Physics/physicsEngineComponent" {
  72188. import { Nullable } from "babylonjs/types";
  72189. import { Observable, Observer } from "babylonjs/Misc/observable";
  72190. import { Vector3 } from "babylonjs/Maths/math.vector";
  72191. import { Mesh } from "babylonjs/Meshes/mesh";
  72192. import { ISceneComponent } from "babylonjs/sceneComponent";
  72193. import { Scene } from "babylonjs/scene";
  72194. import { Node } from "babylonjs/node";
  72195. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72196. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72197. module "babylonjs/scene" {
  72198. interface Scene {
  72199. /** @hidden (Backing field) */
  72200. _physicsEngine: Nullable<IPhysicsEngine>;
  72201. /** @hidden */
  72202. _physicsTimeAccumulator: number;
  72203. /**
  72204. * Gets the current physics engine
  72205. * @returns a IPhysicsEngine or null if none attached
  72206. */
  72207. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72208. /**
  72209. * Enables physics to the current scene
  72210. * @param gravity defines the scene's gravity for the physics engine
  72211. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72212. * @return a boolean indicating if the physics engine was initialized
  72213. */
  72214. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72215. /**
  72216. * Disables and disposes the physics engine associated with the scene
  72217. */
  72218. disablePhysicsEngine(): void;
  72219. /**
  72220. * Gets a boolean indicating if there is an active physics engine
  72221. * @returns a boolean indicating if there is an active physics engine
  72222. */
  72223. isPhysicsEnabled(): boolean;
  72224. /**
  72225. * Deletes a physics compound impostor
  72226. * @param compound defines the compound to delete
  72227. */
  72228. deleteCompoundImpostor(compound: any): void;
  72229. /**
  72230. * An event triggered when physic simulation is about to be run
  72231. */
  72232. onBeforePhysicsObservable: Observable<Scene>;
  72233. /**
  72234. * An event triggered when physic simulation has been done
  72235. */
  72236. onAfterPhysicsObservable: Observable<Scene>;
  72237. }
  72238. }
  72239. module "babylonjs/Meshes/abstractMesh" {
  72240. interface AbstractMesh {
  72241. /** @hidden */
  72242. _physicsImpostor: Nullable<PhysicsImpostor>;
  72243. /**
  72244. * Gets or sets impostor used for physic simulation
  72245. * @see https://doc.babylonjs.com/features/physics_engine
  72246. */
  72247. physicsImpostor: Nullable<PhysicsImpostor>;
  72248. /**
  72249. * Gets the current physics impostor
  72250. * @see https://doc.babylonjs.com/features/physics_engine
  72251. * @returns a physics impostor or null
  72252. */
  72253. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72254. /** Apply a physic impulse to the mesh
  72255. * @param force defines the force to apply
  72256. * @param contactPoint defines where to apply the force
  72257. * @returns the current mesh
  72258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72259. */
  72260. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72261. /**
  72262. * Creates a physic joint between two meshes
  72263. * @param otherMesh defines the other mesh to use
  72264. * @param pivot1 defines the pivot to use on this mesh
  72265. * @param pivot2 defines the pivot to use on the other mesh
  72266. * @param options defines additional options (can be plugin dependent)
  72267. * @returns the current mesh
  72268. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72269. */
  72270. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72271. /** @hidden */
  72272. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72273. }
  72274. }
  72275. /**
  72276. * Defines the physics engine scene component responsible to manage a physics engine
  72277. */
  72278. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72279. /**
  72280. * The component name helpful to identify the component in the list of scene components.
  72281. */
  72282. readonly name: string;
  72283. /**
  72284. * The scene the component belongs to.
  72285. */
  72286. scene: Scene;
  72287. /**
  72288. * Creates a new instance of the component for the given scene
  72289. * @param scene Defines the scene to register the component in
  72290. */
  72291. constructor(scene: Scene);
  72292. /**
  72293. * Registers the component in a given scene
  72294. */
  72295. register(): void;
  72296. /**
  72297. * Rebuilds the elements related to this component in case of
  72298. * context lost for instance.
  72299. */
  72300. rebuild(): void;
  72301. /**
  72302. * Disposes the component and the associated ressources
  72303. */
  72304. dispose(): void;
  72305. }
  72306. }
  72307. declare module "babylonjs/Physics/physicsHelper" {
  72308. import { Nullable } from "babylonjs/types";
  72309. import { Vector3 } from "babylonjs/Maths/math.vector";
  72310. import { Mesh } from "babylonjs/Meshes/mesh";
  72311. import { Scene } from "babylonjs/scene";
  72312. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72313. /**
  72314. * A helper for physics simulations
  72315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72316. */
  72317. export class PhysicsHelper {
  72318. private _scene;
  72319. private _physicsEngine;
  72320. /**
  72321. * Initializes the Physics helper
  72322. * @param scene Babylon.js scene
  72323. */
  72324. constructor(scene: Scene);
  72325. /**
  72326. * Applies a radial explosion impulse
  72327. * @param origin the origin of the explosion
  72328. * @param radiusOrEventOptions the radius or the options of radial explosion
  72329. * @param strength the explosion strength
  72330. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72331. * @returns A physics radial explosion event, or null
  72332. */
  72333. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72334. /**
  72335. * Applies a radial explosion force
  72336. * @param origin the origin of the explosion
  72337. * @param radiusOrEventOptions the radius or the options of radial explosion
  72338. * @param strength the explosion strength
  72339. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72340. * @returns A physics radial explosion event, or null
  72341. */
  72342. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72343. /**
  72344. * Creates a gravitational field
  72345. * @param origin the origin of the explosion
  72346. * @param radiusOrEventOptions the radius or the options of radial explosion
  72347. * @param strength the explosion strength
  72348. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72349. * @returns A physics gravitational field event, or null
  72350. */
  72351. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72352. /**
  72353. * Creates a physics updraft event
  72354. * @param origin the origin of the updraft
  72355. * @param radiusOrEventOptions the radius or the options of the updraft
  72356. * @param strength the strength of the updraft
  72357. * @param height the height of the updraft
  72358. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72359. * @returns A physics updraft event, or null
  72360. */
  72361. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72362. /**
  72363. * Creates a physics vortex event
  72364. * @param origin the of the vortex
  72365. * @param radiusOrEventOptions the radius or the options of the vortex
  72366. * @param strength the strength of the vortex
  72367. * @param height the height of the vortex
  72368. * @returns a Physics vortex event, or null
  72369. * A physics vortex event or null
  72370. */
  72371. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72372. }
  72373. /**
  72374. * Represents a physics radial explosion event
  72375. */
  72376. class PhysicsRadialExplosionEvent {
  72377. private _scene;
  72378. private _options;
  72379. private _sphere;
  72380. private _dataFetched;
  72381. /**
  72382. * Initializes a radial explosioin event
  72383. * @param _scene BabylonJS scene
  72384. * @param _options The options for the vortex event
  72385. */
  72386. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72387. /**
  72388. * Returns the data related to the radial explosion event (sphere).
  72389. * @returns The radial explosion event data
  72390. */
  72391. getData(): PhysicsRadialExplosionEventData;
  72392. /**
  72393. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72394. * @param impostor A physics imposter
  72395. * @param origin the origin of the explosion
  72396. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72397. */
  72398. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72399. /**
  72400. * Triggers affecterd impostors callbacks
  72401. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72402. */
  72403. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72404. /**
  72405. * Disposes the sphere.
  72406. * @param force Specifies if the sphere should be disposed by force
  72407. */
  72408. dispose(force?: boolean): void;
  72409. /*** Helpers ***/
  72410. private _prepareSphere;
  72411. private _intersectsWithSphere;
  72412. }
  72413. /**
  72414. * Represents a gravitational field event
  72415. */
  72416. class PhysicsGravitationalFieldEvent {
  72417. private _physicsHelper;
  72418. private _scene;
  72419. private _origin;
  72420. private _options;
  72421. private _tickCallback;
  72422. private _sphere;
  72423. private _dataFetched;
  72424. /**
  72425. * Initializes the physics gravitational field event
  72426. * @param _physicsHelper A physics helper
  72427. * @param _scene BabylonJS scene
  72428. * @param _origin The origin position of the gravitational field event
  72429. * @param _options The options for the vortex event
  72430. */
  72431. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72432. /**
  72433. * Returns the data related to the gravitational field event (sphere).
  72434. * @returns A gravitational field event
  72435. */
  72436. getData(): PhysicsGravitationalFieldEventData;
  72437. /**
  72438. * Enables the gravitational field.
  72439. */
  72440. enable(): void;
  72441. /**
  72442. * Disables the gravitational field.
  72443. */
  72444. disable(): void;
  72445. /**
  72446. * Disposes the sphere.
  72447. * @param force The force to dispose from the gravitational field event
  72448. */
  72449. dispose(force?: boolean): void;
  72450. private _tick;
  72451. }
  72452. /**
  72453. * Represents a physics updraft event
  72454. */
  72455. class PhysicsUpdraftEvent {
  72456. private _scene;
  72457. private _origin;
  72458. private _options;
  72459. private _physicsEngine;
  72460. private _originTop;
  72461. private _originDirection;
  72462. private _tickCallback;
  72463. private _cylinder;
  72464. private _cylinderPosition;
  72465. private _dataFetched;
  72466. /**
  72467. * Initializes the physics updraft event
  72468. * @param _scene BabylonJS scene
  72469. * @param _origin The origin position of the updraft
  72470. * @param _options The options for the updraft event
  72471. */
  72472. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72473. /**
  72474. * Returns the data related to the updraft event (cylinder).
  72475. * @returns A physics updraft event
  72476. */
  72477. getData(): PhysicsUpdraftEventData;
  72478. /**
  72479. * Enables the updraft.
  72480. */
  72481. enable(): void;
  72482. /**
  72483. * Disables the updraft.
  72484. */
  72485. disable(): void;
  72486. /**
  72487. * Disposes the cylinder.
  72488. * @param force Specifies if the updraft should be disposed by force
  72489. */
  72490. dispose(force?: boolean): void;
  72491. private getImpostorHitData;
  72492. private _tick;
  72493. /*** Helpers ***/
  72494. private _prepareCylinder;
  72495. private _intersectsWithCylinder;
  72496. }
  72497. /**
  72498. * Represents a physics vortex event
  72499. */
  72500. class PhysicsVortexEvent {
  72501. private _scene;
  72502. private _origin;
  72503. private _options;
  72504. private _physicsEngine;
  72505. private _originTop;
  72506. private _tickCallback;
  72507. private _cylinder;
  72508. private _cylinderPosition;
  72509. private _dataFetched;
  72510. /**
  72511. * Initializes the physics vortex event
  72512. * @param _scene The BabylonJS scene
  72513. * @param _origin The origin position of the vortex
  72514. * @param _options The options for the vortex event
  72515. */
  72516. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72517. /**
  72518. * Returns the data related to the vortex event (cylinder).
  72519. * @returns The physics vortex event data
  72520. */
  72521. getData(): PhysicsVortexEventData;
  72522. /**
  72523. * Enables the vortex.
  72524. */
  72525. enable(): void;
  72526. /**
  72527. * Disables the cortex.
  72528. */
  72529. disable(): void;
  72530. /**
  72531. * Disposes the sphere.
  72532. * @param force
  72533. */
  72534. dispose(force?: boolean): void;
  72535. private getImpostorHitData;
  72536. private _tick;
  72537. /*** Helpers ***/
  72538. private _prepareCylinder;
  72539. private _intersectsWithCylinder;
  72540. }
  72541. /**
  72542. * Options fot the radial explosion event
  72543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72544. */
  72545. export class PhysicsRadialExplosionEventOptions {
  72546. /**
  72547. * The radius of the sphere for the radial explosion.
  72548. */
  72549. radius: number;
  72550. /**
  72551. * The strenth of the explosion.
  72552. */
  72553. strength: number;
  72554. /**
  72555. * The strenght of the force in correspondence to the distance of the affected object
  72556. */
  72557. falloff: PhysicsRadialImpulseFalloff;
  72558. /**
  72559. * Sphere options for the radial explosion.
  72560. */
  72561. sphere: {
  72562. segments: number;
  72563. diameter: number;
  72564. };
  72565. /**
  72566. * Sphere options for the radial explosion.
  72567. */
  72568. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72569. }
  72570. /**
  72571. * Options fot the updraft event
  72572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72573. */
  72574. export class PhysicsUpdraftEventOptions {
  72575. /**
  72576. * The radius of the cylinder for the vortex
  72577. */
  72578. radius: number;
  72579. /**
  72580. * The strenth of the updraft.
  72581. */
  72582. strength: number;
  72583. /**
  72584. * The height of the cylinder for the updraft.
  72585. */
  72586. height: number;
  72587. /**
  72588. * The mode for the the updraft.
  72589. */
  72590. updraftMode: PhysicsUpdraftMode;
  72591. }
  72592. /**
  72593. * Options fot the vortex event
  72594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72595. */
  72596. export class PhysicsVortexEventOptions {
  72597. /**
  72598. * The radius of the cylinder for the vortex
  72599. */
  72600. radius: number;
  72601. /**
  72602. * The strenth of the vortex.
  72603. */
  72604. strength: number;
  72605. /**
  72606. * The height of the cylinder for the vortex.
  72607. */
  72608. height: number;
  72609. /**
  72610. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72611. */
  72612. centripetalForceThreshold: number;
  72613. /**
  72614. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72615. */
  72616. centripetalForceMultiplier: number;
  72617. /**
  72618. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72619. */
  72620. centrifugalForceMultiplier: number;
  72621. /**
  72622. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72623. */
  72624. updraftForceMultiplier: number;
  72625. }
  72626. /**
  72627. * The strenght of the force in correspondence to the distance of the affected object
  72628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72629. */
  72630. export enum PhysicsRadialImpulseFalloff {
  72631. /** Defines that impulse is constant in strength across it's whole radius */
  72632. Constant = 0,
  72633. /** Defines that impulse gets weaker if it's further from the origin */
  72634. Linear = 1
  72635. }
  72636. /**
  72637. * The strength of the force in correspondence to the distance of the affected object
  72638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72639. */
  72640. export enum PhysicsUpdraftMode {
  72641. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72642. Center = 0,
  72643. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72644. Perpendicular = 1
  72645. }
  72646. /**
  72647. * Interface for a physics hit data
  72648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72649. */
  72650. export interface PhysicsHitData {
  72651. /**
  72652. * The force applied at the contact point
  72653. */
  72654. force: Vector3;
  72655. /**
  72656. * The contact point
  72657. */
  72658. contactPoint: Vector3;
  72659. /**
  72660. * The distance from the origin to the contact point
  72661. */
  72662. distanceFromOrigin: number;
  72663. }
  72664. /**
  72665. * Interface for radial explosion event data
  72666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72667. */
  72668. export interface PhysicsRadialExplosionEventData {
  72669. /**
  72670. * A sphere used for the radial explosion event
  72671. */
  72672. sphere: Mesh;
  72673. }
  72674. /**
  72675. * Interface for gravitational field event data
  72676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72677. */
  72678. export interface PhysicsGravitationalFieldEventData {
  72679. /**
  72680. * A sphere mesh used for the gravitational field event
  72681. */
  72682. sphere: Mesh;
  72683. }
  72684. /**
  72685. * Interface for updraft event data
  72686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72687. */
  72688. export interface PhysicsUpdraftEventData {
  72689. /**
  72690. * A cylinder used for the updraft event
  72691. */
  72692. cylinder: Mesh;
  72693. }
  72694. /**
  72695. * Interface for vortex event data
  72696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72697. */
  72698. export interface PhysicsVortexEventData {
  72699. /**
  72700. * A cylinder used for the vortex event
  72701. */
  72702. cylinder: Mesh;
  72703. }
  72704. /**
  72705. * Interface for an affected physics impostor
  72706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72707. */
  72708. export interface PhysicsAffectedImpostorWithData {
  72709. /**
  72710. * The impostor affected by the effect
  72711. */
  72712. impostor: PhysicsImpostor;
  72713. /**
  72714. * The data about the hit/horce from the explosion
  72715. */
  72716. hitData: PhysicsHitData;
  72717. }
  72718. }
  72719. declare module "babylonjs/Physics/Plugins/index" {
  72720. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72721. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72722. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72723. }
  72724. declare module "babylonjs/Physics/index" {
  72725. export * from "babylonjs/Physics/IPhysicsEngine";
  72726. export * from "babylonjs/Physics/physicsEngine";
  72727. export * from "babylonjs/Physics/physicsEngineComponent";
  72728. export * from "babylonjs/Physics/physicsHelper";
  72729. export * from "babylonjs/Physics/physicsImpostor";
  72730. export * from "babylonjs/Physics/physicsJoint";
  72731. export * from "babylonjs/Physics/Plugins/index";
  72732. }
  72733. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72734. /** @hidden */
  72735. export var blackAndWhitePixelShader: {
  72736. name: string;
  72737. shader: string;
  72738. };
  72739. }
  72740. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72741. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72742. import { Camera } from "babylonjs/Cameras/camera";
  72743. import { Engine } from "babylonjs/Engines/engine";
  72744. import "babylonjs/Shaders/blackAndWhite.fragment";
  72745. import { Nullable } from "babylonjs/types";
  72746. import { Scene } from "babylonjs/scene";
  72747. /**
  72748. * Post process used to render in black and white
  72749. */
  72750. export class BlackAndWhitePostProcess extends PostProcess {
  72751. /**
  72752. * Linear about to convert he result to black and white (default: 1)
  72753. */
  72754. degree: number;
  72755. /**
  72756. * Gets a string identifying the name of the class
  72757. * @returns "BlackAndWhitePostProcess" string
  72758. */
  72759. getClassName(): string;
  72760. /**
  72761. * Creates a black and white post process
  72762. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72763. * @param name The name of the effect.
  72764. * @param options The required width/height ratio to downsize to before computing the render pass.
  72765. * @param camera The camera to apply the render pass to.
  72766. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72767. * @param engine The engine which the post process will be applied. (default: current engine)
  72768. * @param reusable If the post process can be reused on the same frame. (default: false)
  72769. */
  72770. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72771. /** @hidden */
  72772. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72773. }
  72774. }
  72775. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72776. import { Nullable } from "babylonjs/types";
  72777. import { Camera } from "babylonjs/Cameras/camera";
  72778. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72779. import { Engine } from "babylonjs/Engines/engine";
  72780. /**
  72781. * This represents a set of one or more post processes in Babylon.
  72782. * A post process can be used to apply a shader to a texture after it is rendered.
  72783. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72784. */
  72785. export class PostProcessRenderEffect {
  72786. private _postProcesses;
  72787. private _getPostProcesses;
  72788. private _singleInstance;
  72789. private _cameras;
  72790. private _indicesForCamera;
  72791. /**
  72792. * Name of the effect
  72793. * @hidden
  72794. */
  72795. _name: string;
  72796. /**
  72797. * Instantiates a post process render effect.
  72798. * A post process can be used to apply a shader to a texture after it is rendered.
  72799. * @param engine The engine the effect is tied to
  72800. * @param name The name of the effect
  72801. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72802. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72803. */
  72804. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72805. /**
  72806. * Checks if all the post processes in the effect are supported.
  72807. */
  72808. get isSupported(): boolean;
  72809. /**
  72810. * Updates the current state of the effect
  72811. * @hidden
  72812. */
  72813. _update(): void;
  72814. /**
  72815. * Attaches the effect on cameras
  72816. * @param cameras The camera to attach to.
  72817. * @hidden
  72818. */
  72819. _attachCameras(cameras: Camera): void;
  72820. /**
  72821. * Attaches the effect on cameras
  72822. * @param cameras The camera to attach to.
  72823. * @hidden
  72824. */
  72825. _attachCameras(cameras: Camera[]): void;
  72826. /**
  72827. * Detaches the effect on cameras
  72828. * @param cameras The camera to detatch from.
  72829. * @hidden
  72830. */
  72831. _detachCameras(cameras: Camera): void;
  72832. /**
  72833. * Detatches the effect on cameras
  72834. * @param cameras The camera to detatch from.
  72835. * @hidden
  72836. */
  72837. _detachCameras(cameras: Camera[]): void;
  72838. /**
  72839. * Enables the effect on given cameras
  72840. * @param cameras The camera to enable.
  72841. * @hidden
  72842. */
  72843. _enable(cameras: Camera): void;
  72844. /**
  72845. * Enables the effect on given cameras
  72846. * @param cameras The camera to enable.
  72847. * @hidden
  72848. */
  72849. _enable(cameras: Nullable<Camera[]>): void;
  72850. /**
  72851. * Disables the effect on the given cameras
  72852. * @param cameras The camera to disable.
  72853. * @hidden
  72854. */
  72855. _disable(cameras: Camera): void;
  72856. /**
  72857. * Disables the effect on the given cameras
  72858. * @param cameras The camera to disable.
  72859. * @hidden
  72860. */
  72861. _disable(cameras: Nullable<Camera[]>): void;
  72862. /**
  72863. * Gets a list of the post processes contained in the effect.
  72864. * @param camera The camera to get the post processes on.
  72865. * @returns The list of the post processes in the effect.
  72866. */
  72867. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72868. }
  72869. }
  72870. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72871. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72872. /** @hidden */
  72873. export var extractHighlightsPixelShader: {
  72874. name: string;
  72875. shader: string;
  72876. };
  72877. }
  72878. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72879. import { Nullable } from "babylonjs/types";
  72880. import { Camera } from "babylonjs/Cameras/camera";
  72881. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72882. import { Engine } from "babylonjs/Engines/engine";
  72883. import "babylonjs/Shaders/extractHighlights.fragment";
  72884. /**
  72885. * 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.
  72886. */
  72887. export class ExtractHighlightsPostProcess extends PostProcess {
  72888. /**
  72889. * The luminance threshold, pixels below this value will be set to black.
  72890. */
  72891. threshold: number;
  72892. /** @hidden */
  72893. _exposure: number;
  72894. /**
  72895. * Post process which has the input texture to be used when performing highlight extraction
  72896. * @hidden
  72897. */
  72898. _inputPostProcess: Nullable<PostProcess>;
  72899. /**
  72900. * Gets a string identifying the name of the class
  72901. * @returns "ExtractHighlightsPostProcess" string
  72902. */
  72903. getClassName(): string;
  72904. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72905. }
  72906. }
  72907. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72908. /** @hidden */
  72909. export var bloomMergePixelShader: {
  72910. name: string;
  72911. shader: string;
  72912. };
  72913. }
  72914. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72915. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72916. import { Nullable } from "babylonjs/types";
  72917. import { Engine } from "babylonjs/Engines/engine";
  72918. import { Camera } from "babylonjs/Cameras/camera";
  72919. import "babylonjs/Shaders/bloomMerge.fragment";
  72920. /**
  72921. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72922. */
  72923. export class BloomMergePostProcess extends PostProcess {
  72924. /** Weight of the bloom to be added to the original input. */
  72925. weight: number;
  72926. /**
  72927. * Gets a string identifying the name of the class
  72928. * @returns "BloomMergePostProcess" string
  72929. */
  72930. getClassName(): string;
  72931. /**
  72932. * Creates a new instance of @see BloomMergePostProcess
  72933. * @param name The name of the effect.
  72934. * @param originalFromInput Post process which's input will be used for the merge.
  72935. * @param blurred Blurred highlights post process which's output will be used.
  72936. * @param weight Weight of the bloom to be added to the original input.
  72937. * @param options The required width/height ratio to downsize to before computing the render pass.
  72938. * @param camera The camera to apply the render pass to.
  72939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72940. * @param engine The engine which the post process will be applied. (default: current engine)
  72941. * @param reusable If the post process can be reused on the same frame. (default: false)
  72942. * @param textureType Type of textures used when performing the post process. (default: 0)
  72943. * @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)
  72944. */
  72945. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72946. /** Weight of the bloom to be added to the original input. */
  72947. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72948. }
  72949. }
  72950. declare module "babylonjs/PostProcesses/bloomEffect" {
  72951. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72952. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72953. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72954. import { Camera } from "babylonjs/Cameras/camera";
  72955. import { Scene } from "babylonjs/scene";
  72956. /**
  72957. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72958. */
  72959. export class BloomEffect extends PostProcessRenderEffect {
  72960. private bloomScale;
  72961. /**
  72962. * @hidden Internal
  72963. */
  72964. _effects: Array<PostProcess>;
  72965. /**
  72966. * @hidden Internal
  72967. */
  72968. _downscale: ExtractHighlightsPostProcess;
  72969. private _blurX;
  72970. private _blurY;
  72971. private _merge;
  72972. /**
  72973. * The luminance threshold to find bright areas of the image to bloom.
  72974. */
  72975. get threshold(): number;
  72976. set threshold(value: number);
  72977. /**
  72978. * The strength of the bloom.
  72979. */
  72980. get weight(): number;
  72981. set weight(value: number);
  72982. /**
  72983. * Specifies the size of the bloom blur kernel, relative to the final output size
  72984. */
  72985. get kernel(): number;
  72986. set kernel(value: number);
  72987. /**
  72988. * Creates a new instance of @see BloomEffect
  72989. * @param scene The scene the effect belongs to.
  72990. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72991. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72992. * @param bloomWeight The the strength of bloom.
  72993. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72994. * @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)
  72995. */
  72996. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72997. /**
  72998. * Disposes each of the internal effects for a given camera.
  72999. * @param camera The camera to dispose the effect on.
  73000. */
  73001. disposeEffects(camera: Camera): void;
  73002. /**
  73003. * @hidden Internal
  73004. */
  73005. _updateEffects(): void;
  73006. /**
  73007. * Internal
  73008. * @returns if all the contained post processes are ready.
  73009. * @hidden
  73010. */
  73011. _isReady(): boolean;
  73012. }
  73013. }
  73014. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73015. /** @hidden */
  73016. export var chromaticAberrationPixelShader: {
  73017. name: string;
  73018. shader: string;
  73019. };
  73020. }
  73021. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73022. import { Vector2 } from "babylonjs/Maths/math.vector";
  73023. import { Nullable } from "babylonjs/types";
  73024. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73025. import { Camera } from "babylonjs/Cameras/camera";
  73026. import { Engine } from "babylonjs/Engines/engine";
  73027. import "babylonjs/Shaders/chromaticAberration.fragment";
  73028. import { Scene } from "babylonjs/scene";
  73029. /**
  73030. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73031. */
  73032. export class ChromaticAberrationPostProcess extends PostProcess {
  73033. /**
  73034. * The amount of seperation of rgb channels (default: 30)
  73035. */
  73036. aberrationAmount: number;
  73037. /**
  73038. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73039. */
  73040. radialIntensity: number;
  73041. /**
  73042. * 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))
  73043. */
  73044. direction: Vector2;
  73045. /**
  73046. * 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))
  73047. */
  73048. centerPosition: Vector2;
  73049. /** The width of the screen to apply the effect on */
  73050. screenWidth: number;
  73051. /** The height of the screen to apply the effect on */
  73052. screenHeight: number;
  73053. /**
  73054. * Gets a string identifying the name of the class
  73055. * @returns "ChromaticAberrationPostProcess" string
  73056. */
  73057. getClassName(): string;
  73058. /**
  73059. * Creates a new instance ChromaticAberrationPostProcess
  73060. * @param name The name of the effect.
  73061. * @param screenWidth The width of the screen to apply the effect on.
  73062. * @param screenHeight The height of the screen to apply the effect on.
  73063. * @param options The required width/height ratio to downsize to before computing the render pass.
  73064. * @param camera The camera to apply the render pass to.
  73065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73066. * @param engine The engine which the post process will be applied. (default: current engine)
  73067. * @param reusable If the post process can be reused on the same frame. (default: false)
  73068. * @param textureType Type of textures used when performing the post process. (default: 0)
  73069. * @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)
  73070. */
  73071. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73072. /** @hidden */
  73073. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73074. }
  73075. }
  73076. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73077. /** @hidden */
  73078. export var circleOfConfusionPixelShader: {
  73079. name: string;
  73080. shader: string;
  73081. };
  73082. }
  73083. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73084. import { Nullable } from "babylonjs/types";
  73085. import { Engine } from "babylonjs/Engines/engine";
  73086. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73087. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73088. import { Camera } from "babylonjs/Cameras/camera";
  73089. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73090. /**
  73091. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73092. */
  73093. export class CircleOfConfusionPostProcess extends PostProcess {
  73094. /**
  73095. * 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.
  73096. */
  73097. lensSize: number;
  73098. /**
  73099. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73100. */
  73101. fStop: number;
  73102. /**
  73103. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73104. */
  73105. focusDistance: number;
  73106. /**
  73107. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73108. */
  73109. focalLength: number;
  73110. /**
  73111. * Gets a string identifying the name of the class
  73112. * @returns "CircleOfConfusionPostProcess" string
  73113. */
  73114. getClassName(): string;
  73115. private _depthTexture;
  73116. /**
  73117. * Creates a new instance CircleOfConfusionPostProcess
  73118. * @param name The name of the effect.
  73119. * @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.
  73120. * @param options The required width/height ratio to downsize to before computing the render pass.
  73121. * @param camera The camera to apply the render pass to.
  73122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73123. * @param engine The engine which the post process will be applied. (default: current engine)
  73124. * @param reusable If the post process can be reused on the same frame. (default: false)
  73125. * @param textureType Type of textures used when performing the post process. (default: 0)
  73126. * @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)
  73127. */
  73128. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73129. /**
  73130. * 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.
  73131. */
  73132. set depthTexture(value: RenderTargetTexture);
  73133. }
  73134. }
  73135. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73136. /** @hidden */
  73137. export var colorCorrectionPixelShader: {
  73138. name: string;
  73139. shader: string;
  73140. };
  73141. }
  73142. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73143. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73144. import { Engine } from "babylonjs/Engines/engine";
  73145. import { Camera } from "babylonjs/Cameras/camera";
  73146. import "babylonjs/Shaders/colorCorrection.fragment";
  73147. import { Nullable } from "babylonjs/types";
  73148. import { Scene } from "babylonjs/scene";
  73149. /**
  73150. *
  73151. * This post-process allows the modification of rendered colors by using
  73152. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73153. *
  73154. * The object needs to be provided an url to a texture containing the color
  73155. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73156. * Use an image editing software to tweak the LUT to match your needs.
  73157. *
  73158. * For an example of a color LUT, see here:
  73159. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73160. * For explanations on color grading, see here:
  73161. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73162. *
  73163. */
  73164. export class ColorCorrectionPostProcess extends PostProcess {
  73165. private _colorTableTexture;
  73166. /**
  73167. * Gets the color table url used to create the LUT texture
  73168. */
  73169. colorTableUrl: string;
  73170. /**
  73171. * Gets a string identifying the name of the class
  73172. * @returns "ColorCorrectionPostProcess" string
  73173. */
  73174. getClassName(): string;
  73175. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73176. /** @hidden */
  73177. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73178. }
  73179. }
  73180. declare module "babylonjs/Shaders/convolution.fragment" {
  73181. /** @hidden */
  73182. export var convolutionPixelShader: {
  73183. name: string;
  73184. shader: string;
  73185. };
  73186. }
  73187. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73188. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73189. import { Nullable } from "babylonjs/types";
  73190. import { Camera } from "babylonjs/Cameras/camera";
  73191. import { Engine } from "babylonjs/Engines/engine";
  73192. import "babylonjs/Shaders/convolution.fragment";
  73193. import { Scene } from "babylonjs/scene";
  73194. /**
  73195. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73196. * input texture to perform effects such as edge detection or sharpening
  73197. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73198. */
  73199. export class ConvolutionPostProcess extends PostProcess {
  73200. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73201. kernel: number[];
  73202. /**
  73203. * Gets a string identifying the name of the class
  73204. * @returns "ConvolutionPostProcess" string
  73205. */
  73206. getClassName(): string;
  73207. /**
  73208. * Creates a new instance ConvolutionPostProcess
  73209. * @param name The name of the effect.
  73210. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73211. * @param options The required width/height ratio to downsize to before computing the render pass.
  73212. * @param camera The camera to apply the render pass to.
  73213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73214. * @param engine The engine which the post process will be applied. (default: current engine)
  73215. * @param reusable If the post process can be reused on the same frame. (default: false)
  73216. * @param textureType Type of textures used when performing the post process. (default: 0)
  73217. */
  73218. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73219. /** @hidden */
  73220. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73221. /**
  73222. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73223. */
  73224. static EdgeDetect0Kernel: number[];
  73225. /**
  73226. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73227. */
  73228. static EdgeDetect1Kernel: number[];
  73229. /**
  73230. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73231. */
  73232. static EdgeDetect2Kernel: number[];
  73233. /**
  73234. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73235. */
  73236. static SharpenKernel: number[];
  73237. /**
  73238. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73239. */
  73240. static EmbossKernel: number[];
  73241. /**
  73242. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73243. */
  73244. static GaussianKernel: number[];
  73245. }
  73246. }
  73247. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73248. import { Nullable } from "babylonjs/types";
  73249. import { Vector2 } from "babylonjs/Maths/math.vector";
  73250. import { Camera } from "babylonjs/Cameras/camera";
  73251. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73252. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73253. import { Engine } from "babylonjs/Engines/engine";
  73254. import { Scene } from "babylonjs/scene";
  73255. /**
  73256. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73257. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73258. * based on samples that have a large difference in distance than the center pixel.
  73259. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73260. */
  73261. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73262. /**
  73263. * The direction the blur should be applied
  73264. */
  73265. direction: Vector2;
  73266. /**
  73267. * Gets a string identifying the name of the class
  73268. * @returns "DepthOfFieldBlurPostProcess" string
  73269. */
  73270. getClassName(): string;
  73271. /**
  73272. * Creates a new instance CircleOfConfusionPostProcess
  73273. * @param name The name of the effect.
  73274. * @param scene The scene the effect belongs to.
  73275. * @param direction The direction the blur should be applied.
  73276. * @param kernel The size of the kernel used to blur.
  73277. * @param options The required width/height ratio to downsize to before computing the render pass.
  73278. * @param camera The camera to apply the render pass to.
  73279. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73280. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73282. * @param engine The engine which the post process will be applied. (default: current engine)
  73283. * @param reusable If the post process can be reused on the same frame. (default: false)
  73284. * @param textureType Type of textures used when performing the post process. (default: 0)
  73285. * @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)
  73286. */
  73287. 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);
  73288. }
  73289. }
  73290. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73291. /** @hidden */
  73292. export var depthOfFieldMergePixelShader: {
  73293. name: string;
  73294. shader: string;
  73295. };
  73296. }
  73297. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73298. import { Nullable } from "babylonjs/types";
  73299. import { Camera } from "babylonjs/Cameras/camera";
  73300. import { Effect } from "babylonjs/Materials/effect";
  73301. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73302. import { Engine } from "babylonjs/Engines/engine";
  73303. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73304. /**
  73305. * Options to be set when merging outputs from the default pipeline.
  73306. */
  73307. export class DepthOfFieldMergePostProcessOptions {
  73308. /**
  73309. * The original image to merge on top of
  73310. */
  73311. originalFromInput: PostProcess;
  73312. /**
  73313. * Parameters to perform the merge of the depth of field effect
  73314. */
  73315. depthOfField?: {
  73316. circleOfConfusion: PostProcess;
  73317. blurSteps: Array<PostProcess>;
  73318. };
  73319. /**
  73320. * Parameters to perform the merge of bloom effect
  73321. */
  73322. bloom?: {
  73323. blurred: PostProcess;
  73324. weight: number;
  73325. };
  73326. }
  73327. /**
  73328. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73329. */
  73330. export class DepthOfFieldMergePostProcess extends PostProcess {
  73331. private blurSteps;
  73332. /**
  73333. * Gets a string identifying the name of the class
  73334. * @returns "DepthOfFieldMergePostProcess" string
  73335. */
  73336. getClassName(): string;
  73337. /**
  73338. * Creates a new instance of DepthOfFieldMergePostProcess
  73339. * @param name The name of the effect.
  73340. * @param originalFromInput Post process which's input will be used for the merge.
  73341. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73342. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73343. * @param options The required width/height ratio to downsize to before computing the render pass.
  73344. * @param camera The camera to apply the render pass to.
  73345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73346. * @param engine The engine which the post process will be applied. (default: current engine)
  73347. * @param reusable If the post process can be reused on the same frame. (default: false)
  73348. * @param textureType Type of textures used when performing the post process. (default: 0)
  73349. * @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)
  73350. */
  73351. 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);
  73352. /**
  73353. * Updates the effect with the current post process compile time values and recompiles the shader.
  73354. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73355. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73356. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73357. * @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
  73358. * @param onCompiled Called when the shader has been compiled.
  73359. * @param onError Called if there is an error when compiling a shader.
  73360. */
  73361. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73362. }
  73363. }
  73364. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73365. import { Nullable } from "babylonjs/types";
  73366. import { Camera } from "babylonjs/Cameras/camera";
  73367. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73368. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73369. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73370. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73371. import { Scene } from "babylonjs/scene";
  73372. /**
  73373. * Specifies the level of max blur that should be applied when using the depth of field effect
  73374. */
  73375. export enum DepthOfFieldEffectBlurLevel {
  73376. /**
  73377. * Subtle blur
  73378. */
  73379. Low = 0,
  73380. /**
  73381. * Medium blur
  73382. */
  73383. Medium = 1,
  73384. /**
  73385. * Large blur
  73386. */
  73387. High = 2
  73388. }
  73389. /**
  73390. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73391. */
  73392. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73393. private _circleOfConfusion;
  73394. /**
  73395. * @hidden Internal, blurs from high to low
  73396. */
  73397. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73398. private _depthOfFieldBlurY;
  73399. private _dofMerge;
  73400. /**
  73401. * @hidden Internal post processes in depth of field effect
  73402. */
  73403. _effects: Array<PostProcess>;
  73404. /**
  73405. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73406. */
  73407. set focalLength(value: number);
  73408. get focalLength(): number;
  73409. /**
  73410. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73411. */
  73412. set fStop(value: number);
  73413. get fStop(): number;
  73414. /**
  73415. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73416. */
  73417. set focusDistance(value: number);
  73418. get focusDistance(): number;
  73419. /**
  73420. * 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.
  73421. */
  73422. set lensSize(value: number);
  73423. get lensSize(): number;
  73424. /**
  73425. * Creates a new instance DepthOfFieldEffect
  73426. * @param scene The scene the effect belongs to.
  73427. * @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.
  73428. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73429. * @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)
  73430. */
  73431. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73432. /**
  73433. * Get the current class name of the current effet
  73434. * @returns "DepthOfFieldEffect"
  73435. */
  73436. getClassName(): string;
  73437. /**
  73438. * 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.
  73439. */
  73440. set depthTexture(value: RenderTargetTexture);
  73441. /**
  73442. * Disposes each of the internal effects for a given camera.
  73443. * @param camera The camera to dispose the effect on.
  73444. */
  73445. disposeEffects(camera: Camera): void;
  73446. /**
  73447. * @hidden Internal
  73448. */
  73449. _updateEffects(): void;
  73450. /**
  73451. * Internal
  73452. * @returns if all the contained post processes are ready.
  73453. * @hidden
  73454. */
  73455. _isReady(): boolean;
  73456. }
  73457. }
  73458. declare module "babylonjs/Shaders/displayPass.fragment" {
  73459. /** @hidden */
  73460. export var displayPassPixelShader: {
  73461. name: string;
  73462. shader: string;
  73463. };
  73464. }
  73465. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73466. import { Nullable } from "babylonjs/types";
  73467. import { Camera } from "babylonjs/Cameras/camera";
  73468. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73469. import { Engine } from "babylonjs/Engines/engine";
  73470. import "babylonjs/Shaders/displayPass.fragment";
  73471. import { Scene } from "babylonjs/scene";
  73472. /**
  73473. * DisplayPassPostProcess which produces an output the same as it's input
  73474. */
  73475. export class DisplayPassPostProcess extends PostProcess {
  73476. /**
  73477. * Gets a string identifying the name of the class
  73478. * @returns "DisplayPassPostProcess" string
  73479. */
  73480. getClassName(): string;
  73481. /**
  73482. * Creates the DisplayPassPostProcess
  73483. * @param name The name of the effect.
  73484. * @param options The required width/height ratio to downsize to before computing the render pass.
  73485. * @param camera The camera to apply the render pass to.
  73486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73487. * @param engine The engine which the post process will be applied. (default: current engine)
  73488. * @param reusable If the post process can be reused on the same frame. (default: false)
  73489. */
  73490. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73491. /** @hidden */
  73492. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73493. }
  73494. }
  73495. declare module "babylonjs/Shaders/filter.fragment" {
  73496. /** @hidden */
  73497. export var filterPixelShader: {
  73498. name: string;
  73499. shader: string;
  73500. };
  73501. }
  73502. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73503. import { Nullable } from "babylonjs/types";
  73504. import { Matrix } from "babylonjs/Maths/math.vector";
  73505. import { Camera } from "babylonjs/Cameras/camera";
  73506. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73507. import { Engine } from "babylonjs/Engines/engine";
  73508. import "babylonjs/Shaders/filter.fragment";
  73509. import { Scene } from "babylonjs/scene";
  73510. /**
  73511. * Applies a kernel filter to the image
  73512. */
  73513. export class FilterPostProcess extends PostProcess {
  73514. /** The matrix to be applied to the image */
  73515. kernelMatrix: Matrix;
  73516. /**
  73517. * Gets a string identifying the name of the class
  73518. * @returns "FilterPostProcess" string
  73519. */
  73520. getClassName(): string;
  73521. /**
  73522. *
  73523. * @param name The name of the effect.
  73524. * @param kernelMatrix The matrix to be applied to the image
  73525. * @param options The required width/height ratio to downsize to before computing the render pass.
  73526. * @param camera The camera to apply the render pass to.
  73527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73528. * @param engine The engine which the post process will be applied. (default: current engine)
  73529. * @param reusable If the post process can be reused on the same frame. (default: false)
  73530. */
  73531. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73532. /** @hidden */
  73533. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73534. }
  73535. }
  73536. declare module "babylonjs/Shaders/fxaa.fragment" {
  73537. /** @hidden */
  73538. export var fxaaPixelShader: {
  73539. name: string;
  73540. shader: string;
  73541. };
  73542. }
  73543. declare module "babylonjs/Shaders/fxaa.vertex" {
  73544. /** @hidden */
  73545. export var fxaaVertexShader: {
  73546. name: string;
  73547. shader: string;
  73548. };
  73549. }
  73550. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73551. import { Nullable } from "babylonjs/types";
  73552. import { Camera } from "babylonjs/Cameras/camera";
  73553. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73554. import { Engine } from "babylonjs/Engines/engine";
  73555. import "babylonjs/Shaders/fxaa.fragment";
  73556. import "babylonjs/Shaders/fxaa.vertex";
  73557. import { Scene } from "babylonjs/scene";
  73558. /**
  73559. * Fxaa post process
  73560. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73561. */
  73562. export class FxaaPostProcess extends PostProcess {
  73563. /**
  73564. * Gets a string identifying the name of the class
  73565. * @returns "FxaaPostProcess" string
  73566. */
  73567. getClassName(): string;
  73568. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73569. private _getDefines;
  73570. /** @hidden */
  73571. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73572. }
  73573. }
  73574. declare module "babylonjs/Shaders/grain.fragment" {
  73575. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73576. /** @hidden */
  73577. export var grainPixelShader: {
  73578. name: string;
  73579. shader: string;
  73580. };
  73581. }
  73582. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73583. import { Nullable } from "babylonjs/types";
  73584. import { Camera } from "babylonjs/Cameras/camera";
  73585. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73586. import { Engine } from "babylonjs/Engines/engine";
  73587. import "babylonjs/Shaders/grain.fragment";
  73588. import { Scene } from "babylonjs/scene";
  73589. /**
  73590. * The GrainPostProcess adds noise to the image at mid luminance levels
  73591. */
  73592. export class GrainPostProcess extends PostProcess {
  73593. /**
  73594. * The intensity of the grain added (default: 30)
  73595. */
  73596. intensity: number;
  73597. /**
  73598. * If the grain should be randomized on every frame
  73599. */
  73600. animated: boolean;
  73601. /**
  73602. * Gets a string identifying the name of the class
  73603. * @returns "GrainPostProcess" string
  73604. */
  73605. getClassName(): string;
  73606. /**
  73607. * Creates a new instance of @see GrainPostProcess
  73608. * @param name The name of the effect.
  73609. * @param options The required width/height ratio to downsize to before computing the render pass.
  73610. * @param camera The camera to apply the render pass to.
  73611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73612. * @param engine The engine which the post process will be applied. (default: current engine)
  73613. * @param reusable If the post process can be reused on the same frame. (default: false)
  73614. * @param textureType Type of textures used when performing the post process. (default: 0)
  73615. * @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)
  73616. */
  73617. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73618. /** @hidden */
  73619. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73620. }
  73621. }
  73622. declare module "babylonjs/Shaders/highlights.fragment" {
  73623. /** @hidden */
  73624. export var highlightsPixelShader: {
  73625. name: string;
  73626. shader: string;
  73627. };
  73628. }
  73629. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73630. import { Nullable } from "babylonjs/types";
  73631. import { Camera } from "babylonjs/Cameras/camera";
  73632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73633. import { Engine } from "babylonjs/Engines/engine";
  73634. import "babylonjs/Shaders/highlights.fragment";
  73635. /**
  73636. * Extracts highlights from the image
  73637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73638. */
  73639. export class HighlightsPostProcess extends PostProcess {
  73640. /**
  73641. * Gets a string identifying the name of the class
  73642. * @returns "HighlightsPostProcess" string
  73643. */
  73644. getClassName(): string;
  73645. /**
  73646. * Extracts highlights from the image
  73647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73648. * @param name The name of the effect.
  73649. * @param options The required width/height ratio to downsize to before computing the render pass.
  73650. * @param camera The camera to apply the render pass to.
  73651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73652. * @param engine The engine which the post process will be applied. (default: current engine)
  73653. * @param reusable If the post process can be reused on the same frame. (default: false)
  73654. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73655. */
  73656. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73657. }
  73658. }
  73659. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73660. /** @hidden */
  73661. export var mrtFragmentDeclaration: {
  73662. name: string;
  73663. shader: string;
  73664. };
  73665. }
  73666. declare module "babylonjs/Shaders/geometry.fragment" {
  73667. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73668. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73669. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73670. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73671. /** @hidden */
  73672. export var geometryPixelShader: {
  73673. name: string;
  73674. shader: string;
  73675. };
  73676. }
  73677. declare module "babylonjs/Shaders/geometry.vertex" {
  73678. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73679. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73680. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73681. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73682. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73683. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73684. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73685. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73686. /** @hidden */
  73687. export var geometryVertexShader: {
  73688. name: string;
  73689. shader: string;
  73690. };
  73691. }
  73692. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73693. import { Matrix } from "babylonjs/Maths/math.vector";
  73694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73695. import { Mesh } from "babylonjs/Meshes/mesh";
  73696. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73697. import { Effect } from "babylonjs/Materials/effect";
  73698. import { Scene } from "babylonjs/scene";
  73699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73700. import "babylonjs/Shaders/geometry.fragment";
  73701. import "babylonjs/Shaders/geometry.vertex";
  73702. /** @hidden */
  73703. interface ISavedTransformationMatrix {
  73704. world: Matrix;
  73705. viewProjection: Matrix;
  73706. }
  73707. /**
  73708. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73709. */
  73710. export class GeometryBufferRenderer {
  73711. /**
  73712. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73713. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73714. */
  73715. static readonly POSITION_TEXTURE_TYPE: number;
  73716. /**
  73717. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73718. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73719. */
  73720. static readonly VELOCITY_TEXTURE_TYPE: number;
  73721. /**
  73722. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73723. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73724. */
  73725. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73726. /**
  73727. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73728. * in order to compute objects velocities when enableVelocity is set to "true"
  73729. * @hidden
  73730. */
  73731. _previousTransformationMatrices: {
  73732. [index: number]: ISavedTransformationMatrix;
  73733. };
  73734. /**
  73735. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73736. * in order to compute objects velocities when enableVelocity is set to "true"
  73737. * @hidden
  73738. */
  73739. _previousBonesTransformationMatrices: {
  73740. [index: number]: Float32Array;
  73741. };
  73742. /**
  73743. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73744. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73745. */
  73746. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73747. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73748. renderTransparentMeshes: boolean;
  73749. private _scene;
  73750. private _resizeObserver;
  73751. private _multiRenderTarget;
  73752. private _ratio;
  73753. private _enablePosition;
  73754. private _enableVelocity;
  73755. private _enableReflectivity;
  73756. private _positionIndex;
  73757. private _velocityIndex;
  73758. private _reflectivityIndex;
  73759. protected _effect: Effect;
  73760. protected _cachedDefines: string;
  73761. /**
  73762. * Set the render list (meshes to be rendered) used in the G buffer.
  73763. */
  73764. set renderList(meshes: Mesh[]);
  73765. /**
  73766. * Gets wether or not G buffer are supported by the running hardware.
  73767. * This requires draw buffer supports
  73768. */
  73769. get isSupported(): boolean;
  73770. /**
  73771. * Returns the index of the given texture type in the G-Buffer textures array
  73772. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73773. * @returns the index of the given texture type in the G-Buffer textures array
  73774. */
  73775. getTextureIndex(textureType: number): number;
  73776. /**
  73777. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73778. */
  73779. get enablePosition(): boolean;
  73780. /**
  73781. * Sets whether or not objects positions are enabled for the G buffer.
  73782. */
  73783. set enablePosition(enable: boolean);
  73784. /**
  73785. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73786. */
  73787. get enableVelocity(): boolean;
  73788. /**
  73789. * Sets wether or not objects velocities are enabled for the G buffer.
  73790. */
  73791. set enableVelocity(enable: boolean);
  73792. /**
  73793. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73794. */
  73795. get enableReflectivity(): boolean;
  73796. /**
  73797. * Sets wether or not objects roughness are enabled for the G buffer.
  73798. */
  73799. set enableReflectivity(enable: boolean);
  73800. /**
  73801. * Gets the scene associated with the buffer.
  73802. */
  73803. get scene(): Scene;
  73804. /**
  73805. * Gets the ratio used by the buffer during its creation.
  73806. * How big is the buffer related to the main canvas.
  73807. */
  73808. get ratio(): number;
  73809. /** @hidden */
  73810. static _SceneComponentInitialization: (scene: Scene) => void;
  73811. /**
  73812. * Creates a new G Buffer for the scene
  73813. * @param scene The scene the buffer belongs to
  73814. * @param ratio How big is the buffer related to the main canvas.
  73815. */
  73816. constructor(scene: Scene, ratio?: number);
  73817. /**
  73818. * Checks wether everything is ready to render a submesh to the G buffer.
  73819. * @param subMesh the submesh to check readiness for
  73820. * @param useInstances is the mesh drawn using instance or not
  73821. * @returns true if ready otherwise false
  73822. */
  73823. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73824. /**
  73825. * Gets the current underlying G Buffer.
  73826. * @returns the buffer
  73827. */
  73828. getGBuffer(): MultiRenderTarget;
  73829. /**
  73830. * Gets the number of samples used to render the buffer (anti aliasing).
  73831. */
  73832. get samples(): number;
  73833. /**
  73834. * Sets the number of samples used to render the buffer (anti aliasing).
  73835. */
  73836. set samples(value: number);
  73837. /**
  73838. * Disposes the renderer and frees up associated resources.
  73839. */
  73840. dispose(): void;
  73841. protected _createRenderTargets(): void;
  73842. private _copyBonesTransformationMatrices;
  73843. }
  73844. }
  73845. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73846. import { Nullable } from "babylonjs/types";
  73847. import { Scene } from "babylonjs/scene";
  73848. import { ISceneComponent } from "babylonjs/sceneComponent";
  73849. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73850. module "babylonjs/scene" {
  73851. interface Scene {
  73852. /** @hidden (Backing field) */
  73853. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73854. /**
  73855. * Gets or Sets the current geometry buffer associated to the scene.
  73856. */
  73857. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73858. /**
  73859. * Enables a GeometryBufferRender and associates it with the scene
  73860. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73861. * @returns the GeometryBufferRenderer
  73862. */
  73863. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73864. /**
  73865. * Disables the GeometryBufferRender associated with the scene
  73866. */
  73867. disableGeometryBufferRenderer(): void;
  73868. }
  73869. }
  73870. /**
  73871. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73872. * in several rendering techniques.
  73873. */
  73874. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73875. /**
  73876. * The component name helpful to identify the component in the list of scene components.
  73877. */
  73878. readonly name: string;
  73879. /**
  73880. * The scene the component belongs to.
  73881. */
  73882. scene: Scene;
  73883. /**
  73884. * Creates a new instance of the component for the given scene
  73885. * @param scene Defines the scene to register the component in
  73886. */
  73887. constructor(scene: Scene);
  73888. /**
  73889. * Registers the component in a given scene
  73890. */
  73891. register(): void;
  73892. /**
  73893. * Rebuilds the elements related to this component in case of
  73894. * context lost for instance.
  73895. */
  73896. rebuild(): void;
  73897. /**
  73898. * Disposes the component and the associated ressources
  73899. */
  73900. dispose(): void;
  73901. private _gatherRenderTargets;
  73902. }
  73903. }
  73904. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73905. /** @hidden */
  73906. export var motionBlurPixelShader: {
  73907. name: string;
  73908. shader: string;
  73909. };
  73910. }
  73911. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73912. import { Nullable } from "babylonjs/types";
  73913. import { Camera } from "babylonjs/Cameras/camera";
  73914. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73916. import "babylonjs/Animations/animatable";
  73917. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73918. import "babylonjs/Shaders/motionBlur.fragment";
  73919. import { Engine } from "babylonjs/Engines/engine";
  73920. import { Scene } from "babylonjs/scene";
  73921. /**
  73922. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73923. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73924. * As an example, all you have to do is to create the post-process:
  73925. * var mb = new BABYLON.MotionBlurPostProcess(
  73926. * 'mb', // The name of the effect.
  73927. * scene, // The scene containing the objects to blur according to their velocity.
  73928. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73929. * camera // The camera to apply the render pass to.
  73930. * );
  73931. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73932. */
  73933. export class MotionBlurPostProcess extends PostProcess {
  73934. /**
  73935. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73936. */
  73937. motionStrength: number;
  73938. /**
  73939. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73940. */
  73941. get motionBlurSamples(): number;
  73942. /**
  73943. * Sets the number of iterations to be used for motion blur quality
  73944. */
  73945. set motionBlurSamples(samples: number);
  73946. private _motionBlurSamples;
  73947. private _geometryBufferRenderer;
  73948. /**
  73949. * Gets a string identifying the name of the class
  73950. * @returns "MotionBlurPostProcess" string
  73951. */
  73952. getClassName(): string;
  73953. /**
  73954. * Creates a new instance MotionBlurPostProcess
  73955. * @param name The name of the effect.
  73956. * @param scene The scene containing the objects to blur according to their velocity.
  73957. * @param options The required width/height ratio to downsize to before computing the render pass.
  73958. * @param camera The camera to apply the render pass to.
  73959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73960. * @param engine The engine which the post process will be applied. (default: current engine)
  73961. * @param reusable If the post process can be reused on the same frame. (default: false)
  73962. * @param textureType Type of textures used when performing the post process. (default: 0)
  73963. * @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)
  73964. */
  73965. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73966. /**
  73967. * Excludes the given skinned mesh from computing bones velocities.
  73968. * 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.
  73969. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73970. */
  73971. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73972. /**
  73973. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73974. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73975. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73976. */
  73977. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73978. /**
  73979. * Disposes the post process.
  73980. * @param camera The camera to dispose the post process on.
  73981. */
  73982. dispose(camera?: Camera): void;
  73983. /** @hidden */
  73984. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73985. }
  73986. }
  73987. declare module "babylonjs/Shaders/refraction.fragment" {
  73988. /** @hidden */
  73989. export var refractionPixelShader: {
  73990. name: string;
  73991. shader: string;
  73992. };
  73993. }
  73994. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73995. import { Color3 } from "babylonjs/Maths/math.color";
  73996. import { Camera } from "babylonjs/Cameras/camera";
  73997. import { Texture } from "babylonjs/Materials/Textures/texture";
  73998. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73999. import { Engine } from "babylonjs/Engines/engine";
  74000. import "babylonjs/Shaders/refraction.fragment";
  74001. import { Scene } from "babylonjs/scene";
  74002. /**
  74003. * Post process which applies a refractin texture
  74004. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74005. */
  74006. export class RefractionPostProcess extends PostProcess {
  74007. private _refTexture;
  74008. private _ownRefractionTexture;
  74009. /** the base color of the refraction (used to taint the rendering) */
  74010. color: Color3;
  74011. /** simulated refraction depth */
  74012. depth: number;
  74013. /** the coefficient of the base color (0 to remove base color tainting) */
  74014. colorLevel: number;
  74015. /** Gets the url used to load the refraction texture */
  74016. refractionTextureUrl: string;
  74017. /**
  74018. * Gets or sets the refraction texture
  74019. * Please note that you are responsible for disposing the texture if you set it manually
  74020. */
  74021. get refractionTexture(): Texture;
  74022. set refractionTexture(value: Texture);
  74023. /**
  74024. * Gets a string identifying the name of the class
  74025. * @returns "RefractionPostProcess" string
  74026. */
  74027. getClassName(): string;
  74028. /**
  74029. * Initializes the RefractionPostProcess
  74030. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74031. * @param name The name of the effect.
  74032. * @param refractionTextureUrl Url of the refraction texture to use
  74033. * @param color the base color of the refraction (used to taint the rendering)
  74034. * @param depth simulated refraction depth
  74035. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74036. * @param camera The camera to apply the render pass to.
  74037. * @param options The required width/height ratio to downsize to before computing the render pass.
  74038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74039. * @param engine The engine which the post process will be applied. (default: current engine)
  74040. * @param reusable If the post process can be reused on the same frame. (default: false)
  74041. */
  74042. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74043. /**
  74044. * Disposes of the post process
  74045. * @param camera Camera to dispose post process on
  74046. */
  74047. dispose(camera: Camera): void;
  74048. /** @hidden */
  74049. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74050. }
  74051. }
  74052. declare module "babylonjs/Shaders/sharpen.fragment" {
  74053. /** @hidden */
  74054. export var sharpenPixelShader: {
  74055. name: string;
  74056. shader: string;
  74057. };
  74058. }
  74059. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74060. import { Nullable } from "babylonjs/types";
  74061. import { Camera } from "babylonjs/Cameras/camera";
  74062. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74063. import "babylonjs/Shaders/sharpen.fragment";
  74064. import { Engine } from "babylonjs/Engines/engine";
  74065. import { Scene } from "babylonjs/scene";
  74066. /**
  74067. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74068. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74069. */
  74070. export class SharpenPostProcess extends PostProcess {
  74071. /**
  74072. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74073. */
  74074. colorAmount: number;
  74075. /**
  74076. * How much sharpness should be applied (default: 0.3)
  74077. */
  74078. edgeAmount: number;
  74079. /**
  74080. * Gets a string identifying the name of the class
  74081. * @returns "SharpenPostProcess" string
  74082. */
  74083. getClassName(): string;
  74084. /**
  74085. * Creates a new instance ConvolutionPostProcess
  74086. * @param name The name of the effect.
  74087. * @param options The required width/height ratio to downsize to before computing the render pass.
  74088. * @param camera The camera to apply the render pass to.
  74089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74090. * @param engine The engine which the post process will be applied. (default: current engine)
  74091. * @param reusable If the post process can be reused on the same frame. (default: false)
  74092. * @param textureType Type of textures used when performing the post process. (default: 0)
  74093. * @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)
  74094. */
  74095. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74096. /** @hidden */
  74097. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74098. }
  74099. }
  74100. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74101. import { Nullable } from "babylonjs/types";
  74102. import { Camera } from "babylonjs/Cameras/camera";
  74103. import { Engine } from "babylonjs/Engines/engine";
  74104. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74105. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74106. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74107. /**
  74108. * PostProcessRenderPipeline
  74109. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74110. */
  74111. export class PostProcessRenderPipeline {
  74112. private engine;
  74113. private _renderEffects;
  74114. private _renderEffectsForIsolatedPass;
  74115. /**
  74116. * List of inspectable custom properties (used by the Inspector)
  74117. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74118. */
  74119. inspectableCustomProperties: IInspectable[];
  74120. /**
  74121. * @hidden
  74122. */
  74123. protected _cameras: Camera[];
  74124. /** @hidden */
  74125. _name: string;
  74126. /**
  74127. * Gets pipeline name
  74128. */
  74129. get name(): string;
  74130. /** Gets the list of attached cameras */
  74131. get cameras(): Camera[];
  74132. /**
  74133. * Initializes a PostProcessRenderPipeline
  74134. * @param engine engine to add the pipeline to
  74135. * @param name name of the pipeline
  74136. */
  74137. constructor(engine: Engine, name: string);
  74138. /**
  74139. * Gets the class name
  74140. * @returns "PostProcessRenderPipeline"
  74141. */
  74142. getClassName(): string;
  74143. /**
  74144. * If all the render effects in the pipeline are supported
  74145. */
  74146. get isSupported(): boolean;
  74147. /**
  74148. * Adds an effect to the pipeline
  74149. * @param renderEffect the effect to add
  74150. */
  74151. addEffect(renderEffect: PostProcessRenderEffect): void;
  74152. /** @hidden */
  74153. _rebuild(): void;
  74154. /** @hidden */
  74155. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74156. /** @hidden */
  74157. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74158. /** @hidden */
  74159. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74160. /** @hidden */
  74161. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74162. /** @hidden */
  74163. _attachCameras(cameras: Camera, unique: boolean): void;
  74164. /** @hidden */
  74165. _attachCameras(cameras: Camera[], unique: boolean): void;
  74166. /** @hidden */
  74167. _detachCameras(cameras: Camera): void;
  74168. /** @hidden */
  74169. _detachCameras(cameras: Nullable<Camera[]>): void;
  74170. /** @hidden */
  74171. _update(): void;
  74172. /** @hidden */
  74173. _reset(): void;
  74174. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74175. /**
  74176. * Sets the required values to the prepass renderer.
  74177. * @param prePassRenderer defines the prepass renderer to setup.
  74178. * @returns true if the pre pass is needed.
  74179. */
  74180. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74181. /**
  74182. * Disposes of the pipeline
  74183. */
  74184. dispose(): void;
  74185. }
  74186. }
  74187. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74188. import { Camera } from "babylonjs/Cameras/camera";
  74189. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74190. /**
  74191. * PostProcessRenderPipelineManager class
  74192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74193. */
  74194. export class PostProcessRenderPipelineManager {
  74195. private _renderPipelines;
  74196. /**
  74197. * Initializes a PostProcessRenderPipelineManager
  74198. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74199. */
  74200. constructor();
  74201. /**
  74202. * Gets the list of supported render pipelines
  74203. */
  74204. get supportedPipelines(): PostProcessRenderPipeline[];
  74205. /**
  74206. * Adds a pipeline to the manager
  74207. * @param renderPipeline The pipeline to add
  74208. */
  74209. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74210. /**
  74211. * Attaches a camera to the pipeline
  74212. * @param renderPipelineName The name of the pipeline to attach to
  74213. * @param cameras the camera to attach
  74214. * @param unique if the camera can be attached multiple times to the pipeline
  74215. */
  74216. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74217. /**
  74218. * Detaches a camera from the pipeline
  74219. * @param renderPipelineName The name of the pipeline to detach from
  74220. * @param cameras the camera to detach
  74221. */
  74222. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74223. /**
  74224. * Enables an effect by name on a pipeline
  74225. * @param renderPipelineName the name of the pipeline to enable the effect in
  74226. * @param renderEffectName the name of the effect to enable
  74227. * @param cameras the cameras that the effect should be enabled on
  74228. */
  74229. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74230. /**
  74231. * Disables an effect by name on a pipeline
  74232. * @param renderPipelineName the name of the pipeline to disable the effect in
  74233. * @param renderEffectName the name of the effect to disable
  74234. * @param cameras the cameras that the effect should be disabled on
  74235. */
  74236. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74237. /**
  74238. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74239. */
  74240. update(): void;
  74241. /** @hidden */
  74242. _rebuild(): void;
  74243. /**
  74244. * Disposes of the manager and pipelines
  74245. */
  74246. dispose(): void;
  74247. }
  74248. }
  74249. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74250. import { ISceneComponent } from "babylonjs/sceneComponent";
  74251. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74252. import { Scene } from "babylonjs/scene";
  74253. module "babylonjs/scene" {
  74254. interface Scene {
  74255. /** @hidden (Backing field) */
  74256. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74257. /**
  74258. * Gets the postprocess render pipeline manager
  74259. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74260. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74261. */
  74262. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74263. }
  74264. }
  74265. /**
  74266. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74267. */
  74268. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74269. /**
  74270. * The component name helpfull to identify the component in the list of scene components.
  74271. */
  74272. readonly name: string;
  74273. /**
  74274. * The scene the component belongs to.
  74275. */
  74276. scene: Scene;
  74277. /**
  74278. * Creates a new instance of the component for the given scene
  74279. * @param scene Defines the scene to register the component in
  74280. */
  74281. constructor(scene: Scene);
  74282. /**
  74283. * Registers the component in a given scene
  74284. */
  74285. register(): void;
  74286. /**
  74287. * Rebuilds the elements related to this component in case of
  74288. * context lost for instance.
  74289. */
  74290. rebuild(): void;
  74291. /**
  74292. * Disposes the component and the associated ressources
  74293. */
  74294. dispose(): void;
  74295. private _gatherRenderTargets;
  74296. }
  74297. }
  74298. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74299. import { Nullable } from "babylonjs/types";
  74300. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74301. import { Camera } from "babylonjs/Cameras/camera";
  74302. import { IDisposable } from "babylonjs/scene";
  74303. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74304. import { Scene } from "babylonjs/scene";
  74305. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74306. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74307. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74308. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74309. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74310. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74311. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74312. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74313. import { Animation } from "babylonjs/Animations/animation";
  74314. /**
  74315. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74316. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74317. */
  74318. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74319. private _scene;
  74320. private _camerasToBeAttached;
  74321. /**
  74322. * ID of the sharpen post process,
  74323. */
  74324. private readonly SharpenPostProcessId;
  74325. /**
  74326. * @ignore
  74327. * ID of the image processing post process;
  74328. */
  74329. readonly ImageProcessingPostProcessId: string;
  74330. /**
  74331. * @ignore
  74332. * ID of the Fast Approximate Anti-Aliasing post process;
  74333. */
  74334. readonly FxaaPostProcessId: string;
  74335. /**
  74336. * ID of the chromatic aberration post process,
  74337. */
  74338. private readonly ChromaticAberrationPostProcessId;
  74339. /**
  74340. * ID of the grain post process
  74341. */
  74342. private readonly GrainPostProcessId;
  74343. /**
  74344. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74345. */
  74346. sharpen: SharpenPostProcess;
  74347. private _sharpenEffect;
  74348. private bloom;
  74349. /**
  74350. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74351. */
  74352. depthOfField: DepthOfFieldEffect;
  74353. /**
  74354. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74355. */
  74356. fxaa: FxaaPostProcess;
  74357. /**
  74358. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74359. */
  74360. imageProcessing: ImageProcessingPostProcess;
  74361. /**
  74362. * Chromatic aberration post process which will shift rgb colors in the image
  74363. */
  74364. chromaticAberration: ChromaticAberrationPostProcess;
  74365. private _chromaticAberrationEffect;
  74366. /**
  74367. * Grain post process which add noise to the image
  74368. */
  74369. grain: GrainPostProcess;
  74370. private _grainEffect;
  74371. /**
  74372. * Glow post process which adds a glow to emissive areas of the image
  74373. */
  74374. private _glowLayer;
  74375. /**
  74376. * Animations which can be used to tweak settings over a period of time
  74377. */
  74378. animations: Animation[];
  74379. private _imageProcessingConfigurationObserver;
  74380. private _sharpenEnabled;
  74381. private _bloomEnabled;
  74382. private _depthOfFieldEnabled;
  74383. private _depthOfFieldBlurLevel;
  74384. private _fxaaEnabled;
  74385. private _imageProcessingEnabled;
  74386. private _defaultPipelineTextureType;
  74387. private _bloomScale;
  74388. private _chromaticAberrationEnabled;
  74389. private _grainEnabled;
  74390. private _buildAllowed;
  74391. /**
  74392. * Gets active scene
  74393. */
  74394. get scene(): Scene;
  74395. /**
  74396. * Enable or disable the sharpen process from the pipeline
  74397. */
  74398. set sharpenEnabled(enabled: boolean);
  74399. get sharpenEnabled(): boolean;
  74400. private _resizeObserver;
  74401. private _hardwareScaleLevel;
  74402. private _bloomKernel;
  74403. /**
  74404. * Specifies the size of the bloom blur kernel, relative to the final output size
  74405. */
  74406. get bloomKernel(): number;
  74407. set bloomKernel(value: number);
  74408. /**
  74409. * Specifies the weight of the bloom in the final rendering
  74410. */
  74411. private _bloomWeight;
  74412. /**
  74413. * Specifies the luma threshold for the area that will be blurred by the bloom
  74414. */
  74415. private _bloomThreshold;
  74416. private _hdr;
  74417. /**
  74418. * The strength of the bloom.
  74419. */
  74420. set bloomWeight(value: number);
  74421. get bloomWeight(): number;
  74422. /**
  74423. * The strength of the bloom.
  74424. */
  74425. set bloomThreshold(value: number);
  74426. get bloomThreshold(): number;
  74427. /**
  74428. * The scale of the bloom, lower value will provide better performance.
  74429. */
  74430. set bloomScale(value: number);
  74431. get bloomScale(): number;
  74432. /**
  74433. * Enable or disable the bloom from the pipeline
  74434. */
  74435. set bloomEnabled(enabled: boolean);
  74436. get bloomEnabled(): boolean;
  74437. private _rebuildBloom;
  74438. /**
  74439. * If the depth of field is enabled.
  74440. */
  74441. get depthOfFieldEnabled(): boolean;
  74442. set depthOfFieldEnabled(enabled: boolean);
  74443. /**
  74444. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74445. */
  74446. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74447. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74448. /**
  74449. * If the anti aliasing is enabled.
  74450. */
  74451. set fxaaEnabled(enabled: boolean);
  74452. get fxaaEnabled(): boolean;
  74453. private _samples;
  74454. /**
  74455. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74456. */
  74457. set samples(sampleCount: number);
  74458. get samples(): number;
  74459. /**
  74460. * If image processing is enabled.
  74461. */
  74462. set imageProcessingEnabled(enabled: boolean);
  74463. get imageProcessingEnabled(): boolean;
  74464. /**
  74465. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74466. */
  74467. set glowLayerEnabled(enabled: boolean);
  74468. get glowLayerEnabled(): boolean;
  74469. /**
  74470. * Gets the glow layer (or null if not defined)
  74471. */
  74472. get glowLayer(): Nullable<GlowLayer>;
  74473. /**
  74474. * Enable or disable the chromaticAberration process from the pipeline
  74475. */
  74476. set chromaticAberrationEnabled(enabled: boolean);
  74477. get chromaticAberrationEnabled(): boolean;
  74478. /**
  74479. * Enable or disable the grain process from the pipeline
  74480. */
  74481. set grainEnabled(enabled: boolean);
  74482. get grainEnabled(): boolean;
  74483. /**
  74484. * @constructor
  74485. * @param name - The rendering pipeline name (default: "")
  74486. * @param hdr - If high dynamic range textures should be used (default: true)
  74487. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74488. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74489. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74490. */
  74491. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74492. /**
  74493. * Get the class name
  74494. * @returns "DefaultRenderingPipeline"
  74495. */
  74496. getClassName(): string;
  74497. /**
  74498. * Force the compilation of the entire pipeline.
  74499. */
  74500. prepare(): void;
  74501. private _hasCleared;
  74502. private _prevPostProcess;
  74503. private _prevPrevPostProcess;
  74504. private _setAutoClearAndTextureSharing;
  74505. private _depthOfFieldSceneObserver;
  74506. private _buildPipeline;
  74507. private _disposePostProcesses;
  74508. /**
  74509. * Adds a camera to the pipeline
  74510. * @param camera the camera to be added
  74511. */
  74512. addCamera(camera: Camera): void;
  74513. /**
  74514. * Removes a camera from the pipeline
  74515. * @param camera the camera to remove
  74516. */
  74517. removeCamera(camera: Camera): void;
  74518. /**
  74519. * Dispose of the pipeline and stop all post processes
  74520. */
  74521. dispose(): void;
  74522. /**
  74523. * Serialize the rendering pipeline (Used when exporting)
  74524. * @returns the serialized object
  74525. */
  74526. serialize(): any;
  74527. /**
  74528. * Parse the serialized pipeline
  74529. * @param source Source pipeline.
  74530. * @param scene The scene to load the pipeline to.
  74531. * @param rootUrl The URL of the serialized pipeline.
  74532. * @returns An instantiated pipeline from the serialized object.
  74533. */
  74534. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74535. }
  74536. }
  74537. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74538. /** @hidden */
  74539. export var lensHighlightsPixelShader: {
  74540. name: string;
  74541. shader: string;
  74542. };
  74543. }
  74544. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74545. /** @hidden */
  74546. export var depthOfFieldPixelShader: {
  74547. name: string;
  74548. shader: string;
  74549. };
  74550. }
  74551. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74552. import { Camera } from "babylonjs/Cameras/camera";
  74553. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74554. import { Scene } from "babylonjs/scene";
  74555. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74556. import "babylonjs/Shaders/chromaticAberration.fragment";
  74557. import "babylonjs/Shaders/lensHighlights.fragment";
  74558. import "babylonjs/Shaders/depthOfField.fragment";
  74559. /**
  74560. * BABYLON.JS Chromatic Aberration GLSL Shader
  74561. * Author: Olivier Guyot
  74562. * Separates very slightly R, G and B colors on the edges of the screen
  74563. * Inspired by Francois Tarlier & Martins Upitis
  74564. */
  74565. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74566. /**
  74567. * @ignore
  74568. * The chromatic aberration PostProcess id in the pipeline
  74569. */
  74570. LensChromaticAberrationEffect: string;
  74571. /**
  74572. * @ignore
  74573. * The highlights enhancing PostProcess id in the pipeline
  74574. */
  74575. HighlightsEnhancingEffect: string;
  74576. /**
  74577. * @ignore
  74578. * The depth-of-field PostProcess id in the pipeline
  74579. */
  74580. LensDepthOfFieldEffect: string;
  74581. private _scene;
  74582. private _depthTexture;
  74583. private _grainTexture;
  74584. private _chromaticAberrationPostProcess;
  74585. private _highlightsPostProcess;
  74586. private _depthOfFieldPostProcess;
  74587. private _edgeBlur;
  74588. private _grainAmount;
  74589. private _chromaticAberration;
  74590. private _distortion;
  74591. private _highlightsGain;
  74592. private _highlightsThreshold;
  74593. private _dofDistance;
  74594. private _dofAperture;
  74595. private _dofDarken;
  74596. private _dofPentagon;
  74597. private _blurNoise;
  74598. /**
  74599. * @constructor
  74600. *
  74601. * Effect parameters are as follow:
  74602. * {
  74603. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74604. * edge_blur: number; // from 0 to x (1 for realism)
  74605. * distortion: number; // from 0 to x (1 for realism)
  74606. * grain_amount: number; // from 0 to 1
  74607. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74608. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74609. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74610. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74611. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74612. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74613. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74614. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74615. * }
  74616. * Note: if an effect parameter is unset, effect is disabled
  74617. *
  74618. * @param name The rendering pipeline name
  74619. * @param parameters - An object containing all parameters (see above)
  74620. * @param scene The scene linked to this pipeline
  74621. * @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)
  74622. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74623. */
  74624. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74625. /**
  74626. * Get the class name
  74627. * @returns "LensRenderingPipeline"
  74628. */
  74629. getClassName(): string;
  74630. /**
  74631. * Gets associated scene
  74632. */
  74633. get scene(): Scene;
  74634. /**
  74635. * Gets or sets the edge blur
  74636. */
  74637. get edgeBlur(): number;
  74638. set edgeBlur(value: number);
  74639. /**
  74640. * Gets or sets the grain amount
  74641. */
  74642. get grainAmount(): number;
  74643. set grainAmount(value: number);
  74644. /**
  74645. * Gets or sets the chromatic aberration amount
  74646. */
  74647. get chromaticAberration(): number;
  74648. set chromaticAberration(value: number);
  74649. /**
  74650. * Gets or sets the depth of field aperture
  74651. */
  74652. get dofAperture(): number;
  74653. set dofAperture(value: number);
  74654. /**
  74655. * Gets or sets the edge distortion
  74656. */
  74657. get edgeDistortion(): number;
  74658. set edgeDistortion(value: number);
  74659. /**
  74660. * Gets or sets the depth of field distortion
  74661. */
  74662. get dofDistortion(): number;
  74663. set dofDistortion(value: number);
  74664. /**
  74665. * Gets or sets the darken out of focus amount
  74666. */
  74667. get darkenOutOfFocus(): number;
  74668. set darkenOutOfFocus(value: number);
  74669. /**
  74670. * Gets or sets a boolean indicating if blur noise is enabled
  74671. */
  74672. get blurNoise(): boolean;
  74673. set blurNoise(value: boolean);
  74674. /**
  74675. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74676. */
  74677. get pentagonBokeh(): boolean;
  74678. set pentagonBokeh(value: boolean);
  74679. /**
  74680. * Gets or sets the highlight grain amount
  74681. */
  74682. get highlightsGain(): number;
  74683. set highlightsGain(value: number);
  74684. /**
  74685. * Gets or sets the highlight threshold
  74686. */
  74687. get highlightsThreshold(): number;
  74688. set highlightsThreshold(value: number);
  74689. /**
  74690. * Sets the amount of blur at the edges
  74691. * @param amount blur amount
  74692. */
  74693. setEdgeBlur(amount: number): void;
  74694. /**
  74695. * Sets edge blur to 0
  74696. */
  74697. disableEdgeBlur(): void;
  74698. /**
  74699. * Sets the amout of grain
  74700. * @param amount Amount of grain
  74701. */
  74702. setGrainAmount(amount: number): void;
  74703. /**
  74704. * Set grain amount to 0
  74705. */
  74706. disableGrain(): void;
  74707. /**
  74708. * Sets the chromatic aberration amount
  74709. * @param amount amount of chromatic aberration
  74710. */
  74711. setChromaticAberration(amount: number): void;
  74712. /**
  74713. * Sets chromatic aberration amount to 0
  74714. */
  74715. disableChromaticAberration(): void;
  74716. /**
  74717. * Sets the EdgeDistortion amount
  74718. * @param amount amount of EdgeDistortion
  74719. */
  74720. setEdgeDistortion(amount: number): void;
  74721. /**
  74722. * Sets edge distortion to 0
  74723. */
  74724. disableEdgeDistortion(): void;
  74725. /**
  74726. * Sets the FocusDistance amount
  74727. * @param amount amount of FocusDistance
  74728. */
  74729. setFocusDistance(amount: number): void;
  74730. /**
  74731. * Disables depth of field
  74732. */
  74733. disableDepthOfField(): void;
  74734. /**
  74735. * Sets the Aperture amount
  74736. * @param amount amount of Aperture
  74737. */
  74738. setAperture(amount: number): void;
  74739. /**
  74740. * Sets the DarkenOutOfFocus amount
  74741. * @param amount amount of DarkenOutOfFocus
  74742. */
  74743. setDarkenOutOfFocus(amount: number): void;
  74744. private _pentagonBokehIsEnabled;
  74745. /**
  74746. * Creates a pentagon bokeh effect
  74747. */
  74748. enablePentagonBokeh(): void;
  74749. /**
  74750. * Disables the pentagon bokeh effect
  74751. */
  74752. disablePentagonBokeh(): void;
  74753. /**
  74754. * Enables noise blur
  74755. */
  74756. enableNoiseBlur(): void;
  74757. /**
  74758. * Disables noise blur
  74759. */
  74760. disableNoiseBlur(): void;
  74761. /**
  74762. * Sets the HighlightsGain amount
  74763. * @param amount amount of HighlightsGain
  74764. */
  74765. setHighlightsGain(amount: number): void;
  74766. /**
  74767. * Sets the HighlightsThreshold amount
  74768. * @param amount amount of HighlightsThreshold
  74769. */
  74770. setHighlightsThreshold(amount: number): void;
  74771. /**
  74772. * Disables highlights
  74773. */
  74774. disableHighlights(): void;
  74775. /**
  74776. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74777. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74778. */
  74779. dispose(disableDepthRender?: boolean): void;
  74780. private _createChromaticAberrationPostProcess;
  74781. private _createHighlightsPostProcess;
  74782. private _createDepthOfFieldPostProcess;
  74783. private _createGrainTexture;
  74784. }
  74785. }
  74786. declare module "babylonjs/Rendering/ssao2Configuration" {
  74787. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74788. /**
  74789. * Contains all parameters needed for the prepass to perform
  74790. * screen space subsurface scattering
  74791. */
  74792. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74793. /**
  74794. * Is subsurface enabled
  74795. */
  74796. enabled: boolean;
  74797. /**
  74798. * Name of the configuration
  74799. */
  74800. name: string;
  74801. /**
  74802. * Textures that should be present in the MRT for this effect to work
  74803. */
  74804. readonly texturesRequired: number[];
  74805. /**
  74806. * Builds a ssao2 configuration object
  74807. * @param scene The scene
  74808. */
  74809. constructor();
  74810. /**
  74811. * Disposes the configuration
  74812. */
  74813. dispose(): void;
  74814. }
  74815. }
  74816. declare module "babylonjs/Shaders/ssao2.fragment" {
  74817. /** @hidden */
  74818. export var ssao2PixelShader: {
  74819. name: string;
  74820. shader: string;
  74821. };
  74822. }
  74823. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74824. /** @hidden */
  74825. export var ssaoCombinePixelShader: {
  74826. name: string;
  74827. shader: string;
  74828. };
  74829. }
  74830. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74831. import { Camera } from "babylonjs/Cameras/camera";
  74832. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74833. import { Scene } from "babylonjs/scene";
  74834. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74835. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74836. import "babylonjs/Shaders/ssao2.fragment";
  74837. import "babylonjs/Shaders/ssaoCombine.fragment";
  74838. /**
  74839. * Render pipeline to produce ssao effect
  74840. */
  74841. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74842. /**
  74843. * @ignore
  74844. * The PassPostProcess id in the pipeline that contains the original scene color
  74845. */
  74846. SSAOOriginalSceneColorEffect: string;
  74847. /**
  74848. * @ignore
  74849. * The SSAO PostProcess id in the pipeline
  74850. */
  74851. SSAORenderEffect: string;
  74852. /**
  74853. * @ignore
  74854. * The horizontal blur PostProcess id in the pipeline
  74855. */
  74856. SSAOBlurHRenderEffect: string;
  74857. /**
  74858. * @ignore
  74859. * The vertical blur PostProcess id in the pipeline
  74860. */
  74861. SSAOBlurVRenderEffect: string;
  74862. /**
  74863. * @ignore
  74864. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74865. */
  74866. SSAOCombineRenderEffect: string;
  74867. /**
  74868. * The output strength of the SSAO post-process. Default value is 1.0.
  74869. */
  74870. totalStrength: number;
  74871. /**
  74872. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74873. */
  74874. maxZ: number;
  74875. /**
  74876. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74877. */
  74878. minZAspect: number;
  74879. private _samples;
  74880. /**
  74881. * Number of samples used for the SSAO calculations. Default value is 8
  74882. */
  74883. set samples(n: number);
  74884. get samples(): number;
  74885. private _textureSamples;
  74886. /**
  74887. * Number of samples to use for antialiasing
  74888. */
  74889. set textureSamples(n: number);
  74890. get textureSamples(): number;
  74891. /**
  74892. * Force rendering the geometry through geometry buffer
  74893. */
  74894. private _forceGeometryBuffer;
  74895. /**
  74896. * Ratio object used for SSAO ratio and blur ratio
  74897. */
  74898. private _ratio;
  74899. /**
  74900. * Dynamically generated sphere sampler.
  74901. */
  74902. private _sampleSphere;
  74903. private _ssao2PrePassConfiguration;
  74904. /**
  74905. * Blur filter offsets
  74906. */
  74907. private _samplerOffsets;
  74908. private _expensiveBlur;
  74909. /**
  74910. * If bilateral blur should be used
  74911. */
  74912. set expensiveBlur(b: boolean);
  74913. get expensiveBlur(): boolean;
  74914. /**
  74915. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74916. */
  74917. radius: number;
  74918. /**
  74919. * The base color of the SSAO post-process
  74920. * The final result is "base + ssao" between [0, 1]
  74921. */
  74922. base: number;
  74923. /**
  74924. * Support test.
  74925. */
  74926. static get IsSupported(): boolean;
  74927. private _scene;
  74928. private _randomTexture;
  74929. private _originalColorPostProcess;
  74930. private _ssaoPostProcess;
  74931. private _blurHPostProcess;
  74932. private _blurVPostProcess;
  74933. private _ssaoCombinePostProcess;
  74934. private _prePassRenderer;
  74935. /**
  74936. * Gets active scene
  74937. */
  74938. get scene(): Scene;
  74939. /**
  74940. * @constructor
  74941. * @param name The rendering pipeline name
  74942. * @param scene The scene linked to this pipeline
  74943. * @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 }
  74944. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74945. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74946. */
  74947. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74948. /**
  74949. * Get the class name
  74950. * @returns "SSAO2RenderingPipeline"
  74951. */
  74952. getClassName(): string;
  74953. /**
  74954. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74955. */
  74956. dispose(disableGeometryBufferRenderer?: boolean): void;
  74957. private _createBlurPostProcess;
  74958. /** @hidden */
  74959. _rebuild(): void;
  74960. private _bits;
  74961. private _radicalInverse_VdC;
  74962. private _hammersley;
  74963. private _hemisphereSample_uniform;
  74964. private _generateHemisphere;
  74965. private _getDefinesForSSAO;
  74966. private _createSSAOPostProcess;
  74967. private _createSSAOCombinePostProcess;
  74968. private _createRandomTexture;
  74969. /**
  74970. * Serialize the rendering pipeline (Used when exporting)
  74971. * @returns the serialized object
  74972. */
  74973. serialize(): any;
  74974. /**
  74975. * Parse the serialized pipeline
  74976. * @param source Source pipeline.
  74977. * @param scene The scene to load the pipeline to.
  74978. * @param rootUrl The URL of the serialized pipeline.
  74979. * @returns An instantiated pipeline from the serialized object.
  74980. */
  74981. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74982. /**
  74983. * Sets the required values to the prepass renderer.
  74984. * @param prePassRenderer defines the prepass renderer to setup
  74985. * @returns true if the pre pass is needed.
  74986. */
  74987. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74988. }
  74989. }
  74990. declare module "babylonjs/Shaders/ssao.fragment" {
  74991. /** @hidden */
  74992. export var ssaoPixelShader: {
  74993. name: string;
  74994. shader: string;
  74995. };
  74996. }
  74997. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74998. import { Camera } from "babylonjs/Cameras/camera";
  74999. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75000. import { Scene } from "babylonjs/scene";
  75001. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75002. import "babylonjs/Shaders/ssao.fragment";
  75003. import "babylonjs/Shaders/ssaoCombine.fragment";
  75004. /**
  75005. * Render pipeline to produce ssao effect
  75006. */
  75007. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75008. /**
  75009. * @ignore
  75010. * The PassPostProcess id in the pipeline that contains the original scene color
  75011. */
  75012. SSAOOriginalSceneColorEffect: string;
  75013. /**
  75014. * @ignore
  75015. * The SSAO PostProcess id in the pipeline
  75016. */
  75017. SSAORenderEffect: string;
  75018. /**
  75019. * @ignore
  75020. * The horizontal blur PostProcess id in the pipeline
  75021. */
  75022. SSAOBlurHRenderEffect: string;
  75023. /**
  75024. * @ignore
  75025. * The vertical blur PostProcess id in the pipeline
  75026. */
  75027. SSAOBlurVRenderEffect: string;
  75028. /**
  75029. * @ignore
  75030. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75031. */
  75032. SSAOCombineRenderEffect: string;
  75033. /**
  75034. * The output strength of the SSAO post-process. Default value is 1.0.
  75035. */
  75036. totalStrength: number;
  75037. /**
  75038. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75039. */
  75040. radius: number;
  75041. /**
  75042. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75043. * Must not be equal to fallOff and superior to fallOff.
  75044. * Default value is 0.0075
  75045. */
  75046. area: number;
  75047. /**
  75048. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75049. * Must not be equal to area and inferior to area.
  75050. * Default value is 0.000001
  75051. */
  75052. fallOff: number;
  75053. /**
  75054. * The base color of the SSAO post-process
  75055. * The final result is "base + ssao" between [0, 1]
  75056. */
  75057. base: number;
  75058. private _scene;
  75059. private _depthTexture;
  75060. private _randomTexture;
  75061. private _originalColorPostProcess;
  75062. private _ssaoPostProcess;
  75063. private _blurHPostProcess;
  75064. private _blurVPostProcess;
  75065. private _ssaoCombinePostProcess;
  75066. private _firstUpdate;
  75067. /**
  75068. * Gets active scene
  75069. */
  75070. get scene(): Scene;
  75071. /**
  75072. * @constructor
  75073. * @param name - The rendering pipeline name
  75074. * @param scene - The scene linked to this pipeline
  75075. * @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 }
  75076. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75077. */
  75078. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75079. /**
  75080. * Get the class name
  75081. * @returns "SSAORenderingPipeline"
  75082. */
  75083. getClassName(): string;
  75084. /**
  75085. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75086. */
  75087. dispose(disableDepthRender?: boolean): void;
  75088. private _createBlurPostProcess;
  75089. /** @hidden */
  75090. _rebuild(): void;
  75091. private _createSSAOPostProcess;
  75092. private _createSSAOCombinePostProcess;
  75093. private _createRandomTexture;
  75094. }
  75095. }
  75096. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75097. /** @hidden */
  75098. export var screenSpaceReflectionPixelShader: {
  75099. name: string;
  75100. shader: string;
  75101. };
  75102. }
  75103. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75104. import { Nullable } from "babylonjs/types";
  75105. import { Camera } from "babylonjs/Cameras/camera";
  75106. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75107. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75108. import { Engine } from "babylonjs/Engines/engine";
  75109. import { Scene } from "babylonjs/scene";
  75110. /**
  75111. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75112. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75113. */
  75114. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75115. /**
  75116. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75117. */
  75118. threshold: number;
  75119. /**
  75120. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75121. */
  75122. strength: number;
  75123. /**
  75124. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75125. */
  75126. reflectionSpecularFalloffExponent: number;
  75127. /**
  75128. * 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]
  75129. */
  75130. step: number;
  75131. /**
  75132. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75133. */
  75134. roughnessFactor: number;
  75135. private _geometryBufferRenderer;
  75136. private _enableSmoothReflections;
  75137. private _reflectionSamples;
  75138. private _smoothSteps;
  75139. /**
  75140. * Gets a string identifying the name of the class
  75141. * @returns "ScreenSpaceReflectionPostProcess" string
  75142. */
  75143. getClassName(): string;
  75144. /**
  75145. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75146. * @param name The name of the effect.
  75147. * @param scene The scene containing the objects to calculate reflections.
  75148. * @param options The required width/height ratio to downsize to before computing the render pass.
  75149. * @param camera The camera to apply the render pass to.
  75150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75151. * @param engine The engine which the post process will be applied. (default: current engine)
  75152. * @param reusable If the post process can be reused on the same frame. (default: false)
  75153. * @param textureType Type of textures used when performing the post process. (default: 0)
  75154. * @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)
  75155. */
  75156. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75157. /**
  75158. * Gets wether or not smoothing reflections is enabled.
  75159. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75160. */
  75161. get enableSmoothReflections(): boolean;
  75162. /**
  75163. * Sets wether or not smoothing reflections is enabled.
  75164. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75165. */
  75166. set enableSmoothReflections(enabled: boolean);
  75167. /**
  75168. * Gets the number of samples taken while computing reflections. More samples count is high,
  75169. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75170. */
  75171. get reflectionSamples(): number;
  75172. /**
  75173. * Sets the number of samples taken while computing reflections. More samples count is high,
  75174. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75175. */
  75176. set reflectionSamples(samples: number);
  75177. /**
  75178. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75179. * more the post-process will require GPU power and can generate a drop in FPS.
  75180. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75181. */
  75182. get smoothSteps(): number;
  75183. set smoothSteps(steps: number);
  75184. private _updateEffectDefines;
  75185. /** @hidden */
  75186. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75187. }
  75188. }
  75189. declare module "babylonjs/Shaders/standard.fragment" {
  75190. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75191. /** @hidden */
  75192. export var standardPixelShader: {
  75193. name: string;
  75194. shader: string;
  75195. };
  75196. }
  75197. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75198. import { Nullable } from "babylonjs/types";
  75199. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75200. import { Camera } from "babylonjs/Cameras/camera";
  75201. import { Texture } from "babylonjs/Materials/Textures/texture";
  75202. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75203. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75204. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75205. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75206. import { IDisposable } from "babylonjs/scene";
  75207. import { SpotLight } from "babylonjs/Lights/spotLight";
  75208. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75209. import { Scene } from "babylonjs/scene";
  75210. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75211. import { Animation } from "babylonjs/Animations/animation";
  75212. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75213. import "babylonjs/Shaders/standard.fragment";
  75214. /**
  75215. * Standard rendering pipeline
  75216. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75217. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75218. */
  75219. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75220. /**
  75221. * Public members
  75222. */
  75223. /**
  75224. * Post-process which contains the original scene color before the pipeline applies all the effects
  75225. */
  75226. originalPostProcess: Nullable<PostProcess>;
  75227. /**
  75228. * Post-process used to down scale an image x4
  75229. */
  75230. downSampleX4PostProcess: Nullable<PostProcess>;
  75231. /**
  75232. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75233. */
  75234. brightPassPostProcess: Nullable<PostProcess>;
  75235. /**
  75236. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75237. */
  75238. blurHPostProcesses: PostProcess[];
  75239. /**
  75240. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75241. */
  75242. blurVPostProcesses: PostProcess[];
  75243. /**
  75244. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75245. */
  75246. textureAdderPostProcess: Nullable<PostProcess>;
  75247. /**
  75248. * Post-process used to create volumetric lighting effect
  75249. */
  75250. volumetricLightPostProcess: Nullable<PostProcess>;
  75251. /**
  75252. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75253. */
  75254. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75255. /**
  75256. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75257. */
  75258. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75259. /**
  75260. * Post-process used to merge the volumetric light effect and the real scene color
  75261. */
  75262. volumetricLightMergePostProces: Nullable<PostProcess>;
  75263. /**
  75264. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75265. */
  75266. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75267. /**
  75268. * Base post-process used to calculate the average luminance of the final image for HDR
  75269. */
  75270. luminancePostProcess: Nullable<PostProcess>;
  75271. /**
  75272. * Post-processes used to create down sample post-processes in order to get
  75273. * the average luminance of the final image for HDR
  75274. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75275. */
  75276. luminanceDownSamplePostProcesses: PostProcess[];
  75277. /**
  75278. * Post-process used to create a HDR effect (light adaptation)
  75279. */
  75280. hdrPostProcess: Nullable<PostProcess>;
  75281. /**
  75282. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75283. */
  75284. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75285. /**
  75286. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75287. */
  75288. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75289. /**
  75290. * Post-process used to merge the final HDR post-process and the real scene color
  75291. */
  75292. hdrFinalPostProcess: Nullable<PostProcess>;
  75293. /**
  75294. * Post-process used to create a lens flare effect
  75295. */
  75296. lensFlarePostProcess: Nullable<PostProcess>;
  75297. /**
  75298. * Post-process that merges the result of the lens flare post-process and the real scene color
  75299. */
  75300. lensFlareComposePostProcess: Nullable<PostProcess>;
  75301. /**
  75302. * Post-process used to create a motion blur effect
  75303. */
  75304. motionBlurPostProcess: Nullable<PostProcess>;
  75305. /**
  75306. * Post-process used to create a depth of field effect
  75307. */
  75308. depthOfFieldPostProcess: Nullable<PostProcess>;
  75309. /**
  75310. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75311. */
  75312. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75313. /**
  75314. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75315. */
  75316. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75317. /**
  75318. * Represents the brightness threshold in order to configure the illuminated surfaces
  75319. */
  75320. brightThreshold: number;
  75321. /**
  75322. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75323. */
  75324. blurWidth: number;
  75325. /**
  75326. * Sets if the blur for highlighted surfaces must be only horizontal
  75327. */
  75328. horizontalBlur: boolean;
  75329. /**
  75330. * Gets the overall exposure used by the pipeline
  75331. */
  75332. get exposure(): number;
  75333. /**
  75334. * Sets the overall exposure used by the pipeline
  75335. */
  75336. set exposure(value: number);
  75337. /**
  75338. * Texture used typically to simulate "dirty" on camera lens
  75339. */
  75340. lensTexture: Nullable<Texture>;
  75341. /**
  75342. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75343. */
  75344. volumetricLightCoefficient: number;
  75345. /**
  75346. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75347. */
  75348. volumetricLightPower: number;
  75349. /**
  75350. * Used the set the blur intensity to smooth the volumetric lights
  75351. */
  75352. volumetricLightBlurScale: number;
  75353. /**
  75354. * Light (spot or directional) used to generate the volumetric lights rays
  75355. * The source light must have a shadow generate so the pipeline can get its
  75356. * depth map
  75357. */
  75358. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75359. /**
  75360. * For eye adaptation, represents the minimum luminance the eye can see
  75361. */
  75362. hdrMinimumLuminance: number;
  75363. /**
  75364. * For eye adaptation, represents the decrease luminance speed
  75365. */
  75366. hdrDecreaseRate: number;
  75367. /**
  75368. * For eye adaptation, represents the increase luminance speed
  75369. */
  75370. hdrIncreaseRate: number;
  75371. /**
  75372. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75373. */
  75374. get hdrAutoExposure(): boolean;
  75375. /**
  75376. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75377. */
  75378. set hdrAutoExposure(value: boolean);
  75379. /**
  75380. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75381. */
  75382. lensColorTexture: Nullable<Texture>;
  75383. /**
  75384. * The overall strengh for the lens flare effect
  75385. */
  75386. lensFlareStrength: number;
  75387. /**
  75388. * Dispersion coefficient for lens flare ghosts
  75389. */
  75390. lensFlareGhostDispersal: number;
  75391. /**
  75392. * Main lens flare halo width
  75393. */
  75394. lensFlareHaloWidth: number;
  75395. /**
  75396. * Based on the lens distortion effect, defines how much the lens flare result
  75397. * is distorted
  75398. */
  75399. lensFlareDistortionStrength: number;
  75400. /**
  75401. * Configures the blur intensity used for for lens flare (halo)
  75402. */
  75403. lensFlareBlurWidth: number;
  75404. /**
  75405. * Lens star texture must be used to simulate rays on the flares and is available
  75406. * in the documentation
  75407. */
  75408. lensStarTexture: Nullable<Texture>;
  75409. /**
  75410. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75411. * flare effect by taking account of the dirt texture
  75412. */
  75413. lensFlareDirtTexture: Nullable<Texture>;
  75414. /**
  75415. * Represents the focal length for the depth of field effect
  75416. */
  75417. depthOfFieldDistance: number;
  75418. /**
  75419. * Represents the blur intensity for the blurred part of the depth of field effect
  75420. */
  75421. depthOfFieldBlurWidth: number;
  75422. /**
  75423. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75424. */
  75425. get motionStrength(): number;
  75426. /**
  75427. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75428. */
  75429. set motionStrength(strength: number);
  75430. /**
  75431. * Gets wether or not the motion blur post-process is object based or screen based.
  75432. */
  75433. get objectBasedMotionBlur(): boolean;
  75434. /**
  75435. * Sets wether or not the motion blur post-process should be object based or screen based
  75436. */
  75437. set objectBasedMotionBlur(value: boolean);
  75438. /**
  75439. * List of animations for the pipeline (IAnimatable implementation)
  75440. */
  75441. animations: Animation[];
  75442. /**
  75443. * Private members
  75444. */
  75445. private _scene;
  75446. private _currentDepthOfFieldSource;
  75447. private _basePostProcess;
  75448. private _fixedExposure;
  75449. private _currentExposure;
  75450. private _hdrAutoExposure;
  75451. private _hdrCurrentLuminance;
  75452. private _motionStrength;
  75453. private _isObjectBasedMotionBlur;
  75454. private _floatTextureType;
  75455. private _camerasToBeAttached;
  75456. private _ratio;
  75457. private _bloomEnabled;
  75458. private _depthOfFieldEnabled;
  75459. private _vlsEnabled;
  75460. private _lensFlareEnabled;
  75461. private _hdrEnabled;
  75462. private _motionBlurEnabled;
  75463. private _fxaaEnabled;
  75464. private _screenSpaceReflectionsEnabled;
  75465. private _motionBlurSamples;
  75466. private _volumetricLightStepsCount;
  75467. private _samples;
  75468. /**
  75469. * @ignore
  75470. * Specifies if the bloom pipeline is enabled
  75471. */
  75472. get BloomEnabled(): boolean;
  75473. set BloomEnabled(enabled: boolean);
  75474. /**
  75475. * @ignore
  75476. * Specifies if the depth of field pipeline is enabed
  75477. */
  75478. get DepthOfFieldEnabled(): boolean;
  75479. set DepthOfFieldEnabled(enabled: boolean);
  75480. /**
  75481. * @ignore
  75482. * Specifies if the lens flare pipeline is enabed
  75483. */
  75484. get LensFlareEnabled(): boolean;
  75485. set LensFlareEnabled(enabled: boolean);
  75486. /**
  75487. * @ignore
  75488. * Specifies if the HDR pipeline is enabled
  75489. */
  75490. get HDREnabled(): boolean;
  75491. set HDREnabled(enabled: boolean);
  75492. /**
  75493. * @ignore
  75494. * Specifies if the volumetric lights scattering effect is enabled
  75495. */
  75496. get VLSEnabled(): boolean;
  75497. set VLSEnabled(enabled: boolean);
  75498. /**
  75499. * @ignore
  75500. * Specifies if the motion blur effect is enabled
  75501. */
  75502. get MotionBlurEnabled(): boolean;
  75503. set MotionBlurEnabled(enabled: boolean);
  75504. /**
  75505. * Specifies if anti-aliasing is enabled
  75506. */
  75507. get fxaaEnabled(): boolean;
  75508. set fxaaEnabled(enabled: boolean);
  75509. /**
  75510. * Specifies if screen space reflections are enabled.
  75511. */
  75512. get screenSpaceReflectionsEnabled(): boolean;
  75513. set screenSpaceReflectionsEnabled(enabled: boolean);
  75514. /**
  75515. * Specifies the number of steps used to calculate the volumetric lights
  75516. * Typically in interval [50, 200]
  75517. */
  75518. get volumetricLightStepsCount(): number;
  75519. set volumetricLightStepsCount(count: number);
  75520. /**
  75521. * Specifies the number of samples used for the motion blur effect
  75522. * Typically in interval [16, 64]
  75523. */
  75524. get motionBlurSamples(): number;
  75525. set motionBlurSamples(samples: number);
  75526. /**
  75527. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75528. */
  75529. get samples(): number;
  75530. set samples(sampleCount: number);
  75531. /**
  75532. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75533. * @constructor
  75534. * @param name The rendering pipeline name
  75535. * @param scene The scene linked to this pipeline
  75536. * @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)
  75537. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75538. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75539. */
  75540. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75541. private _buildPipeline;
  75542. private _createDownSampleX4PostProcess;
  75543. private _createBrightPassPostProcess;
  75544. private _createBlurPostProcesses;
  75545. private _createTextureAdderPostProcess;
  75546. private _createVolumetricLightPostProcess;
  75547. private _createLuminancePostProcesses;
  75548. private _createHdrPostProcess;
  75549. private _createLensFlarePostProcess;
  75550. private _createDepthOfFieldPostProcess;
  75551. private _createMotionBlurPostProcess;
  75552. private _getDepthTexture;
  75553. private _disposePostProcesses;
  75554. /**
  75555. * Dispose of the pipeline and stop all post processes
  75556. */
  75557. dispose(): void;
  75558. /**
  75559. * Serialize the rendering pipeline (Used when exporting)
  75560. * @returns the serialized object
  75561. */
  75562. serialize(): any;
  75563. /**
  75564. * Parse the serialized pipeline
  75565. * @param source Source pipeline.
  75566. * @param scene The scene to load the pipeline to.
  75567. * @param rootUrl The URL of the serialized pipeline.
  75568. * @returns An instantiated pipeline from the serialized object.
  75569. */
  75570. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75571. /**
  75572. * Luminance steps
  75573. */
  75574. static LuminanceSteps: number;
  75575. }
  75576. }
  75577. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75578. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75579. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75580. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75581. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75582. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75583. }
  75584. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75585. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75586. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75587. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75588. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75589. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75590. }
  75591. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75592. /** @hidden */
  75593. export var stereoscopicInterlacePixelShader: {
  75594. name: string;
  75595. shader: string;
  75596. };
  75597. }
  75598. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75599. import { Camera } from "babylonjs/Cameras/camera";
  75600. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75601. import { Engine } from "babylonjs/Engines/engine";
  75602. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75603. /**
  75604. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75605. */
  75606. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75607. private _stepSize;
  75608. private _passedProcess;
  75609. /**
  75610. * Gets a string identifying the name of the class
  75611. * @returns "StereoscopicInterlacePostProcessI" string
  75612. */
  75613. getClassName(): string;
  75614. /**
  75615. * Initializes a StereoscopicInterlacePostProcessI
  75616. * @param name The name of the effect.
  75617. * @param rigCameras The rig cameras to be appled to the post process
  75618. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75619. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75621. * @param engine The engine which the post process will be applied. (default: current engine)
  75622. * @param reusable If the post process can be reused on the same frame. (default: false)
  75623. */
  75624. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75625. }
  75626. /**
  75627. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75628. */
  75629. export class StereoscopicInterlacePostProcess extends PostProcess {
  75630. private _stepSize;
  75631. private _passedProcess;
  75632. /**
  75633. * Gets a string identifying the name of the class
  75634. * @returns "StereoscopicInterlacePostProcess" string
  75635. */
  75636. getClassName(): string;
  75637. /**
  75638. * Initializes a StereoscopicInterlacePostProcess
  75639. * @param name The name of the effect.
  75640. * @param rigCameras The rig cameras to be appled to the post process
  75641. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75643. * @param engine The engine which the post process will be applied. (default: current engine)
  75644. * @param reusable If the post process can be reused on the same frame. (default: false)
  75645. */
  75646. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75647. }
  75648. }
  75649. declare module "babylonjs/Shaders/tonemap.fragment" {
  75650. /** @hidden */
  75651. export var tonemapPixelShader: {
  75652. name: string;
  75653. shader: string;
  75654. };
  75655. }
  75656. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75657. import { Camera } from "babylonjs/Cameras/camera";
  75658. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75659. import "babylonjs/Shaders/tonemap.fragment";
  75660. import { Engine } from "babylonjs/Engines/engine";
  75661. /** Defines operator used for tonemapping */
  75662. export enum TonemappingOperator {
  75663. /** Hable */
  75664. Hable = 0,
  75665. /** Reinhard */
  75666. Reinhard = 1,
  75667. /** HejiDawson */
  75668. HejiDawson = 2,
  75669. /** Photographic */
  75670. Photographic = 3
  75671. }
  75672. /**
  75673. * Defines a post process to apply tone mapping
  75674. */
  75675. export class TonemapPostProcess extends PostProcess {
  75676. private _operator;
  75677. /** Defines the required exposure adjustement */
  75678. exposureAdjustment: number;
  75679. /**
  75680. * Gets a string identifying the name of the class
  75681. * @returns "TonemapPostProcess" string
  75682. */
  75683. getClassName(): string;
  75684. /**
  75685. * Creates a new TonemapPostProcess
  75686. * @param name defines the name of the postprocess
  75687. * @param _operator defines the operator to use
  75688. * @param exposureAdjustment defines the required exposure adjustement
  75689. * @param camera defines the camera to use (can be null)
  75690. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75691. * @param engine defines the hosting engine (can be ignore if camera is set)
  75692. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75693. */
  75694. constructor(name: string, _operator: TonemappingOperator,
  75695. /** Defines the required exposure adjustement */
  75696. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75697. }
  75698. }
  75699. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75700. /** @hidden */
  75701. export var volumetricLightScatteringPixelShader: {
  75702. name: string;
  75703. shader: string;
  75704. };
  75705. }
  75706. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75707. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75708. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75709. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75710. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75711. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75712. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75713. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75714. /** @hidden */
  75715. export var volumetricLightScatteringPassVertexShader: {
  75716. name: string;
  75717. shader: string;
  75718. };
  75719. }
  75720. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75721. /** @hidden */
  75722. export var volumetricLightScatteringPassPixelShader: {
  75723. name: string;
  75724. shader: string;
  75725. };
  75726. }
  75727. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75728. import { Vector3 } from "babylonjs/Maths/math.vector";
  75729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75730. import { Mesh } from "babylonjs/Meshes/mesh";
  75731. import { Camera } from "babylonjs/Cameras/camera";
  75732. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75733. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75734. import { Scene } from "babylonjs/scene";
  75735. import "babylonjs/Meshes/Builders/planeBuilder";
  75736. import "babylonjs/Shaders/depth.vertex";
  75737. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75738. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75739. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75740. import { Engine } from "babylonjs/Engines/engine";
  75741. /**
  75742. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75743. */
  75744. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75745. private _volumetricLightScatteringPass;
  75746. private _volumetricLightScatteringRTT;
  75747. private _viewPort;
  75748. private _screenCoordinates;
  75749. private _cachedDefines;
  75750. /**
  75751. * If not undefined, the mesh position is computed from the attached node position
  75752. */
  75753. attachedNode: {
  75754. position: Vector3;
  75755. };
  75756. /**
  75757. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75758. */
  75759. customMeshPosition: Vector3;
  75760. /**
  75761. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75762. */
  75763. useCustomMeshPosition: boolean;
  75764. /**
  75765. * If the post-process should inverse the light scattering direction
  75766. */
  75767. invert: boolean;
  75768. /**
  75769. * The internal mesh used by the post-process
  75770. */
  75771. mesh: Mesh;
  75772. /**
  75773. * @hidden
  75774. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75775. */
  75776. get useDiffuseColor(): boolean;
  75777. set useDiffuseColor(useDiffuseColor: boolean);
  75778. /**
  75779. * Array containing the excluded meshes not rendered in the internal pass
  75780. */
  75781. excludedMeshes: AbstractMesh[];
  75782. /**
  75783. * Controls the overall intensity of the post-process
  75784. */
  75785. exposure: number;
  75786. /**
  75787. * Dissipates each sample's contribution in range [0, 1]
  75788. */
  75789. decay: number;
  75790. /**
  75791. * Controls the overall intensity of each sample
  75792. */
  75793. weight: number;
  75794. /**
  75795. * Controls the density of each sample
  75796. */
  75797. density: number;
  75798. /**
  75799. * @constructor
  75800. * @param name The post-process name
  75801. * @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)
  75802. * @param camera The camera that the post-process will be attached to
  75803. * @param mesh The mesh used to create the light scattering
  75804. * @param samples The post-process quality, default 100
  75805. * @param samplingModeThe post-process filtering mode
  75806. * @param engine The babylon engine
  75807. * @param reusable If the post-process is reusable
  75808. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75809. */
  75810. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75811. /**
  75812. * Returns the string "VolumetricLightScatteringPostProcess"
  75813. * @returns "VolumetricLightScatteringPostProcess"
  75814. */
  75815. getClassName(): string;
  75816. private _isReady;
  75817. /**
  75818. * Sets the new light position for light scattering effect
  75819. * @param position The new custom light position
  75820. */
  75821. setCustomMeshPosition(position: Vector3): void;
  75822. /**
  75823. * Returns the light position for light scattering effect
  75824. * @return Vector3 The custom light position
  75825. */
  75826. getCustomMeshPosition(): Vector3;
  75827. /**
  75828. * Disposes the internal assets and detaches the post-process from the camera
  75829. */
  75830. dispose(camera: Camera): void;
  75831. /**
  75832. * Returns the render target texture used by the post-process
  75833. * @return the render target texture used by the post-process
  75834. */
  75835. getPass(): RenderTargetTexture;
  75836. private _meshExcluded;
  75837. private _createPass;
  75838. private _updateMeshScreenCoordinates;
  75839. /**
  75840. * Creates a default mesh for the Volumeric Light Scattering post-process
  75841. * @param name The mesh name
  75842. * @param scene The scene where to create the mesh
  75843. * @return the default mesh
  75844. */
  75845. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75846. }
  75847. }
  75848. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75849. /** @hidden */
  75850. export var screenSpaceCurvaturePixelShader: {
  75851. name: string;
  75852. shader: string;
  75853. };
  75854. }
  75855. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75856. import { Nullable } from "babylonjs/types";
  75857. import { Camera } from "babylonjs/Cameras/camera";
  75858. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75859. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75860. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75861. import { Engine } from "babylonjs/Engines/engine";
  75862. import { Scene } from "babylonjs/scene";
  75863. /**
  75864. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75865. */
  75866. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75867. /**
  75868. * Defines how much ridge the curvature effect displays.
  75869. */
  75870. ridge: number;
  75871. /**
  75872. * Defines how much valley the curvature effect displays.
  75873. */
  75874. valley: number;
  75875. private _geometryBufferRenderer;
  75876. /**
  75877. * Gets a string identifying the name of the class
  75878. * @returns "ScreenSpaceCurvaturePostProcess" string
  75879. */
  75880. getClassName(): string;
  75881. /**
  75882. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75883. * @param name The name of the effect.
  75884. * @param scene The scene containing the objects to blur according to their velocity.
  75885. * @param options The required width/height ratio to downsize to before computing the render pass.
  75886. * @param camera The camera to apply the render pass to.
  75887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75888. * @param engine The engine which the post process will be applied. (default: current engine)
  75889. * @param reusable If the post process can be reused on the same frame. (default: false)
  75890. * @param textureType Type of textures used when performing the post process. (default: 0)
  75891. * @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)
  75892. */
  75893. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75894. /**
  75895. * Support test.
  75896. */
  75897. static get IsSupported(): boolean;
  75898. /** @hidden */
  75899. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75900. }
  75901. }
  75902. declare module "babylonjs/PostProcesses/index" {
  75903. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75904. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75905. export * from "babylonjs/PostProcesses/bloomEffect";
  75906. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75907. export * from "babylonjs/PostProcesses/blurPostProcess";
  75908. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75909. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75910. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75911. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75912. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75913. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75914. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75915. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75916. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75917. export * from "babylonjs/PostProcesses/filterPostProcess";
  75918. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75919. export * from "babylonjs/PostProcesses/grainPostProcess";
  75920. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75921. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75922. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75923. export * from "babylonjs/PostProcesses/passPostProcess";
  75924. export * from "babylonjs/PostProcesses/postProcess";
  75925. export * from "babylonjs/PostProcesses/postProcessManager";
  75926. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75927. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75928. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75929. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75930. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75931. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75932. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75933. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75934. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75935. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75936. }
  75937. declare module "babylonjs/Probes/index" {
  75938. export * from "babylonjs/Probes/reflectionProbe";
  75939. }
  75940. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75941. import { Scene } from "babylonjs/scene";
  75942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75943. import { SmartArray } from "babylonjs/Misc/smartArray";
  75944. import { ISceneComponent } from "babylonjs/sceneComponent";
  75945. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75946. import "babylonjs/Meshes/Builders/boxBuilder";
  75947. import "babylonjs/Shaders/color.fragment";
  75948. import "babylonjs/Shaders/color.vertex";
  75949. import { Color3 } from "babylonjs/Maths/math.color";
  75950. import { Observable } from "babylonjs/Misc/observable";
  75951. module "babylonjs/scene" {
  75952. interface Scene {
  75953. /** @hidden (Backing field) */
  75954. _boundingBoxRenderer: BoundingBoxRenderer;
  75955. /** @hidden (Backing field) */
  75956. _forceShowBoundingBoxes: boolean;
  75957. /**
  75958. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75959. */
  75960. forceShowBoundingBoxes: boolean;
  75961. /**
  75962. * Gets the bounding box renderer associated with the scene
  75963. * @returns a BoundingBoxRenderer
  75964. */
  75965. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75966. }
  75967. }
  75968. module "babylonjs/Meshes/abstractMesh" {
  75969. interface AbstractMesh {
  75970. /** @hidden (Backing field) */
  75971. _showBoundingBox: boolean;
  75972. /**
  75973. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75974. */
  75975. showBoundingBox: boolean;
  75976. }
  75977. }
  75978. /**
  75979. * Component responsible of rendering the bounding box of the meshes in a scene.
  75980. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75981. */
  75982. export class BoundingBoxRenderer implements ISceneComponent {
  75983. /**
  75984. * The component name helpfull to identify the component in the list of scene components.
  75985. */
  75986. readonly name: string;
  75987. /**
  75988. * The scene the component belongs to.
  75989. */
  75990. scene: Scene;
  75991. /**
  75992. * Color of the bounding box lines placed in front of an object
  75993. */
  75994. frontColor: Color3;
  75995. /**
  75996. * Color of the bounding box lines placed behind an object
  75997. */
  75998. backColor: Color3;
  75999. /**
  76000. * Defines if the renderer should show the back lines or not
  76001. */
  76002. showBackLines: boolean;
  76003. /**
  76004. * Observable raised before rendering a bounding box
  76005. */
  76006. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76007. /**
  76008. * Observable raised after rendering a bounding box
  76009. */
  76010. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76011. /**
  76012. * @hidden
  76013. */
  76014. renderList: SmartArray<BoundingBox>;
  76015. private _colorShader;
  76016. private _vertexBuffers;
  76017. private _indexBuffer;
  76018. private _fillIndexBuffer;
  76019. private _fillIndexData;
  76020. /**
  76021. * Instantiates a new bounding box renderer in a scene.
  76022. * @param scene the scene the renderer renders in
  76023. */
  76024. constructor(scene: Scene);
  76025. /**
  76026. * Registers the component in a given scene
  76027. */
  76028. register(): void;
  76029. private _evaluateSubMesh;
  76030. private _activeMesh;
  76031. private _prepareRessources;
  76032. private _createIndexBuffer;
  76033. /**
  76034. * Rebuilds the elements related to this component in case of
  76035. * context lost for instance.
  76036. */
  76037. rebuild(): void;
  76038. /**
  76039. * @hidden
  76040. */
  76041. reset(): void;
  76042. /**
  76043. * Render the bounding boxes of a specific rendering group
  76044. * @param renderingGroupId defines the rendering group to render
  76045. */
  76046. render(renderingGroupId: number): void;
  76047. /**
  76048. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76049. * @param mesh Define the mesh to render the occlusion bounding box for
  76050. */
  76051. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76052. /**
  76053. * Dispose and release the resources attached to this renderer.
  76054. */
  76055. dispose(): void;
  76056. }
  76057. }
  76058. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76059. import { Nullable } from "babylonjs/types";
  76060. import { Scene } from "babylonjs/scene";
  76061. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76062. import { Camera } from "babylonjs/Cameras/camera";
  76063. import { ISceneComponent } from "babylonjs/sceneComponent";
  76064. module "babylonjs/scene" {
  76065. interface Scene {
  76066. /** @hidden (Backing field) */
  76067. _depthRenderer: {
  76068. [id: string]: DepthRenderer;
  76069. };
  76070. /**
  76071. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76072. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76073. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76074. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76075. * @returns the created depth renderer
  76076. */
  76077. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76078. /**
  76079. * Disables a depth renderer for a given camera
  76080. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76081. */
  76082. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76083. }
  76084. }
  76085. /**
  76086. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76087. * in several rendering techniques.
  76088. */
  76089. export class DepthRendererSceneComponent implements ISceneComponent {
  76090. /**
  76091. * The component name helpfull to identify the component in the list of scene components.
  76092. */
  76093. readonly name: string;
  76094. /**
  76095. * The scene the component belongs to.
  76096. */
  76097. scene: Scene;
  76098. /**
  76099. * Creates a new instance of the component for the given scene
  76100. * @param scene Defines the scene to register the component in
  76101. */
  76102. constructor(scene: Scene);
  76103. /**
  76104. * Registers the component in a given scene
  76105. */
  76106. register(): void;
  76107. /**
  76108. * Rebuilds the elements related to this component in case of
  76109. * context lost for instance.
  76110. */
  76111. rebuild(): void;
  76112. /**
  76113. * Disposes the component and the associated ressources
  76114. */
  76115. dispose(): void;
  76116. private _gatherRenderTargets;
  76117. private _gatherActiveCameraRenderTargets;
  76118. }
  76119. }
  76120. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76121. import { Nullable } from "babylonjs/types";
  76122. import { Scene } from "babylonjs/scene";
  76123. import { ISceneComponent } from "babylonjs/sceneComponent";
  76124. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76125. module "babylonjs/abstractScene" {
  76126. interface AbstractScene {
  76127. /** @hidden (Backing field) */
  76128. _prePassRenderer: Nullable<PrePassRenderer>;
  76129. /**
  76130. * Gets or Sets the current prepass renderer associated to the scene.
  76131. */
  76132. prePassRenderer: Nullable<PrePassRenderer>;
  76133. /**
  76134. * Enables the prepass and associates it with the scene
  76135. * @returns the PrePassRenderer
  76136. */
  76137. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76138. /**
  76139. * Disables the prepass associated with the scene
  76140. */
  76141. disablePrePassRenderer(): void;
  76142. }
  76143. }
  76144. /**
  76145. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76146. * in several rendering techniques.
  76147. */
  76148. export class PrePassRendererSceneComponent implements ISceneComponent {
  76149. /**
  76150. * The component name helpful to identify the component in the list of scene components.
  76151. */
  76152. readonly name: string;
  76153. /**
  76154. * The scene the component belongs to.
  76155. */
  76156. scene: Scene;
  76157. /**
  76158. * Creates a new instance of the component for the given scene
  76159. * @param scene Defines the scene to register the component in
  76160. */
  76161. constructor(scene: Scene);
  76162. /**
  76163. * Registers the component in a given scene
  76164. */
  76165. register(): void;
  76166. private _beforeCameraDraw;
  76167. private _afterCameraDraw;
  76168. private _beforeClearStage;
  76169. /**
  76170. * Rebuilds the elements related to this component in case of
  76171. * context lost for instance.
  76172. */
  76173. rebuild(): void;
  76174. /**
  76175. * Disposes the component and the associated ressources
  76176. */
  76177. dispose(): void;
  76178. }
  76179. }
  76180. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76181. /** @hidden */
  76182. export var fibonacci: {
  76183. name: string;
  76184. shader: string;
  76185. };
  76186. }
  76187. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76188. /** @hidden */
  76189. export var diffusionProfile: {
  76190. name: string;
  76191. shader: string;
  76192. };
  76193. }
  76194. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76195. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76196. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76197. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76198. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76199. /** @hidden */
  76200. export var subSurfaceScatteringPixelShader: {
  76201. name: string;
  76202. shader: string;
  76203. };
  76204. }
  76205. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76206. import { Nullable } from "babylonjs/types";
  76207. import { Camera } from "babylonjs/Cameras/camera";
  76208. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76209. import { Engine } from "babylonjs/Engines/engine";
  76210. import { Scene } from "babylonjs/scene";
  76211. import "babylonjs/Shaders/imageProcessing.fragment";
  76212. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76213. import "babylonjs/Shaders/postprocess.vertex";
  76214. /**
  76215. * Sub surface scattering post process
  76216. */
  76217. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76218. /**
  76219. * Gets a string identifying the name of the class
  76220. * @returns "SubSurfaceScatteringPostProcess" string
  76221. */
  76222. getClassName(): string;
  76223. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76224. }
  76225. }
  76226. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76227. import { Scene } from "babylonjs/scene";
  76228. import { Color3 } from "babylonjs/Maths/math.color";
  76229. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76230. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76231. /**
  76232. * Contains all parameters needed for the prepass to perform
  76233. * screen space subsurface scattering
  76234. */
  76235. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76236. /** @hidden */
  76237. static _SceneComponentInitialization: (scene: Scene) => void;
  76238. private _ssDiffusionS;
  76239. private _ssFilterRadii;
  76240. private _ssDiffusionD;
  76241. /**
  76242. * Post process to attach for screen space subsurface scattering
  76243. */
  76244. postProcess: SubSurfaceScatteringPostProcess;
  76245. /**
  76246. * Diffusion profile color for subsurface scattering
  76247. */
  76248. get ssDiffusionS(): number[];
  76249. /**
  76250. * Diffusion profile max color channel value for subsurface scattering
  76251. */
  76252. get ssDiffusionD(): number[];
  76253. /**
  76254. * Diffusion profile filter radius for subsurface scattering
  76255. */
  76256. get ssFilterRadii(): number[];
  76257. /**
  76258. * Is subsurface enabled
  76259. */
  76260. enabled: boolean;
  76261. /**
  76262. * Name of the configuration
  76263. */
  76264. name: string;
  76265. /**
  76266. * Diffusion profile colors for subsurface scattering
  76267. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76268. * See ...
  76269. * Note that you can only store up to 5 of them
  76270. */
  76271. ssDiffusionProfileColors: Color3[];
  76272. /**
  76273. * Defines the ratio real world => scene units.
  76274. * Used for subsurface scattering
  76275. */
  76276. metersPerUnit: number;
  76277. /**
  76278. * Textures that should be present in the MRT for this effect to work
  76279. */
  76280. readonly texturesRequired: number[];
  76281. private _scene;
  76282. /**
  76283. * Builds a subsurface configuration object
  76284. * @param scene The scene
  76285. */
  76286. constructor(scene: Scene);
  76287. /**
  76288. * Adds a new diffusion profile.
  76289. * Useful for more realistic subsurface scattering on diverse materials.
  76290. * @param color The color of the diffusion profile. Should be the average color of the material.
  76291. * @return The index of the diffusion profile for the material subsurface configuration
  76292. */
  76293. addDiffusionProfile(color: Color3): number;
  76294. /**
  76295. * Creates the sss post process
  76296. * @return The created post process
  76297. */
  76298. createPostProcess(): SubSurfaceScatteringPostProcess;
  76299. /**
  76300. * Deletes all diffusion profiles.
  76301. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76302. */
  76303. clearAllDiffusionProfiles(): void;
  76304. /**
  76305. * Disposes this object
  76306. */
  76307. dispose(): void;
  76308. /**
  76309. * @hidden
  76310. * https://zero-radiance.github.io/post/sampling-diffusion/
  76311. *
  76312. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76313. * ------------------------------------------------------------------------------------
  76314. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76315. * PDF[r, phi, s] = r * R[r, phi, s]
  76316. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76317. * ------------------------------------------------------------------------------------
  76318. * We importance sample the color channel with the widest scattering distance.
  76319. */
  76320. getDiffusionProfileParameters(color: Color3): number;
  76321. /**
  76322. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76323. * 'u' is the random number (the value of the CDF): [0, 1).
  76324. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76325. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76326. */
  76327. private _sampleBurleyDiffusionProfile;
  76328. }
  76329. }
  76330. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76331. import { Nullable } from "babylonjs/types";
  76332. import { Scene } from "babylonjs/scene";
  76333. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76334. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76335. import { AbstractScene } from "babylonjs/abstractScene";
  76336. module "babylonjs/abstractScene" {
  76337. interface AbstractScene {
  76338. /** @hidden (Backing field) */
  76339. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76340. /**
  76341. * Gets or Sets the current prepass renderer associated to the scene.
  76342. */
  76343. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76344. /**
  76345. * Enables the subsurface effect for prepass
  76346. * @returns the SubSurfaceConfiguration
  76347. */
  76348. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76349. /**
  76350. * Disables the subsurface effect for prepass
  76351. */
  76352. disableSubSurfaceForPrePass(): void;
  76353. }
  76354. }
  76355. /**
  76356. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76357. * in several rendering techniques.
  76358. */
  76359. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76360. /**
  76361. * The component name helpful to identify the component in the list of scene components.
  76362. */
  76363. readonly name: string;
  76364. /**
  76365. * The scene the component belongs to.
  76366. */
  76367. scene: Scene;
  76368. /**
  76369. * Creates a new instance of the component for the given scene
  76370. * @param scene Defines the scene to register the component in
  76371. */
  76372. constructor(scene: Scene);
  76373. /**
  76374. * Registers the component in a given scene
  76375. */
  76376. register(): void;
  76377. /**
  76378. * Serializes the component data to the specified json object
  76379. * @param serializationObject The object to serialize to
  76380. */
  76381. serialize(serializationObject: any): void;
  76382. /**
  76383. * Adds all the elements from the container to the scene
  76384. * @param container the container holding the elements
  76385. */
  76386. addFromContainer(container: AbstractScene): void;
  76387. /**
  76388. * Removes all the elements in the container from the scene
  76389. * @param container contains the elements to remove
  76390. * @param dispose if the removed element should be disposed (default: false)
  76391. */
  76392. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76393. /**
  76394. * Rebuilds the elements related to this component in case of
  76395. * context lost for instance.
  76396. */
  76397. rebuild(): void;
  76398. /**
  76399. * Disposes the component and the associated ressources
  76400. */
  76401. dispose(): void;
  76402. }
  76403. }
  76404. declare module "babylonjs/Shaders/outline.fragment" {
  76405. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76406. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76407. /** @hidden */
  76408. export var outlinePixelShader: {
  76409. name: string;
  76410. shader: string;
  76411. };
  76412. }
  76413. declare module "babylonjs/Shaders/outline.vertex" {
  76414. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76415. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76417. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76418. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76419. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76420. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76421. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76422. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76423. /** @hidden */
  76424. export var outlineVertexShader: {
  76425. name: string;
  76426. shader: string;
  76427. };
  76428. }
  76429. declare module "babylonjs/Rendering/outlineRenderer" {
  76430. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76431. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76432. import { Scene } from "babylonjs/scene";
  76433. import { ISceneComponent } from "babylonjs/sceneComponent";
  76434. import "babylonjs/Shaders/outline.fragment";
  76435. import "babylonjs/Shaders/outline.vertex";
  76436. module "babylonjs/scene" {
  76437. interface Scene {
  76438. /** @hidden */
  76439. _outlineRenderer: OutlineRenderer;
  76440. /**
  76441. * Gets the outline renderer associated with the scene
  76442. * @returns a OutlineRenderer
  76443. */
  76444. getOutlineRenderer(): OutlineRenderer;
  76445. }
  76446. }
  76447. module "babylonjs/Meshes/abstractMesh" {
  76448. interface AbstractMesh {
  76449. /** @hidden (Backing field) */
  76450. _renderOutline: boolean;
  76451. /**
  76452. * Gets or sets a boolean indicating if the outline must be rendered as well
  76453. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76454. */
  76455. renderOutline: boolean;
  76456. /** @hidden (Backing field) */
  76457. _renderOverlay: boolean;
  76458. /**
  76459. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76460. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76461. */
  76462. renderOverlay: boolean;
  76463. }
  76464. }
  76465. /**
  76466. * This class is responsible to draw bothe outline/overlay of meshes.
  76467. * It should not be used directly but through the available method on mesh.
  76468. */
  76469. export class OutlineRenderer implements ISceneComponent {
  76470. /**
  76471. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76472. */
  76473. private static _StencilReference;
  76474. /**
  76475. * The name of the component. Each component must have a unique name.
  76476. */
  76477. name: string;
  76478. /**
  76479. * The scene the component belongs to.
  76480. */
  76481. scene: Scene;
  76482. /**
  76483. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76484. */
  76485. zOffset: number;
  76486. private _engine;
  76487. private _effect;
  76488. private _cachedDefines;
  76489. private _savedDepthWrite;
  76490. /**
  76491. * Instantiates a new outline renderer. (There could be only one per scene).
  76492. * @param scene Defines the scene it belongs to
  76493. */
  76494. constructor(scene: Scene);
  76495. /**
  76496. * Register the component to one instance of a scene.
  76497. */
  76498. register(): void;
  76499. /**
  76500. * Rebuilds the elements related to this component in case of
  76501. * context lost for instance.
  76502. */
  76503. rebuild(): void;
  76504. /**
  76505. * Disposes the component and the associated ressources.
  76506. */
  76507. dispose(): void;
  76508. /**
  76509. * Renders the outline in the canvas.
  76510. * @param subMesh Defines the sumesh to render
  76511. * @param batch Defines the batch of meshes in case of instances
  76512. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76513. */
  76514. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76515. /**
  76516. * Returns whether or not the outline renderer is ready for a given submesh.
  76517. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76518. * @param subMesh Defines the submesh to check readyness for
  76519. * @param useInstances Defines wheter wee are trying to render instances or not
  76520. * @returns true if ready otherwise false
  76521. */
  76522. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76523. private _beforeRenderingMesh;
  76524. private _afterRenderingMesh;
  76525. }
  76526. }
  76527. declare module "babylonjs/Rendering/index" {
  76528. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76529. export * from "babylonjs/Rendering/depthRenderer";
  76530. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76531. export * from "babylonjs/Rendering/edgesRenderer";
  76532. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76533. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76534. export * from "babylonjs/Rendering/prePassRenderer";
  76535. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76536. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76537. export * from "babylonjs/Rendering/outlineRenderer";
  76538. export * from "babylonjs/Rendering/renderingGroup";
  76539. export * from "babylonjs/Rendering/renderingManager";
  76540. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76541. }
  76542. declare module "babylonjs/Sprites/ISprites" {
  76543. /**
  76544. * Defines the basic options interface of a Sprite Frame Source Size.
  76545. */
  76546. export interface ISpriteJSONSpriteSourceSize {
  76547. /**
  76548. * number of the original width of the Frame
  76549. */
  76550. w: number;
  76551. /**
  76552. * number of the original height of the Frame
  76553. */
  76554. h: number;
  76555. }
  76556. /**
  76557. * Defines the basic options interface of a Sprite Frame Data.
  76558. */
  76559. export interface ISpriteJSONSpriteFrameData {
  76560. /**
  76561. * number of the x offset of the Frame
  76562. */
  76563. x: number;
  76564. /**
  76565. * number of the y offset of the Frame
  76566. */
  76567. y: number;
  76568. /**
  76569. * number of the width of the Frame
  76570. */
  76571. w: number;
  76572. /**
  76573. * number of the height of the Frame
  76574. */
  76575. h: number;
  76576. }
  76577. /**
  76578. * Defines the basic options interface of a JSON Sprite.
  76579. */
  76580. export interface ISpriteJSONSprite {
  76581. /**
  76582. * string name of the Frame
  76583. */
  76584. filename: string;
  76585. /**
  76586. * ISpriteJSONSpriteFrame basic object of the frame data
  76587. */
  76588. frame: ISpriteJSONSpriteFrameData;
  76589. /**
  76590. * boolean to flag is the frame was rotated.
  76591. */
  76592. rotated: boolean;
  76593. /**
  76594. * boolean to flag is the frame was trimmed.
  76595. */
  76596. trimmed: boolean;
  76597. /**
  76598. * ISpriteJSONSpriteFrame basic object of the source data
  76599. */
  76600. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76601. /**
  76602. * ISpriteJSONSpriteFrame basic object of the source data
  76603. */
  76604. sourceSize: ISpriteJSONSpriteSourceSize;
  76605. }
  76606. /**
  76607. * Defines the basic options interface of a JSON atlas.
  76608. */
  76609. export interface ISpriteJSONAtlas {
  76610. /**
  76611. * Array of objects that contain the frame data.
  76612. */
  76613. frames: Array<ISpriteJSONSprite>;
  76614. /**
  76615. * object basic object containing the sprite meta data.
  76616. */
  76617. meta?: object;
  76618. }
  76619. }
  76620. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76621. /** @hidden */
  76622. export var spriteMapPixelShader: {
  76623. name: string;
  76624. shader: string;
  76625. };
  76626. }
  76627. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76628. /** @hidden */
  76629. export var spriteMapVertexShader: {
  76630. name: string;
  76631. shader: string;
  76632. };
  76633. }
  76634. declare module "babylonjs/Sprites/spriteMap" {
  76635. import { IDisposable, Scene } from "babylonjs/scene";
  76636. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76637. import { Texture } from "babylonjs/Materials/Textures/texture";
  76638. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76639. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76640. import "babylonjs/Meshes/Builders/planeBuilder";
  76641. import "babylonjs/Shaders/spriteMap.fragment";
  76642. import "babylonjs/Shaders/spriteMap.vertex";
  76643. /**
  76644. * Defines the basic options interface of a SpriteMap
  76645. */
  76646. export interface ISpriteMapOptions {
  76647. /**
  76648. * Vector2 of the number of cells in the grid.
  76649. */
  76650. stageSize?: Vector2;
  76651. /**
  76652. * Vector2 of the size of the output plane in World Units.
  76653. */
  76654. outputSize?: Vector2;
  76655. /**
  76656. * Vector3 of the position of the output plane in World Units.
  76657. */
  76658. outputPosition?: Vector3;
  76659. /**
  76660. * Vector3 of the rotation of the output plane.
  76661. */
  76662. outputRotation?: Vector3;
  76663. /**
  76664. * number of layers that the system will reserve in resources.
  76665. */
  76666. layerCount?: number;
  76667. /**
  76668. * number of max animation frames a single cell will reserve in resources.
  76669. */
  76670. maxAnimationFrames?: number;
  76671. /**
  76672. * number cell index of the base tile when the system compiles.
  76673. */
  76674. baseTile?: number;
  76675. /**
  76676. * boolean flip the sprite after its been repositioned by the framing data.
  76677. */
  76678. flipU?: boolean;
  76679. /**
  76680. * Vector3 scalar of the global RGB values of the SpriteMap.
  76681. */
  76682. colorMultiply?: Vector3;
  76683. }
  76684. /**
  76685. * Defines the IDisposable interface in order to be cleanable from resources.
  76686. */
  76687. export interface ISpriteMap extends IDisposable {
  76688. /**
  76689. * String name of the SpriteMap.
  76690. */
  76691. name: string;
  76692. /**
  76693. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76694. */
  76695. atlasJSON: ISpriteJSONAtlas;
  76696. /**
  76697. * Texture of the SpriteMap.
  76698. */
  76699. spriteSheet: Texture;
  76700. /**
  76701. * The parameters to initialize the SpriteMap with.
  76702. */
  76703. options: ISpriteMapOptions;
  76704. }
  76705. /**
  76706. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76707. */
  76708. export class SpriteMap implements ISpriteMap {
  76709. /** The Name of the spriteMap */
  76710. name: string;
  76711. /** The JSON file with the frame and meta data */
  76712. atlasJSON: ISpriteJSONAtlas;
  76713. /** The systems Sprite Sheet Texture */
  76714. spriteSheet: Texture;
  76715. /** Arguments passed with the Constructor */
  76716. options: ISpriteMapOptions;
  76717. /** Public Sprite Storage array, parsed from atlasJSON */
  76718. sprites: Array<ISpriteJSONSprite>;
  76719. /** Returns the Number of Sprites in the System */
  76720. get spriteCount(): number;
  76721. /** Returns the Position of Output Plane*/
  76722. get position(): Vector3;
  76723. /** Returns the Position of Output Plane*/
  76724. set position(v: Vector3);
  76725. /** Returns the Rotation of Output Plane*/
  76726. get rotation(): Vector3;
  76727. /** Returns the Rotation of Output Plane*/
  76728. set rotation(v: Vector3);
  76729. /** Sets the AnimationMap*/
  76730. get animationMap(): RawTexture;
  76731. /** Sets the AnimationMap*/
  76732. set animationMap(v: RawTexture);
  76733. /** Scene that the SpriteMap was created in */
  76734. private _scene;
  76735. /** Texture Buffer of Float32 that holds tile frame data*/
  76736. private _frameMap;
  76737. /** Texture Buffers of Float32 that holds tileMap data*/
  76738. private _tileMaps;
  76739. /** Texture Buffer of Float32 that holds Animation Data*/
  76740. private _animationMap;
  76741. /** Custom ShaderMaterial Central to the System*/
  76742. private _material;
  76743. /** Custom ShaderMaterial Central to the System*/
  76744. private _output;
  76745. /** Systems Time Ticker*/
  76746. private _time;
  76747. /**
  76748. * Creates a new SpriteMap
  76749. * @param name defines the SpriteMaps Name
  76750. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76751. * @param spriteSheet is the Texture that the Sprites are on.
  76752. * @param options a basic deployment configuration
  76753. * @param scene The Scene that the map is deployed on
  76754. */
  76755. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76756. /**
  76757. * Returns tileID location
  76758. * @returns Vector2 the cell position ID
  76759. */
  76760. getTileID(): Vector2;
  76761. /**
  76762. * Gets the UV location of the mouse over the SpriteMap.
  76763. * @returns Vector2 the UV position of the mouse interaction
  76764. */
  76765. getMousePosition(): Vector2;
  76766. /**
  76767. * Creates the "frame" texture Buffer
  76768. * -------------------------------------
  76769. * Structure of frames
  76770. * "filename": "Falling-Water-2.png",
  76771. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76772. * "rotated": true,
  76773. * "trimmed": true,
  76774. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76775. * "sourceSize": {"w":32,"h":32}
  76776. * @returns RawTexture of the frameMap
  76777. */
  76778. private _createFrameBuffer;
  76779. /**
  76780. * Creates the tileMap texture Buffer
  76781. * @param buffer normally and array of numbers, or a false to generate from scratch
  76782. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76783. * @returns RawTexture of the tileMap
  76784. */
  76785. private _createTileBuffer;
  76786. /**
  76787. * Modifies the data of the tileMaps
  76788. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76789. * @param pos is the iVector2 Coordinates of the Tile
  76790. * @param tile The SpriteIndex of the new Tile
  76791. */
  76792. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76793. /**
  76794. * Creates the animationMap texture Buffer
  76795. * @param buffer normally and array of numbers, or a false to generate from scratch
  76796. * @returns RawTexture of the animationMap
  76797. */
  76798. private _createTileAnimationBuffer;
  76799. /**
  76800. * Modifies the data of the animationMap
  76801. * @param cellID is the Index of the Sprite
  76802. * @param _frame is the target Animation frame
  76803. * @param toCell is the Target Index of the next frame of the animation
  76804. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76805. * @param speed is a global scalar of the time variable on the map.
  76806. */
  76807. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76808. /**
  76809. * Exports the .tilemaps file
  76810. */
  76811. saveTileMaps(): void;
  76812. /**
  76813. * Imports the .tilemaps file
  76814. * @param url of the .tilemaps file
  76815. */
  76816. loadTileMaps(url: string): void;
  76817. /**
  76818. * Release associated resources
  76819. */
  76820. dispose(): void;
  76821. }
  76822. }
  76823. declare module "babylonjs/Sprites/spritePackedManager" {
  76824. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76825. import { Scene } from "babylonjs/scene";
  76826. /**
  76827. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76828. * @see https://doc.babylonjs.com/babylon101/sprites
  76829. */
  76830. export class SpritePackedManager extends SpriteManager {
  76831. /** defines the packed manager's name */
  76832. name: string;
  76833. /**
  76834. * Creates a new sprite manager from a packed sprite sheet
  76835. * @param name defines the manager's name
  76836. * @param imgUrl defines the sprite sheet url
  76837. * @param capacity defines the maximum allowed number of sprites
  76838. * @param scene defines the hosting scene
  76839. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76840. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76841. * @param samplingMode defines the smapling mode to use with spritesheet
  76842. * @param fromPacked set to true; do not alter
  76843. */
  76844. constructor(
  76845. /** defines the packed manager's name */
  76846. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76847. }
  76848. }
  76849. declare module "babylonjs/Sprites/index" {
  76850. export * from "babylonjs/Sprites/sprite";
  76851. export * from "babylonjs/Sprites/ISprites";
  76852. export * from "babylonjs/Sprites/spriteManager";
  76853. export * from "babylonjs/Sprites/spriteMap";
  76854. export * from "babylonjs/Sprites/spritePackedManager";
  76855. export * from "babylonjs/Sprites/spriteSceneComponent";
  76856. }
  76857. declare module "babylonjs/States/index" {
  76858. export * from "babylonjs/States/alphaCullingState";
  76859. export * from "babylonjs/States/depthCullingState";
  76860. export * from "babylonjs/States/stencilState";
  76861. }
  76862. declare module "babylonjs/Misc/assetsManager" {
  76863. import { Scene } from "babylonjs/scene";
  76864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76865. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76866. import { Skeleton } from "babylonjs/Bones/skeleton";
  76867. import { Observable } from "babylonjs/Misc/observable";
  76868. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76869. import { Texture } from "babylonjs/Materials/Textures/texture";
  76870. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76871. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76872. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76873. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76874. import { AssetContainer } from "babylonjs/assetContainer";
  76875. /**
  76876. * Defines the list of states available for a task inside a AssetsManager
  76877. */
  76878. export enum AssetTaskState {
  76879. /**
  76880. * Initialization
  76881. */
  76882. INIT = 0,
  76883. /**
  76884. * Running
  76885. */
  76886. RUNNING = 1,
  76887. /**
  76888. * Done
  76889. */
  76890. DONE = 2,
  76891. /**
  76892. * Error
  76893. */
  76894. ERROR = 3
  76895. }
  76896. /**
  76897. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76898. */
  76899. export abstract class AbstractAssetTask {
  76900. /**
  76901. * Task name
  76902. */ name: string;
  76903. /**
  76904. * Callback called when the task is successful
  76905. */
  76906. onSuccess: (task: any) => void;
  76907. /**
  76908. * Callback called when the task is not successful
  76909. */
  76910. onError: (task: any, message?: string, exception?: any) => void;
  76911. /**
  76912. * Creates a new AssetsManager
  76913. * @param name defines the name of the task
  76914. */
  76915. constructor(
  76916. /**
  76917. * Task name
  76918. */ name: string);
  76919. private _isCompleted;
  76920. private _taskState;
  76921. private _errorObject;
  76922. /**
  76923. * Get if the task is completed
  76924. */
  76925. get isCompleted(): boolean;
  76926. /**
  76927. * Gets the current state of the task
  76928. */
  76929. get taskState(): AssetTaskState;
  76930. /**
  76931. * Gets the current error object (if task is in error)
  76932. */
  76933. get errorObject(): {
  76934. message?: string;
  76935. exception?: any;
  76936. };
  76937. /**
  76938. * Internal only
  76939. * @hidden
  76940. */
  76941. _setErrorObject(message?: string, exception?: any): void;
  76942. /**
  76943. * Execute the current task
  76944. * @param scene defines the scene where you want your assets to be loaded
  76945. * @param onSuccess is a callback called when the task is successfully executed
  76946. * @param onError is a callback called if an error occurs
  76947. */
  76948. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76949. /**
  76950. * Execute the current task
  76951. * @param scene defines the scene where you want your assets to be loaded
  76952. * @param onSuccess is a callback called when the task is successfully executed
  76953. * @param onError is a callback called if an error occurs
  76954. */
  76955. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76956. /**
  76957. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76958. * This can be used with failed tasks that have the reason for failure fixed.
  76959. */
  76960. reset(): void;
  76961. private onErrorCallback;
  76962. private onDoneCallback;
  76963. }
  76964. /**
  76965. * Define the interface used by progress events raised during assets loading
  76966. */
  76967. export interface IAssetsProgressEvent {
  76968. /**
  76969. * Defines the number of remaining tasks to process
  76970. */
  76971. remainingCount: number;
  76972. /**
  76973. * Defines the total number of tasks
  76974. */
  76975. totalCount: number;
  76976. /**
  76977. * Defines the task that was just processed
  76978. */
  76979. task: AbstractAssetTask;
  76980. }
  76981. /**
  76982. * Class used to share progress information about assets loading
  76983. */
  76984. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76985. /**
  76986. * Defines the number of remaining tasks to process
  76987. */
  76988. remainingCount: number;
  76989. /**
  76990. * Defines the total number of tasks
  76991. */
  76992. totalCount: number;
  76993. /**
  76994. * Defines the task that was just processed
  76995. */
  76996. task: AbstractAssetTask;
  76997. /**
  76998. * Creates a AssetsProgressEvent
  76999. * @param remainingCount defines the number of remaining tasks to process
  77000. * @param totalCount defines the total number of tasks
  77001. * @param task defines the task that was just processed
  77002. */
  77003. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77004. }
  77005. /**
  77006. * Define a task used by AssetsManager to load assets into a container
  77007. */
  77008. export class ContainerAssetTask extends AbstractAssetTask {
  77009. /**
  77010. * Defines the name of the task
  77011. */
  77012. name: string;
  77013. /**
  77014. * Defines the list of mesh's names you want to load
  77015. */
  77016. meshesNames: any;
  77017. /**
  77018. * Defines the root url to use as a base to load your meshes and associated resources
  77019. */
  77020. rootUrl: string;
  77021. /**
  77022. * Defines the filename or File of the scene to load from
  77023. */
  77024. sceneFilename: string | File;
  77025. /**
  77026. * Get the loaded asset container
  77027. */
  77028. loadedContainer: AssetContainer;
  77029. /**
  77030. * Gets the list of loaded meshes
  77031. */
  77032. loadedMeshes: Array<AbstractMesh>;
  77033. /**
  77034. * Gets the list of loaded particle systems
  77035. */
  77036. loadedParticleSystems: Array<IParticleSystem>;
  77037. /**
  77038. * Gets the list of loaded skeletons
  77039. */
  77040. loadedSkeletons: Array<Skeleton>;
  77041. /**
  77042. * Gets the list of loaded animation groups
  77043. */
  77044. loadedAnimationGroups: Array<AnimationGroup>;
  77045. /**
  77046. * Callback called when the task is successful
  77047. */
  77048. onSuccess: (task: ContainerAssetTask) => void;
  77049. /**
  77050. * Callback called when the task is successful
  77051. */
  77052. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77053. /**
  77054. * Creates a new ContainerAssetTask
  77055. * @param name defines the name of the task
  77056. * @param meshesNames defines the list of mesh's names you want to load
  77057. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77058. * @param sceneFilename defines the filename or File of the scene to load from
  77059. */
  77060. constructor(
  77061. /**
  77062. * Defines the name of the task
  77063. */
  77064. name: string,
  77065. /**
  77066. * Defines the list of mesh's names you want to load
  77067. */
  77068. meshesNames: any,
  77069. /**
  77070. * Defines the root url to use as a base to load your meshes and associated resources
  77071. */
  77072. rootUrl: string,
  77073. /**
  77074. * Defines the filename or File of the scene to load from
  77075. */
  77076. sceneFilename: string | File);
  77077. /**
  77078. * Execute the current task
  77079. * @param scene defines the scene where you want your assets to be loaded
  77080. * @param onSuccess is a callback called when the task is successfully executed
  77081. * @param onError is a callback called if an error occurs
  77082. */
  77083. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77084. }
  77085. /**
  77086. * Define a task used by AssetsManager to load meshes
  77087. */
  77088. export class MeshAssetTask extends AbstractAssetTask {
  77089. /**
  77090. * Defines the name of the task
  77091. */
  77092. name: string;
  77093. /**
  77094. * Defines the list of mesh's names you want to load
  77095. */
  77096. meshesNames: any;
  77097. /**
  77098. * Defines the root url to use as a base to load your meshes and associated resources
  77099. */
  77100. rootUrl: string;
  77101. /**
  77102. * Defines the filename or File of the scene to load from
  77103. */
  77104. sceneFilename: string | File;
  77105. /**
  77106. * Gets the list of loaded meshes
  77107. */
  77108. loadedMeshes: Array<AbstractMesh>;
  77109. /**
  77110. * Gets the list of loaded particle systems
  77111. */
  77112. loadedParticleSystems: Array<IParticleSystem>;
  77113. /**
  77114. * Gets the list of loaded skeletons
  77115. */
  77116. loadedSkeletons: Array<Skeleton>;
  77117. /**
  77118. * Gets the list of loaded animation groups
  77119. */
  77120. loadedAnimationGroups: Array<AnimationGroup>;
  77121. /**
  77122. * Callback called when the task is successful
  77123. */
  77124. onSuccess: (task: MeshAssetTask) => void;
  77125. /**
  77126. * Callback called when the task is successful
  77127. */
  77128. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77129. /**
  77130. * Creates a new MeshAssetTask
  77131. * @param name defines the name of the task
  77132. * @param meshesNames defines the list of mesh's names you want to load
  77133. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77134. * @param sceneFilename defines the filename or File of the scene to load from
  77135. */
  77136. constructor(
  77137. /**
  77138. * Defines the name of the task
  77139. */
  77140. name: string,
  77141. /**
  77142. * Defines the list of mesh's names you want to load
  77143. */
  77144. meshesNames: any,
  77145. /**
  77146. * Defines the root url to use as a base to load your meshes and associated resources
  77147. */
  77148. rootUrl: string,
  77149. /**
  77150. * Defines the filename or File of the scene to load from
  77151. */
  77152. sceneFilename: string | File);
  77153. /**
  77154. * Execute the current task
  77155. * @param scene defines the scene where you want your assets to be loaded
  77156. * @param onSuccess is a callback called when the task is successfully executed
  77157. * @param onError is a callback called if an error occurs
  77158. */
  77159. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77160. }
  77161. /**
  77162. * Define a task used by AssetsManager to load text content
  77163. */
  77164. export class TextFileAssetTask extends AbstractAssetTask {
  77165. /**
  77166. * Defines the name of the task
  77167. */
  77168. name: string;
  77169. /**
  77170. * Defines the location of the file to load
  77171. */
  77172. url: string;
  77173. /**
  77174. * Gets the loaded text string
  77175. */
  77176. text: string;
  77177. /**
  77178. * Callback called when the task is successful
  77179. */
  77180. onSuccess: (task: TextFileAssetTask) => void;
  77181. /**
  77182. * Callback called when the task is successful
  77183. */
  77184. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77185. /**
  77186. * Creates a new TextFileAssetTask object
  77187. * @param name defines the name of the task
  77188. * @param url defines the location of the file to load
  77189. */
  77190. constructor(
  77191. /**
  77192. * Defines the name of the task
  77193. */
  77194. name: string,
  77195. /**
  77196. * Defines the location of the file to load
  77197. */
  77198. url: string);
  77199. /**
  77200. * Execute the current task
  77201. * @param scene defines the scene where you want your assets to be loaded
  77202. * @param onSuccess is a callback called when the task is successfully executed
  77203. * @param onError is a callback called if an error occurs
  77204. */
  77205. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77206. }
  77207. /**
  77208. * Define a task used by AssetsManager to load binary data
  77209. */
  77210. export class BinaryFileAssetTask extends AbstractAssetTask {
  77211. /**
  77212. * Defines the name of the task
  77213. */
  77214. name: string;
  77215. /**
  77216. * Defines the location of the file to load
  77217. */
  77218. url: string;
  77219. /**
  77220. * Gets the lodaded data (as an array buffer)
  77221. */
  77222. data: ArrayBuffer;
  77223. /**
  77224. * Callback called when the task is successful
  77225. */
  77226. onSuccess: (task: BinaryFileAssetTask) => void;
  77227. /**
  77228. * Callback called when the task is successful
  77229. */
  77230. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77231. /**
  77232. * Creates a new BinaryFileAssetTask object
  77233. * @param name defines the name of the new task
  77234. * @param url defines the location of the file to load
  77235. */
  77236. constructor(
  77237. /**
  77238. * Defines the name of the task
  77239. */
  77240. name: string,
  77241. /**
  77242. * Defines the location of the file to load
  77243. */
  77244. url: string);
  77245. /**
  77246. * Execute the current task
  77247. * @param scene defines the scene where you want your assets to be loaded
  77248. * @param onSuccess is a callback called when the task is successfully executed
  77249. * @param onError is a callback called if an error occurs
  77250. */
  77251. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77252. }
  77253. /**
  77254. * Define a task used by AssetsManager to load images
  77255. */
  77256. export class ImageAssetTask extends AbstractAssetTask {
  77257. /**
  77258. * Defines the name of the task
  77259. */
  77260. name: string;
  77261. /**
  77262. * Defines the location of the image to load
  77263. */
  77264. url: string;
  77265. /**
  77266. * Gets the loaded images
  77267. */
  77268. image: HTMLImageElement;
  77269. /**
  77270. * Callback called when the task is successful
  77271. */
  77272. onSuccess: (task: ImageAssetTask) => void;
  77273. /**
  77274. * Callback called when the task is successful
  77275. */
  77276. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77277. /**
  77278. * Creates a new ImageAssetTask
  77279. * @param name defines the name of the task
  77280. * @param url defines the location of the image to load
  77281. */
  77282. constructor(
  77283. /**
  77284. * Defines the name of the task
  77285. */
  77286. name: string,
  77287. /**
  77288. * Defines the location of the image to load
  77289. */
  77290. url: string);
  77291. /**
  77292. * Execute the current task
  77293. * @param scene defines the scene where you want your assets to be loaded
  77294. * @param onSuccess is a callback called when the task is successfully executed
  77295. * @param onError is a callback called if an error occurs
  77296. */
  77297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77298. }
  77299. /**
  77300. * Defines the interface used by texture loading tasks
  77301. */
  77302. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77303. /**
  77304. * Gets the loaded texture
  77305. */
  77306. texture: TEX;
  77307. }
  77308. /**
  77309. * Define a task used by AssetsManager to load 2D textures
  77310. */
  77311. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77312. /**
  77313. * Defines the name of the task
  77314. */
  77315. name: string;
  77316. /**
  77317. * Defines the location of the file to load
  77318. */
  77319. url: string;
  77320. /**
  77321. * Defines if mipmap should not be generated (default is false)
  77322. */
  77323. noMipmap?: boolean | undefined;
  77324. /**
  77325. * Defines if texture must be inverted on Y axis (default is true)
  77326. */
  77327. invertY: boolean;
  77328. /**
  77329. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77330. */
  77331. samplingMode: number;
  77332. /**
  77333. * Gets the loaded texture
  77334. */
  77335. texture: Texture;
  77336. /**
  77337. * Callback called when the task is successful
  77338. */
  77339. onSuccess: (task: TextureAssetTask) => void;
  77340. /**
  77341. * Callback called when the task is successful
  77342. */
  77343. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77344. /**
  77345. * Creates a new TextureAssetTask object
  77346. * @param name defines the name of the task
  77347. * @param url defines the location of the file to load
  77348. * @param noMipmap defines if mipmap should not be generated (default is false)
  77349. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77350. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77351. */
  77352. constructor(
  77353. /**
  77354. * Defines the name of the task
  77355. */
  77356. name: string,
  77357. /**
  77358. * Defines the location of the file to load
  77359. */
  77360. url: string,
  77361. /**
  77362. * Defines if mipmap should not be generated (default is false)
  77363. */
  77364. noMipmap?: boolean | undefined,
  77365. /**
  77366. * Defines if texture must be inverted on Y axis (default is true)
  77367. */
  77368. invertY?: boolean,
  77369. /**
  77370. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77371. */
  77372. samplingMode?: number);
  77373. /**
  77374. * Execute the current task
  77375. * @param scene defines the scene where you want your assets to be loaded
  77376. * @param onSuccess is a callback called when the task is successfully executed
  77377. * @param onError is a callback called if an error occurs
  77378. */
  77379. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77380. }
  77381. /**
  77382. * Define a task used by AssetsManager to load cube textures
  77383. */
  77384. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77385. /**
  77386. * Defines the name of the task
  77387. */
  77388. name: string;
  77389. /**
  77390. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77391. */
  77392. url: string;
  77393. /**
  77394. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77395. */
  77396. extensions?: string[] | undefined;
  77397. /**
  77398. * Defines if mipmaps should not be generated (default is false)
  77399. */
  77400. noMipmap?: boolean | undefined;
  77401. /**
  77402. * Defines the explicit list of files (undefined by default)
  77403. */
  77404. files?: string[] | undefined;
  77405. /**
  77406. * Gets the loaded texture
  77407. */
  77408. texture: CubeTexture;
  77409. /**
  77410. * Callback called when the task is successful
  77411. */
  77412. onSuccess: (task: CubeTextureAssetTask) => void;
  77413. /**
  77414. * Callback called when the task is successful
  77415. */
  77416. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77417. /**
  77418. * Creates a new CubeTextureAssetTask
  77419. * @param name defines the name of the task
  77420. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77421. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77422. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77423. * @param files defines the explicit list of files (undefined by default)
  77424. */
  77425. constructor(
  77426. /**
  77427. * Defines the name of the task
  77428. */
  77429. name: string,
  77430. /**
  77431. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77432. */
  77433. url: string,
  77434. /**
  77435. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77436. */
  77437. extensions?: string[] | undefined,
  77438. /**
  77439. * Defines if mipmaps should not be generated (default is false)
  77440. */
  77441. noMipmap?: boolean | undefined,
  77442. /**
  77443. * Defines the explicit list of files (undefined by default)
  77444. */
  77445. files?: string[] | undefined);
  77446. /**
  77447. * Execute the current task
  77448. * @param scene defines the scene where you want your assets to be loaded
  77449. * @param onSuccess is a callback called when the task is successfully executed
  77450. * @param onError is a callback called if an error occurs
  77451. */
  77452. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77453. }
  77454. /**
  77455. * Define a task used by AssetsManager to load HDR cube textures
  77456. */
  77457. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77458. /**
  77459. * Defines the name of the task
  77460. */
  77461. name: string;
  77462. /**
  77463. * Defines the location of the file to load
  77464. */
  77465. url: string;
  77466. /**
  77467. * Defines the desired size (the more it increases the longer the generation will be)
  77468. */
  77469. size: number;
  77470. /**
  77471. * Defines if mipmaps should not be generated (default is false)
  77472. */
  77473. noMipmap: boolean;
  77474. /**
  77475. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77476. */
  77477. generateHarmonics: boolean;
  77478. /**
  77479. * 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)
  77480. */
  77481. gammaSpace: boolean;
  77482. /**
  77483. * Internal Use Only
  77484. */
  77485. reserved: boolean;
  77486. /**
  77487. * Gets the loaded texture
  77488. */
  77489. texture: HDRCubeTexture;
  77490. /**
  77491. * Callback called when the task is successful
  77492. */
  77493. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77494. /**
  77495. * Callback called when the task is successful
  77496. */
  77497. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77498. /**
  77499. * Creates a new HDRCubeTextureAssetTask object
  77500. * @param name defines the name of the task
  77501. * @param url defines the location of the file to load
  77502. * @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.
  77503. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77504. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77505. * @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)
  77506. * @param reserved Internal use only
  77507. */
  77508. constructor(
  77509. /**
  77510. * Defines the name of the task
  77511. */
  77512. name: string,
  77513. /**
  77514. * Defines the location of the file to load
  77515. */
  77516. url: string,
  77517. /**
  77518. * Defines the desired size (the more it increases the longer the generation will be)
  77519. */
  77520. size: number,
  77521. /**
  77522. * Defines if mipmaps should not be generated (default is false)
  77523. */
  77524. noMipmap?: boolean,
  77525. /**
  77526. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77527. */
  77528. generateHarmonics?: boolean,
  77529. /**
  77530. * 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)
  77531. */
  77532. gammaSpace?: boolean,
  77533. /**
  77534. * Internal Use Only
  77535. */
  77536. reserved?: boolean);
  77537. /**
  77538. * Execute the current task
  77539. * @param scene defines the scene where you want your assets to be loaded
  77540. * @param onSuccess is a callback called when the task is successfully executed
  77541. * @param onError is a callback called if an error occurs
  77542. */
  77543. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77544. }
  77545. /**
  77546. * Define a task used by AssetsManager to load Equirectangular cube textures
  77547. */
  77548. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77549. /**
  77550. * Defines the name of the task
  77551. */
  77552. name: string;
  77553. /**
  77554. * Defines the location of the file to load
  77555. */
  77556. url: string;
  77557. /**
  77558. * Defines the desired size (the more it increases the longer the generation will be)
  77559. */
  77560. size: number;
  77561. /**
  77562. * Defines if mipmaps should not be generated (default is false)
  77563. */
  77564. noMipmap: boolean;
  77565. /**
  77566. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77567. * but the standard material would require them in Gamma space) (default is true)
  77568. */
  77569. gammaSpace: boolean;
  77570. /**
  77571. * Gets the loaded texture
  77572. */
  77573. texture: EquiRectangularCubeTexture;
  77574. /**
  77575. * Callback called when the task is successful
  77576. */
  77577. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77578. /**
  77579. * Callback called when the task is successful
  77580. */
  77581. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77582. /**
  77583. * Creates a new EquiRectangularCubeTextureAssetTask object
  77584. * @param name defines the name of the task
  77585. * @param url defines the location of the file to load
  77586. * @param size defines the desired size (the more it increases the longer the generation will be)
  77587. * If the size is omitted this implies you are using a preprocessed cubemap.
  77588. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77589. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77590. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77591. * (default is true)
  77592. */
  77593. constructor(
  77594. /**
  77595. * Defines the name of the task
  77596. */
  77597. name: string,
  77598. /**
  77599. * Defines the location of the file to load
  77600. */
  77601. url: string,
  77602. /**
  77603. * Defines the desired size (the more it increases the longer the generation will be)
  77604. */
  77605. size: number,
  77606. /**
  77607. * Defines if mipmaps should not be generated (default is false)
  77608. */
  77609. noMipmap?: boolean,
  77610. /**
  77611. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77612. * but the standard material would require them in Gamma space) (default is true)
  77613. */
  77614. gammaSpace?: boolean);
  77615. /**
  77616. * Execute the current task
  77617. * @param scene defines the scene where you want your assets to be loaded
  77618. * @param onSuccess is a callback called when the task is successfully executed
  77619. * @param onError is a callback called if an error occurs
  77620. */
  77621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77622. }
  77623. /**
  77624. * This class can be used to easily import assets into a scene
  77625. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77626. */
  77627. export class AssetsManager {
  77628. private _scene;
  77629. private _isLoading;
  77630. protected _tasks: AbstractAssetTask[];
  77631. protected _waitingTasksCount: number;
  77632. protected _totalTasksCount: number;
  77633. /**
  77634. * Callback called when all tasks are processed
  77635. */
  77636. onFinish: (tasks: AbstractAssetTask[]) => void;
  77637. /**
  77638. * Callback called when a task is successful
  77639. */
  77640. onTaskSuccess: (task: AbstractAssetTask) => void;
  77641. /**
  77642. * Callback called when a task had an error
  77643. */
  77644. onTaskError: (task: AbstractAssetTask) => void;
  77645. /**
  77646. * Callback called when a task is done (whatever the result is)
  77647. */
  77648. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77649. /**
  77650. * Observable called when all tasks are processed
  77651. */
  77652. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77653. /**
  77654. * Observable called when a task had an error
  77655. */
  77656. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77657. /**
  77658. * Observable called when all tasks were executed
  77659. */
  77660. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77661. /**
  77662. * Observable called when a task is done (whatever the result is)
  77663. */
  77664. onProgressObservable: Observable<IAssetsProgressEvent>;
  77665. /**
  77666. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77667. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77668. */
  77669. useDefaultLoadingScreen: boolean;
  77670. /**
  77671. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77672. * when all assets have been downloaded.
  77673. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77674. */
  77675. autoHideLoadingUI: boolean;
  77676. /**
  77677. * Creates a new AssetsManager
  77678. * @param scene defines the scene to work on
  77679. */
  77680. constructor(scene: Scene);
  77681. /**
  77682. * Add a ContainerAssetTask to the list of active tasks
  77683. * @param taskName defines the name of the new task
  77684. * @param meshesNames defines the name of meshes to load
  77685. * @param rootUrl defines the root url to use to locate files
  77686. * @param sceneFilename defines the filename of the scene file
  77687. * @returns a new ContainerAssetTask object
  77688. */
  77689. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77690. /**
  77691. * Add a MeshAssetTask to the list of active tasks
  77692. * @param taskName defines the name of the new task
  77693. * @param meshesNames defines the name of meshes to load
  77694. * @param rootUrl defines the root url to use to locate files
  77695. * @param sceneFilename defines the filename of the scene file
  77696. * @returns a new MeshAssetTask object
  77697. */
  77698. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77699. /**
  77700. * Add a TextFileAssetTask to the list of active tasks
  77701. * @param taskName defines the name of the new task
  77702. * @param url defines the url of the file to load
  77703. * @returns a new TextFileAssetTask object
  77704. */
  77705. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77706. /**
  77707. * Add a BinaryFileAssetTask to the list of active tasks
  77708. * @param taskName defines the name of the new task
  77709. * @param url defines the url of the file to load
  77710. * @returns a new BinaryFileAssetTask object
  77711. */
  77712. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77713. /**
  77714. * Add a ImageAssetTask to the list of active tasks
  77715. * @param taskName defines the name of the new task
  77716. * @param url defines the url of the file to load
  77717. * @returns a new ImageAssetTask object
  77718. */
  77719. addImageTask(taskName: string, url: string): ImageAssetTask;
  77720. /**
  77721. * Add a TextureAssetTask to the list of active tasks
  77722. * @param taskName defines the name of the new task
  77723. * @param url defines the url of the file to load
  77724. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77725. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77726. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77727. * @returns a new TextureAssetTask object
  77728. */
  77729. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77730. /**
  77731. * Add a CubeTextureAssetTask to the list of active tasks
  77732. * @param taskName defines the name of the new task
  77733. * @param url defines the url of the file to load
  77734. * @param extensions defines the extension to use to load the cube map (can be null)
  77735. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77736. * @param files defines the list of files to load (can be null)
  77737. * @returns a new CubeTextureAssetTask object
  77738. */
  77739. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77740. /**
  77741. *
  77742. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77743. * @param taskName defines the name of the new task
  77744. * @param url defines the url of the file to load
  77745. * @param size defines the size you want for the cubemap (can be null)
  77746. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77747. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77748. * @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)
  77749. * @param reserved Internal use only
  77750. * @returns a new HDRCubeTextureAssetTask object
  77751. */
  77752. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77753. /**
  77754. *
  77755. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77756. * @param taskName defines the name of the new task
  77757. * @param url defines the url of the file to load
  77758. * @param size defines the size you want for the cubemap (can be null)
  77759. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77760. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77761. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77762. * @returns a new EquiRectangularCubeTextureAssetTask object
  77763. */
  77764. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77765. /**
  77766. * Remove a task from the assets manager.
  77767. * @param task the task to remove
  77768. */
  77769. removeTask(task: AbstractAssetTask): void;
  77770. private _decreaseWaitingTasksCount;
  77771. private _runTask;
  77772. /**
  77773. * Reset the AssetsManager and remove all tasks
  77774. * @return the current instance of the AssetsManager
  77775. */
  77776. reset(): AssetsManager;
  77777. /**
  77778. * Start the loading process
  77779. * @return the current instance of the AssetsManager
  77780. */
  77781. load(): AssetsManager;
  77782. /**
  77783. * Start the loading process as an async operation
  77784. * @return a promise returning the list of failed tasks
  77785. */
  77786. loadAsync(): Promise<void>;
  77787. }
  77788. }
  77789. declare module "babylonjs/Misc/deferred" {
  77790. /**
  77791. * Wrapper class for promise with external resolve and reject.
  77792. */
  77793. export class Deferred<T> {
  77794. /**
  77795. * The promise associated with this deferred object.
  77796. */
  77797. readonly promise: Promise<T>;
  77798. private _resolve;
  77799. private _reject;
  77800. /**
  77801. * The resolve method of the promise associated with this deferred object.
  77802. */
  77803. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77804. /**
  77805. * The reject method of the promise associated with this deferred object.
  77806. */
  77807. get reject(): (reason?: any) => void;
  77808. /**
  77809. * Constructor for this deferred object.
  77810. */
  77811. constructor();
  77812. }
  77813. }
  77814. declare module "babylonjs/Misc/meshExploder" {
  77815. import { Mesh } from "babylonjs/Meshes/mesh";
  77816. /**
  77817. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77818. */
  77819. export class MeshExploder {
  77820. private _centerMesh;
  77821. private _meshes;
  77822. private _meshesOrigins;
  77823. private _toCenterVectors;
  77824. private _scaledDirection;
  77825. private _newPosition;
  77826. private _centerPosition;
  77827. /**
  77828. * Explodes meshes from a center mesh.
  77829. * @param meshes The meshes to explode.
  77830. * @param centerMesh The mesh to be center of explosion.
  77831. */
  77832. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77833. private _setCenterMesh;
  77834. /**
  77835. * Get class name
  77836. * @returns "MeshExploder"
  77837. */
  77838. getClassName(): string;
  77839. /**
  77840. * "Exploded meshes"
  77841. * @returns Array of meshes with the centerMesh at index 0.
  77842. */
  77843. getMeshes(): Array<Mesh>;
  77844. /**
  77845. * Explodes meshes giving a specific direction
  77846. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77847. */
  77848. explode(direction?: number): void;
  77849. }
  77850. }
  77851. declare module "babylonjs/Misc/filesInput" {
  77852. import { Engine } from "babylonjs/Engines/engine";
  77853. import { Scene } from "babylonjs/scene";
  77854. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77855. import { Nullable } from "babylonjs/types";
  77856. /**
  77857. * Class used to help managing file picking and drag'n'drop
  77858. */
  77859. export class FilesInput {
  77860. /**
  77861. * List of files ready to be loaded
  77862. */
  77863. static get FilesToLoad(): {
  77864. [key: string]: File;
  77865. };
  77866. /**
  77867. * Callback called when a file is processed
  77868. */
  77869. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77870. private _engine;
  77871. private _currentScene;
  77872. private _sceneLoadedCallback;
  77873. private _progressCallback;
  77874. private _additionalRenderLoopLogicCallback;
  77875. private _textureLoadingCallback;
  77876. private _startingProcessingFilesCallback;
  77877. private _onReloadCallback;
  77878. private _errorCallback;
  77879. private _elementToMonitor;
  77880. private _sceneFileToLoad;
  77881. private _filesToLoad;
  77882. /**
  77883. * Creates a new FilesInput
  77884. * @param engine defines the rendering engine
  77885. * @param scene defines the hosting scene
  77886. * @param sceneLoadedCallback callback called when scene is loaded
  77887. * @param progressCallback callback called to track progress
  77888. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77889. * @param textureLoadingCallback callback called when a texture is loading
  77890. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77891. * @param onReloadCallback callback called when a reload is requested
  77892. * @param errorCallback callback call if an error occurs
  77893. */
  77894. 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>);
  77895. private _dragEnterHandler;
  77896. private _dragOverHandler;
  77897. private _dropHandler;
  77898. /**
  77899. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77900. * @param elementToMonitor defines the DOM element to track
  77901. */
  77902. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77903. /** Gets the current list of files to load */
  77904. get filesToLoad(): File[];
  77905. /**
  77906. * Release all associated resources
  77907. */
  77908. dispose(): void;
  77909. private renderFunction;
  77910. private drag;
  77911. private drop;
  77912. private _traverseFolder;
  77913. private _processFiles;
  77914. /**
  77915. * Load files from a drop event
  77916. * @param event defines the drop event to use as source
  77917. */
  77918. loadFiles(event: any): void;
  77919. private _processReload;
  77920. /**
  77921. * Reload the current scene from the loaded files
  77922. */
  77923. reload(): void;
  77924. }
  77925. }
  77926. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77927. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77928. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77929. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77930. }
  77931. declare module "babylonjs/Misc/sceneOptimizer" {
  77932. import { Scene, IDisposable } from "babylonjs/scene";
  77933. import { Observable } from "babylonjs/Misc/observable";
  77934. /**
  77935. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77936. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77937. */
  77938. export class SceneOptimization {
  77939. /**
  77940. * Defines the priority of this optimization (0 by default which means first in the list)
  77941. */
  77942. priority: number;
  77943. /**
  77944. * Gets a string describing the action executed by the current optimization
  77945. * @returns description string
  77946. */
  77947. getDescription(): string;
  77948. /**
  77949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77950. * @param scene defines the current scene where to apply this optimization
  77951. * @param optimizer defines the current optimizer
  77952. * @returns true if everything that can be done was applied
  77953. */
  77954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77955. /**
  77956. * Creates the SceneOptimization object
  77957. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77958. * @param desc defines the description associated with the optimization
  77959. */
  77960. constructor(
  77961. /**
  77962. * Defines the priority of this optimization (0 by default which means first in the list)
  77963. */
  77964. priority?: number);
  77965. }
  77966. /**
  77967. * Defines an optimization used to reduce the size of render target textures
  77968. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77969. */
  77970. export class TextureOptimization extends SceneOptimization {
  77971. /**
  77972. * Defines the priority of this optimization (0 by default which means first in the list)
  77973. */
  77974. priority: number;
  77975. /**
  77976. * 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
  77977. */
  77978. maximumSize: number;
  77979. /**
  77980. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77981. */
  77982. step: number;
  77983. /**
  77984. * Gets a string describing the action executed by the current optimization
  77985. * @returns description string
  77986. */
  77987. getDescription(): string;
  77988. /**
  77989. * Creates the TextureOptimization object
  77990. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77991. * @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
  77992. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77993. */
  77994. constructor(
  77995. /**
  77996. * Defines the priority of this optimization (0 by default which means first in the list)
  77997. */
  77998. priority?: number,
  77999. /**
  78000. * 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
  78001. */
  78002. maximumSize?: number,
  78003. /**
  78004. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78005. */
  78006. step?: number);
  78007. /**
  78008. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78009. * @param scene defines the current scene where to apply this optimization
  78010. * @param optimizer defines the current optimizer
  78011. * @returns true if everything that can be done was applied
  78012. */
  78013. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78014. }
  78015. /**
  78016. * Defines an optimization used to increase or decrease the rendering resolution
  78017. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78018. */
  78019. export class HardwareScalingOptimization extends SceneOptimization {
  78020. /**
  78021. * Defines the priority of this optimization (0 by default which means first in the list)
  78022. */
  78023. priority: number;
  78024. /**
  78025. * Defines the maximum scale to use (2 by default)
  78026. */
  78027. maximumScale: number;
  78028. /**
  78029. * Defines the step to use between two passes (0.5 by default)
  78030. */
  78031. step: number;
  78032. private _currentScale;
  78033. private _directionOffset;
  78034. /**
  78035. * Gets a string describing the action executed by the current optimization
  78036. * @return description string
  78037. */
  78038. getDescription(): string;
  78039. /**
  78040. * Creates the HardwareScalingOptimization object
  78041. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78042. * @param maximumScale defines the maximum scale to use (2 by default)
  78043. * @param step defines the step to use between two passes (0.5 by default)
  78044. */
  78045. constructor(
  78046. /**
  78047. * Defines the priority of this optimization (0 by default which means first in the list)
  78048. */
  78049. priority?: number,
  78050. /**
  78051. * Defines the maximum scale to use (2 by default)
  78052. */
  78053. maximumScale?: number,
  78054. /**
  78055. * Defines the step to use between two passes (0.5 by default)
  78056. */
  78057. step?: number);
  78058. /**
  78059. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78060. * @param scene defines the current scene where to apply this optimization
  78061. * @param optimizer defines the current optimizer
  78062. * @returns true if everything that can be done was applied
  78063. */
  78064. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78065. }
  78066. /**
  78067. * Defines an optimization used to remove shadows
  78068. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78069. */
  78070. export class ShadowsOptimization extends SceneOptimization {
  78071. /**
  78072. * Gets a string describing the action executed by the current optimization
  78073. * @return description string
  78074. */
  78075. getDescription(): string;
  78076. /**
  78077. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78078. * @param scene defines the current scene where to apply this optimization
  78079. * @param optimizer defines the current optimizer
  78080. * @returns true if everything that can be done was applied
  78081. */
  78082. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78083. }
  78084. /**
  78085. * Defines an optimization used to turn post-processes off
  78086. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78087. */
  78088. export class PostProcessesOptimization extends SceneOptimization {
  78089. /**
  78090. * Gets a string describing the action executed by the current optimization
  78091. * @return description string
  78092. */
  78093. getDescription(): string;
  78094. /**
  78095. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78096. * @param scene defines the current scene where to apply this optimization
  78097. * @param optimizer defines the current optimizer
  78098. * @returns true if everything that can be done was applied
  78099. */
  78100. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78101. }
  78102. /**
  78103. * Defines an optimization used to turn lens flares off
  78104. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78105. */
  78106. export class LensFlaresOptimization extends SceneOptimization {
  78107. /**
  78108. * Gets a string describing the action executed by the current optimization
  78109. * @return description string
  78110. */
  78111. getDescription(): string;
  78112. /**
  78113. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78114. * @param scene defines the current scene where to apply this optimization
  78115. * @param optimizer defines the current optimizer
  78116. * @returns true if everything that can be done was applied
  78117. */
  78118. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78119. }
  78120. /**
  78121. * Defines an optimization based on user defined callback.
  78122. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78123. */
  78124. export class CustomOptimization extends SceneOptimization {
  78125. /**
  78126. * Callback called to apply the custom optimization.
  78127. */
  78128. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78129. /**
  78130. * Callback called to get custom description
  78131. */
  78132. onGetDescription: () => string;
  78133. /**
  78134. * Gets a string describing the action executed by the current optimization
  78135. * @returns description string
  78136. */
  78137. getDescription(): string;
  78138. /**
  78139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78140. * @param scene defines the current scene where to apply this optimization
  78141. * @param optimizer defines the current optimizer
  78142. * @returns true if everything that can be done was applied
  78143. */
  78144. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78145. }
  78146. /**
  78147. * Defines an optimization used to turn particles off
  78148. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78149. */
  78150. export class ParticlesOptimization extends SceneOptimization {
  78151. /**
  78152. * Gets a string describing the action executed by the current optimization
  78153. * @return description string
  78154. */
  78155. getDescription(): string;
  78156. /**
  78157. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78158. * @param scene defines the current scene where to apply this optimization
  78159. * @param optimizer defines the current optimizer
  78160. * @returns true if everything that can be done was applied
  78161. */
  78162. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78163. }
  78164. /**
  78165. * Defines an optimization used to turn render targets off
  78166. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78167. */
  78168. export class RenderTargetsOptimization extends SceneOptimization {
  78169. /**
  78170. * Gets a string describing the action executed by the current optimization
  78171. * @return description string
  78172. */
  78173. getDescription(): string;
  78174. /**
  78175. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78176. * @param scene defines the current scene where to apply this optimization
  78177. * @param optimizer defines the current optimizer
  78178. * @returns true if everything that can be done was applied
  78179. */
  78180. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78181. }
  78182. /**
  78183. * Defines an optimization used to merge meshes with compatible materials
  78184. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78185. */
  78186. export class MergeMeshesOptimization extends SceneOptimization {
  78187. private static _UpdateSelectionTree;
  78188. /**
  78189. * Gets or sets a boolean which defines if optimization octree has to be updated
  78190. */
  78191. static get UpdateSelectionTree(): boolean;
  78192. /**
  78193. * Gets or sets a boolean which defines if optimization octree has to be updated
  78194. */
  78195. static set UpdateSelectionTree(value: boolean);
  78196. /**
  78197. * Gets a string describing the action executed by the current optimization
  78198. * @return description string
  78199. */
  78200. getDescription(): string;
  78201. private _canBeMerged;
  78202. /**
  78203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78204. * @param scene defines the current scene where to apply this optimization
  78205. * @param optimizer defines the current optimizer
  78206. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78207. * @returns true if everything that can be done was applied
  78208. */
  78209. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78210. }
  78211. /**
  78212. * Defines a list of options used by SceneOptimizer
  78213. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78214. */
  78215. export class SceneOptimizerOptions {
  78216. /**
  78217. * Defines the target frame rate to reach (60 by default)
  78218. */
  78219. targetFrameRate: number;
  78220. /**
  78221. * Defines the interval between two checkes (2000ms by default)
  78222. */
  78223. trackerDuration: number;
  78224. /**
  78225. * Gets the list of optimizations to apply
  78226. */
  78227. optimizations: SceneOptimization[];
  78228. /**
  78229. * Creates a new list of options used by SceneOptimizer
  78230. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78231. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78232. */
  78233. constructor(
  78234. /**
  78235. * Defines the target frame rate to reach (60 by default)
  78236. */
  78237. targetFrameRate?: number,
  78238. /**
  78239. * Defines the interval between two checkes (2000ms by default)
  78240. */
  78241. trackerDuration?: number);
  78242. /**
  78243. * Add a new optimization
  78244. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78245. * @returns the current SceneOptimizerOptions
  78246. */
  78247. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78248. /**
  78249. * Add a new custom optimization
  78250. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78251. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78252. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78253. * @returns the current SceneOptimizerOptions
  78254. */
  78255. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78256. /**
  78257. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78258. * @param targetFrameRate defines the target frame rate (60 by default)
  78259. * @returns a SceneOptimizerOptions object
  78260. */
  78261. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78262. /**
  78263. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78264. * @param targetFrameRate defines the target frame rate (60 by default)
  78265. * @returns a SceneOptimizerOptions object
  78266. */
  78267. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78268. /**
  78269. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78270. * @param targetFrameRate defines the target frame rate (60 by default)
  78271. * @returns a SceneOptimizerOptions object
  78272. */
  78273. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78274. }
  78275. /**
  78276. * Class used to run optimizations in order to reach a target frame rate
  78277. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78278. */
  78279. export class SceneOptimizer implements IDisposable {
  78280. private _isRunning;
  78281. private _options;
  78282. private _scene;
  78283. private _currentPriorityLevel;
  78284. private _targetFrameRate;
  78285. private _trackerDuration;
  78286. private _currentFrameRate;
  78287. private _sceneDisposeObserver;
  78288. private _improvementMode;
  78289. /**
  78290. * Defines an observable called when the optimizer reaches the target frame rate
  78291. */
  78292. onSuccessObservable: Observable<SceneOptimizer>;
  78293. /**
  78294. * Defines an observable called when the optimizer enables an optimization
  78295. */
  78296. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78297. /**
  78298. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78299. */
  78300. onFailureObservable: Observable<SceneOptimizer>;
  78301. /**
  78302. * Gets a boolean indicating if the optimizer is in improvement mode
  78303. */
  78304. get isInImprovementMode(): boolean;
  78305. /**
  78306. * Gets the current priority level (0 at start)
  78307. */
  78308. get currentPriorityLevel(): number;
  78309. /**
  78310. * Gets the current frame rate checked by the SceneOptimizer
  78311. */
  78312. get currentFrameRate(): number;
  78313. /**
  78314. * Gets or sets the current target frame rate (60 by default)
  78315. */
  78316. get targetFrameRate(): number;
  78317. /**
  78318. * Gets or sets the current target frame rate (60 by default)
  78319. */
  78320. set targetFrameRate(value: number);
  78321. /**
  78322. * Gets or sets the current interval between two checks (every 2000ms by default)
  78323. */
  78324. get trackerDuration(): number;
  78325. /**
  78326. * Gets or sets the current interval between two checks (every 2000ms by default)
  78327. */
  78328. set trackerDuration(value: number);
  78329. /**
  78330. * Gets the list of active optimizations
  78331. */
  78332. get optimizations(): SceneOptimization[];
  78333. /**
  78334. * Creates a new SceneOptimizer
  78335. * @param scene defines the scene to work on
  78336. * @param options defines the options to use with the SceneOptimizer
  78337. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78338. * @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)
  78339. */
  78340. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78341. /**
  78342. * Stops the current optimizer
  78343. */
  78344. stop(): void;
  78345. /**
  78346. * Reset the optimizer to initial step (current priority level = 0)
  78347. */
  78348. reset(): void;
  78349. /**
  78350. * Start the optimizer. By default it will try to reach a specific framerate
  78351. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78352. */
  78353. start(): void;
  78354. private _checkCurrentState;
  78355. /**
  78356. * Release all resources
  78357. */
  78358. dispose(): void;
  78359. /**
  78360. * Helper function to create a SceneOptimizer with one single line of code
  78361. * @param scene defines the scene to work on
  78362. * @param options defines the options to use with the SceneOptimizer
  78363. * @param onSuccess defines a callback to call on success
  78364. * @param onFailure defines a callback to call on failure
  78365. * @returns the new SceneOptimizer object
  78366. */
  78367. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78368. }
  78369. }
  78370. declare module "babylonjs/Misc/sceneSerializer" {
  78371. import { Scene } from "babylonjs/scene";
  78372. /**
  78373. * Class used to serialize a scene into a string
  78374. */
  78375. export class SceneSerializer {
  78376. /**
  78377. * Clear cache used by a previous serialization
  78378. */
  78379. static ClearCache(): void;
  78380. /**
  78381. * Serialize a scene into a JSON compatible object
  78382. * @param scene defines the scene to serialize
  78383. * @returns a JSON compatible object
  78384. */
  78385. static Serialize(scene: Scene): any;
  78386. /**
  78387. * Serialize a mesh into a JSON compatible object
  78388. * @param toSerialize defines the mesh to serialize
  78389. * @param withParents defines if parents must be serialized as well
  78390. * @param withChildren defines if children must be serialized as well
  78391. * @returns a JSON compatible object
  78392. */
  78393. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78394. }
  78395. }
  78396. declare module "babylonjs/Misc/textureTools" {
  78397. import { Texture } from "babylonjs/Materials/Textures/texture";
  78398. /**
  78399. * Class used to host texture specific utilities
  78400. */
  78401. export class TextureTools {
  78402. /**
  78403. * Uses the GPU to create a copy texture rescaled at a given size
  78404. * @param texture Texture to copy from
  78405. * @param width defines the desired width
  78406. * @param height defines the desired height
  78407. * @param useBilinearMode defines if bilinear mode has to be used
  78408. * @return the generated texture
  78409. */
  78410. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78411. }
  78412. }
  78413. declare module "babylonjs/Misc/videoRecorder" {
  78414. import { Nullable } from "babylonjs/types";
  78415. import { Engine } from "babylonjs/Engines/engine";
  78416. /**
  78417. * This represents the different options available for the video capture.
  78418. */
  78419. export interface VideoRecorderOptions {
  78420. /** Defines the mime type of the video. */
  78421. mimeType: string;
  78422. /** Defines the FPS the video should be recorded at. */
  78423. fps: number;
  78424. /** Defines the chunk size for the recording data. */
  78425. recordChunckSize: number;
  78426. /** The audio tracks to attach to the recording. */
  78427. audioTracks?: MediaStreamTrack[];
  78428. }
  78429. /**
  78430. * This can help with recording videos from BabylonJS.
  78431. * This is based on the available WebRTC functionalities of the browser.
  78432. *
  78433. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78434. */
  78435. export class VideoRecorder {
  78436. private static readonly _defaultOptions;
  78437. /**
  78438. * Returns whether or not the VideoRecorder is available in your browser.
  78439. * @param engine Defines the Babylon Engine.
  78440. * @returns true if supported otherwise false.
  78441. */
  78442. static IsSupported(engine: Engine): boolean;
  78443. private readonly _options;
  78444. private _canvas;
  78445. private _mediaRecorder;
  78446. private _recordedChunks;
  78447. private _fileName;
  78448. private _resolve;
  78449. private _reject;
  78450. /**
  78451. * True when a recording is already in progress.
  78452. */
  78453. get isRecording(): boolean;
  78454. /**
  78455. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78456. * @param engine Defines the BabylonJS Engine you wish to record.
  78457. * @param options Defines options that can be used to customize the capture.
  78458. */
  78459. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78460. /**
  78461. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78462. */
  78463. stopRecording(): void;
  78464. /**
  78465. * Starts recording the canvas for a max duration specified in parameters.
  78466. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78467. * If null no automatic download will start and you can rely on the promise to get the data back.
  78468. * @param maxDuration Defines the maximum recording time in seconds.
  78469. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78470. * @return A promise callback at the end of the recording with the video data in Blob.
  78471. */
  78472. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78473. /**
  78474. * Releases internal resources used during the recording.
  78475. */
  78476. dispose(): void;
  78477. private _handleDataAvailable;
  78478. private _handleError;
  78479. private _handleStop;
  78480. }
  78481. }
  78482. declare module "babylonjs/Misc/screenshotTools" {
  78483. import { Camera } from "babylonjs/Cameras/camera";
  78484. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78485. import { Engine } from "babylonjs/Engines/engine";
  78486. /**
  78487. * Class containing a set of static utilities functions for screenshots
  78488. */
  78489. export class ScreenshotTools {
  78490. /**
  78491. * Captures a screenshot of the current rendering
  78492. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78493. * @param engine defines the rendering engine
  78494. * @param camera defines the source camera
  78495. * @param size This parameter can be set to a single number or to an object with the
  78496. * following (optional) properties: precision, width, height. If a single number is passed,
  78497. * it will be used for both width and height. If an object is passed, the screenshot size
  78498. * will be derived from the parameters. The precision property is a multiplier allowing
  78499. * rendering at a higher or lower resolution
  78500. * @param successCallback defines the callback receives a single parameter which contains the
  78501. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78502. * src parameter of an <img> to display it
  78503. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78504. * Check your browser for supported MIME types
  78505. */
  78506. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78507. /**
  78508. * Captures a screenshot of the current rendering
  78509. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78510. * @param engine defines the rendering engine
  78511. * @param camera defines the source camera
  78512. * @param size This parameter can be set to a single number or to an object with the
  78513. * following (optional) properties: precision, width, height. If a single number is passed,
  78514. * it will be used for both width and height. If an object is passed, the screenshot size
  78515. * will be derived from the parameters. The precision property is a multiplier allowing
  78516. * rendering at a higher or lower resolution
  78517. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78518. * Check your browser for supported MIME types
  78519. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78520. * to the src parameter of an <img> to display it
  78521. */
  78522. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78523. /**
  78524. * Generates an image screenshot from the specified camera.
  78525. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78526. * @param engine The engine to use for rendering
  78527. * @param camera The camera to use for rendering
  78528. * @param size This parameter can be set to a single number or to an object with the
  78529. * following (optional) properties: precision, width, height. If a single number is passed,
  78530. * it will be used for both width and height. If an object is passed, the screenshot size
  78531. * will be derived from the parameters. The precision property is a multiplier allowing
  78532. * rendering at a higher or lower resolution
  78533. * @param successCallback The callback receives a single parameter which contains the
  78534. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78535. * src parameter of an <img> to display it
  78536. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78537. * Check your browser for supported MIME types
  78538. * @param samples Texture samples (default: 1)
  78539. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78540. * @param fileName A name for for the downloaded file.
  78541. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78542. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78543. */
  78544. 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;
  78545. /**
  78546. * Generates an image screenshot from the specified camera.
  78547. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78548. * @param engine The engine to use for rendering
  78549. * @param camera The camera to use for rendering
  78550. * @param size This parameter can be set to a single number or to an object with the
  78551. * following (optional) properties: precision, width, height. If a single number is passed,
  78552. * it will be used for both width and height. If an object is passed, the screenshot size
  78553. * will be derived from the parameters. The precision property is a multiplier allowing
  78554. * rendering at a higher or lower resolution
  78555. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78556. * Check your browser for supported MIME types
  78557. * @param samples Texture samples (default: 1)
  78558. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78559. * @param fileName A name for for the downloaded file.
  78560. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78561. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78562. * to the src parameter of an <img> to display it
  78563. */
  78564. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78565. /**
  78566. * Gets height and width for screenshot size
  78567. * @private
  78568. */
  78569. private static _getScreenshotSize;
  78570. }
  78571. }
  78572. declare module "babylonjs/Misc/dataReader" {
  78573. /**
  78574. * Interface for a data buffer
  78575. */
  78576. export interface IDataBuffer {
  78577. /**
  78578. * Reads bytes from the data buffer.
  78579. * @param byteOffset The byte offset to read
  78580. * @param byteLength The byte length to read
  78581. * @returns A promise that resolves when the bytes are read
  78582. */
  78583. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78584. /**
  78585. * The byte length of the buffer.
  78586. */
  78587. readonly byteLength: number;
  78588. }
  78589. /**
  78590. * Utility class for reading from a data buffer
  78591. */
  78592. export class DataReader {
  78593. /**
  78594. * The data buffer associated with this data reader.
  78595. */
  78596. readonly buffer: IDataBuffer;
  78597. /**
  78598. * The current byte offset from the beginning of the data buffer.
  78599. */
  78600. byteOffset: number;
  78601. private _dataView;
  78602. private _dataByteOffset;
  78603. /**
  78604. * Constructor
  78605. * @param buffer The buffer to read
  78606. */
  78607. constructor(buffer: IDataBuffer);
  78608. /**
  78609. * Loads the given byte length.
  78610. * @param byteLength The byte length to load
  78611. * @returns A promise that resolves when the load is complete
  78612. */
  78613. loadAsync(byteLength: number): Promise<void>;
  78614. /**
  78615. * Read a unsigned 32-bit integer from the currently loaded data range.
  78616. * @returns The 32-bit integer read
  78617. */
  78618. readUint32(): number;
  78619. /**
  78620. * Read a byte array from the currently loaded data range.
  78621. * @param byteLength The byte length to read
  78622. * @returns The byte array read
  78623. */
  78624. readUint8Array(byteLength: number): Uint8Array;
  78625. /**
  78626. * Read a string from the currently loaded data range.
  78627. * @param byteLength The byte length to read
  78628. * @returns The string read
  78629. */
  78630. readString(byteLength: number): string;
  78631. /**
  78632. * Skips the given byte length the currently loaded data range.
  78633. * @param byteLength The byte length to skip
  78634. */
  78635. skipBytes(byteLength: number): void;
  78636. }
  78637. }
  78638. declare module "babylonjs/Misc/dataStorage" {
  78639. /**
  78640. * Class for storing data to local storage if available or in-memory storage otherwise
  78641. */
  78642. export class DataStorage {
  78643. private static _Storage;
  78644. private static _GetStorage;
  78645. /**
  78646. * Reads a string from the data storage
  78647. * @param key The key to read
  78648. * @param defaultValue The value if the key doesn't exist
  78649. * @returns The string value
  78650. */
  78651. static ReadString(key: string, defaultValue: string): string;
  78652. /**
  78653. * Writes a string to the data storage
  78654. * @param key The key to write
  78655. * @param value The value to write
  78656. */
  78657. static WriteString(key: string, value: string): void;
  78658. /**
  78659. * Reads a boolean from the data storage
  78660. * @param key The key to read
  78661. * @param defaultValue The value if the key doesn't exist
  78662. * @returns The boolean value
  78663. */
  78664. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78665. /**
  78666. * Writes a boolean to the data storage
  78667. * @param key The key to write
  78668. * @param value The value to write
  78669. */
  78670. static WriteBoolean(key: string, value: boolean): void;
  78671. /**
  78672. * Reads a number from the data storage
  78673. * @param key The key to read
  78674. * @param defaultValue The value if the key doesn't exist
  78675. * @returns The number value
  78676. */
  78677. static ReadNumber(key: string, defaultValue: number): number;
  78678. /**
  78679. * Writes a number to the data storage
  78680. * @param key The key to write
  78681. * @param value The value to write
  78682. */
  78683. static WriteNumber(key: string, value: number): void;
  78684. }
  78685. }
  78686. declare module "babylonjs/Misc/sceneRecorder" {
  78687. import { Scene } from "babylonjs/scene";
  78688. /**
  78689. * Class used to record delta files between 2 scene states
  78690. */
  78691. export class SceneRecorder {
  78692. private _trackedScene;
  78693. private _savedJSON;
  78694. /**
  78695. * Track a given scene. This means the current scene state will be considered the original state
  78696. * @param scene defines the scene to track
  78697. */
  78698. track(scene: Scene): void;
  78699. /**
  78700. * Get the delta between current state and original state
  78701. * @returns a string containing the delta
  78702. */
  78703. getDelta(): any;
  78704. private _compareArray;
  78705. private _compareObjects;
  78706. private _compareCollections;
  78707. private static GetShadowGeneratorById;
  78708. /**
  78709. * Apply a given delta to a given scene
  78710. * @param deltaJSON defines the JSON containing the delta
  78711. * @param scene defines the scene to apply the delta to
  78712. */
  78713. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78714. private static _ApplyPropertiesToEntity;
  78715. private static _ApplyDeltaForEntity;
  78716. }
  78717. }
  78718. declare module "babylonjs/Misc/trajectoryClassifier" {
  78719. import { DeepImmutable, Nullable } from "babylonjs/types";
  78720. import { Vector3 } from "babylonjs/Maths/math.vector";
  78721. /**
  78722. * A 3D trajectory consisting of an order list of vectors describing a
  78723. * path of motion through 3D space.
  78724. */
  78725. export class Trajectory {
  78726. private _points;
  78727. private readonly _segmentLength;
  78728. /**
  78729. * Serialize to JSON.
  78730. * @returns serialized JSON string
  78731. */
  78732. serialize(): string;
  78733. /**
  78734. * Deserialize from JSON.
  78735. * @param json serialized JSON string
  78736. * @returns deserialized Trajectory
  78737. */
  78738. static Deserialize(json: string): Trajectory;
  78739. /**
  78740. * Create a new empty Trajectory.
  78741. * @param segmentLength radius of discretization for Trajectory points
  78742. */
  78743. constructor(segmentLength?: number);
  78744. /**
  78745. * Get the length of the Trajectory.
  78746. * @returns length of the Trajectory
  78747. */
  78748. getLength(): number;
  78749. /**
  78750. * Append a new point to the Trajectory.
  78751. * NOTE: This implementation has many allocations.
  78752. * @param point point to append to the Trajectory
  78753. */
  78754. add(point: DeepImmutable<Vector3>): void;
  78755. /**
  78756. * Create a new Trajectory with a segment length chosen to make it
  78757. * probable that the new Trajectory will have a specified number of
  78758. * segments. This operation is imprecise.
  78759. * @param targetResolution number of segments desired
  78760. * @returns new Trajectory with approximately the requested number of segments
  78761. */
  78762. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78763. /**
  78764. * Convert Trajectory segments into tokenized representation. This
  78765. * representation is an array of numbers where each nth number is the
  78766. * index of the token which is most similar to the nth segment of the
  78767. * Trajectory.
  78768. * @param tokens list of vectors which serve as discrete tokens
  78769. * @returns list of indices of most similar token per segment
  78770. */
  78771. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78772. private static _forwardDir;
  78773. private static _inverseFromVec;
  78774. private static _upDir;
  78775. private static _fromToVec;
  78776. private static _lookMatrix;
  78777. /**
  78778. * Transform the rotation (i.e., direction) of a segment to isolate
  78779. * the relative transformation represented by the segment. This operation
  78780. * may or may not succeed due to singularities in the equations that define
  78781. * motion relativity in this context.
  78782. * @param priorVec the origin of the prior segment
  78783. * @param fromVec the origin of the current segment
  78784. * @param toVec the destination of the current segment
  78785. * @param result reference to output variable
  78786. * @returns whether or not transformation was successful
  78787. */
  78788. private static _transformSegmentDirToRef;
  78789. private static _bestMatch;
  78790. private static _score;
  78791. private static _bestScore;
  78792. /**
  78793. * Determine which token vector is most similar to the
  78794. * segment vector.
  78795. * @param segment segment vector
  78796. * @param tokens token vector list
  78797. * @returns index of the most similar token to the segment
  78798. */
  78799. private static _tokenizeSegment;
  78800. }
  78801. /**
  78802. * Class representing a set of known, named trajectories to which Trajectories can be
  78803. * added and using which Trajectories can be recognized.
  78804. */
  78805. export class TrajectoryClassifier {
  78806. private _maximumAllowableMatchCost;
  78807. private _vector3Alphabet;
  78808. private _levenshteinAlphabet;
  78809. private _nameToDescribedTrajectory;
  78810. /**
  78811. * Serialize to JSON.
  78812. * @returns JSON serialization
  78813. */
  78814. serialize(): string;
  78815. /**
  78816. * Deserialize from JSON.
  78817. * @param json JSON serialization
  78818. * @returns deserialized TrajectorySet
  78819. */
  78820. static Deserialize(json: string): TrajectoryClassifier;
  78821. /**
  78822. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78823. * VERY naive, need to be generating these things from known
  78824. * sets. Better version later, probably eliminating this one.
  78825. * @returns auto-generated TrajectorySet
  78826. */
  78827. static Generate(): TrajectoryClassifier;
  78828. private constructor();
  78829. /**
  78830. * Add a new Trajectory to the set with a given name.
  78831. * @param trajectory new Trajectory to be added
  78832. * @param classification name to which to add the Trajectory
  78833. */
  78834. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78835. /**
  78836. * Remove a known named trajectory and all Trajectories associated with it.
  78837. * @param classification name to remove
  78838. * @returns whether anything was removed
  78839. */
  78840. deleteClassification(classification: string): boolean;
  78841. /**
  78842. * Attempt to recognize a Trajectory from among all the classifications
  78843. * already known to the classifier.
  78844. * @param trajectory Trajectory to be recognized
  78845. * @returns classification of Trajectory if recognized, null otherwise
  78846. */
  78847. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78848. }
  78849. }
  78850. declare module "babylonjs/Misc/index" {
  78851. export * from "babylonjs/Misc/andOrNotEvaluator";
  78852. export * from "babylonjs/Misc/assetsManager";
  78853. export * from "babylonjs/Misc/basis";
  78854. export * from "babylonjs/Misc/dds";
  78855. export * from "babylonjs/Misc/decorators";
  78856. export * from "babylonjs/Misc/deferred";
  78857. export * from "babylonjs/Misc/environmentTextureTools";
  78858. export * from "babylonjs/Misc/meshExploder";
  78859. export * from "babylonjs/Misc/filesInput";
  78860. export * from "babylonjs/Misc/HighDynamicRange/index";
  78861. export * from "babylonjs/Misc/khronosTextureContainer";
  78862. export * from "babylonjs/Misc/observable";
  78863. export * from "babylonjs/Misc/performanceMonitor";
  78864. export * from "babylonjs/Misc/promise";
  78865. export * from "babylonjs/Misc/sceneOptimizer";
  78866. export * from "babylonjs/Misc/sceneSerializer";
  78867. export * from "babylonjs/Misc/smartArray";
  78868. export * from "babylonjs/Misc/stringDictionary";
  78869. export * from "babylonjs/Misc/tags";
  78870. export * from "babylonjs/Misc/textureTools";
  78871. export * from "babylonjs/Misc/tga";
  78872. export * from "babylonjs/Misc/tools";
  78873. export * from "babylonjs/Misc/videoRecorder";
  78874. export * from "babylonjs/Misc/virtualJoystick";
  78875. export * from "babylonjs/Misc/workerPool";
  78876. export * from "babylonjs/Misc/logger";
  78877. export * from "babylonjs/Misc/typeStore";
  78878. export * from "babylonjs/Misc/filesInputStore";
  78879. export * from "babylonjs/Misc/deepCopier";
  78880. export * from "babylonjs/Misc/pivotTools";
  78881. export * from "babylonjs/Misc/precisionDate";
  78882. export * from "babylonjs/Misc/screenshotTools";
  78883. export * from "babylonjs/Misc/typeStore";
  78884. export * from "babylonjs/Misc/webRequest";
  78885. export * from "babylonjs/Misc/iInspectable";
  78886. export * from "babylonjs/Misc/brdfTextureTools";
  78887. export * from "babylonjs/Misc/rgbdTextureTools";
  78888. export * from "babylonjs/Misc/gradients";
  78889. export * from "babylonjs/Misc/perfCounter";
  78890. export * from "babylonjs/Misc/fileRequest";
  78891. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78892. export * from "babylonjs/Misc/retryStrategy";
  78893. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78894. export * from "babylonjs/Misc/canvasGenerator";
  78895. export * from "babylonjs/Misc/fileTools";
  78896. export * from "babylonjs/Misc/stringTools";
  78897. export * from "babylonjs/Misc/dataReader";
  78898. export * from "babylonjs/Misc/minMaxReducer";
  78899. export * from "babylonjs/Misc/depthReducer";
  78900. export * from "babylonjs/Misc/dataStorage";
  78901. export * from "babylonjs/Misc/sceneRecorder";
  78902. export * from "babylonjs/Misc/khronosTextureContainer2";
  78903. export * from "babylonjs/Misc/trajectoryClassifier";
  78904. }
  78905. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78906. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78907. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78908. import { Observable } from "babylonjs/Misc/observable";
  78909. import { Matrix } from "babylonjs/Maths/math.vector";
  78910. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78911. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78912. /**
  78913. * An interface for all Hit test features
  78914. */
  78915. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78916. /**
  78917. * Triggered when new babylon (transformed) hit test results are available
  78918. */
  78919. onHitTestResultObservable: Observable<T[]>;
  78920. }
  78921. /**
  78922. * Options used for hit testing
  78923. */
  78924. export interface IWebXRLegacyHitTestOptions {
  78925. /**
  78926. * Only test when user interacted with the scene. Default - hit test every frame
  78927. */
  78928. testOnPointerDownOnly?: boolean;
  78929. /**
  78930. * The node to use to transform the local results to world coordinates
  78931. */
  78932. worldParentNode?: TransformNode;
  78933. }
  78934. /**
  78935. * Interface defining the babylon result of raycasting/hit-test
  78936. */
  78937. export interface IWebXRLegacyHitResult {
  78938. /**
  78939. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78940. */
  78941. transformationMatrix: Matrix;
  78942. /**
  78943. * The native hit test result
  78944. */
  78945. xrHitResult: XRHitResult | XRHitTestResult;
  78946. }
  78947. /**
  78948. * The currently-working hit-test module.
  78949. * Hit test (or Ray-casting) is used to interact with the real world.
  78950. * For further information read here - https://github.com/immersive-web/hit-test
  78951. */
  78952. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78953. /**
  78954. * options to use when constructing this feature
  78955. */
  78956. readonly options: IWebXRLegacyHitTestOptions;
  78957. private _direction;
  78958. private _mat;
  78959. private _onSelectEnabled;
  78960. private _origin;
  78961. /**
  78962. * The module's name
  78963. */
  78964. static readonly Name: string;
  78965. /**
  78966. * The (Babylon) version of this module.
  78967. * This is an integer representing the implementation version.
  78968. * This number does not correspond to the WebXR specs version
  78969. */
  78970. static readonly Version: number;
  78971. /**
  78972. * Populated with the last native XR Hit Results
  78973. */
  78974. lastNativeXRHitResults: XRHitResult[];
  78975. /**
  78976. * Triggered when new babylon (transformed) hit test results are available
  78977. */
  78978. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78979. /**
  78980. * Creates a new instance of the (legacy version) hit test feature
  78981. * @param _xrSessionManager an instance of WebXRSessionManager
  78982. * @param options options to use when constructing this feature
  78983. */
  78984. constructor(_xrSessionManager: WebXRSessionManager,
  78985. /**
  78986. * options to use when constructing this feature
  78987. */
  78988. options?: IWebXRLegacyHitTestOptions);
  78989. /**
  78990. * execute a hit test with an XR Ray
  78991. *
  78992. * @param xrSession a native xrSession that will execute this hit test
  78993. * @param xrRay the ray (position and direction) to use for ray-casting
  78994. * @param referenceSpace native XR reference space to use for the hit-test
  78995. * @param filter filter function that will filter the results
  78996. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78997. */
  78998. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78999. /**
  79000. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79001. * @param event the (select) event to use to select with
  79002. * @param referenceSpace the reference space to use for this hit test
  79003. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79004. */
  79005. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79006. /**
  79007. * attach this feature
  79008. * Will usually be called by the features manager
  79009. *
  79010. * @returns true if successful.
  79011. */
  79012. attach(): boolean;
  79013. /**
  79014. * detach this feature.
  79015. * Will usually be called by the features manager
  79016. *
  79017. * @returns true if successful.
  79018. */
  79019. detach(): boolean;
  79020. /**
  79021. * Dispose this feature and all of the resources attached
  79022. */
  79023. dispose(): void;
  79024. protected _onXRFrame(frame: XRFrame): void;
  79025. private _onHitTestResults;
  79026. private _onSelect;
  79027. }
  79028. }
  79029. declare module "babylonjs/XR/features/WebXRHitTest" {
  79030. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79031. import { Observable } from "babylonjs/Misc/observable";
  79032. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79033. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79034. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79035. /**
  79036. * Options used for hit testing (version 2)
  79037. */
  79038. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79039. /**
  79040. * Do not create a permanent hit test. Will usually be used when only
  79041. * transient inputs are needed.
  79042. */
  79043. disablePermanentHitTest?: boolean;
  79044. /**
  79045. * Enable transient (for example touch-based) hit test inspections
  79046. */
  79047. enableTransientHitTest?: boolean;
  79048. /**
  79049. * Offset ray for the permanent hit test
  79050. */
  79051. offsetRay?: Vector3;
  79052. /**
  79053. * Offset ray for the transient hit test
  79054. */
  79055. transientOffsetRay?: Vector3;
  79056. /**
  79057. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79058. */
  79059. useReferenceSpace?: boolean;
  79060. /**
  79061. * Override the default entity type(s) of the hit-test result
  79062. */
  79063. entityTypes?: XRHitTestTrackableType[];
  79064. }
  79065. /**
  79066. * Interface defining the babylon result of hit-test
  79067. */
  79068. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79069. /**
  79070. * The input source that generated this hit test (if transient)
  79071. */
  79072. inputSource?: XRInputSource;
  79073. /**
  79074. * Is this a transient hit test
  79075. */
  79076. isTransient?: boolean;
  79077. /**
  79078. * Position of the hit test result
  79079. */
  79080. position: Vector3;
  79081. /**
  79082. * Rotation of the hit test result
  79083. */
  79084. rotationQuaternion: Quaternion;
  79085. /**
  79086. * The native hit test result
  79087. */
  79088. xrHitResult: XRHitTestResult;
  79089. }
  79090. /**
  79091. * The currently-working hit-test module.
  79092. * Hit test (or Ray-casting) is used to interact with the real world.
  79093. * For further information read here - https://github.com/immersive-web/hit-test
  79094. *
  79095. * Tested on chrome (mobile) 80.
  79096. */
  79097. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79098. /**
  79099. * options to use when constructing this feature
  79100. */
  79101. readonly options: IWebXRHitTestOptions;
  79102. private _tmpMat;
  79103. private _tmpPos;
  79104. private _tmpQuat;
  79105. private _transientXrHitTestSource;
  79106. private _xrHitTestSource;
  79107. private initHitTestSource;
  79108. /**
  79109. * The module's name
  79110. */
  79111. static readonly Name: string;
  79112. /**
  79113. * The (Babylon) version of this module.
  79114. * This is an integer representing the implementation version.
  79115. * This number does not correspond to the WebXR specs version
  79116. */
  79117. static readonly Version: number;
  79118. /**
  79119. * When set to true, each hit test will have its own position/rotation objects
  79120. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79121. * the developers will clone them or copy them as they see fit.
  79122. */
  79123. autoCloneTransformation: boolean;
  79124. /**
  79125. * Triggered when new babylon (transformed) hit test results are available
  79126. * Note - this will be called when results come back from the device. It can be an empty array!!
  79127. */
  79128. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79129. /**
  79130. * Use this to temporarily pause hit test checks.
  79131. */
  79132. paused: boolean;
  79133. /**
  79134. * Creates a new instance of the hit test feature
  79135. * @param _xrSessionManager an instance of WebXRSessionManager
  79136. * @param options options to use when constructing this feature
  79137. */
  79138. constructor(_xrSessionManager: WebXRSessionManager,
  79139. /**
  79140. * options to use when constructing this feature
  79141. */
  79142. options?: IWebXRHitTestOptions);
  79143. /**
  79144. * attach this feature
  79145. * Will usually be called by the features manager
  79146. *
  79147. * @returns true if successful.
  79148. */
  79149. attach(): boolean;
  79150. /**
  79151. * detach this feature.
  79152. * Will usually be called by the features manager
  79153. *
  79154. * @returns true if successful.
  79155. */
  79156. detach(): boolean;
  79157. /**
  79158. * Dispose this feature and all of the resources attached
  79159. */
  79160. dispose(): void;
  79161. protected _onXRFrame(frame: XRFrame): void;
  79162. private _processWebXRHitTestResult;
  79163. }
  79164. }
  79165. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79166. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79167. import { Observable } from "babylonjs/Misc/observable";
  79168. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79169. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79170. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79171. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79172. /**
  79173. * Configuration options of the anchor system
  79174. */
  79175. export interface IWebXRAnchorSystemOptions {
  79176. /**
  79177. * a node that will be used to convert local to world coordinates
  79178. */
  79179. worldParentNode?: TransformNode;
  79180. /**
  79181. * If set to true a reference of the created anchors will be kept until the next session starts
  79182. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79183. */
  79184. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79185. }
  79186. /**
  79187. * A babylon container for an XR Anchor
  79188. */
  79189. export interface IWebXRAnchor {
  79190. /**
  79191. * A babylon-assigned ID for this anchor
  79192. */
  79193. id: number;
  79194. /**
  79195. * Transformation matrix to apply to an object attached to this anchor
  79196. */
  79197. transformationMatrix: Matrix;
  79198. /**
  79199. * The native anchor object
  79200. */
  79201. xrAnchor: XRAnchor;
  79202. /**
  79203. * if defined, this object will be constantly updated by the anchor's position and rotation
  79204. */
  79205. attachedNode?: TransformNode;
  79206. }
  79207. /**
  79208. * An implementation of the anchor system for WebXR.
  79209. * For further information see https://github.com/immersive-web/anchors/
  79210. */
  79211. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79212. private _options;
  79213. private _lastFrameDetected;
  79214. private _trackedAnchors;
  79215. private _referenceSpaceForFrameAnchors;
  79216. private _futureAnchors;
  79217. /**
  79218. * The module's name
  79219. */
  79220. static readonly Name: string;
  79221. /**
  79222. * The (Babylon) version of this module.
  79223. * This is an integer representing the implementation version.
  79224. * This number does not correspond to the WebXR specs version
  79225. */
  79226. static readonly Version: number;
  79227. /**
  79228. * Observers registered here will be executed when a new anchor was added to the session
  79229. */
  79230. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79231. /**
  79232. * Observers registered here will be executed when an anchor was removed from the session
  79233. */
  79234. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79235. /**
  79236. * Observers registered here will be executed when an existing anchor updates
  79237. * This can execute N times every frame
  79238. */
  79239. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79240. /**
  79241. * Set the reference space to use for anchor creation, when not using a hit test.
  79242. * Will default to the session's reference space if not defined
  79243. */
  79244. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79245. /**
  79246. * constructs a new anchor system
  79247. * @param _xrSessionManager an instance of WebXRSessionManager
  79248. * @param _options configuration object for this feature
  79249. */
  79250. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79251. private _tmpVector;
  79252. private _tmpQuaternion;
  79253. private _populateTmpTransformation;
  79254. /**
  79255. * Create a new anchor point using a hit test result at a specific point in the scene
  79256. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79257. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79258. *
  79259. * @param hitTestResult The hit test result to use for this anchor creation
  79260. * @param position an optional position offset for this anchor
  79261. * @param rotationQuaternion an optional rotation offset for this anchor
  79262. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79263. */
  79264. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79265. /**
  79266. * Add a new anchor at a specific position and rotation
  79267. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79268. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79269. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79270. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79271. *
  79272. * @param position the position in which to add an anchor
  79273. * @param rotationQuaternion an optional rotation for the anchor transformation
  79274. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79275. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79276. */
  79277. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79278. /**
  79279. * detach this feature.
  79280. * Will usually be called by the features manager
  79281. *
  79282. * @returns true if successful.
  79283. */
  79284. detach(): boolean;
  79285. /**
  79286. * Dispose this feature and all of the resources attached
  79287. */
  79288. dispose(): void;
  79289. protected _onXRFrame(frame: XRFrame): void;
  79290. /**
  79291. * avoiding using Array.find for global support.
  79292. * @param xrAnchor the plane to find in the array
  79293. */
  79294. private _findIndexInAnchorArray;
  79295. private _updateAnchorWithXRFrame;
  79296. private _createAnchorAtTransformation;
  79297. }
  79298. }
  79299. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79300. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79301. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79302. import { Observable } from "babylonjs/Misc/observable";
  79303. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79304. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79305. /**
  79306. * Options used in the plane detector module
  79307. */
  79308. export interface IWebXRPlaneDetectorOptions {
  79309. /**
  79310. * The node to use to transform the local results to world coordinates
  79311. */
  79312. worldParentNode?: TransformNode;
  79313. /**
  79314. * If set to true a reference of the created planes will be kept until the next session starts
  79315. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79316. */
  79317. doNotRemovePlanesOnSessionEnded?: boolean;
  79318. }
  79319. /**
  79320. * A babylon interface for a WebXR plane.
  79321. * A Plane is actually a polygon, built from N points in space
  79322. *
  79323. * Supported in chrome 79, not supported in canary 81 ATM
  79324. */
  79325. export interface IWebXRPlane {
  79326. /**
  79327. * a babylon-assigned ID for this polygon
  79328. */
  79329. id: number;
  79330. /**
  79331. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79332. */
  79333. polygonDefinition: Array<Vector3>;
  79334. /**
  79335. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79336. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79337. */
  79338. transformationMatrix: Matrix;
  79339. /**
  79340. * the native xr-plane object
  79341. */
  79342. xrPlane: XRPlane;
  79343. }
  79344. /**
  79345. * The plane detector is used to detect planes in the real world when in AR
  79346. * For more information see https://github.com/immersive-web/real-world-geometry/
  79347. */
  79348. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79349. private _options;
  79350. private _detectedPlanes;
  79351. private _enabled;
  79352. private _lastFrameDetected;
  79353. /**
  79354. * The module's name
  79355. */
  79356. static readonly Name: string;
  79357. /**
  79358. * The (Babylon) version of this module.
  79359. * This is an integer representing the implementation version.
  79360. * This number does not correspond to the WebXR specs version
  79361. */
  79362. static readonly Version: number;
  79363. /**
  79364. * Observers registered here will be executed when a new plane was added to the session
  79365. */
  79366. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79367. /**
  79368. * Observers registered here will be executed when a plane is no longer detected in the session
  79369. */
  79370. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79371. /**
  79372. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79373. * This can execute N times every frame
  79374. */
  79375. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79376. /**
  79377. * construct a new Plane Detector
  79378. * @param _xrSessionManager an instance of xr Session manager
  79379. * @param _options configuration to use when constructing this feature
  79380. */
  79381. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79382. /**
  79383. * detach this feature.
  79384. * Will usually be called by the features manager
  79385. *
  79386. * @returns true if successful.
  79387. */
  79388. detach(): boolean;
  79389. /**
  79390. * Dispose this feature and all of the resources attached
  79391. */
  79392. dispose(): void;
  79393. protected _onXRFrame(frame: XRFrame): void;
  79394. private _init;
  79395. private _updatePlaneWithXRPlane;
  79396. /**
  79397. * avoiding using Array.find for global support.
  79398. * @param xrPlane the plane to find in the array
  79399. */
  79400. private findIndexInPlaneArray;
  79401. }
  79402. }
  79403. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79404. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79406. import { Observable } from "babylonjs/Misc/observable";
  79407. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79408. /**
  79409. * Options interface for the background remover plugin
  79410. */
  79411. export interface IWebXRBackgroundRemoverOptions {
  79412. /**
  79413. * Further background meshes to disable when entering AR
  79414. */
  79415. backgroundMeshes?: AbstractMesh[];
  79416. /**
  79417. * flags to configure the removal of the environment helper.
  79418. * If not set, the entire background will be removed. If set, flags should be set as well.
  79419. */
  79420. environmentHelperRemovalFlags?: {
  79421. /**
  79422. * Should the skybox be removed (default false)
  79423. */
  79424. skyBox?: boolean;
  79425. /**
  79426. * Should the ground be removed (default false)
  79427. */
  79428. ground?: boolean;
  79429. };
  79430. /**
  79431. * don't disable the environment helper
  79432. */
  79433. ignoreEnvironmentHelper?: boolean;
  79434. }
  79435. /**
  79436. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79437. */
  79438. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79439. /**
  79440. * read-only options to be used in this module
  79441. */
  79442. readonly options: IWebXRBackgroundRemoverOptions;
  79443. /**
  79444. * The module's name
  79445. */
  79446. static readonly Name: string;
  79447. /**
  79448. * The (Babylon) version of this module.
  79449. * This is an integer representing the implementation version.
  79450. * This number does not correspond to the WebXR specs version
  79451. */
  79452. static readonly Version: number;
  79453. /**
  79454. * registered observers will be triggered when the background state changes
  79455. */
  79456. onBackgroundStateChangedObservable: Observable<boolean>;
  79457. /**
  79458. * constructs a new background remover module
  79459. * @param _xrSessionManager the session manager for this module
  79460. * @param options read-only options to be used in this module
  79461. */
  79462. constructor(_xrSessionManager: WebXRSessionManager,
  79463. /**
  79464. * read-only options to be used in this module
  79465. */
  79466. options?: IWebXRBackgroundRemoverOptions);
  79467. /**
  79468. * attach this feature
  79469. * Will usually be called by the features manager
  79470. *
  79471. * @returns true if successful.
  79472. */
  79473. attach(): boolean;
  79474. /**
  79475. * detach this feature.
  79476. * Will usually be called by the features manager
  79477. *
  79478. * @returns true if successful.
  79479. */
  79480. detach(): boolean;
  79481. /**
  79482. * Dispose this feature and all of the resources attached
  79483. */
  79484. dispose(): void;
  79485. protected _onXRFrame(_xrFrame: XRFrame): void;
  79486. private _setBackgroundState;
  79487. }
  79488. }
  79489. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79490. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79491. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79492. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79493. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79494. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79495. import { Nullable } from "babylonjs/types";
  79496. /**
  79497. * Options for the controller physics feature
  79498. */
  79499. export class IWebXRControllerPhysicsOptions {
  79500. /**
  79501. * Should the headset get its own impostor
  79502. */
  79503. enableHeadsetImpostor?: boolean;
  79504. /**
  79505. * Optional parameters for the headset impostor
  79506. */
  79507. headsetImpostorParams?: {
  79508. /**
  79509. * The type of impostor to create. Default is sphere
  79510. */
  79511. impostorType: number;
  79512. /**
  79513. * the size of the impostor. Defaults to 10cm
  79514. */
  79515. impostorSize?: number | {
  79516. width: number;
  79517. height: number;
  79518. depth: number;
  79519. };
  79520. /**
  79521. * Friction definitions
  79522. */
  79523. friction?: number;
  79524. /**
  79525. * Restitution
  79526. */
  79527. restitution?: number;
  79528. };
  79529. /**
  79530. * The physics properties of the future impostors
  79531. */
  79532. physicsProperties?: {
  79533. /**
  79534. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79535. * Note that this requires a physics engine that supports mesh impostors!
  79536. */
  79537. useControllerMesh?: boolean;
  79538. /**
  79539. * The type of impostor to create. Default is sphere
  79540. */
  79541. impostorType?: number;
  79542. /**
  79543. * the size of the impostor. Defaults to 10cm
  79544. */
  79545. impostorSize?: number | {
  79546. width: number;
  79547. height: number;
  79548. depth: number;
  79549. };
  79550. /**
  79551. * Friction definitions
  79552. */
  79553. friction?: number;
  79554. /**
  79555. * Restitution
  79556. */
  79557. restitution?: number;
  79558. };
  79559. /**
  79560. * the xr input to use with this pointer selection
  79561. */
  79562. xrInput: WebXRInput;
  79563. }
  79564. /**
  79565. * Add physics impostor to your webxr controllers,
  79566. * including naive calculation of their linear and angular velocity
  79567. */
  79568. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79569. private readonly _options;
  79570. private _attachController;
  79571. private _controllers;
  79572. private _debugMode;
  79573. private _delta;
  79574. private _headsetImpostor?;
  79575. private _headsetMesh?;
  79576. private _lastTimestamp;
  79577. private _tmpQuaternion;
  79578. private _tmpVector;
  79579. /**
  79580. * The module's name
  79581. */
  79582. static readonly Name: string;
  79583. /**
  79584. * The (Babylon) version of this module.
  79585. * This is an integer representing the implementation version.
  79586. * This number does not correspond to the webxr specs version
  79587. */
  79588. static readonly Version: number;
  79589. /**
  79590. * Construct a new Controller Physics Feature
  79591. * @param _xrSessionManager the corresponding xr session manager
  79592. * @param _options options to create this feature with
  79593. */
  79594. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79595. /**
  79596. * @hidden
  79597. * enable debugging - will show console outputs and the impostor mesh
  79598. */
  79599. _enablePhysicsDebug(): void;
  79600. /**
  79601. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79602. * @param xrController the controller to add
  79603. */
  79604. addController(xrController: WebXRInputSource): void;
  79605. /**
  79606. * attach this feature
  79607. * Will usually be called by the features manager
  79608. *
  79609. * @returns true if successful.
  79610. */
  79611. attach(): boolean;
  79612. /**
  79613. * detach this feature.
  79614. * Will usually be called by the features manager
  79615. *
  79616. * @returns true if successful.
  79617. */
  79618. detach(): boolean;
  79619. /**
  79620. * Get the headset impostor, if enabled
  79621. * @returns the impostor
  79622. */
  79623. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79624. /**
  79625. * Get the physics impostor of a specific controller.
  79626. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79627. * @param controller the controller or the controller id of which to get the impostor
  79628. * @returns the impostor or null
  79629. */
  79630. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79631. /**
  79632. * Update the physics properties provided in the constructor
  79633. * @param newProperties the new properties object
  79634. */
  79635. setPhysicsProperties(newProperties: {
  79636. impostorType?: number;
  79637. impostorSize?: number | {
  79638. width: number;
  79639. height: number;
  79640. depth: number;
  79641. };
  79642. friction?: number;
  79643. restitution?: number;
  79644. }): void;
  79645. protected _onXRFrame(_xrFrame: any): void;
  79646. private _detachController;
  79647. }
  79648. }
  79649. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79650. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79651. import { Observable } from "babylonjs/Misc/observable";
  79652. import { Vector3 } from "babylonjs/Maths/math.vector";
  79653. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79654. /**
  79655. * A babylon interface for a "WebXR" feature point.
  79656. * Represents the position and confidence value of a given feature point.
  79657. */
  79658. export interface IWebXRFeaturePoint {
  79659. /**
  79660. * Represents the position of the feature point in world space.
  79661. */
  79662. position: Vector3;
  79663. /**
  79664. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79665. */
  79666. confidenceValue: number;
  79667. }
  79668. /**
  79669. * The feature point system is used to detect feature points from real world geometry.
  79670. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79671. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79672. */
  79673. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79674. private _enabled;
  79675. private _featurePointCloud;
  79676. /**
  79677. * The module's name
  79678. */
  79679. static readonly Name: string;
  79680. /**
  79681. * The (Babylon) version of this module.
  79682. * This is an integer representing the implementation version.
  79683. * This number does not correspond to the WebXR specs version
  79684. */
  79685. static readonly Version: number;
  79686. /**
  79687. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79688. * Will notify the observers about which feature points have been added.
  79689. */
  79690. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79691. /**
  79692. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79693. * Will notify the observers about which feature points have been updated.
  79694. */
  79695. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79696. /**
  79697. * The current feature point cloud maintained across frames.
  79698. */
  79699. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79700. /**
  79701. * construct the feature point system
  79702. * @param _xrSessionManager an instance of xr Session manager
  79703. */
  79704. constructor(_xrSessionManager: WebXRSessionManager);
  79705. /**
  79706. * Detach this feature.
  79707. * Will usually be called by the features manager
  79708. *
  79709. * @returns true if successful.
  79710. */
  79711. detach(): boolean;
  79712. /**
  79713. * Dispose this feature and all of the resources attached
  79714. */
  79715. dispose(): void;
  79716. /**
  79717. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79718. */
  79719. protected _onXRFrame(frame: XRFrame): void;
  79720. /**
  79721. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79722. */
  79723. private _init;
  79724. }
  79725. }
  79726. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79727. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79728. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79730. import { Mesh } from "babylonjs/Meshes/mesh";
  79731. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79732. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79733. import { Nullable } from "babylonjs/types";
  79734. import { IDisposable } from "babylonjs/scene";
  79735. import { Observable } from "babylonjs/Misc/observable";
  79736. /**
  79737. * Configuration interface for the hand tracking feature
  79738. */
  79739. export interface IWebXRHandTrackingOptions {
  79740. /**
  79741. * The xrInput that will be used as source for new hands
  79742. */
  79743. xrInput: WebXRInput;
  79744. /**
  79745. * Configuration object for the joint meshes
  79746. */
  79747. jointMeshes?: {
  79748. /**
  79749. * Should the meshes created be invisible (defaults to false)
  79750. */
  79751. invisible?: boolean;
  79752. /**
  79753. * A source mesh to be used to create instances. Defaults to a sphere.
  79754. * This mesh will be the source for all other (25) meshes.
  79755. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79756. */
  79757. sourceMesh?: Mesh;
  79758. /**
  79759. * Should the source mesh stay visible. Defaults to false
  79760. */
  79761. keepOriginalVisible?: boolean;
  79762. /**
  79763. * Scale factor for all instances (defaults to 2)
  79764. */
  79765. scaleFactor?: number;
  79766. /**
  79767. * Should each instance have its own physics impostor
  79768. */
  79769. enablePhysics?: boolean;
  79770. /**
  79771. * If enabled, override default physics properties
  79772. */
  79773. physicsProps?: {
  79774. friction?: number;
  79775. restitution?: number;
  79776. impostorType?: number;
  79777. };
  79778. /**
  79779. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79780. */
  79781. handMesh?: AbstractMesh;
  79782. };
  79783. }
  79784. /**
  79785. * Parts of the hands divided to writs and finger names
  79786. */
  79787. export const enum HandPart {
  79788. /**
  79789. * HandPart - Wrist
  79790. */
  79791. WRIST = "wrist",
  79792. /**
  79793. * HandPart - The THumb
  79794. */
  79795. THUMB = "thumb",
  79796. /**
  79797. * HandPart - Index finger
  79798. */
  79799. INDEX = "index",
  79800. /**
  79801. * HandPart - Middle finger
  79802. */
  79803. MIDDLE = "middle",
  79804. /**
  79805. * HandPart - Ring finger
  79806. */
  79807. RING = "ring",
  79808. /**
  79809. * HandPart - Little finger
  79810. */
  79811. LITTLE = "little"
  79812. }
  79813. /**
  79814. * Representing a single hand (with its corresponding native XRHand object)
  79815. */
  79816. export class WebXRHand implements IDisposable {
  79817. /** the controller to which the hand correlates */
  79818. readonly xrController: WebXRInputSource;
  79819. /** the meshes to be used to track the hand joints */
  79820. readonly trackedMeshes: AbstractMesh[];
  79821. /**
  79822. * Hand-parts definition (key is HandPart)
  79823. */
  79824. handPartsDefinition: {
  79825. [key: string]: number[];
  79826. };
  79827. /**
  79828. * Populate the HandPartsDefinition object.
  79829. * This is called as a side effect since certain browsers don't have XRHand defined.
  79830. */
  79831. private generateHandPartsDefinition;
  79832. /**
  79833. * Construct a new hand object
  79834. * @param xrController the controller to which the hand correlates
  79835. * @param trackedMeshes the meshes to be used to track the hand joints
  79836. */
  79837. constructor(
  79838. /** the controller to which the hand correlates */
  79839. xrController: WebXRInputSource,
  79840. /** the meshes to be used to track the hand joints */
  79841. trackedMeshes: AbstractMesh[]);
  79842. /**
  79843. * Update this hand from the latest xr frame
  79844. * @param xrFrame xrFrame to update from
  79845. * @param referenceSpace The current viewer reference space
  79846. * @param scaleFactor optional scale factor for the meshes
  79847. */
  79848. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79849. /**
  79850. * Get meshes of part of the hand
  79851. * @param part the part of hand to get
  79852. * @returns An array of meshes that correlate to the hand part requested
  79853. */
  79854. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79855. /**
  79856. * Dispose this Hand object
  79857. */
  79858. dispose(): void;
  79859. }
  79860. /**
  79861. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79862. */
  79863. export class WebXRHandTracking extends WebXRAbstractFeature {
  79864. /**
  79865. * options to use when constructing this feature
  79866. */
  79867. readonly options: IWebXRHandTrackingOptions;
  79868. private static _idCounter;
  79869. /**
  79870. * The module's name
  79871. */
  79872. static readonly Name: string;
  79873. /**
  79874. * The (Babylon) version of this module.
  79875. * This is an integer representing the implementation version.
  79876. * This number does not correspond to the WebXR specs version
  79877. */
  79878. static readonly Version: number;
  79879. /**
  79880. * This observable will notify registered observers when a new hand object was added and initialized
  79881. */
  79882. onHandAddedObservable: Observable<WebXRHand>;
  79883. /**
  79884. * This observable will notify its observers right before the hand object is disposed
  79885. */
  79886. onHandRemovedObservable: Observable<WebXRHand>;
  79887. private _hands;
  79888. /**
  79889. * Creates a new instance of the hit test feature
  79890. * @param _xrSessionManager an instance of WebXRSessionManager
  79891. * @param options options to use when constructing this feature
  79892. */
  79893. constructor(_xrSessionManager: WebXRSessionManager,
  79894. /**
  79895. * options to use when constructing this feature
  79896. */
  79897. options: IWebXRHandTrackingOptions);
  79898. /**
  79899. * Check if the needed objects are defined.
  79900. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79901. */
  79902. isCompatible(): boolean;
  79903. /**
  79904. * attach this feature
  79905. * Will usually be called by the features manager
  79906. *
  79907. * @returns true if successful.
  79908. */
  79909. attach(): boolean;
  79910. /**
  79911. * detach this feature.
  79912. * Will usually be called by the features manager
  79913. *
  79914. * @returns true if successful.
  79915. */
  79916. detach(): boolean;
  79917. /**
  79918. * Dispose this feature and all of the resources attached
  79919. */
  79920. dispose(): void;
  79921. /**
  79922. * Get the hand object according to the controller id
  79923. * @param controllerId the controller id to which we want to get the hand
  79924. * @returns null if not found or the WebXRHand object if found
  79925. */
  79926. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79927. /**
  79928. * Get a hand object according to the requested handedness
  79929. * @param handedness the handedness to request
  79930. * @returns null if not found or the WebXRHand object if found
  79931. */
  79932. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79933. protected _onXRFrame(_xrFrame: XRFrame): void;
  79934. private _attachHand;
  79935. private _detachHand;
  79936. }
  79937. }
  79938. declare module "babylonjs/XR/features/index" {
  79939. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79940. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79941. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79942. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79943. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79944. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79945. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79946. export * from "babylonjs/XR/features/WebXRHitTest";
  79947. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79948. export * from "babylonjs/XR/features/WebXRHandTracking";
  79949. }
  79950. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79951. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79953. import { Scene } from "babylonjs/scene";
  79954. /**
  79955. * The motion controller class for all microsoft mixed reality controllers
  79956. */
  79957. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79958. protected readonly _mapping: {
  79959. defaultButton: {
  79960. valueNodeName: string;
  79961. unpressedNodeName: string;
  79962. pressedNodeName: string;
  79963. };
  79964. defaultAxis: {
  79965. valueNodeName: string;
  79966. minNodeName: string;
  79967. maxNodeName: string;
  79968. };
  79969. buttons: {
  79970. "xr-standard-trigger": {
  79971. rootNodeName: string;
  79972. componentProperty: string;
  79973. states: string[];
  79974. };
  79975. "xr-standard-squeeze": {
  79976. rootNodeName: string;
  79977. componentProperty: string;
  79978. states: string[];
  79979. };
  79980. "xr-standard-touchpad": {
  79981. rootNodeName: string;
  79982. labelAnchorNodeName: string;
  79983. touchPointNodeName: string;
  79984. };
  79985. "xr-standard-thumbstick": {
  79986. rootNodeName: string;
  79987. componentProperty: string;
  79988. states: string[];
  79989. };
  79990. };
  79991. axes: {
  79992. "xr-standard-touchpad": {
  79993. "x-axis": {
  79994. rootNodeName: string;
  79995. };
  79996. "y-axis": {
  79997. rootNodeName: string;
  79998. };
  79999. };
  80000. "xr-standard-thumbstick": {
  80001. "x-axis": {
  80002. rootNodeName: string;
  80003. };
  80004. "y-axis": {
  80005. rootNodeName: string;
  80006. };
  80007. };
  80008. };
  80009. };
  80010. /**
  80011. * The base url used to load the left and right controller models
  80012. */
  80013. static MODEL_BASE_URL: string;
  80014. /**
  80015. * The name of the left controller model file
  80016. */
  80017. static MODEL_LEFT_FILENAME: string;
  80018. /**
  80019. * The name of the right controller model file
  80020. */
  80021. static MODEL_RIGHT_FILENAME: string;
  80022. profileId: string;
  80023. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80024. protected _getFilenameAndPath(): {
  80025. filename: string;
  80026. path: string;
  80027. };
  80028. protected _getModelLoadingConstraints(): boolean;
  80029. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80030. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80031. protected _updateModel(): void;
  80032. }
  80033. }
  80034. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80035. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80037. import { Scene } from "babylonjs/scene";
  80038. /**
  80039. * The motion controller class for oculus touch (quest, rift).
  80040. * This class supports legacy mapping as well the standard xr mapping
  80041. */
  80042. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80043. private _forceLegacyControllers;
  80044. private _modelRootNode;
  80045. /**
  80046. * The base url used to load the left and right controller models
  80047. */
  80048. static MODEL_BASE_URL: string;
  80049. /**
  80050. * The name of the left controller model file
  80051. */
  80052. static MODEL_LEFT_FILENAME: string;
  80053. /**
  80054. * The name of the right controller model file
  80055. */
  80056. static MODEL_RIGHT_FILENAME: string;
  80057. /**
  80058. * Base Url for the Quest controller model.
  80059. */
  80060. static QUEST_MODEL_BASE_URL: string;
  80061. profileId: string;
  80062. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80063. protected _getFilenameAndPath(): {
  80064. filename: string;
  80065. path: string;
  80066. };
  80067. protected _getModelLoadingConstraints(): boolean;
  80068. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80069. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80070. protected _updateModel(): void;
  80071. /**
  80072. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80073. * between the touch and touch 2.
  80074. */
  80075. private _isQuest;
  80076. }
  80077. }
  80078. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80079. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80080. import { Scene } from "babylonjs/scene";
  80081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80082. /**
  80083. * The motion controller class for the standard HTC-Vive controllers
  80084. */
  80085. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80086. private _modelRootNode;
  80087. /**
  80088. * The base url used to load the left and right controller models
  80089. */
  80090. static MODEL_BASE_URL: string;
  80091. /**
  80092. * File name for the controller model.
  80093. */
  80094. static MODEL_FILENAME: string;
  80095. profileId: string;
  80096. /**
  80097. * Create a new Vive motion controller object
  80098. * @param scene the scene to use to create this controller
  80099. * @param gamepadObject the corresponding gamepad object
  80100. * @param handedness the handedness of the controller
  80101. */
  80102. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80103. protected _getFilenameAndPath(): {
  80104. filename: string;
  80105. path: string;
  80106. };
  80107. protected _getModelLoadingConstraints(): boolean;
  80108. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80109. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80110. protected _updateModel(): void;
  80111. }
  80112. }
  80113. declare module "babylonjs/XR/motionController/index" {
  80114. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80115. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80116. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80117. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80118. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80119. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80120. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80121. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80122. }
  80123. declare module "babylonjs/XR/index" {
  80124. export * from "babylonjs/XR/webXRCamera";
  80125. export * from "babylonjs/XR/webXREnterExitUI";
  80126. export * from "babylonjs/XR/webXRExperienceHelper";
  80127. export * from "babylonjs/XR/webXRInput";
  80128. export * from "babylonjs/XR/webXRInputSource";
  80129. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80130. export * from "babylonjs/XR/webXRTypes";
  80131. export * from "babylonjs/XR/webXRSessionManager";
  80132. export * from "babylonjs/XR/webXRDefaultExperience";
  80133. export * from "babylonjs/XR/webXRFeaturesManager";
  80134. export * from "babylonjs/XR/features/index";
  80135. export * from "babylonjs/XR/motionController/index";
  80136. }
  80137. declare module "babylonjs/index" {
  80138. export * from "babylonjs/abstractScene";
  80139. export * from "babylonjs/Actions/index";
  80140. export * from "babylonjs/Animations/index";
  80141. export * from "babylonjs/assetContainer";
  80142. export * from "babylonjs/Audio/index";
  80143. export * from "babylonjs/Behaviors/index";
  80144. export * from "babylonjs/Bones/index";
  80145. export * from "babylonjs/Cameras/index";
  80146. export * from "babylonjs/Collisions/index";
  80147. export * from "babylonjs/Culling/index";
  80148. export * from "babylonjs/Debug/index";
  80149. export * from "babylonjs/DeviceInput/index";
  80150. export * from "babylonjs/Engines/index";
  80151. export * from "babylonjs/Events/index";
  80152. export * from "babylonjs/Gamepads/index";
  80153. export * from "babylonjs/Gizmos/index";
  80154. export * from "babylonjs/Helpers/index";
  80155. export * from "babylonjs/Instrumentation/index";
  80156. export * from "babylonjs/Layers/index";
  80157. export * from "babylonjs/LensFlares/index";
  80158. export * from "babylonjs/Lights/index";
  80159. export * from "babylonjs/Loading/index";
  80160. export * from "babylonjs/Materials/index";
  80161. export * from "babylonjs/Maths/index";
  80162. export * from "babylonjs/Meshes/index";
  80163. export * from "babylonjs/Morph/index";
  80164. export * from "babylonjs/Navigation/index";
  80165. export * from "babylonjs/node";
  80166. export * from "babylonjs/Offline/index";
  80167. export * from "babylonjs/Particles/index";
  80168. export * from "babylonjs/Physics/index";
  80169. export * from "babylonjs/PostProcesses/index";
  80170. export * from "babylonjs/Probes/index";
  80171. export * from "babylonjs/Rendering/index";
  80172. export * from "babylonjs/scene";
  80173. export * from "babylonjs/sceneComponent";
  80174. export * from "babylonjs/Sprites/index";
  80175. export * from "babylonjs/States/index";
  80176. export * from "babylonjs/Misc/index";
  80177. export * from "babylonjs/XR/index";
  80178. export * from "babylonjs/types";
  80179. }
  80180. declare module "babylonjs/Animations/pathCursor" {
  80181. import { Vector3 } from "babylonjs/Maths/math.vector";
  80182. import { Path2 } from "babylonjs/Maths/math.path";
  80183. /**
  80184. * A cursor which tracks a point on a path
  80185. */
  80186. export class PathCursor {
  80187. private path;
  80188. /**
  80189. * Stores path cursor callbacks for when an onchange event is triggered
  80190. */
  80191. private _onchange;
  80192. /**
  80193. * The value of the path cursor
  80194. */
  80195. value: number;
  80196. /**
  80197. * The animation array of the path cursor
  80198. */
  80199. animations: Animation[];
  80200. /**
  80201. * Initializes the path cursor
  80202. * @param path The path to track
  80203. */
  80204. constructor(path: Path2);
  80205. /**
  80206. * Gets the cursor point on the path
  80207. * @returns A point on the path cursor at the cursor location
  80208. */
  80209. getPoint(): Vector3;
  80210. /**
  80211. * Moves the cursor ahead by the step amount
  80212. * @param step The amount to move the cursor forward
  80213. * @returns This path cursor
  80214. */
  80215. moveAhead(step?: number): PathCursor;
  80216. /**
  80217. * Moves the cursor behind by the step amount
  80218. * @param step The amount to move the cursor back
  80219. * @returns This path cursor
  80220. */
  80221. moveBack(step?: number): PathCursor;
  80222. /**
  80223. * Moves the cursor by the step amount
  80224. * If the step amount is greater than one, an exception is thrown
  80225. * @param step The amount to move the cursor
  80226. * @returns This path cursor
  80227. */
  80228. move(step: number): PathCursor;
  80229. /**
  80230. * Ensures that the value is limited between zero and one
  80231. * @returns This path cursor
  80232. */
  80233. private ensureLimits;
  80234. /**
  80235. * Runs onchange callbacks on change (used by the animation engine)
  80236. * @returns This path cursor
  80237. */
  80238. private raiseOnChange;
  80239. /**
  80240. * Executes a function on change
  80241. * @param f A path cursor onchange callback
  80242. * @returns This path cursor
  80243. */
  80244. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80245. }
  80246. }
  80247. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80248. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80249. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80250. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80251. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80252. }
  80253. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80254. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80255. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80256. }
  80257. declare module "babylonjs/Engines/Processors/index" {
  80258. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80259. export * from "babylonjs/Engines/Processors/Expressions/index";
  80260. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80261. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80262. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80263. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80264. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80265. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80266. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80267. }
  80268. declare module "babylonjs/Legacy/legacy" {
  80269. import * as Babylon from "babylonjs/index";
  80270. export * from "babylonjs/index";
  80271. }
  80272. declare module "babylonjs/Shaders/blur.fragment" {
  80273. /** @hidden */
  80274. export var blurPixelShader: {
  80275. name: string;
  80276. shader: string;
  80277. };
  80278. }
  80279. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80280. /** @hidden */
  80281. export var pointCloudVertexDeclaration: {
  80282. name: string;
  80283. shader: string;
  80284. };
  80285. }
  80286. declare module "babylonjs" {
  80287. export * from "babylonjs/Legacy/legacy";
  80288. }
  80289. declare module BABYLON {
  80290. /** Alias type for value that can be null */
  80291. export type Nullable<T> = T | null;
  80292. /**
  80293. * Alias type for number that are floats
  80294. * @ignorenaming
  80295. */
  80296. export type float = number;
  80297. /**
  80298. * Alias type for number that are doubles.
  80299. * @ignorenaming
  80300. */
  80301. export type double = number;
  80302. /**
  80303. * Alias type for number that are integer
  80304. * @ignorenaming
  80305. */
  80306. export type int = number;
  80307. /** Alias type for number array or Float32Array */
  80308. export type FloatArray = number[] | Float32Array;
  80309. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80310. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80311. /**
  80312. * Alias for types that can be used by a Buffer or VertexBuffer.
  80313. */
  80314. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80315. /**
  80316. * Alias type for primitive types
  80317. * @ignorenaming
  80318. */
  80319. type Primitive = undefined | null | boolean | string | number | Function;
  80320. /**
  80321. * Type modifier to make all the properties of an object Readonly
  80322. */
  80323. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80324. /**
  80325. * Type modifier to make all the properties of an object Readonly recursively
  80326. */
  80327. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80328. /**
  80329. * Type modifier to make object properties readonly.
  80330. */
  80331. export type DeepImmutableObject<T> = {
  80332. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80333. };
  80334. /** @hidden */
  80335. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80336. }
  80337. }
  80338. declare module BABYLON {
  80339. /**
  80340. * A class serves as a medium between the observable and its observers
  80341. */
  80342. export class EventState {
  80343. /**
  80344. * Create a new EventState
  80345. * @param mask defines the mask associated with this state
  80346. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80347. * @param target defines the original target of the state
  80348. * @param currentTarget defines the current target of the state
  80349. */
  80350. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80351. /**
  80352. * Initialize the current event state
  80353. * @param mask defines the mask associated with this state
  80354. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80355. * @param target defines the original target of the state
  80356. * @param currentTarget defines the current target of the state
  80357. * @returns the current event state
  80358. */
  80359. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80360. /**
  80361. * An Observer can set this property to true to prevent subsequent observers of being notified
  80362. */
  80363. skipNextObservers: boolean;
  80364. /**
  80365. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80366. */
  80367. mask: number;
  80368. /**
  80369. * The object that originally notified the event
  80370. */
  80371. target?: any;
  80372. /**
  80373. * The current object in the bubbling phase
  80374. */
  80375. currentTarget?: any;
  80376. /**
  80377. * This will be populated with the return value of the last function that was executed.
  80378. * If it is the first function in the callback chain it will be the event data.
  80379. */
  80380. lastReturnValue?: any;
  80381. }
  80382. /**
  80383. * Represent an Observer registered to a given Observable object.
  80384. */
  80385. export class Observer<T> {
  80386. /**
  80387. * Defines the callback to call when the observer is notified
  80388. */
  80389. callback: (eventData: T, eventState: EventState) => void;
  80390. /**
  80391. * Defines the mask of the observer (used to filter notifications)
  80392. */
  80393. mask: number;
  80394. /**
  80395. * Defines the current scope used to restore the JS context
  80396. */
  80397. scope: any;
  80398. /** @hidden */
  80399. _willBeUnregistered: boolean;
  80400. /**
  80401. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80402. */
  80403. unregisterOnNextCall: boolean;
  80404. /**
  80405. * Creates a new observer
  80406. * @param callback defines the callback to call when the observer is notified
  80407. * @param mask defines the mask of the observer (used to filter notifications)
  80408. * @param scope defines the current scope used to restore the JS context
  80409. */
  80410. constructor(
  80411. /**
  80412. * Defines the callback to call when the observer is notified
  80413. */
  80414. callback: (eventData: T, eventState: EventState) => void,
  80415. /**
  80416. * Defines the mask of the observer (used to filter notifications)
  80417. */
  80418. mask: number,
  80419. /**
  80420. * Defines the current scope used to restore the JS context
  80421. */
  80422. scope?: any);
  80423. }
  80424. /**
  80425. * Represent a list of observers registered to multiple Observables object.
  80426. */
  80427. export class MultiObserver<T> {
  80428. private _observers;
  80429. private _observables;
  80430. /**
  80431. * Release associated resources
  80432. */
  80433. dispose(): void;
  80434. /**
  80435. * Raise a callback when one of the observable will notify
  80436. * @param observables defines a list of observables to watch
  80437. * @param callback defines the callback to call on notification
  80438. * @param mask defines the mask used to filter notifications
  80439. * @param scope defines the current scope used to restore the JS context
  80440. * @returns the new MultiObserver
  80441. */
  80442. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80443. }
  80444. /**
  80445. * The Observable class is a simple implementation of the Observable pattern.
  80446. *
  80447. * 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.
  80448. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80449. * 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).
  80450. * 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.
  80451. */
  80452. export class Observable<T> {
  80453. private _observers;
  80454. private _eventState;
  80455. private _onObserverAdded;
  80456. /**
  80457. * Gets the list of observers
  80458. */
  80459. get observers(): Array<Observer<T>>;
  80460. /**
  80461. * Creates a new observable
  80462. * @param onObserverAdded defines a callback to call when a new observer is added
  80463. */
  80464. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80465. /**
  80466. * Create a new Observer with the specified callback
  80467. * @param callback the callback that will be executed for that Observer
  80468. * @param mask the mask used to filter observers
  80469. * @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.
  80470. * @param scope optional scope for the callback to be called from
  80471. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80472. * @returns the new observer created for the callback
  80473. */
  80474. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80475. /**
  80476. * Create a new Observer with the specified callback and unregisters after the next notification
  80477. * @param callback the callback that will be executed for that Observer
  80478. * @returns the new observer created for the callback
  80479. */
  80480. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80481. /**
  80482. * Remove an Observer from the Observable object
  80483. * @param observer the instance of the Observer to remove
  80484. * @returns false if it doesn't belong to this Observable
  80485. */
  80486. remove(observer: Nullable<Observer<T>>): boolean;
  80487. /**
  80488. * Remove a callback from the Observable object
  80489. * @param callback the callback to remove
  80490. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80491. * @returns false if it doesn't belong to this Observable
  80492. */
  80493. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80494. private _deferUnregister;
  80495. private _remove;
  80496. /**
  80497. * Moves the observable to the top of the observer list making it get called first when notified
  80498. * @param observer the observer to move
  80499. */
  80500. makeObserverTopPriority(observer: Observer<T>): void;
  80501. /**
  80502. * Moves the observable to the bottom of the observer list making it get called last when notified
  80503. * @param observer the observer to move
  80504. */
  80505. makeObserverBottomPriority(observer: Observer<T>): void;
  80506. /**
  80507. * Notify all Observers by calling their respective callback with the given data
  80508. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80509. * @param eventData defines the data to send to all observers
  80510. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80511. * @param target defines the original target of the state
  80512. * @param currentTarget defines the current target of the state
  80513. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80514. */
  80515. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80516. /**
  80517. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80518. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80519. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80520. * and it is crucial that all callbacks will be executed.
  80521. * The order of the callbacks is kept, callbacks are not executed parallel.
  80522. *
  80523. * @param eventData The data to be sent to each callback
  80524. * @param mask is used to filter observers defaults to -1
  80525. * @param target defines the callback target (see EventState)
  80526. * @param currentTarget defines he current object in the bubbling phase
  80527. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80528. */
  80529. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80530. /**
  80531. * Notify a specific observer
  80532. * @param observer defines the observer to notify
  80533. * @param eventData defines the data to be sent to each callback
  80534. * @param mask is used to filter observers defaults to -1
  80535. */
  80536. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80537. /**
  80538. * Gets a boolean indicating if the observable has at least one observer
  80539. * @returns true is the Observable has at least one Observer registered
  80540. */
  80541. hasObservers(): boolean;
  80542. /**
  80543. * Clear the list of observers
  80544. */
  80545. clear(): void;
  80546. /**
  80547. * Clone the current observable
  80548. * @returns a new observable
  80549. */
  80550. clone(): Observable<T>;
  80551. /**
  80552. * Does this observable handles observer registered with a given mask
  80553. * @param mask defines the mask to be tested
  80554. * @return whether or not one observer registered with the given mask is handeled
  80555. **/
  80556. hasSpecificMask(mask?: number): boolean;
  80557. }
  80558. }
  80559. declare module BABYLON {
  80560. /**
  80561. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80562. * Babylon.js
  80563. */
  80564. export class DomManagement {
  80565. /**
  80566. * Checks if the window object exists
  80567. * @returns true if the window object exists
  80568. */
  80569. static IsWindowObjectExist(): boolean;
  80570. /**
  80571. * Checks if the navigator object exists
  80572. * @returns true if the navigator object exists
  80573. */
  80574. static IsNavigatorAvailable(): boolean;
  80575. /**
  80576. * Check if the document object exists
  80577. * @returns true if the document object exists
  80578. */
  80579. static IsDocumentAvailable(): boolean;
  80580. /**
  80581. * Extracts text content from a DOM element hierarchy
  80582. * @param element defines the root element
  80583. * @returns a string
  80584. */
  80585. static GetDOMTextContent(element: HTMLElement): string;
  80586. }
  80587. }
  80588. declare module BABYLON {
  80589. /**
  80590. * Logger used througouht the application to allow configuration of
  80591. * the log level required for the messages.
  80592. */
  80593. export class Logger {
  80594. /**
  80595. * No log
  80596. */
  80597. static readonly NoneLogLevel: number;
  80598. /**
  80599. * Only message logs
  80600. */
  80601. static readonly MessageLogLevel: number;
  80602. /**
  80603. * Only warning logs
  80604. */
  80605. static readonly WarningLogLevel: number;
  80606. /**
  80607. * Only error logs
  80608. */
  80609. static readonly ErrorLogLevel: number;
  80610. /**
  80611. * All logs
  80612. */
  80613. static readonly AllLogLevel: number;
  80614. private static _LogCache;
  80615. /**
  80616. * Gets a value indicating the number of loading errors
  80617. * @ignorenaming
  80618. */
  80619. static errorsCount: number;
  80620. /**
  80621. * Callback called when a new log is added
  80622. */
  80623. static OnNewCacheEntry: (entry: string) => void;
  80624. private static _AddLogEntry;
  80625. private static _FormatMessage;
  80626. private static _LogDisabled;
  80627. private static _LogEnabled;
  80628. private static _WarnDisabled;
  80629. private static _WarnEnabled;
  80630. private static _ErrorDisabled;
  80631. private static _ErrorEnabled;
  80632. /**
  80633. * Log a message to the console
  80634. */
  80635. static Log: (message: string) => void;
  80636. /**
  80637. * Write a warning message to the console
  80638. */
  80639. static Warn: (message: string) => void;
  80640. /**
  80641. * Write an error message to the console
  80642. */
  80643. static Error: (message: string) => void;
  80644. /**
  80645. * Gets current log cache (list of logs)
  80646. */
  80647. static get LogCache(): string;
  80648. /**
  80649. * Clears the log cache
  80650. */
  80651. static ClearLogCache(): void;
  80652. /**
  80653. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80654. */
  80655. static set LogLevels(level: number);
  80656. }
  80657. }
  80658. declare module BABYLON {
  80659. /** @hidden */
  80660. export class _TypeStore {
  80661. /** @hidden */
  80662. static RegisteredTypes: {
  80663. [key: string]: Object;
  80664. };
  80665. /** @hidden */
  80666. static GetClass(fqdn: string): any;
  80667. }
  80668. }
  80669. declare module BABYLON {
  80670. /**
  80671. * Helper to manipulate strings
  80672. */
  80673. export class StringTools {
  80674. /**
  80675. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80676. * @param str Source string
  80677. * @param suffix Suffix to search for in the source string
  80678. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80679. */
  80680. static EndsWith(str: string, suffix: string): boolean;
  80681. /**
  80682. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80683. * @param str Source string
  80684. * @param suffix Suffix to search for in the source string
  80685. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80686. */
  80687. static StartsWith(str: string, suffix: string): boolean;
  80688. /**
  80689. * Decodes a buffer into a string
  80690. * @param buffer The buffer to decode
  80691. * @returns The decoded string
  80692. */
  80693. static Decode(buffer: Uint8Array | Uint16Array): string;
  80694. /**
  80695. * Encode a buffer to a base64 string
  80696. * @param buffer defines the buffer to encode
  80697. * @returns the encoded string
  80698. */
  80699. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80700. /**
  80701. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80702. * @param num the number to convert and pad
  80703. * @param length the expected length of the string
  80704. * @returns the padded string
  80705. */
  80706. static PadNumber(num: number, length: number): string;
  80707. }
  80708. }
  80709. declare module BABYLON {
  80710. /**
  80711. * Class containing a set of static utilities functions for deep copy.
  80712. */
  80713. export class DeepCopier {
  80714. /**
  80715. * Tries to copy an object by duplicating every property
  80716. * @param source defines the source object
  80717. * @param destination defines the target object
  80718. * @param doNotCopyList defines a list of properties to avoid
  80719. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80720. */
  80721. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80722. }
  80723. }
  80724. declare module BABYLON {
  80725. /**
  80726. * Class containing a set of static utilities functions for precision date
  80727. */
  80728. export class PrecisionDate {
  80729. /**
  80730. * Gets either window.performance.now() if supported or Date.now() else
  80731. */
  80732. static get Now(): number;
  80733. }
  80734. }
  80735. declare module BABYLON {
  80736. /** @hidden */
  80737. export class _DevTools {
  80738. static WarnImport(name: string): string;
  80739. }
  80740. }
  80741. declare module BABYLON {
  80742. /**
  80743. * Interface used to define the mechanism to get data from the network
  80744. */
  80745. export interface IWebRequest {
  80746. /**
  80747. * Returns client's response url
  80748. */
  80749. responseURL: string;
  80750. /**
  80751. * Returns client's status
  80752. */
  80753. status: number;
  80754. /**
  80755. * Returns client's status as a text
  80756. */
  80757. statusText: string;
  80758. }
  80759. }
  80760. declare module BABYLON {
  80761. /**
  80762. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80763. */
  80764. export class WebRequest implements IWebRequest {
  80765. private _xhr;
  80766. /**
  80767. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80768. * i.e. when loading files, where the server/service expects an Authorization header
  80769. */
  80770. static CustomRequestHeaders: {
  80771. [key: string]: string;
  80772. };
  80773. /**
  80774. * Add callback functions in this array to update all the requests before they get sent to the network
  80775. */
  80776. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80777. private _injectCustomRequestHeaders;
  80778. /**
  80779. * Gets or sets a function to be called when loading progress changes
  80780. */
  80781. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80782. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80783. /**
  80784. * Returns client's state
  80785. */
  80786. get readyState(): number;
  80787. /**
  80788. * Returns client's status
  80789. */
  80790. get status(): number;
  80791. /**
  80792. * Returns client's status as a text
  80793. */
  80794. get statusText(): string;
  80795. /**
  80796. * Returns client's response
  80797. */
  80798. get response(): any;
  80799. /**
  80800. * Returns client's response url
  80801. */
  80802. get responseURL(): string;
  80803. /**
  80804. * Returns client's response as text
  80805. */
  80806. get responseText(): string;
  80807. /**
  80808. * Gets or sets the expected response type
  80809. */
  80810. get responseType(): XMLHttpRequestResponseType;
  80811. set responseType(value: XMLHttpRequestResponseType);
  80812. /** @hidden */
  80813. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80814. /** @hidden */
  80815. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80816. /**
  80817. * Cancels any network activity
  80818. */
  80819. abort(): void;
  80820. /**
  80821. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80822. * @param body defines an optional request body
  80823. */
  80824. send(body?: Document | BodyInit | null): void;
  80825. /**
  80826. * Sets the request method, request URL
  80827. * @param method defines the method to use (GET, POST, etc..)
  80828. * @param url defines the url to connect with
  80829. */
  80830. open(method: string, url: string): void;
  80831. /**
  80832. * Sets the value of a request header.
  80833. * @param name The name of the header whose value is to be set
  80834. * @param value The value to set as the body of the header
  80835. */
  80836. setRequestHeader(name: string, value: string): void;
  80837. /**
  80838. * Get the string containing the text of a particular header's value.
  80839. * @param name The name of the header
  80840. * @returns The string containing the text of the given header name
  80841. */
  80842. getResponseHeader(name: string): Nullable<string>;
  80843. }
  80844. }
  80845. declare module BABYLON {
  80846. /**
  80847. * File request interface
  80848. */
  80849. export interface IFileRequest {
  80850. /**
  80851. * Raised when the request is complete (success or error).
  80852. */
  80853. onCompleteObservable: Observable<IFileRequest>;
  80854. /**
  80855. * Aborts the request for a file.
  80856. */
  80857. abort: () => void;
  80858. }
  80859. }
  80860. declare module BABYLON {
  80861. /**
  80862. * Define options used to create a render target texture
  80863. */
  80864. export class RenderTargetCreationOptions {
  80865. /**
  80866. * Specifies is mipmaps must be generated
  80867. */
  80868. generateMipMaps?: boolean;
  80869. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80870. generateDepthBuffer?: boolean;
  80871. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80872. generateStencilBuffer?: boolean;
  80873. /** Defines texture type (int by default) */
  80874. type?: number;
  80875. /** Defines sampling mode (trilinear by default) */
  80876. samplingMode?: number;
  80877. /** Defines format (RGBA by default) */
  80878. format?: number;
  80879. }
  80880. }
  80881. declare module BABYLON {
  80882. /** Defines the cross module used constants to avoid circular dependncies */
  80883. export class Constants {
  80884. /** Defines that alpha blending is disabled */
  80885. static readonly ALPHA_DISABLE: number;
  80886. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80887. static readonly ALPHA_ADD: number;
  80888. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80889. static readonly ALPHA_COMBINE: number;
  80890. /** Defines that alpha blending is DEST - SRC * DEST */
  80891. static readonly ALPHA_SUBTRACT: number;
  80892. /** Defines that alpha blending is SRC * DEST */
  80893. static readonly ALPHA_MULTIPLY: number;
  80894. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80895. static readonly ALPHA_MAXIMIZED: number;
  80896. /** Defines that alpha blending is SRC + DEST */
  80897. static readonly ALPHA_ONEONE: number;
  80898. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80899. static readonly ALPHA_PREMULTIPLIED: number;
  80900. /**
  80901. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80902. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80903. */
  80904. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80905. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80906. static readonly ALPHA_INTERPOLATE: number;
  80907. /**
  80908. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80909. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80910. */
  80911. static readonly ALPHA_SCREENMODE: number;
  80912. /**
  80913. * Defines that alpha blending is SRC + DST
  80914. * Alpha will be set to SRC ALPHA + DST ALPHA
  80915. */
  80916. static readonly ALPHA_ONEONE_ONEONE: number;
  80917. /**
  80918. * Defines that alpha blending is SRC * DST ALPHA + DST
  80919. * Alpha will be set to 0
  80920. */
  80921. static readonly ALPHA_ALPHATOCOLOR: number;
  80922. /**
  80923. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80924. */
  80925. static readonly ALPHA_REVERSEONEMINUS: number;
  80926. /**
  80927. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80928. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80929. */
  80930. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80931. /**
  80932. * Defines that alpha blending is SRC + DST
  80933. * Alpha will be set to SRC ALPHA
  80934. */
  80935. static readonly ALPHA_ONEONE_ONEZERO: number;
  80936. /**
  80937. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80938. * Alpha will be set to DST ALPHA
  80939. */
  80940. static readonly ALPHA_EXCLUSION: number;
  80941. /** Defines that alpha blending equation a SUM */
  80942. static readonly ALPHA_EQUATION_ADD: number;
  80943. /** Defines that alpha blending equation a SUBSTRACTION */
  80944. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80945. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80946. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80947. /** Defines that alpha blending equation a MAX operation */
  80948. static readonly ALPHA_EQUATION_MAX: number;
  80949. /** Defines that alpha blending equation a MIN operation */
  80950. static readonly ALPHA_EQUATION_MIN: number;
  80951. /**
  80952. * Defines that alpha blending equation a DARKEN operation:
  80953. * It takes the min of the src and sums the alpha channels.
  80954. */
  80955. static readonly ALPHA_EQUATION_DARKEN: number;
  80956. /** Defines that the ressource is not delayed*/
  80957. static readonly DELAYLOADSTATE_NONE: number;
  80958. /** Defines that the ressource was successfully delay loaded */
  80959. static readonly DELAYLOADSTATE_LOADED: number;
  80960. /** Defines that the ressource is currently delay loading */
  80961. static readonly DELAYLOADSTATE_LOADING: number;
  80962. /** Defines that the ressource is delayed and has not started loading */
  80963. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80964. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80965. static readonly NEVER: number;
  80966. /** 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 */
  80967. static readonly ALWAYS: number;
  80968. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80969. static readonly LESS: number;
  80970. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80971. static readonly EQUAL: number;
  80972. /** 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 */
  80973. static readonly LEQUAL: number;
  80974. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80975. static readonly GREATER: number;
  80976. /** 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 */
  80977. static readonly GEQUAL: number;
  80978. /** 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 */
  80979. static readonly NOTEQUAL: number;
  80980. /** Passed to stencilOperation to specify that stencil value must be kept */
  80981. static readonly KEEP: number;
  80982. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80983. static readonly REPLACE: number;
  80984. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80985. static readonly INCR: number;
  80986. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80987. static readonly DECR: number;
  80988. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80989. static readonly INVERT: number;
  80990. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80991. static readonly INCR_WRAP: number;
  80992. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80993. static readonly DECR_WRAP: number;
  80994. /** Texture is not repeating outside of 0..1 UVs */
  80995. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80996. /** Texture is repeating outside of 0..1 UVs */
  80997. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80998. /** Texture is repeating and mirrored */
  80999. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81000. /** ALPHA */
  81001. static readonly TEXTUREFORMAT_ALPHA: number;
  81002. /** LUMINANCE */
  81003. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81004. /** LUMINANCE_ALPHA */
  81005. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81006. /** RGB */
  81007. static readonly TEXTUREFORMAT_RGB: number;
  81008. /** RGBA */
  81009. static readonly TEXTUREFORMAT_RGBA: number;
  81010. /** RED */
  81011. static readonly TEXTUREFORMAT_RED: number;
  81012. /** RED (2nd reference) */
  81013. static readonly TEXTUREFORMAT_R: number;
  81014. /** RG */
  81015. static readonly TEXTUREFORMAT_RG: number;
  81016. /** RED_INTEGER */
  81017. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81018. /** RED_INTEGER (2nd reference) */
  81019. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81020. /** RG_INTEGER */
  81021. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81022. /** RGB_INTEGER */
  81023. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81024. /** RGBA_INTEGER */
  81025. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81026. /** UNSIGNED_BYTE */
  81027. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81028. /** UNSIGNED_BYTE (2nd reference) */
  81029. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81030. /** FLOAT */
  81031. static readonly TEXTURETYPE_FLOAT: number;
  81032. /** HALF_FLOAT */
  81033. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81034. /** BYTE */
  81035. static readonly TEXTURETYPE_BYTE: number;
  81036. /** SHORT */
  81037. static readonly TEXTURETYPE_SHORT: number;
  81038. /** UNSIGNED_SHORT */
  81039. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81040. /** INT */
  81041. static readonly TEXTURETYPE_INT: number;
  81042. /** UNSIGNED_INT */
  81043. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81044. /** UNSIGNED_SHORT_4_4_4_4 */
  81045. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81046. /** UNSIGNED_SHORT_5_5_5_1 */
  81047. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81048. /** UNSIGNED_SHORT_5_6_5 */
  81049. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81050. /** UNSIGNED_INT_2_10_10_10_REV */
  81051. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81052. /** UNSIGNED_INT_24_8 */
  81053. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81054. /** UNSIGNED_INT_10F_11F_11F_REV */
  81055. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81056. /** UNSIGNED_INT_5_9_9_9_REV */
  81057. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81058. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81059. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81060. /** nearest is mag = nearest and min = nearest and no mip */
  81061. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81062. /** mag = nearest and min = nearest and mip = none */
  81063. static readonly TEXTURE_NEAREST_NEAREST: number;
  81064. /** Bilinear is mag = linear and min = linear and no mip */
  81065. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81066. /** mag = linear and min = linear and mip = none */
  81067. static readonly TEXTURE_LINEAR_LINEAR: number;
  81068. /** Trilinear is mag = linear and min = linear and mip = linear */
  81069. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81070. /** Trilinear is mag = linear and min = linear and mip = linear */
  81071. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81072. /** mag = nearest and min = nearest and mip = nearest */
  81073. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81074. /** mag = nearest and min = linear and mip = nearest */
  81075. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81076. /** mag = nearest and min = linear and mip = linear */
  81077. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81078. /** mag = nearest and min = linear and mip = none */
  81079. static readonly TEXTURE_NEAREST_LINEAR: number;
  81080. /** nearest is mag = nearest and min = nearest and mip = linear */
  81081. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81082. /** mag = linear and min = nearest and mip = nearest */
  81083. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81084. /** mag = linear and min = nearest and mip = linear */
  81085. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81086. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81087. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81088. /** mag = linear and min = nearest and mip = none */
  81089. static readonly TEXTURE_LINEAR_NEAREST: number;
  81090. /** Explicit coordinates mode */
  81091. static readonly TEXTURE_EXPLICIT_MODE: number;
  81092. /** Spherical coordinates mode */
  81093. static readonly TEXTURE_SPHERICAL_MODE: number;
  81094. /** Planar coordinates mode */
  81095. static readonly TEXTURE_PLANAR_MODE: number;
  81096. /** Cubic coordinates mode */
  81097. static readonly TEXTURE_CUBIC_MODE: number;
  81098. /** Projection coordinates mode */
  81099. static readonly TEXTURE_PROJECTION_MODE: number;
  81100. /** Skybox coordinates mode */
  81101. static readonly TEXTURE_SKYBOX_MODE: number;
  81102. /** Inverse Cubic coordinates mode */
  81103. static readonly TEXTURE_INVCUBIC_MODE: number;
  81104. /** Equirectangular coordinates mode */
  81105. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81106. /** Equirectangular Fixed coordinates mode */
  81107. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81108. /** Equirectangular Fixed Mirrored coordinates mode */
  81109. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81110. /** Offline (baking) quality for texture filtering */
  81111. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81112. /** High quality for texture filtering */
  81113. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81114. /** Medium quality for texture filtering */
  81115. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81116. /** Low quality for texture filtering */
  81117. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81118. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81119. static readonly SCALEMODE_FLOOR: number;
  81120. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81121. static readonly SCALEMODE_NEAREST: number;
  81122. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81123. static readonly SCALEMODE_CEILING: number;
  81124. /**
  81125. * The dirty texture flag value
  81126. */
  81127. static readonly MATERIAL_TextureDirtyFlag: number;
  81128. /**
  81129. * The dirty light flag value
  81130. */
  81131. static readonly MATERIAL_LightDirtyFlag: number;
  81132. /**
  81133. * The dirty fresnel flag value
  81134. */
  81135. static readonly MATERIAL_FresnelDirtyFlag: number;
  81136. /**
  81137. * The dirty attribute flag value
  81138. */
  81139. static readonly MATERIAL_AttributesDirtyFlag: number;
  81140. /**
  81141. * The dirty misc flag value
  81142. */
  81143. static readonly MATERIAL_MiscDirtyFlag: number;
  81144. /**
  81145. * The all dirty flag value
  81146. */
  81147. static readonly MATERIAL_AllDirtyFlag: number;
  81148. /**
  81149. * Returns the triangle fill mode
  81150. */
  81151. static readonly MATERIAL_TriangleFillMode: number;
  81152. /**
  81153. * Returns the wireframe mode
  81154. */
  81155. static readonly MATERIAL_WireFrameFillMode: number;
  81156. /**
  81157. * Returns the point fill mode
  81158. */
  81159. static readonly MATERIAL_PointFillMode: number;
  81160. /**
  81161. * Returns the point list draw mode
  81162. */
  81163. static readonly MATERIAL_PointListDrawMode: number;
  81164. /**
  81165. * Returns the line list draw mode
  81166. */
  81167. static readonly MATERIAL_LineListDrawMode: number;
  81168. /**
  81169. * Returns the line loop draw mode
  81170. */
  81171. static readonly MATERIAL_LineLoopDrawMode: number;
  81172. /**
  81173. * Returns the line strip draw mode
  81174. */
  81175. static readonly MATERIAL_LineStripDrawMode: number;
  81176. /**
  81177. * Returns the triangle strip draw mode
  81178. */
  81179. static readonly MATERIAL_TriangleStripDrawMode: number;
  81180. /**
  81181. * Returns the triangle fan draw mode
  81182. */
  81183. static readonly MATERIAL_TriangleFanDrawMode: number;
  81184. /**
  81185. * Stores the clock-wise side orientation
  81186. */
  81187. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81188. /**
  81189. * Stores the counter clock-wise side orientation
  81190. */
  81191. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81192. /**
  81193. * Nothing
  81194. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81195. */
  81196. static readonly ACTION_NothingTrigger: number;
  81197. /**
  81198. * On pick
  81199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81200. */
  81201. static readonly ACTION_OnPickTrigger: number;
  81202. /**
  81203. * On left pick
  81204. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81205. */
  81206. static readonly ACTION_OnLeftPickTrigger: number;
  81207. /**
  81208. * On right pick
  81209. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81210. */
  81211. static readonly ACTION_OnRightPickTrigger: number;
  81212. /**
  81213. * On center pick
  81214. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81215. */
  81216. static readonly ACTION_OnCenterPickTrigger: number;
  81217. /**
  81218. * On pick down
  81219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81220. */
  81221. static readonly ACTION_OnPickDownTrigger: number;
  81222. /**
  81223. * On double pick
  81224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81225. */
  81226. static readonly ACTION_OnDoublePickTrigger: number;
  81227. /**
  81228. * On pick up
  81229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81230. */
  81231. static readonly ACTION_OnPickUpTrigger: number;
  81232. /**
  81233. * On pick out.
  81234. * This trigger will only be raised if you also declared a OnPickDown
  81235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81236. */
  81237. static readonly ACTION_OnPickOutTrigger: number;
  81238. /**
  81239. * On long press
  81240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81241. */
  81242. static readonly ACTION_OnLongPressTrigger: number;
  81243. /**
  81244. * On pointer over
  81245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81246. */
  81247. static readonly ACTION_OnPointerOverTrigger: number;
  81248. /**
  81249. * On pointer out
  81250. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81251. */
  81252. static readonly ACTION_OnPointerOutTrigger: number;
  81253. /**
  81254. * On every frame
  81255. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81256. */
  81257. static readonly ACTION_OnEveryFrameTrigger: number;
  81258. /**
  81259. * On intersection enter
  81260. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81261. */
  81262. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81263. /**
  81264. * On intersection exit
  81265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81266. */
  81267. static readonly ACTION_OnIntersectionExitTrigger: number;
  81268. /**
  81269. * On key down
  81270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81271. */
  81272. static readonly ACTION_OnKeyDownTrigger: number;
  81273. /**
  81274. * On key up
  81275. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81276. */
  81277. static readonly ACTION_OnKeyUpTrigger: number;
  81278. /**
  81279. * Billboard mode will only apply to Y axis
  81280. */
  81281. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81282. /**
  81283. * Billboard mode will apply to all axes
  81284. */
  81285. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81286. /**
  81287. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81288. */
  81289. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81290. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81291. * Test order :
  81292. * Is the bounding sphere outside the frustum ?
  81293. * If not, are the bounding box vertices outside the frustum ?
  81294. * It not, then the cullable object is in the frustum.
  81295. */
  81296. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81297. /** Culling strategy : Bounding Sphere Only.
  81298. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81299. * It's also less accurate than the standard because some not visible objects can still be selected.
  81300. * Test : is the bounding sphere outside the frustum ?
  81301. * If not, then the cullable object is in the frustum.
  81302. */
  81303. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81304. /** Culling strategy : Optimistic Inclusion.
  81305. * This in an inclusion test first, then the standard exclusion test.
  81306. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81307. * 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.
  81308. * Anyway, it's as accurate as the standard strategy.
  81309. * Test :
  81310. * Is the cullable object bounding sphere center in the frustum ?
  81311. * If not, apply the default culling strategy.
  81312. */
  81313. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81314. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81315. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81316. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81317. * 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.
  81318. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81319. * Test :
  81320. * Is the cullable object bounding sphere center in the frustum ?
  81321. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81322. */
  81323. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81324. /**
  81325. * No logging while loading
  81326. */
  81327. static readonly SCENELOADER_NO_LOGGING: number;
  81328. /**
  81329. * Minimal logging while loading
  81330. */
  81331. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81332. /**
  81333. * Summary logging while loading
  81334. */
  81335. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81336. /**
  81337. * Detailled logging while loading
  81338. */
  81339. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81340. /**
  81341. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81342. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81343. */
  81344. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81345. /**
  81346. * Constant used to retrieve the position texture index in the textures array in the prepass
  81347. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81348. */
  81349. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81350. /**
  81351. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81352. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81353. */
  81354. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81355. /**
  81356. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81357. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81358. */
  81359. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81360. /**
  81361. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81362. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81363. */
  81364. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81365. /**
  81366. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81367. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81368. */
  81369. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81370. /**
  81371. * Constant used to retrieve albedo index in the textures array in the prepass
  81372. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81373. */
  81374. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81375. }
  81376. }
  81377. declare module BABYLON {
  81378. /**
  81379. * This represents the required contract to create a new type of texture loader.
  81380. */
  81381. export interface IInternalTextureLoader {
  81382. /**
  81383. * Defines wether the loader supports cascade loading the different faces.
  81384. */
  81385. supportCascades: boolean;
  81386. /**
  81387. * This returns if the loader support the current file information.
  81388. * @param extension defines the file extension of the file being loaded
  81389. * @param mimeType defines the optional mime type of the file being loaded
  81390. * @returns true if the loader can load the specified file
  81391. */
  81392. canLoad(extension: string, mimeType?: string): boolean;
  81393. /**
  81394. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81395. * @param data contains the texture data
  81396. * @param texture defines the BabylonJS internal texture
  81397. * @param createPolynomials will be true if polynomials have been requested
  81398. * @param onLoad defines the callback to trigger once the texture is ready
  81399. * @param onError defines the callback to trigger in case of error
  81400. */
  81401. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81402. /**
  81403. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81404. * @param data contains the texture data
  81405. * @param texture defines the BabylonJS internal texture
  81406. * @param callback defines the method to call once ready to upload
  81407. */
  81408. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81409. }
  81410. }
  81411. declare module BABYLON {
  81412. /**
  81413. * Class used to store and describe the pipeline context associated with an effect
  81414. */
  81415. export interface IPipelineContext {
  81416. /**
  81417. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81418. */
  81419. isAsync: boolean;
  81420. /**
  81421. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81422. */
  81423. isReady: boolean;
  81424. /** @hidden */
  81425. _getVertexShaderCode(): string | null;
  81426. /** @hidden */
  81427. _getFragmentShaderCode(): string | null;
  81428. /** @hidden */
  81429. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81430. }
  81431. }
  81432. declare module BABYLON {
  81433. /**
  81434. * Class used to store gfx data (like WebGLBuffer)
  81435. */
  81436. export class DataBuffer {
  81437. /**
  81438. * Gets or sets the number of objects referencing this buffer
  81439. */
  81440. references: number;
  81441. /** Gets or sets the size of the underlying buffer */
  81442. capacity: number;
  81443. /**
  81444. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81445. */
  81446. is32Bits: boolean;
  81447. /**
  81448. * Gets the underlying buffer
  81449. */
  81450. get underlyingResource(): any;
  81451. }
  81452. }
  81453. declare module BABYLON {
  81454. /** @hidden */
  81455. export interface IShaderProcessor {
  81456. attributeProcessor?: (attribute: string) => string;
  81457. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81458. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81459. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81460. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81461. lineProcessor?: (line: string, isFragment: boolean) => string;
  81462. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81463. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81464. }
  81465. }
  81466. declare module BABYLON {
  81467. /** @hidden */
  81468. export interface ProcessingOptions {
  81469. defines: string[];
  81470. indexParameters: any;
  81471. isFragment: boolean;
  81472. shouldUseHighPrecisionShader: boolean;
  81473. supportsUniformBuffers: boolean;
  81474. shadersRepository: string;
  81475. includesShadersStore: {
  81476. [key: string]: string;
  81477. };
  81478. processor?: IShaderProcessor;
  81479. version: string;
  81480. platformName: string;
  81481. lookForClosingBracketForUniformBuffer?: boolean;
  81482. }
  81483. }
  81484. declare module BABYLON {
  81485. /** @hidden */
  81486. export class ShaderCodeNode {
  81487. line: string;
  81488. children: ShaderCodeNode[];
  81489. additionalDefineKey?: string;
  81490. additionalDefineValue?: string;
  81491. isValid(preprocessors: {
  81492. [key: string]: string;
  81493. }): boolean;
  81494. process(preprocessors: {
  81495. [key: string]: string;
  81496. }, options: ProcessingOptions): string;
  81497. }
  81498. }
  81499. declare module BABYLON {
  81500. /** @hidden */
  81501. export class ShaderCodeCursor {
  81502. private _lines;
  81503. lineIndex: number;
  81504. get currentLine(): string;
  81505. get canRead(): boolean;
  81506. set lines(value: string[]);
  81507. }
  81508. }
  81509. declare module BABYLON {
  81510. /** @hidden */
  81511. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81512. process(preprocessors: {
  81513. [key: string]: string;
  81514. }, options: ProcessingOptions): string;
  81515. }
  81516. }
  81517. declare module BABYLON {
  81518. /** @hidden */
  81519. export class ShaderDefineExpression {
  81520. isTrue(preprocessors: {
  81521. [key: string]: string;
  81522. }): boolean;
  81523. private static _OperatorPriority;
  81524. private static _Stack;
  81525. static postfixToInfix(postfix: string[]): string;
  81526. static infixToPostfix(infix: string): string[];
  81527. }
  81528. }
  81529. declare module BABYLON {
  81530. /** @hidden */
  81531. export class ShaderCodeTestNode extends ShaderCodeNode {
  81532. testExpression: ShaderDefineExpression;
  81533. isValid(preprocessors: {
  81534. [key: string]: string;
  81535. }): boolean;
  81536. }
  81537. }
  81538. declare module BABYLON {
  81539. /** @hidden */
  81540. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81541. define: string;
  81542. not: boolean;
  81543. constructor(define: string, not?: boolean);
  81544. isTrue(preprocessors: {
  81545. [key: string]: string;
  81546. }): boolean;
  81547. }
  81548. }
  81549. declare module BABYLON {
  81550. /** @hidden */
  81551. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81552. leftOperand: ShaderDefineExpression;
  81553. rightOperand: ShaderDefineExpression;
  81554. isTrue(preprocessors: {
  81555. [key: string]: string;
  81556. }): boolean;
  81557. }
  81558. }
  81559. declare module BABYLON {
  81560. /** @hidden */
  81561. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81562. leftOperand: ShaderDefineExpression;
  81563. rightOperand: ShaderDefineExpression;
  81564. isTrue(preprocessors: {
  81565. [key: string]: string;
  81566. }): boolean;
  81567. }
  81568. }
  81569. declare module BABYLON {
  81570. /** @hidden */
  81571. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81572. define: string;
  81573. operand: string;
  81574. testValue: string;
  81575. constructor(define: string, operand: string, testValue: string);
  81576. isTrue(preprocessors: {
  81577. [key: string]: string;
  81578. }): boolean;
  81579. }
  81580. }
  81581. declare module BABYLON {
  81582. /**
  81583. * Class used to enable access to offline support
  81584. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81585. */
  81586. export interface IOfflineProvider {
  81587. /**
  81588. * Gets a boolean indicating if scene must be saved in the database
  81589. */
  81590. enableSceneOffline: boolean;
  81591. /**
  81592. * Gets a boolean indicating if textures must be saved in the database
  81593. */
  81594. enableTexturesOffline: boolean;
  81595. /**
  81596. * Open the offline support and make it available
  81597. * @param successCallback defines the callback to call on success
  81598. * @param errorCallback defines the callback to call on error
  81599. */
  81600. open(successCallback: () => void, errorCallback: () => void): void;
  81601. /**
  81602. * Loads an image from the offline support
  81603. * @param url defines the url to load from
  81604. * @param image defines the target DOM image
  81605. */
  81606. loadImage(url: string, image: HTMLImageElement): void;
  81607. /**
  81608. * Loads a file from offline support
  81609. * @param url defines the URL to load from
  81610. * @param sceneLoaded defines a callback to call on success
  81611. * @param progressCallBack defines a callback to call when progress changed
  81612. * @param errorCallback defines a callback to call on error
  81613. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81614. */
  81615. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81616. }
  81617. }
  81618. declare module BABYLON {
  81619. /**
  81620. * Class used to help managing file picking and drag'n'drop
  81621. * File Storage
  81622. */
  81623. export class FilesInputStore {
  81624. /**
  81625. * List of files ready to be loaded
  81626. */
  81627. static FilesToLoad: {
  81628. [key: string]: File;
  81629. };
  81630. }
  81631. }
  81632. declare module BABYLON {
  81633. /**
  81634. * Class used to define a retry strategy when error happens while loading assets
  81635. */
  81636. export class RetryStrategy {
  81637. /**
  81638. * Function used to defines an exponential back off strategy
  81639. * @param maxRetries defines the maximum number of retries (3 by default)
  81640. * @param baseInterval defines the interval between retries
  81641. * @returns the strategy function to use
  81642. */
  81643. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81644. }
  81645. }
  81646. declare module BABYLON {
  81647. /**
  81648. * @ignore
  81649. * Application error to support additional information when loading a file
  81650. */
  81651. export abstract class BaseError extends Error {
  81652. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81653. }
  81654. }
  81655. declare module BABYLON {
  81656. /** @ignore */
  81657. export class LoadFileError extends BaseError {
  81658. request?: WebRequest;
  81659. file?: File;
  81660. /**
  81661. * Creates a new LoadFileError
  81662. * @param message defines the message of the error
  81663. * @param request defines the optional web request
  81664. * @param file defines the optional file
  81665. */
  81666. constructor(message: string, object?: WebRequest | File);
  81667. }
  81668. /** @ignore */
  81669. export class RequestFileError extends BaseError {
  81670. request: WebRequest;
  81671. /**
  81672. * Creates a new LoadFileError
  81673. * @param message defines the message of the error
  81674. * @param request defines the optional web request
  81675. */
  81676. constructor(message: string, request: WebRequest);
  81677. }
  81678. /** @ignore */
  81679. export class ReadFileError extends BaseError {
  81680. file: File;
  81681. /**
  81682. * Creates a new ReadFileError
  81683. * @param message defines the message of the error
  81684. * @param file defines the optional file
  81685. */
  81686. constructor(message: string, file: File);
  81687. }
  81688. /**
  81689. * @hidden
  81690. */
  81691. export class FileTools {
  81692. /**
  81693. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81694. */
  81695. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81696. /**
  81697. * Gets or sets the base URL to use to load assets
  81698. */
  81699. static BaseUrl: string;
  81700. /**
  81701. * Default behaviour for cors in the application.
  81702. * It can be a string if the expected behavior is identical in the entire app.
  81703. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81704. */
  81705. static CorsBehavior: string | ((url: string | string[]) => string);
  81706. /**
  81707. * Gets or sets a function used to pre-process url before using them to load assets
  81708. */
  81709. static PreprocessUrl: (url: string) => string;
  81710. /**
  81711. * Removes unwanted characters from an url
  81712. * @param url defines the url to clean
  81713. * @returns the cleaned url
  81714. */
  81715. private static _CleanUrl;
  81716. /**
  81717. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81718. * @param url define the url we are trying
  81719. * @param element define the dom element where to configure the cors policy
  81720. */
  81721. static SetCorsBehavior(url: string | string[], element: {
  81722. crossOrigin: string | null;
  81723. }): void;
  81724. /**
  81725. * Loads an image as an HTMLImageElement.
  81726. * @param input url string, ArrayBuffer, or Blob to load
  81727. * @param onLoad callback called when the image successfully loads
  81728. * @param onError callback called when the image fails to load
  81729. * @param offlineProvider offline provider for caching
  81730. * @param mimeType optional mime type
  81731. * @returns the HTMLImageElement of the loaded image
  81732. */
  81733. 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>;
  81734. /**
  81735. * Reads a file from a File object
  81736. * @param file defines the file to load
  81737. * @param onSuccess defines the callback to call when data is loaded
  81738. * @param onProgress defines the callback to call during loading process
  81739. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81740. * @param onError defines the callback to call when an error occurs
  81741. * @returns a file request object
  81742. */
  81743. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81744. /**
  81745. * Loads a file from a url
  81746. * @param url url to load
  81747. * @param onSuccess callback called when the file successfully loads
  81748. * @param onProgress callback called while file is loading (if the server supports this mode)
  81749. * @param offlineProvider defines the offline provider for caching
  81750. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81751. * @param onError callback called when the file fails to load
  81752. * @returns a file request object
  81753. */
  81754. 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;
  81755. /**
  81756. * Loads a file
  81757. * @param url url to load
  81758. * @param onSuccess callback called when the file successfully loads
  81759. * @param onProgress callback called while file is loading (if the server supports this mode)
  81760. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81761. * @param onError callback called when the file fails to load
  81762. * @param onOpened callback called when the web request is opened
  81763. * @returns a file request object
  81764. */
  81765. 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;
  81766. /**
  81767. * Checks if the loaded document was accessed via `file:`-Protocol.
  81768. * @returns boolean
  81769. */
  81770. static IsFileURL(): boolean;
  81771. }
  81772. }
  81773. declare module BABYLON {
  81774. /** @hidden */
  81775. export class ShaderProcessor {
  81776. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81777. private static _ProcessPrecision;
  81778. private static _ExtractOperation;
  81779. private static _BuildSubExpression;
  81780. private static _BuildExpression;
  81781. private static _MoveCursorWithinIf;
  81782. private static _MoveCursor;
  81783. private static _EvaluatePreProcessors;
  81784. private static _PreparePreProcessors;
  81785. private static _ProcessShaderConversion;
  81786. private static _ProcessIncludes;
  81787. /**
  81788. * Loads a file from a url
  81789. * @param url url to load
  81790. * @param onSuccess callback called when the file successfully loads
  81791. * @param onProgress callback called while file is loading (if the server supports this mode)
  81792. * @param offlineProvider defines the offline provider for caching
  81793. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81794. * @param onError callback called when the file fails to load
  81795. * @returns a file request object
  81796. * @hidden
  81797. */
  81798. 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;
  81799. }
  81800. }
  81801. declare module BABYLON {
  81802. /**
  81803. * @hidden
  81804. */
  81805. export interface IColor4Like {
  81806. r: float;
  81807. g: float;
  81808. b: float;
  81809. a: float;
  81810. }
  81811. /**
  81812. * @hidden
  81813. */
  81814. export interface IColor3Like {
  81815. r: float;
  81816. g: float;
  81817. b: float;
  81818. }
  81819. /**
  81820. * @hidden
  81821. */
  81822. export interface IVector4Like {
  81823. x: float;
  81824. y: float;
  81825. z: float;
  81826. w: float;
  81827. }
  81828. /**
  81829. * @hidden
  81830. */
  81831. export interface IVector3Like {
  81832. x: float;
  81833. y: float;
  81834. z: float;
  81835. }
  81836. /**
  81837. * @hidden
  81838. */
  81839. export interface IVector2Like {
  81840. x: float;
  81841. y: float;
  81842. }
  81843. /**
  81844. * @hidden
  81845. */
  81846. export interface IMatrixLike {
  81847. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81848. updateFlag: int;
  81849. }
  81850. /**
  81851. * @hidden
  81852. */
  81853. export interface IViewportLike {
  81854. x: float;
  81855. y: float;
  81856. width: float;
  81857. height: float;
  81858. }
  81859. /**
  81860. * @hidden
  81861. */
  81862. export interface IPlaneLike {
  81863. normal: IVector3Like;
  81864. d: float;
  81865. normalize(): void;
  81866. }
  81867. }
  81868. declare module BABYLON {
  81869. /**
  81870. * Interface used to define common properties for effect fallbacks
  81871. */
  81872. export interface IEffectFallbacks {
  81873. /**
  81874. * Removes the defines that should be removed when falling back.
  81875. * @param currentDefines defines the current define statements for the shader.
  81876. * @param effect defines the current effect we try to compile
  81877. * @returns The resulting defines with defines of the current rank removed.
  81878. */
  81879. reduce(currentDefines: string, effect: Effect): string;
  81880. /**
  81881. * Removes the fallback from the bound mesh.
  81882. */
  81883. unBindMesh(): void;
  81884. /**
  81885. * Checks to see if more fallbacks are still availible.
  81886. */
  81887. hasMoreFallbacks: boolean;
  81888. }
  81889. }
  81890. declare module BABYLON {
  81891. /**
  81892. * Class used to evalaute queries containing `and` and `or` operators
  81893. */
  81894. export class AndOrNotEvaluator {
  81895. /**
  81896. * Evaluate a query
  81897. * @param query defines the query to evaluate
  81898. * @param evaluateCallback defines the callback used to filter result
  81899. * @returns true if the query matches
  81900. */
  81901. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81902. private static _HandleParenthesisContent;
  81903. private static _SimplifyNegation;
  81904. }
  81905. }
  81906. declare module BABYLON {
  81907. /**
  81908. * Class used to store custom tags
  81909. */
  81910. export class Tags {
  81911. /**
  81912. * Adds support for tags on the given object
  81913. * @param obj defines the object to use
  81914. */
  81915. static EnableFor(obj: any): void;
  81916. /**
  81917. * Removes tags support
  81918. * @param obj defines the object to use
  81919. */
  81920. static DisableFor(obj: any): void;
  81921. /**
  81922. * Gets a boolean indicating if the given object has tags
  81923. * @param obj defines the object to use
  81924. * @returns a boolean
  81925. */
  81926. static HasTags(obj: any): boolean;
  81927. /**
  81928. * Gets the tags available on a given object
  81929. * @param obj defines the object to use
  81930. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81931. * @returns the tags
  81932. */
  81933. static GetTags(obj: any, asString?: boolean): any;
  81934. /**
  81935. * Adds tags to an object
  81936. * @param obj defines the object to use
  81937. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81938. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81939. */
  81940. static AddTagsTo(obj: any, tagsString: string): void;
  81941. /**
  81942. * @hidden
  81943. */
  81944. static _AddTagTo(obj: any, tag: string): void;
  81945. /**
  81946. * Removes specific tags from a specific object
  81947. * @param obj defines the object to use
  81948. * @param tagsString defines the tags to remove
  81949. */
  81950. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81951. /**
  81952. * @hidden
  81953. */
  81954. static _RemoveTagFrom(obj: any, tag: string): void;
  81955. /**
  81956. * Defines if tags hosted on an object match a given query
  81957. * @param obj defines the object to use
  81958. * @param tagsQuery defines the tag query
  81959. * @returns a boolean
  81960. */
  81961. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81962. }
  81963. }
  81964. declare module BABYLON {
  81965. /**
  81966. * Scalar computation library
  81967. */
  81968. export class Scalar {
  81969. /**
  81970. * Two pi constants convenient for computation.
  81971. */
  81972. static TwoPi: number;
  81973. /**
  81974. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81975. * @param a number
  81976. * @param b number
  81977. * @param epsilon (default = 1.401298E-45)
  81978. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81979. */
  81980. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81981. /**
  81982. * Returns a string : the upper case translation of the number i to hexadecimal.
  81983. * @param i number
  81984. * @returns the upper case translation of the number i to hexadecimal.
  81985. */
  81986. static ToHex(i: number): string;
  81987. /**
  81988. * Returns -1 if value is negative and +1 is value is positive.
  81989. * @param value the value
  81990. * @returns the value itself if it's equal to zero.
  81991. */
  81992. static Sign(value: number): number;
  81993. /**
  81994. * Returns the value itself if it's between min and max.
  81995. * Returns min if the value is lower than min.
  81996. * Returns max if the value is greater than max.
  81997. * @param value the value to clmap
  81998. * @param min the min value to clamp to (default: 0)
  81999. * @param max the max value to clamp to (default: 1)
  82000. * @returns the clamped value
  82001. */
  82002. static Clamp(value: number, min?: number, max?: number): number;
  82003. /**
  82004. * the log2 of value.
  82005. * @param value the value to compute log2 of
  82006. * @returns the log2 of value.
  82007. */
  82008. static Log2(value: number): number;
  82009. /**
  82010. * Loops the value, so that it is never larger than length and never smaller than 0.
  82011. *
  82012. * This is similar to the modulo operator but it works with floating point numbers.
  82013. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82014. * With t = 5 and length = 2.5, the result would be 0.0.
  82015. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82016. * @param value the value
  82017. * @param length the length
  82018. * @returns the looped value
  82019. */
  82020. static Repeat(value: number, length: number): number;
  82021. /**
  82022. * Normalize the value between 0.0 and 1.0 using min and max values
  82023. * @param value value to normalize
  82024. * @param min max to normalize between
  82025. * @param max min to normalize between
  82026. * @returns the normalized value
  82027. */
  82028. static Normalize(value: number, min: number, max: number): number;
  82029. /**
  82030. * Denormalize the value from 0.0 and 1.0 using min and max values
  82031. * @param normalized value to denormalize
  82032. * @param min max to denormalize between
  82033. * @param max min to denormalize between
  82034. * @returns the denormalized value
  82035. */
  82036. static Denormalize(normalized: number, min: number, max: number): number;
  82037. /**
  82038. * Calculates the shortest difference between two given angles given in degrees.
  82039. * @param current current angle in degrees
  82040. * @param target target angle in degrees
  82041. * @returns the delta
  82042. */
  82043. static DeltaAngle(current: number, target: number): number;
  82044. /**
  82045. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82046. * @param tx value
  82047. * @param length length
  82048. * @returns The returned value will move back and forth between 0 and length
  82049. */
  82050. static PingPong(tx: number, length: number): number;
  82051. /**
  82052. * Interpolates between min and max with smoothing at the limits.
  82053. *
  82054. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82055. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82056. * @param from from
  82057. * @param to to
  82058. * @param tx value
  82059. * @returns the smooth stepped value
  82060. */
  82061. static SmoothStep(from: number, to: number, tx: number): number;
  82062. /**
  82063. * Moves a value current towards target.
  82064. *
  82065. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82066. * Negative values of maxDelta pushes the value away from target.
  82067. * @param current current value
  82068. * @param target target value
  82069. * @param maxDelta max distance to move
  82070. * @returns resulting value
  82071. */
  82072. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82073. /**
  82074. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82075. *
  82076. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82077. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82078. * @param current current value
  82079. * @param target target value
  82080. * @param maxDelta max distance to move
  82081. * @returns resulting angle
  82082. */
  82083. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82084. /**
  82085. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82086. * @param start start value
  82087. * @param end target value
  82088. * @param amount amount to lerp between
  82089. * @returns the lerped value
  82090. */
  82091. static Lerp(start: number, end: number, amount: number): number;
  82092. /**
  82093. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82094. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82095. * @param start start value
  82096. * @param end target value
  82097. * @param amount amount to lerp between
  82098. * @returns the lerped value
  82099. */
  82100. static LerpAngle(start: number, end: number, amount: number): number;
  82101. /**
  82102. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82103. * @param a start value
  82104. * @param b target value
  82105. * @param value value between a and b
  82106. * @returns the inverseLerp value
  82107. */
  82108. static InverseLerp(a: number, b: number, value: number): number;
  82109. /**
  82110. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82111. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82112. * @param value1 spline value
  82113. * @param tangent1 spline value
  82114. * @param value2 spline value
  82115. * @param tangent2 spline value
  82116. * @param amount input value
  82117. * @returns hermite result
  82118. */
  82119. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82120. /**
  82121. * Returns a random float number between and min and max values
  82122. * @param min min value of random
  82123. * @param max max value of random
  82124. * @returns random value
  82125. */
  82126. static RandomRange(min: number, max: number): number;
  82127. /**
  82128. * This function returns percentage of a number in a given range.
  82129. *
  82130. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82131. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82132. * @param number to convert to percentage
  82133. * @param min min range
  82134. * @param max max range
  82135. * @returns the percentage
  82136. */
  82137. static RangeToPercent(number: number, min: number, max: number): number;
  82138. /**
  82139. * This function returns number that corresponds to the percentage in a given range.
  82140. *
  82141. * PercentToRange(0.34,0,100) will return 34.
  82142. * @param percent to convert to number
  82143. * @param min min range
  82144. * @param max max range
  82145. * @returns the number
  82146. */
  82147. static PercentToRange(percent: number, min: number, max: number): number;
  82148. /**
  82149. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82150. * @param angle The angle to normalize in radian.
  82151. * @return The converted angle.
  82152. */
  82153. static NormalizeRadians(angle: number): number;
  82154. }
  82155. }
  82156. declare module BABYLON {
  82157. /**
  82158. * Constant used to convert a value to gamma space
  82159. * @ignorenaming
  82160. */
  82161. export const ToGammaSpace: number;
  82162. /**
  82163. * Constant used to convert a value to linear space
  82164. * @ignorenaming
  82165. */
  82166. export const ToLinearSpace = 2.2;
  82167. /**
  82168. * Constant used to define the minimal number value in Babylon.js
  82169. * @ignorenaming
  82170. */
  82171. let Epsilon: number;
  82172. }
  82173. declare module BABYLON {
  82174. /**
  82175. * Class used to represent a viewport on screen
  82176. */
  82177. export class Viewport {
  82178. /** viewport left coordinate */
  82179. x: number;
  82180. /** viewport top coordinate */
  82181. y: number;
  82182. /**viewport width */
  82183. width: number;
  82184. /** viewport height */
  82185. height: number;
  82186. /**
  82187. * Creates a Viewport object located at (x, y) and sized (width, height)
  82188. * @param x defines viewport left coordinate
  82189. * @param y defines viewport top coordinate
  82190. * @param width defines the viewport width
  82191. * @param height defines the viewport height
  82192. */
  82193. constructor(
  82194. /** viewport left coordinate */
  82195. x: number,
  82196. /** viewport top coordinate */
  82197. y: number,
  82198. /**viewport width */
  82199. width: number,
  82200. /** viewport height */
  82201. height: number);
  82202. /**
  82203. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82204. * @param renderWidth defines the rendering width
  82205. * @param renderHeight defines the rendering height
  82206. * @returns a new Viewport
  82207. */
  82208. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82209. /**
  82210. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82211. * @param renderWidth defines the rendering width
  82212. * @param renderHeight defines the rendering height
  82213. * @param ref defines the target viewport
  82214. * @returns the current viewport
  82215. */
  82216. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82217. /**
  82218. * Returns a new Viewport copied from the current one
  82219. * @returns a new Viewport
  82220. */
  82221. clone(): Viewport;
  82222. }
  82223. }
  82224. declare module BABYLON {
  82225. /**
  82226. * Class containing a set of static utilities functions for arrays.
  82227. */
  82228. export class ArrayTools {
  82229. /**
  82230. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82231. * @param size the number of element to construct and put in the array
  82232. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82233. * @returns a new array filled with new objects
  82234. */
  82235. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82236. }
  82237. }
  82238. declare module BABYLON {
  82239. /**
  82240. * Represents a plane by the equation ax + by + cz + d = 0
  82241. */
  82242. export class Plane {
  82243. private static _TmpMatrix;
  82244. /**
  82245. * Normal of the plane (a,b,c)
  82246. */
  82247. normal: Vector3;
  82248. /**
  82249. * d component of the plane
  82250. */
  82251. d: number;
  82252. /**
  82253. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82254. * @param a a component of the plane
  82255. * @param b b component of the plane
  82256. * @param c c component of the plane
  82257. * @param d d component of the plane
  82258. */
  82259. constructor(a: number, b: number, c: number, d: number);
  82260. /**
  82261. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82262. */
  82263. asArray(): number[];
  82264. /**
  82265. * @returns a new plane copied from the current Plane.
  82266. */
  82267. clone(): Plane;
  82268. /**
  82269. * @returns the string "Plane".
  82270. */
  82271. getClassName(): string;
  82272. /**
  82273. * @returns the Plane hash code.
  82274. */
  82275. getHashCode(): number;
  82276. /**
  82277. * Normalize the current Plane in place.
  82278. * @returns the updated Plane.
  82279. */
  82280. normalize(): Plane;
  82281. /**
  82282. * Applies a transformation the plane and returns the result
  82283. * @param transformation the transformation matrix to be applied to the plane
  82284. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82285. */
  82286. transform(transformation: DeepImmutable<Matrix>): Plane;
  82287. /**
  82288. * Compute the dot product between the point and the plane normal
  82289. * @param point point to calculate the dot product with
  82290. * @returns the dot product (float) of the point coordinates and the plane normal.
  82291. */
  82292. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82293. /**
  82294. * Updates the current Plane from the plane defined by the three given points.
  82295. * @param point1 one of the points used to contruct the plane
  82296. * @param point2 one of the points used to contruct the plane
  82297. * @param point3 one of the points used to contruct the plane
  82298. * @returns the updated Plane.
  82299. */
  82300. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82301. /**
  82302. * Checks if the plane is facing a given direction
  82303. * @param direction the direction to check if the plane is facing
  82304. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82305. * @returns True is the vector "direction" is the same side than the plane normal.
  82306. */
  82307. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82308. /**
  82309. * Calculates the distance to a point
  82310. * @param point point to calculate distance to
  82311. * @returns the signed distance (float) from the given point to the Plane.
  82312. */
  82313. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82314. /**
  82315. * Creates a plane from an array
  82316. * @param array the array to create a plane from
  82317. * @returns a new Plane from the given array.
  82318. */
  82319. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82320. /**
  82321. * Creates a plane from three points
  82322. * @param point1 point used to create the plane
  82323. * @param point2 point used to create the plane
  82324. * @param point3 point used to create the plane
  82325. * @returns a new Plane defined by the three given points.
  82326. */
  82327. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82328. /**
  82329. * Creates a plane from an origin point and a normal
  82330. * @param origin origin of the plane to be constructed
  82331. * @param normal normal of the plane to be constructed
  82332. * @returns a new Plane the normal vector to this plane at the given origin point.
  82333. * Note : the vector "normal" is updated because normalized.
  82334. */
  82335. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82336. /**
  82337. * Calculates the distance from a plane and a point
  82338. * @param origin origin of the plane to be constructed
  82339. * @param normal normal of the plane to be constructed
  82340. * @param point point to calculate distance to
  82341. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82342. */
  82343. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82344. }
  82345. }
  82346. declare module BABYLON {
  82347. /** @hidden */
  82348. export class PerformanceConfigurator {
  82349. /** @hidden */
  82350. static MatrixUse64Bits: boolean;
  82351. /** @hidden */
  82352. static MatrixTrackPrecisionChange: boolean;
  82353. /** @hidden */
  82354. static MatrixCurrentType: any;
  82355. /** @hidden */
  82356. static MatrixTrackedMatrices: Array<any> | null;
  82357. /** @hidden */
  82358. static SetMatrixPrecision(use64bits: boolean): void;
  82359. }
  82360. }
  82361. declare module BABYLON {
  82362. /**
  82363. * Class representing a vector containing 2 coordinates
  82364. */
  82365. export class Vector2 {
  82366. /** defines the first coordinate */
  82367. x: number;
  82368. /** defines the second coordinate */
  82369. y: number;
  82370. /**
  82371. * Creates a new Vector2 from the given x and y coordinates
  82372. * @param x defines the first coordinate
  82373. * @param y defines the second coordinate
  82374. */
  82375. constructor(
  82376. /** defines the first coordinate */
  82377. x?: number,
  82378. /** defines the second coordinate */
  82379. y?: number);
  82380. /**
  82381. * Gets a string with the Vector2 coordinates
  82382. * @returns a string with the Vector2 coordinates
  82383. */
  82384. toString(): string;
  82385. /**
  82386. * Gets class name
  82387. * @returns the string "Vector2"
  82388. */
  82389. getClassName(): string;
  82390. /**
  82391. * Gets current vector hash code
  82392. * @returns the Vector2 hash code as a number
  82393. */
  82394. getHashCode(): number;
  82395. /**
  82396. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82397. * @param array defines the source array
  82398. * @param index defines the offset in source array
  82399. * @returns the current Vector2
  82400. */
  82401. toArray(array: FloatArray, index?: number): Vector2;
  82402. /**
  82403. * Update the current vector from an array
  82404. * @param array defines the destination array
  82405. * @param index defines the offset in the destination array
  82406. * @returns the current Vector3
  82407. */
  82408. fromArray(array: FloatArray, index?: number): Vector2;
  82409. /**
  82410. * Copy the current vector to an array
  82411. * @returns a new array with 2 elements: the Vector2 coordinates.
  82412. */
  82413. asArray(): number[];
  82414. /**
  82415. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82416. * @param source defines the source Vector2
  82417. * @returns the current updated Vector2
  82418. */
  82419. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82420. /**
  82421. * Sets the Vector2 coordinates with the given floats
  82422. * @param x defines the first coordinate
  82423. * @param y defines the second coordinate
  82424. * @returns the current updated Vector2
  82425. */
  82426. copyFromFloats(x: number, y: number): Vector2;
  82427. /**
  82428. * Sets the Vector2 coordinates with the given floats
  82429. * @param x defines the first coordinate
  82430. * @param y defines the second coordinate
  82431. * @returns the current updated Vector2
  82432. */
  82433. set(x: number, y: number): Vector2;
  82434. /**
  82435. * Add another vector with the current one
  82436. * @param otherVector defines the other vector
  82437. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82438. */
  82439. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82440. /**
  82441. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82442. * @param otherVector defines the other vector
  82443. * @param result defines the target vector
  82444. * @returns the unmodified current Vector2
  82445. */
  82446. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82447. /**
  82448. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82449. * @param otherVector defines the other vector
  82450. * @returns the current updated Vector2
  82451. */
  82452. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82453. /**
  82454. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82455. * @param otherVector defines the other vector
  82456. * @returns a new Vector2
  82457. */
  82458. addVector3(otherVector: Vector3): Vector2;
  82459. /**
  82460. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82461. * @param otherVector defines the other vector
  82462. * @returns a new Vector2
  82463. */
  82464. subtract(otherVector: Vector2): Vector2;
  82465. /**
  82466. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82467. * @param otherVector defines the other vector
  82468. * @param result defines the target vector
  82469. * @returns the unmodified current Vector2
  82470. */
  82471. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82472. /**
  82473. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82474. * @param otherVector defines the other vector
  82475. * @returns the current updated Vector2
  82476. */
  82477. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82478. /**
  82479. * Multiplies in place the current Vector2 coordinates by the given ones
  82480. * @param otherVector defines the other vector
  82481. * @returns the current updated Vector2
  82482. */
  82483. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82484. /**
  82485. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82486. * @param otherVector defines the other vector
  82487. * @returns a new Vector2
  82488. */
  82489. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82490. /**
  82491. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82492. * @param otherVector defines the other vector
  82493. * @param result defines the target vector
  82494. * @returns the unmodified current Vector2
  82495. */
  82496. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82497. /**
  82498. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82499. * @param x defines the first coordinate
  82500. * @param y defines the second coordinate
  82501. * @returns a new Vector2
  82502. */
  82503. multiplyByFloats(x: number, y: number): Vector2;
  82504. /**
  82505. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82506. * @param otherVector defines the other vector
  82507. * @returns a new Vector2
  82508. */
  82509. divide(otherVector: Vector2): Vector2;
  82510. /**
  82511. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82512. * @param otherVector defines the other vector
  82513. * @param result defines the target vector
  82514. * @returns the unmodified current Vector2
  82515. */
  82516. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82517. /**
  82518. * Divides the current Vector2 coordinates by the given ones
  82519. * @param otherVector defines the other vector
  82520. * @returns the current updated Vector2
  82521. */
  82522. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82523. /**
  82524. * Gets a new Vector2 with current Vector2 negated coordinates
  82525. * @returns a new Vector2
  82526. */
  82527. negate(): Vector2;
  82528. /**
  82529. * Negate this vector in place
  82530. * @returns this
  82531. */
  82532. negateInPlace(): Vector2;
  82533. /**
  82534. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82535. * @param result defines the Vector3 object where to store the result
  82536. * @returns the current Vector2
  82537. */
  82538. negateToRef(result: Vector2): Vector2;
  82539. /**
  82540. * Multiply the Vector2 coordinates by scale
  82541. * @param scale defines the scaling factor
  82542. * @returns the current updated Vector2
  82543. */
  82544. scaleInPlace(scale: number): Vector2;
  82545. /**
  82546. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82547. * @param scale defines the scaling factor
  82548. * @returns a new Vector2
  82549. */
  82550. scale(scale: number): Vector2;
  82551. /**
  82552. * Scale the current Vector2 values by a factor to a given Vector2
  82553. * @param scale defines the scale factor
  82554. * @param result defines the Vector2 object where to store the result
  82555. * @returns the unmodified current Vector2
  82556. */
  82557. scaleToRef(scale: number, result: Vector2): Vector2;
  82558. /**
  82559. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82560. * @param scale defines the scale factor
  82561. * @param result defines the Vector2 object where to store the result
  82562. * @returns the unmodified current Vector2
  82563. */
  82564. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82565. /**
  82566. * Gets a boolean if two vectors are equals
  82567. * @param otherVector defines the other vector
  82568. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82569. */
  82570. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82571. /**
  82572. * Gets a boolean if two vectors are equals (using an epsilon value)
  82573. * @param otherVector defines the other vector
  82574. * @param epsilon defines the minimal distance to consider equality
  82575. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82576. */
  82577. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82578. /**
  82579. * Gets a new Vector2 from current Vector2 floored values
  82580. * @returns a new Vector2
  82581. */
  82582. floor(): Vector2;
  82583. /**
  82584. * Gets a new Vector2 from current Vector2 floored values
  82585. * @returns a new Vector2
  82586. */
  82587. fract(): Vector2;
  82588. /**
  82589. * Gets the length of the vector
  82590. * @returns the vector length (float)
  82591. */
  82592. length(): number;
  82593. /**
  82594. * Gets the vector squared length
  82595. * @returns the vector squared length (float)
  82596. */
  82597. lengthSquared(): number;
  82598. /**
  82599. * Normalize the vector
  82600. * @returns the current updated Vector2
  82601. */
  82602. normalize(): Vector2;
  82603. /**
  82604. * Gets a new Vector2 copied from the Vector2
  82605. * @returns a new Vector2
  82606. */
  82607. clone(): Vector2;
  82608. /**
  82609. * Gets a new Vector2(0, 0)
  82610. * @returns a new Vector2
  82611. */
  82612. static Zero(): Vector2;
  82613. /**
  82614. * Gets a new Vector2(1, 1)
  82615. * @returns a new Vector2
  82616. */
  82617. static One(): Vector2;
  82618. /**
  82619. * Gets a new Vector2 set from the given index element of the given array
  82620. * @param array defines the data source
  82621. * @param offset defines the offset in the data source
  82622. * @returns a new Vector2
  82623. */
  82624. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82625. /**
  82626. * Sets "result" from the given index element of the given array
  82627. * @param array defines the data source
  82628. * @param offset defines the offset in the data source
  82629. * @param result defines the target vector
  82630. */
  82631. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82632. /**
  82633. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82634. * @param value1 defines 1st point of control
  82635. * @param value2 defines 2nd point of control
  82636. * @param value3 defines 3rd point of control
  82637. * @param value4 defines 4th point of control
  82638. * @param amount defines the interpolation factor
  82639. * @returns a new Vector2
  82640. */
  82641. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82642. /**
  82643. * 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".
  82644. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82645. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82646. * @param value defines the value to clamp
  82647. * @param min defines the lower limit
  82648. * @param max defines the upper limit
  82649. * @returns a new Vector2
  82650. */
  82651. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82652. /**
  82653. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82654. * @param value1 defines the 1st control point
  82655. * @param tangent1 defines the outgoing tangent
  82656. * @param value2 defines the 2nd control point
  82657. * @param tangent2 defines the incoming tangent
  82658. * @param amount defines the interpolation factor
  82659. * @returns a new Vector2
  82660. */
  82661. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82662. /**
  82663. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82664. * @param start defines the start vector
  82665. * @param end defines the end vector
  82666. * @param amount defines the interpolation factor
  82667. * @returns a new Vector2
  82668. */
  82669. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82670. /**
  82671. * Gets the dot product of the vector "left" and the vector "right"
  82672. * @param left defines first vector
  82673. * @param right defines second vector
  82674. * @returns the dot product (float)
  82675. */
  82676. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82677. /**
  82678. * Returns a new Vector2 equal to the normalized given vector
  82679. * @param vector defines the vector to normalize
  82680. * @returns a new Vector2
  82681. */
  82682. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82683. /**
  82684. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82685. * @param left defines 1st vector
  82686. * @param right defines 2nd vector
  82687. * @returns a new Vector2
  82688. */
  82689. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82690. /**
  82691. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82692. * @param left defines 1st vector
  82693. * @param right defines 2nd vector
  82694. * @returns a new Vector2
  82695. */
  82696. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82697. /**
  82698. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82699. * @param vector defines the vector to transform
  82700. * @param transformation defines the matrix to apply
  82701. * @returns a new Vector2
  82702. */
  82703. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82704. /**
  82705. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82706. * @param vector defines the vector to transform
  82707. * @param transformation defines the matrix to apply
  82708. * @param result defines the target vector
  82709. */
  82710. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82711. /**
  82712. * Determines if a given vector is included in a triangle
  82713. * @param p defines the vector to test
  82714. * @param p0 defines 1st triangle point
  82715. * @param p1 defines 2nd triangle point
  82716. * @param p2 defines 3rd triangle point
  82717. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82718. */
  82719. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82720. /**
  82721. * Gets the distance between the vectors "value1" and "value2"
  82722. * @param value1 defines first vector
  82723. * @param value2 defines second vector
  82724. * @returns the distance between vectors
  82725. */
  82726. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82727. /**
  82728. * Returns the squared distance between the vectors "value1" and "value2"
  82729. * @param value1 defines first vector
  82730. * @param value2 defines second vector
  82731. * @returns the squared distance between vectors
  82732. */
  82733. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82734. /**
  82735. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82736. * @param value1 defines first vector
  82737. * @param value2 defines second vector
  82738. * @returns a new Vector2
  82739. */
  82740. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82741. /**
  82742. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82743. * @param p defines the middle point
  82744. * @param segA defines one point of the segment
  82745. * @param segB defines the other point of the segment
  82746. * @returns the shortest distance
  82747. */
  82748. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82749. }
  82750. /**
  82751. * Class used to store (x,y,z) vector representation
  82752. * A Vector3 is the main object used in 3D geometry
  82753. * It can represent etiher the coordinates of a point the space, either a direction
  82754. * Reminder: js uses a left handed forward facing system
  82755. */
  82756. export class Vector3 {
  82757. private static _UpReadOnly;
  82758. private static _ZeroReadOnly;
  82759. /** @hidden */
  82760. _x: number;
  82761. /** @hidden */
  82762. _y: number;
  82763. /** @hidden */
  82764. _z: number;
  82765. /** @hidden */
  82766. _isDirty: boolean;
  82767. /** Gets or sets the x coordinate */
  82768. get x(): number;
  82769. set x(value: number);
  82770. /** Gets or sets the y coordinate */
  82771. get y(): number;
  82772. set y(value: number);
  82773. /** Gets or sets the z coordinate */
  82774. get z(): number;
  82775. set z(value: number);
  82776. /**
  82777. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82778. * @param x defines the first coordinates (on X axis)
  82779. * @param y defines the second coordinates (on Y axis)
  82780. * @param z defines the third coordinates (on Z axis)
  82781. */
  82782. constructor(x?: number, y?: number, z?: number);
  82783. /**
  82784. * Creates a string representation of the Vector3
  82785. * @returns a string with the Vector3 coordinates.
  82786. */
  82787. toString(): string;
  82788. /**
  82789. * Gets the class name
  82790. * @returns the string "Vector3"
  82791. */
  82792. getClassName(): string;
  82793. /**
  82794. * Creates the Vector3 hash code
  82795. * @returns a number which tends to be unique between Vector3 instances
  82796. */
  82797. getHashCode(): number;
  82798. /**
  82799. * Creates an array containing three elements : the coordinates of the Vector3
  82800. * @returns a new array of numbers
  82801. */
  82802. asArray(): number[];
  82803. /**
  82804. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82805. * @param array defines the destination array
  82806. * @param index defines the offset in the destination array
  82807. * @returns the current Vector3
  82808. */
  82809. toArray(array: FloatArray, index?: number): Vector3;
  82810. /**
  82811. * Update the current vector from an array
  82812. * @param array defines the destination array
  82813. * @param index defines the offset in the destination array
  82814. * @returns the current Vector3
  82815. */
  82816. fromArray(array: FloatArray, index?: number): Vector3;
  82817. /**
  82818. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82819. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82820. */
  82821. toQuaternion(): Quaternion;
  82822. /**
  82823. * Adds the given vector to the current Vector3
  82824. * @param otherVector defines the second operand
  82825. * @returns the current updated Vector3
  82826. */
  82827. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82828. /**
  82829. * Adds the given coordinates to the current Vector3
  82830. * @param x defines the x coordinate of the operand
  82831. * @param y defines the y coordinate of the operand
  82832. * @param z defines the z coordinate of the operand
  82833. * @returns the current updated Vector3
  82834. */
  82835. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82836. /**
  82837. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82838. * @param otherVector defines the second operand
  82839. * @returns the resulting Vector3
  82840. */
  82841. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82842. /**
  82843. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82844. * @param otherVector defines the second operand
  82845. * @param result defines the Vector3 object where to store the result
  82846. * @returns the current Vector3
  82847. */
  82848. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82849. /**
  82850. * Subtract the given vector from the current Vector3
  82851. * @param otherVector defines the second operand
  82852. * @returns the current updated Vector3
  82853. */
  82854. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82855. /**
  82856. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82857. * @param otherVector defines the second operand
  82858. * @returns the resulting Vector3
  82859. */
  82860. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82861. /**
  82862. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82863. * @param otherVector defines the second operand
  82864. * @param result defines the Vector3 object where to store the result
  82865. * @returns the current Vector3
  82866. */
  82867. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82868. /**
  82869. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82870. * @param x defines the x coordinate of the operand
  82871. * @param y defines the y coordinate of the operand
  82872. * @param z defines the z coordinate of the operand
  82873. * @returns the resulting Vector3
  82874. */
  82875. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82876. /**
  82877. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82878. * @param x defines the x coordinate of the operand
  82879. * @param y defines the y coordinate of the operand
  82880. * @param z defines the z coordinate of the operand
  82881. * @param result defines the Vector3 object where to store the result
  82882. * @returns the current Vector3
  82883. */
  82884. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82885. /**
  82886. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82887. * @returns a new Vector3
  82888. */
  82889. negate(): Vector3;
  82890. /**
  82891. * Negate this vector in place
  82892. * @returns this
  82893. */
  82894. negateInPlace(): Vector3;
  82895. /**
  82896. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82897. * @param result defines the Vector3 object where to store the result
  82898. * @returns the current Vector3
  82899. */
  82900. negateToRef(result: Vector3): Vector3;
  82901. /**
  82902. * Multiplies the Vector3 coordinates by the float "scale"
  82903. * @param scale defines the multiplier factor
  82904. * @returns the current updated Vector3
  82905. */
  82906. scaleInPlace(scale: number): Vector3;
  82907. /**
  82908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82909. * @param scale defines the multiplier factor
  82910. * @returns a new Vector3
  82911. */
  82912. scale(scale: number): Vector3;
  82913. /**
  82914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82915. * @param scale defines the multiplier factor
  82916. * @param result defines the Vector3 object where to store the result
  82917. * @returns the current Vector3
  82918. */
  82919. scaleToRef(scale: number, result: Vector3): Vector3;
  82920. /**
  82921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82922. * @param scale defines the scale factor
  82923. * @param result defines the Vector3 object where to store the result
  82924. * @returns the unmodified current Vector3
  82925. */
  82926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82927. /**
  82928. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82929. * @param origin defines the origin of the projection ray
  82930. * @param plane defines the plane to project to
  82931. * @returns the projected vector3
  82932. */
  82933. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82934. /**
  82935. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82936. * @param origin defines the origin of the projection ray
  82937. * @param plane defines the plane to project to
  82938. * @param result defines the Vector3 where to store the result
  82939. */
  82940. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82941. /**
  82942. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82943. * @param otherVector defines the second operand
  82944. * @returns true if both vectors are equals
  82945. */
  82946. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82947. /**
  82948. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82949. * @param otherVector defines the second operand
  82950. * @param epsilon defines the minimal distance to define values as equals
  82951. * @returns true if both vectors are distant less than epsilon
  82952. */
  82953. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82954. /**
  82955. * Returns true if the current Vector3 coordinates equals the given floats
  82956. * @param x defines the x coordinate of the operand
  82957. * @param y defines the y coordinate of the operand
  82958. * @param z defines the z coordinate of the operand
  82959. * @returns true if both vectors are equals
  82960. */
  82961. equalsToFloats(x: number, y: number, z: number): boolean;
  82962. /**
  82963. * Multiplies the current Vector3 coordinates by the given ones
  82964. * @param otherVector defines the second operand
  82965. * @returns the current updated Vector3
  82966. */
  82967. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82968. /**
  82969. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82970. * @param otherVector defines the second operand
  82971. * @returns the new Vector3
  82972. */
  82973. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82974. /**
  82975. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82976. * @param otherVector defines the second operand
  82977. * @param result defines the Vector3 object where to store the result
  82978. * @returns the current Vector3
  82979. */
  82980. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82981. /**
  82982. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82983. * @param x defines the x coordinate of the operand
  82984. * @param y defines the y coordinate of the operand
  82985. * @param z defines the z coordinate of the operand
  82986. * @returns the new Vector3
  82987. */
  82988. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82989. /**
  82990. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82991. * @param otherVector defines the second operand
  82992. * @returns the new Vector3
  82993. */
  82994. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82995. /**
  82996. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82997. * @param otherVector defines the second operand
  82998. * @param result defines the Vector3 object where to store the result
  82999. * @returns the current Vector3
  83000. */
  83001. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83002. /**
  83003. * Divides the current Vector3 coordinates by the given ones.
  83004. * @param otherVector defines the second operand
  83005. * @returns the current updated Vector3
  83006. */
  83007. divideInPlace(otherVector: Vector3): Vector3;
  83008. /**
  83009. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83010. * @param other defines the second operand
  83011. * @returns the current updated Vector3
  83012. */
  83013. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83014. /**
  83015. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83016. * @param other defines the second operand
  83017. * @returns the current updated Vector3
  83018. */
  83019. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83020. /**
  83021. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83022. * @param x defines the x coordinate of the operand
  83023. * @param y defines the y coordinate of the operand
  83024. * @param z defines the z coordinate of the operand
  83025. * @returns the current updated Vector3
  83026. */
  83027. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83028. /**
  83029. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83030. * @param x defines the x coordinate of the operand
  83031. * @param y defines the y coordinate of the operand
  83032. * @param z defines the z coordinate of the operand
  83033. * @returns the current updated Vector3
  83034. */
  83035. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83036. /**
  83037. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83038. * Check if is non uniform within a certain amount of decimal places to account for this
  83039. * @param epsilon the amount the values can differ
  83040. * @returns if the the vector is non uniform to a certain number of decimal places
  83041. */
  83042. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83043. /**
  83044. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83045. */
  83046. get isNonUniform(): boolean;
  83047. /**
  83048. * Gets a new Vector3 from current Vector3 floored values
  83049. * @returns a new Vector3
  83050. */
  83051. floor(): Vector3;
  83052. /**
  83053. * Gets a new Vector3 from current Vector3 floored values
  83054. * @returns a new Vector3
  83055. */
  83056. fract(): Vector3;
  83057. /**
  83058. * Gets the length of the Vector3
  83059. * @returns the length of the Vector3
  83060. */
  83061. length(): number;
  83062. /**
  83063. * Gets the squared length of the Vector3
  83064. * @returns squared length of the Vector3
  83065. */
  83066. lengthSquared(): number;
  83067. /**
  83068. * Normalize the current Vector3.
  83069. * Please note that this is an in place operation.
  83070. * @returns the current updated Vector3
  83071. */
  83072. normalize(): Vector3;
  83073. /**
  83074. * Reorders the x y z properties of the vector in place
  83075. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83076. * @returns the current updated vector
  83077. */
  83078. reorderInPlace(order: string): this;
  83079. /**
  83080. * Rotates the vector around 0,0,0 by a quaternion
  83081. * @param quaternion the rotation quaternion
  83082. * @param result vector to store the result
  83083. * @returns the resulting vector
  83084. */
  83085. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83086. /**
  83087. * Rotates a vector around a given point
  83088. * @param quaternion the rotation quaternion
  83089. * @param point the point to rotate around
  83090. * @param result vector to store the result
  83091. * @returns the resulting vector
  83092. */
  83093. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83094. /**
  83095. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83096. * The cross product is then orthogonal to both current and "other"
  83097. * @param other defines the right operand
  83098. * @returns the cross product
  83099. */
  83100. cross(other: Vector3): Vector3;
  83101. /**
  83102. * Normalize the current Vector3 with the given input length.
  83103. * Please note that this is an in place operation.
  83104. * @param len the length of the vector
  83105. * @returns the current updated Vector3
  83106. */
  83107. normalizeFromLength(len: number): Vector3;
  83108. /**
  83109. * Normalize the current Vector3 to a new vector
  83110. * @returns the new Vector3
  83111. */
  83112. normalizeToNew(): Vector3;
  83113. /**
  83114. * Normalize the current Vector3 to the reference
  83115. * @param reference define the Vector3 to update
  83116. * @returns the updated Vector3
  83117. */
  83118. normalizeToRef(reference: Vector3): Vector3;
  83119. /**
  83120. * Creates a new Vector3 copied from the current Vector3
  83121. * @returns the new Vector3
  83122. */
  83123. clone(): Vector3;
  83124. /**
  83125. * Copies the given vector coordinates to the current Vector3 ones
  83126. * @param source defines the source Vector3
  83127. * @returns the current updated Vector3
  83128. */
  83129. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83130. /**
  83131. * Copies the given floats to the current Vector3 coordinates
  83132. * @param x defines the x coordinate of the operand
  83133. * @param y defines the y coordinate of the operand
  83134. * @param z defines the z coordinate of the operand
  83135. * @returns the current updated Vector3
  83136. */
  83137. copyFromFloats(x: number, y: number, z: number): Vector3;
  83138. /**
  83139. * Copies the given floats to the current Vector3 coordinates
  83140. * @param x defines the x coordinate of the operand
  83141. * @param y defines the y coordinate of the operand
  83142. * @param z defines the z coordinate of the operand
  83143. * @returns the current updated Vector3
  83144. */
  83145. set(x: number, y: number, z: number): Vector3;
  83146. /**
  83147. * Copies the given float to the current Vector3 coordinates
  83148. * @param v defines the x, y and z coordinates of the operand
  83149. * @returns the current updated Vector3
  83150. */
  83151. setAll(v: number): Vector3;
  83152. /**
  83153. * Get the clip factor between two vectors
  83154. * @param vector0 defines the first operand
  83155. * @param vector1 defines the second operand
  83156. * @param axis defines the axis to use
  83157. * @param size defines the size along the axis
  83158. * @returns the clip factor
  83159. */
  83160. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83161. /**
  83162. * Get angle between two vectors
  83163. * @param vector0 angle between vector0 and vector1
  83164. * @param vector1 angle between vector0 and vector1
  83165. * @param normal direction of the normal
  83166. * @return the angle between vector0 and vector1
  83167. */
  83168. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83169. /**
  83170. * Returns a new Vector3 set from the index "offset" of the given array
  83171. * @param array defines the source array
  83172. * @param offset defines the offset in the source array
  83173. * @returns the new Vector3
  83174. */
  83175. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83176. /**
  83177. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83178. * @param array defines the source array
  83179. * @param offset defines the offset in the source array
  83180. * @returns the new Vector3
  83181. * @deprecated Please use FromArray instead.
  83182. */
  83183. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83184. /**
  83185. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83186. * @param array defines the source array
  83187. * @param offset defines the offset in the source array
  83188. * @param result defines the Vector3 where to store the result
  83189. */
  83190. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83191. /**
  83192. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83193. * @param array defines the source array
  83194. * @param offset defines the offset in the source array
  83195. * @param result defines the Vector3 where to store the result
  83196. * @deprecated Please use FromArrayToRef instead.
  83197. */
  83198. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83199. /**
  83200. * Sets the given vector "result" with the given floats.
  83201. * @param x defines the x coordinate of the source
  83202. * @param y defines the y coordinate of the source
  83203. * @param z defines the z coordinate of the source
  83204. * @param result defines the Vector3 where to store the result
  83205. */
  83206. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83207. /**
  83208. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83209. * @returns a new empty Vector3
  83210. */
  83211. static Zero(): Vector3;
  83212. /**
  83213. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83214. * @returns a new unit Vector3
  83215. */
  83216. static One(): Vector3;
  83217. /**
  83218. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83219. * @returns a new up Vector3
  83220. */
  83221. static Up(): Vector3;
  83222. /**
  83223. * Gets a up Vector3 that must not be updated
  83224. */
  83225. static get UpReadOnly(): DeepImmutable<Vector3>;
  83226. /**
  83227. * Gets a zero Vector3 that must not be updated
  83228. */
  83229. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83230. /**
  83231. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83232. * @returns a new down Vector3
  83233. */
  83234. static Down(): Vector3;
  83235. /**
  83236. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83237. * @param rightHandedSystem is the scene right-handed (negative z)
  83238. * @returns a new forward Vector3
  83239. */
  83240. static Forward(rightHandedSystem?: boolean): Vector3;
  83241. /**
  83242. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83243. * @param rightHandedSystem is the scene right-handed (negative-z)
  83244. * @returns a new forward Vector3
  83245. */
  83246. static Backward(rightHandedSystem?: boolean): Vector3;
  83247. /**
  83248. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83249. * @returns a new right Vector3
  83250. */
  83251. static Right(): Vector3;
  83252. /**
  83253. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83254. * @returns a new left Vector3
  83255. */
  83256. static Left(): Vector3;
  83257. /**
  83258. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83259. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83260. * @param vector defines the Vector3 to transform
  83261. * @param transformation defines the transformation matrix
  83262. * @returns the transformed Vector3
  83263. */
  83264. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83265. /**
  83266. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83267. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83268. * @param vector defines the Vector3 to transform
  83269. * @param transformation defines the transformation matrix
  83270. * @param result defines the Vector3 where to store the result
  83271. */
  83272. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83273. /**
  83274. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83275. * This method computes tranformed coordinates only, not transformed direction vectors
  83276. * @param x define the x coordinate of the source vector
  83277. * @param y define the y coordinate of the source vector
  83278. * @param z define the z coordinate of the source vector
  83279. * @param transformation defines the transformation matrix
  83280. * @param result defines the Vector3 where to store the result
  83281. */
  83282. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83283. /**
  83284. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83285. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83286. * @param vector defines the Vector3 to transform
  83287. * @param transformation defines the transformation matrix
  83288. * @returns the new Vector3
  83289. */
  83290. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83291. /**
  83292. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83293. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83294. * @param vector defines the Vector3 to transform
  83295. * @param transformation defines the transformation matrix
  83296. * @param result defines the Vector3 where to store the result
  83297. */
  83298. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83299. /**
  83300. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83301. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83302. * @param x define the x coordinate of the source vector
  83303. * @param y define the y coordinate of the source vector
  83304. * @param z define the z coordinate of the source vector
  83305. * @param transformation defines the transformation matrix
  83306. * @param result defines the Vector3 where to store the result
  83307. */
  83308. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83309. /**
  83310. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83311. * @param value1 defines the first control point
  83312. * @param value2 defines the second control point
  83313. * @param value3 defines the third control point
  83314. * @param value4 defines the fourth control point
  83315. * @param amount defines the amount on the spline to use
  83316. * @returns the new Vector3
  83317. */
  83318. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83319. /**
  83320. * 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"
  83321. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83322. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83323. * @param value defines the current value
  83324. * @param min defines the lower range value
  83325. * @param max defines the upper range value
  83326. * @returns the new Vector3
  83327. */
  83328. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83329. /**
  83330. * 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"
  83331. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83332. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83333. * @param value defines the current value
  83334. * @param min defines the lower range value
  83335. * @param max defines the upper range value
  83336. * @param result defines the Vector3 where to store the result
  83337. */
  83338. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83339. /**
  83340. * Checks if a given vector is inside a specific range
  83341. * @param v defines the vector to test
  83342. * @param min defines the minimum range
  83343. * @param max defines the maximum range
  83344. */
  83345. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83346. /**
  83347. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83348. * @param value1 defines the first control point
  83349. * @param tangent1 defines the first tangent vector
  83350. * @param value2 defines the second control point
  83351. * @param tangent2 defines the second tangent vector
  83352. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83353. * @returns the new Vector3
  83354. */
  83355. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83356. /**
  83357. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83358. * @param start defines the start value
  83359. * @param end defines the end value
  83360. * @param amount max defines amount between both (between 0 and 1)
  83361. * @returns the new Vector3
  83362. */
  83363. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83364. /**
  83365. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83366. * @param start defines the start value
  83367. * @param end defines the end value
  83368. * @param amount max defines amount between both (between 0 and 1)
  83369. * @param result defines the Vector3 where to store the result
  83370. */
  83371. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83372. /**
  83373. * Returns the dot product (float) between the vectors "left" and "right"
  83374. * @param left defines the left operand
  83375. * @param right defines the right operand
  83376. * @returns the dot product
  83377. */
  83378. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83379. /**
  83380. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83381. * The cross product is then orthogonal to both "left" and "right"
  83382. * @param left defines the left operand
  83383. * @param right defines the right operand
  83384. * @returns the cross product
  83385. */
  83386. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83387. /**
  83388. * Sets the given vector "result" with the cross product of "left" and "right"
  83389. * The cross product is then orthogonal to both "left" and "right"
  83390. * @param left defines the left operand
  83391. * @param right defines the right operand
  83392. * @param result defines the Vector3 where to store the result
  83393. */
  83394. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83395. /**
  83396. * Returns a new Vector3 as the normalization of the given vector
  83397. * @param vector defines the Vector3 to normalize
  83398. * @returns the new Vector3
  83399. */
  83400. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83401. /**
  83402. * Sets the given vector "result" with the normalization of the given first vector
  83403. * @param vector defines the Vector3 to normalize
  83404. * @param result defines the Vector3 where to store the result
  83405. */
  83406. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83407. /**
  83408. * Project a Vector3 onto screen space
  83409. * @param vector defines the Vector3 to project
  83410. * @param world defines the world matrix to use
  83411. * @param transform defines the transform (view x projection) matrix to use
  83412. * @param viewport defines the screen viewport to use
  83413. * @returns the new Vector3
  83414. */
  83415. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83416. /** @hidden */
  83417. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83418. /**
  83419. * Unproject from screen space to object space
  83420. * @param source defines the screen space Vector3 to use
  83421. * @param viewportWidth defines the current width of the viewport
  83422. * @param viewportHeight defines the current height of the viewport
  83423. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83424. * @param transform defines the transform (view x projection) matrix to use
  83425. * @returns the new Vector3
  83426. */
  83427. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83428. /**
  83429. * Unproject from screen space to object space
  83430. * @param source defines the screen space Vector3 to use
  83431. * @param viewportWidth defines the current width of the viewport
  83432. * @param viewportHeight defines the current height of the viewport
  83433. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83434. * @param view defines the view matrix to use
  83435. * @param projection defines the projection matrix to use
  83436. * @returns the new Vector3
  83437. */
  83438. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83439. /**
  83440. * Unproject from screen space to object space
  83441. * @param source defines the screen space Vector3 to use
  83442. * @param viewportWidth defines the current width of the viewport
  83443. * @param viewportHeight defines the current height of the viewport
  83444. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83445. * @param view defines the view matrix to use
  83446. * @param projection defines the projection matrix to use
  83447. * @param result defines the Vector3 where to store the result
  83448. */
  83449. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83450. /**
  83451. * Unproject from screen space to object space
  83452. * @param sourceX defines the screen space x coordinate to use
  83453. * @param sourceY defines the screen space y coordinate to use
  83454. * @param sourceZ defines the screen space z coordinate to use
  83455. * @param viewportWidth defines the current width of the viewport
  83456. * @param viewportHeight defines the current height of the viewport
  83457. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83458. * @param view defines the view matrix to use
  83459. * @param projection defines the projection matrix to use
  83460. * @param result defines the Vector3 where to store the result
  83461. */
  83462. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83463. /**
  83464. * Gets the minimal coordinate values between two Vector3
  83465. * @param left defines the first operand
  83466. * @param right defines the second operand
  83467. * @returns the new Vector3
  83468. */
  83469. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83470. /**
  83471. * Gets the maximal coordinate values between two Vector3
  83472. * @param left defines the first operand
  83473. * @param right defines the second operand
  83474. * @returns the new Vector3
  83475. */
  83476. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83477. /**
  83478. * Returns the distance between the vectors "value1" and "value2"
  83479. * @param value1 defines the first operand
  83480. * @param value2 defines the second operand
  83481. * @returns the distance
  83482. */
  83483. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83484. /**
  83485. * Returns the squared distance between the vectors "value1" and "value2"
  83486. * @param value1 defines the first operand
  83487. * @param value2 defines the second operand
  83488. * @returns the squared distance
  83489. */
  83490. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83491. /**
  83492. * Returns a new Vector3 located at the center between "value1" and "value2"
  83493. * @param value1 defines the first operand
  83494. * @param value2 defines the second operand
  83495. * @returns the new Vector3
  83496. */
  83497. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83498. /**
  83499. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83500. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83501. * to something in order to rotate it from its local system to the given target system
  83502. * Note: axis1, axis2 and axis3 are normalized during this operation
  83503. * @param axis1 defines the first axis
  83504. * @param axis2 defines the second axis
  83505. * @param axis3 defines the third axis
  83506. * @returns a new Vector3
  83507. */
  83508. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83509. /**
  83510. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83511. * @param axis1 defines the first axis
  83512. * @param axis2 defines the second axis
  83513. * @param axis3 defines the third axis
  83514. * @param ref defines the Vector3 where to store the result
  83515. */
  83516. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83517. }
  83518. /**
  83519. * Vector4 class created for EulerAngle class conversion to Quaternion
  83520. */
  83521. export class Vector4 {
  83522. /** x value of the vector */
  83523. x: number;
  83524. /** y value of the vector */
  83525. y: number;
  83526. /** z value of the vector */
  83527. z: number;
  83528. /** w value of the vector */
  83529. w: number;
  83530. /**
  83531. * Creates a Vector4 object from the given floats.
  83532. * @param x x value of the vector
  83533. * @param y y value of the vector
  83534. * @param z z value of the vector
  83535. * @param w w value of the vector
  83536. */
  83537. constructor(
  83538. /** x value of the vector */
  83539. x: number,
  83540. /** y value of the vector */
  83541. y: number,
  83542. /** z value of the vector */
  83543. z: number,
  83544. /** w value of the vector */
  83545. w: number);
  83546. /**
  83547. * Returns the string with the Vector4 coordinates.
  83548. * @returns a string containing all the vector values
  83549. */
  83550. toString(): string;
  83551. /**
  83552. * Returns the string "Vector4".
  83553. * @returns "Vector4"
  83554. */
  83555. getClassName(): string;
  83556. /**
  83557. * Returns the Vector4 hash code.
  83558. * @returns a unique hash code
  83559. */
  83560. getHashCode(): number;
  83561. /**
  83562. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83563. * @returns the resulting array
  83564. */
  83565. asArray(): number[];
  83566. /**
  83567. * Populates the given array from the given index with the Vector4 coordinates.
  83568. * @param array array to populate
  83569. * @param index index of the array to start at (default: 0)
  83570. * @returns the Vector4.
  83571. */
  83572. toArray(array: FloatArray, index?: number): Vector4;
  83573. /**
  83574. * Update the current vector from an array
  83575. * @param array defines the destination array
  83576. * @param index defines the offset in the destination array
  83577. * @returns the current Vector3
  83578. */
  83579. fromArray(array: FloatArray, index?: number): Vector4;
  83580. /**
  83581. * Adds the given vector to the current Vector4.
  83582. * @param otherVector the vector to add
  83583. * @returns the updated Vector4.
  83584. */
  83585. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83586. /**
  83587. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83588. * @param otherVector the vector to add
  83589. * @returns the resulting vector
  83590. */
  83591. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83592. /**
  83593. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83594. * @param otherVector the vector to add
  83595. * @param result the vector to store the result
  83596. * @returns the current Vector4.
  83597. */
  83598. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83599. /**
  83600. * Subtract in place the given vector from the current Vector4.
  83601. * @param otherVector the vector to subtract
  83602. * @returns the updated Vector4.
  83603. */
  83604. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83605. /**
  83606. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83607. * @param otherVector the vector to add
  83608. * @returns the new vector with the result
  83609. */
  83610. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83611. /**
  83612. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83613. * @param otherVector the vector to subtract
  83614. * @param result the vector to store the result
  83615. * @returns the current Vector4.
  83616. */
  83617. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83618. /**
  83619. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83620. */
  83621. /**
  83622. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83623. * @param x value to subtract
  83624. * @param y value to subtract
  83625. * @param z value to subtract
  83626. * @param w value to subtract
  83627. * @returns new vector containing the result
  83628. */
  83629. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83630. /**
  83631. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83632. * @param x value to subtract
  83633. * @param y value to subtract
  83634. * @param z value to subtract
  83635. * @param w value to subtract
  83636. * @param result the vector to store the result in
  83637. * @returns the current Vector4.
  83638. */
  83639. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83640. /**
  83641. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83642. * @returns a new vector with the negated values
  83643. */
  83644. negate(): Vector4;
  83645. /**
  83646. * Negate this vector in place
  83647. * @returns this
  83648. */
  83649. negateInPlace(): Vector4;
  83650. /**
  83651. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83652. * @param result defines the Vector3 object where to store the result
  83653. * @returns the current Vector4
  83654. */
  83655. negateToRef(result: Vector4): Vector4;
  83656. /**
  83657. * Multiplies the current Vector4 coordinates by scale (float).
  83658. * @param scale the number to scale with
  83659. * @returns the updated Vector4.
  83660. */
  83661. scaleInPlace(scale: number): Vector4;
  83662. /**
  83663. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83664. * @param scale the number to scale with
  83665. * @returns a new vector with the result
  83666. */
  83667. scale(scale: number): Vector4;
  83668. /**
  83669. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83670. * @param scale the number to scale with
  83671. * @param result a vector to store the result in
  83672. * @returns the current Vector4.
  83673. */
  83674. scaleToRef(scale: number, result: Vector4): Vector4;
  83675. /**
  83676. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83677. * @param scale defines the scale factor
  83678. * @param result defines the Vector4 object where to store the result
  83679. * @returns the unmodified current Vector4
  83680. */
  83681. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83682. /**
  83683. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83684. * @param otherVector the vector to compare against
  83685. * @returns true if they are equal
  83686. */
  83687. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83688. /**
  83689. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83690. * @param otherVector vector to compare against
  83691. * @param epsilon (Default: very small number)
  83692. * @returns true if they are equal
  83693. */
  83694. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83695. /**
  83696. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83697. * @param x x value to compare against
  83698. * @param y y value to compare against
  83699. * @param z z value to compare against
  83700. * @param w w value to compare against
  83701. * @returns true if equal
  83702. */
  83703. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83704. /**
  83705. * Multiplies in place the current Vector4 by the given one.
  83706. * @param otherVector vector to multiple with
  83707. * @returns the updated Vector4.
  83708. */
  83709. multiplyInPlace(otherVector: Vector4): Vector4;
  83710. /**
  83711. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83712. * @param otherVector vector to multiple with
  83713. * @returns resulting new vector
  83714. */
  83715. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83716. /**
  83717. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83718. * @param otherVector vector to multiple with
  83719. * @param result vector to store the result
  83720. * @returns the current Vector4.
  83721. */
  83722. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83723. /**
  83724. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83725. * @param x x value multiply with
  83726. * @param y y value multiply with
  83727. * @param z z value multiply with
  83728. * @param w w value multiply with
  83729. * @returns resulting new vector
  83730. */
  83731. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83732. /**
  83733. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83734. * @param otherVector vector to devide with
  83735. * @returns resulting new vector
  83736. */
  83737. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83738. /**
  83739. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83740. * @param otherVector vector to devide with
  83741. * @param result vector to store the result
  83742. * @returns the current Vector4.
  83743. */
  83744. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83745. /**
  83746. * Divides the current Vector3 coordinates by the given ones.
  83747. * @param otherVector vector to devide with
  83748. * @returns the updated Vector3.
  83749. */
  83750. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83751. /**
  83752. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83753. * @param other defines the second operand
  83754. * @returns the current updated Vector4
  83755. */
  83756. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83757. /**
  83758. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83759. * @param other defines the second operand
  83760. * @returns the current updated Vector4
  83761. */
  83762. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83763. /**
  83764. * Gets a new Vector4 from current Vector4 floored values
  83765. * @returns a new Vector4
  83766. */
  83767. floor(): Vector4;
  83768. /**
  83769. * Gets a new Vector4 from current Vector3 floored values
  83770. * @returns a new Vector4
  83771. */
  83772. fract(): Vector4;
  83773. /**
  83774. * Returns the Vector4 length (float).
  83775. * @returns the length
  83776. */
  83777. length(): number;
  83778. /**
  83779. * Returns the Vector4 squared length (float).
  83780. * @returns the length squared
  83781. */
  83782. lengthSquared(): number;
  83783. /**
  83784. * Normalizes in place the Vector4.
  83785. * @returns the updated Vector4.
  83786. */
  83787. normalize(): Vector4;
  83788. /**
  83789. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83790. * @returns this converted to a new vector3
  83791. */
  83792. toVector3(): Vector3;
  83793. /**
  83794. * Returns a new Vector4 copied from the current one.
  83795. * @returns the new cloned vector
  83796. */
  83797. clone(): Vector4;
  83798. /**
  83799. * Updates the current Vector4 with the given one coordinates.
  83800. * @param source the source vector to copy from
  83801. * @returns the updated Vector4.
  83802. */
  83803. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83804. /**
  83805. * Updates the current Vector4 coordinates with the given floats.
  83806. * @param x float to copy from
  83807. * @param y float to copy from
  83808. * @param z float to copy from
  83809. * @param w float to copy from
  83810. * @returns the updated Vector4.
  83811. */
  83812. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83813. /**
  83814. * Updates the current Vector4 coordinates with the given floats.
  83815. * @param x float to set from
  83816. * @param y float to set from
  83817. * @param z float to set from
  83818. * @param w float to set from
  83819. * @returns the updated Vector4.
  83820. */
  83821. set(x: number, y: number, z: number, w: number): Vector4;
  83822. /**
  83823. * Copies the given float to the current Vector3 coordinates
  83824. * @param v defines the x, y, z and w coordinates of the operand
  83825. * @returns the current updated Vector3
  83826. */
  83827. setAll(v: number): Vector4;
  83828. /**
  83829. * Returns a new Vector4 set from the starting index of the given array.
  83830. * @param array the array to pull values from
  83831. * @param offset the offset into the array to start at
  83832. * @returns the new vector
  83833. */
  83834. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83835. /**
  83836. * Updates the given vector "result" from the starting index of the given array.
  83837. * @param array the array to pull values from
  83838. * @param offset the offset into the array to start at
  83839. * @param result the vector to store the result in
  83840. */
  83841. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83842. /**
  83843. * Updates the given vector "result" from the starting index of the given Float32Array.
  83844. * @param array the array to pull values from
  83845. * @param offset the offset into the array to start at
  83846. * @param result the vector to store the result in
  83847. */
  83848. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83849. /**
  83850. * Updates the given vector "result" coordinates from the given floats.
  83851. * @param x float to set from
  83852. * @param y float to set from
  83853. * @param z float to set from
  83854. * @param w float to set from
  83855. * @param result the vector to the floats in
  83856. */
  83857. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83858. /**
  83859. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83860. * @returns the new vector
  83861. */
  83862. static Zero(): Vector4;
  83863. /**
  83864. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83865. * @returns the new vector
  83866. */
  83867. static One(): Vector4;
  83868. /**
  83869. * Returns a new normalized Vector4 from the given one.
  83870. * @param vector the vector to normalize
  83871. * @returns the vector
  83872. */
  83873. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83874. /**
  83875. * Updates the given vector "result" from the normalization of the given one.
  83876. * @param vector the vector to normalize
  83877. * @param result the vector to store the result in
  83878. */
  83879. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83880. /**
  83881. * Returns a vector with the minimum values from the left and right vectors
  83882. * @param left left vector to minimize
  83883. * @param right right vector to minimize
  83884. * @returns a new vector with the minimum of the left and right vector values
  83885. */
  83886. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83887. /**
  83888. * Returns a vector with the maximum values from the left and right vectors
  83889. * @param left left vector to maximize
  83890. * @param right right vector to maximize
  83891. * @returns a new vector with the maximum of the left and right vector values
  83892. */
  83893. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83894. /**
  83895. * Returns the distance (float) between the vectors "value1" and "value2".
  83896. * @param value1 value to calulate the distance between
  83897. * @param value2 value to calulate the distance between
  83898. * @return the distance between the two vectors
  83899. */
  83900. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83901. /**
  83902. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83903. * @param value1 value to calulate the distance between
  83904. * @param value2 value to calulate the distance between
  83905. * @return the distance between the two vectors squared
  83906. */
  83907. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83908. /**
  83909. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83910. * @param value1 value to calulate the center between
  83911. * @param value2 value to calulate the center between
  83912. * @return the center between the two vectors
  83913. */
  83914. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83915. /**
  83916. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83917. * This methods computes transformed normalized direction vectors only.
  83918. * @param vector the vector to transform
  83919. * @param transformation the transformation matrix to apply
  83920. * @returns the new vector
  83921. */
  83922. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83923. /**
  83924. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83925. * This methods computes transformed normalized direction vectors only.
  83926. * @param vector the vector to transform
  83927. * @param transformation the transformation matrix to apply
  83928. * @param result the vector to store the result in
  83929. */
  83930. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83931. /**
  83932. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83933. * This methods computes transformed normalized direction vectors only.
  83934. * @param x value to transform
  83935. * @param y value to transform
  83936. * @param z value to transform
  83937. * @param w value to transform
  83938. * @param transformation the transformation matrix to apply
  83939. * @param result the vector to store the results in
  83940. */
  83941. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83942. /**
  83943. * Creates a new Vector4 from a Vector3
  83944. * @param source defines the source data
  83945. * @param w defines the 4th component (default is 0)
  83946. * @returns a new Vector4
  83947. */
  83948. static FromVector3(source: Vector3, w?: number): Vector4;
  83949. }
  83950. /**
  83951. * Class used to store quaternion data
  83952. * @see https://en.wikipedia.org/wiki/Quaternion
  83953. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83954. */
  83955. export class Quaternion {
  83956. /** @hidden */
  83957. _x: number;
  83958. /** @hidden */
  83959. _y: number;
  83960. /** @hidden */
  83961. _z: number;
  83962. /** @hidden */
  83963. _w: number;
  83964. /** @hidden */
  83965. _isDirty: boolean;
  83966. /** Gets or sets the x coordinate */
  83967. get x(): number;
  83968. set x(value: number);
  83969. /** Gets or sets the y coordinate */
  83970. get y(): number;
  83971. set y(value: number);
  83972. /** Gets or sets the z coordinate */
  83973. get z(): number;
  83974. set z(value: number);
  83975. /** Gets or sets the w coordinate */
  83976. get w(): number;
  83977. set w(value: number);
  83978. /**
  83979. * Creates a new Quaternion from the given floats
  83980. * @param x defines the first component (0 by default)
  83981. * @param y defines the second component (0 by default)
  83982. * @param z defines the third component (0 by default)
  83983. * @param w defines the fourth component (1.0 by default)
  83984. */
  83985. constructor(x?: number, y?: number, z?: number, w?: number);
  83986. /**
  83987. * Gets a string representation for the current quaternion
  83988. * @returns a string with the Quaternion coordinates
  83989. */
  83990. toString(): string;
  83991. /**
  83992. * Gets the class name of the quaternion
  83993. * @returns the string "Quaternion"
  83994. */
  83995. getClassName(): string;
  83996. /**
  83997. * Gets a hash code for this quaternion
  83998. * @returns the quaternion hash code
  83999. */
  84000. getHashCode(): number;
  84001. /**
  84002. * Copy the quaternion to an array
  84003. * @returns a new array populated with 4 elements from the quaternion coordinates
  84004. */
  84005. asArray(): number[];
  84006. /**
  84007. * Check if two quaternions are equals
  84008. * @param otherQuaternion defines the second operand
  84009. * @return true if the current quaternion and the given one coordinates are strictly equals
  84010. */
  84011. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84012. /**
  84013. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84014. * @param otherQuaternion defines the other quaternion
  84015. * @param epsilon defines the minimal distance to consider equality
  84016. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84017. */
  84018. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84019. /**
  84020. * Clone the current quaternion
  84021. * @returns a new quaternion copied from the current one
  84022. */
  84023. clone(): Quaternion;
  84024. /**
  84025. * Copy a quaternion to the current one
  84026. * @param other defines the other quaternion
  84027. * @returns the updated current quaternion
  84028. */
  84029. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84030. /**
  84031. * Updates the current quaternion with the given float coordinates
  84032. * @param x defines the x coordinate
  84033. * @param y defines the y coordinate
  84034. * @param z defines the z coordinate
  84035. * @param w defines the w coordinate
  84036. * @returns the updated current quaternion
  84037. */
  84038. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84039. /**
  84040. * Updates the current quaternion from the given float coordinates
  84041. * @param x defines the x coordinate
  84042. * @param y defines the y coordinate
  84043. * @param z defines the z coordinate
  84044. * @param w defines the w coordinate
  84045. * @returns the updated current quaternion
  84046. */
  84047. set(x: number, y: number, z: number, w: number): Quaternion;
  84048. /**
  84049. * Adds two quaternions
  84050. * @param other defines the second operand
  84051. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84052. */
  84053. add(other: DeepImmutable<Quaternion>): Quaternion;
  84054. /**
  84055. * Add a quaternion to the current one
  84056. * @param other defines the quaternion to add
  84057. * @returns the current quaternion
  84058. */
  84059. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84060. /**
  84061. * Subtract two quaternions
  84062. * @param other defines the second operand
  84063. * @returns a new quaternion as the subtraction result of the given one from the current one
  84064. */
  84065. subtract(other: Quaternion): Quaternion;
  84066. /**
  84067. * Multiplies the current quaternion by a scale factor
  84068. * @param value defines the scale factor
  84069. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84070. */
  84071. scale(value: number): Quaternion;
  84072. /**
  84073. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84074. * @param scale defines the scale factor
  84075. * @param result defines the Quaternion object where to store the result
  84076. * @returns the unmodified current quaternion
  84077. */
  84078. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84079. /**
  84080. * Multiplies in place the current quaternion by a scale factor
  84081. * @param value defines the scale factor
  84082. * @returns the current modified quaternion
  84083. */
  84084. scaleInPlace(value: number): Quaternion;
  84085. /**
  84086. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84087. * @param scale defines the scale factor
  84088. * @param result defines the Quaternion object where to store the result
  84089. * @returns the unmodified current quaternion
  84090. */
  84091. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84092. /**
  84093. * Multiplies two quaternions
  84094. * @param q1 defines the second operand
  84095. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84096. */
  84097. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84098. /**
  84099. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84100. * @param q1 defines the second operand
  84101. * @param result defines the target quaternion
  84102. * @returns the current quaternion
  84103. */
  84104. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84105. /**
  84106. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84107. * @param q1 defines the second operand
  84108. * @returns the currentupdated quaternion
  84109. */
  84110. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84111. /**
  84112. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84113. * @param ref defines the target quaternion
  84114. * @returns the current quaternion
  84115. */
  84116. conjugateToRef(ref: Quaternion): Quaternion;
  84117. /**
  84118. * Conjugates in place (1-q) the current quaternion
  84119. * @returns the current updated quaternion
  84120. */
  84121. conjugateInPlace(): Quaternion;
  84122. /**
  84123. * Conjugates in place (1-q) the current quaternion
  84124. * @returns a new quaternion
  84125. */
  84126. conjugate(): Quaternion;
  84127. /**
  84128. * Gets length of current quaternion
  84129. * @returns the quaternion length (float)
  84130. */
  84131. length(): number;
  84132. /**
  84133. * Normalize in place the current quaternion
  84134. * @returns the current updated quaternion
  84135. */
  84136. normalize(): Quaternion;
  84137. /**
  84138. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84139. * @param order is a reserved parameter and is ignored for now
  84140. * @returns a new Vector3 containing the Euler angles
  84141. */
  84142. toEulerAngles(order?: string): Vector3;
  84143. /**
  84144. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84145. * @param result defines the vector which will be filled with the Euler angles
  84146. * @returns the current unchanged quaternion
  84147. */
  84148. toEulerAnglesToRef(result: Vector3): Quaternion;
  84149. /**
  84150. * Updates the given rotation matrix with the current quaternion values
  84151. * @param result defines the target matrix
  84152. * @returns the current unchanged quaternion
  84153. */
  84154. toRotationMatrix(result: Matrix): Quaternion;
  84155. /**
  84156. * Updates the current quaternion from the given rotation matrix values
  84157. * @param matrix defines the source matrix
  84158. * @returns the current updated quaternion
  84159. */
  84160. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84161. /**
  84162. * Creates a new quaternion from a rotation matrix
  84163. * @param matrix defines the source matrix
  84164. * @returns a new quaternion created from the given rotation matrix values
  84165. */
  84166. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84167. /**
  84168. * Updates the given quaternion with the given rotation matrix values
  84169. * @param matrix defines the source matrix
  84170. * @param result defines the target quaternion
  84171. */
  84172. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84173. /**
  84174. * Returns the dot product (float) between the quaternions "left" and "right"
  84175. * @param left defines the left operand
  84176. * @param right defines the right operand
  84177. * @returns the dot product
  84178. */
  84179. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84180. /**
  84181. * Checks if the two quaternions are close to each other
  84182. * @param quat0 defines the first quaternion to check
  84183. * @param quat1 defines the second quaternion to check
  84184. * @returns true if the two quaternions are close to each other
  84185. */
  84186. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84187. /**
  84188. * Creates an empty quaternion
  84189. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84190. */
  84191. static Zero(): Quaternion;
  84192. /**
  84193. * Inverse a given quaternion
  84194. * @param q defines the source quaternion
  84195. * @returns a new quaternion as the inverted current quaternion
  84196. */
  84197. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84198. /**
  84199. * Inverse a given quaternion
  84200. * @param q defines the source quaternion
  84201. * @param result the quaternion the result will be stored in
  84202. * @returns the result quaternion
  84203. */
  84204. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84205. /**
  84206. * Creates an identity quaternion
  84207. * @returns the identity quaternion
  84208. */
  84209. static Identity(): Quaternion;
  84210. /**
  84211. * Gets a boolean indicating if the given quaternion is identity
  84212. * @param quaternion defines the quaternion to check
  84213. * @returns true if the quaternion is identity
  84214. */
  84215. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84216. /**
  84217. * Creates a quaternion from a rotation around an axis
  84218. * @param axis defines the axis to use
  84219. * @param angle defines the angle to use
  84220. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84221. */
  84222. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84223. /**
  84224. * Creates a rotation around an axis and stores it into the given quaternion
  84225. * @param axis defines the axis to use
  84226. * @param angle defines the angle to use
  84227. * @param result defines the target quaternion
  84228. * @returns the target quaternion
  84229. */
  84230. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84231. /**
  84232. * Creates a new quaternion from data stored into an array
  84233. * @param array defines the data source
  84234. * @param offset defines the offset in the source array where the data starts
  84235. * @returns a new quaternion
  84236. */
  84237. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84238. /**
  84239. * Updates the given quaternion "result" from the starting index of the given array.
  84240. * @param array the array to pull values from
  84241. * @param offset the offset into the array to start at
  84242. * @param result the quaternion to store the result in
  84243. */
  84244. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84245. /**
  84246. * Create a quaternion from Euler rotation angles
  84247. * @param x Pitch
  84248. * @param y Yaw
  84249. * @param z Roll
  84250. * @returns the new Quaternion
  84251. */
  84252. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84253. /**
  84254. * Updates a quaternion from Euler rotation angles
  84255. * @param x Pitch
  84256. * @param y Yaw
  84257. * @param z Roll
  84258. * @param result the quaternion to store the result
  84259. * @returns the updated quaternion
  84260. */
  84261. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84262. /**
  84263. * Create a quaternion from Euler rotation vector
  84264. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84265. * @returns the new Quaternion
  84266. */
  84267. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84268. /**
  84269. * Updates a quaternion from Euler rotation vector
  84270. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84271. * @param result the quaternion to store the result
  84272. * @returns the updated quaternion
  84273. */
  84274. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84275. /**
  84276. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84277. * @param yaw defines the rotation around Y axis
  84278. * @param pitch defines the rotation around X axis
  84279. * @param roll defines the rotation around Z axis
  84280. * @returns the new quaternion
  84281. */
  84282. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84283. /**
  84284. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84285. * @param yaw defines the rotation around Y axis
  84286. * @param pitch defines the rotation around X axis
  84287. * @param roll defines the rotation around Z axis
  84288. * @param result defines the target quaternion
  84289. */
  84290. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84291. /**
  84292. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84293. * @param alpha defines the rotation around first axis
  84294. * @param beta defines the rotation around second axis
  84295. * @param gamma defines the rotation around third axis
  84296. * @returns the new quaternion
  84297. */
  84298. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84299. /**
  84300. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84301. * @param alpha defines the rotation around first axis
  84302. * @param beta defines the rotation around second axis
  84303. * @param gamma defines the rotation around third axis
  84304. * @param result defines the target quaternion
  84305. */
  84306. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84307. /**
  84308. * 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)
  84309. * @param axis1 defines the first axis
  84310. * @param axis2 defines the second axis
  84311. * @param axis3 defines the third axis
  84312. * @returns the new quaternion
  84313. */
  84314. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84315. /**
  84316. * 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
  84317. * @param axis1 defines the first axis
  84318. * @param axis2 defines the second axis
  84319. * @param axis3 defines the third axis
  84320. * @param ref defines the target quaternion
  84321. */
  84322. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84323. /**
  84324. * Interpolates between two quaternions
  84325. * @param left defines first quaternion
  84326. * @param right defines second quaternion
  84327. * @param amount defines the gradient to use
  84328. * @returns the new interpolated quaternion
  84329. */
  84330. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84331. /**
  84332. * Interpolates between two quaternions and stores it into a target quaternion
  84333. * @param left defines first quaternion
  84334. * @param right defines second quaternion
  84335. * @param amount defines the gradient to use
  84336. * @param result defines the target quaternion
  84337. */
  84338. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84339. /**
  84340. * Interpolate between two quaternions using Hermite interpolation
  84341. * @param value1 defines first quaternion
  84342. * @param tangent1 defines the incoming tangent
  84343. * @param value2 defines second quaternion
  84344. * @param tangent2 defines the outgoing tangent
  84345. * @param amount defines the target quaternion
  84346. * @returns the new interpolated quaternion
  84347. */
  84348. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84349. }
  84350. /**
  84351. * Class used to store matrix data (4x4)
  84352. */
  84353. export class Matrix {
  84354. /**
  84355. * Gets the precision of matrix computations
  84356. */
  84357. static get Use64Bits(): boolean;
  84358. private static _updateFlagSeed;
  84359. private static _identityReadOnly;
  84360. private _isIdentity;
  84361. private _isIdentityDirty;
  84362. private _isIdentity3x2;
  84363. private _isIdentity3x2Dirty;
  84364. /**
  84365. * Gets the update flag of the matrix which is an unique number for the matrix.
  84366. * It will be incremented every time the matrix data change.
  84367. * You can use it to speed the comparison between two versions of the same matrix.
  84368. */
  84369. updateFlag: number;
  84370. private readonly _m;
  84371. /**
  84372. * Gets the internal data of the matrix
  84373. */
  84374. get m(): DeepImmutable<Float32Array | Array<number>>;
  84375. /** @hidden */
  84376. _markAsUpdated(): void;
  84377. /** @hidden */
  84378. private _updateIdentityStatus;
  84379. /**
  84380. * Creates an empty matrix (filled with zeros)
  84381. */
  84382. constructor();
  84383. /**
  84384. * Check if the current matrix is identity
  84385. * @returns true is the matrix is the identity matrix
  84386. */
  84387. isIdentity(): boolean;
  84388. /**
  84389. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84390. * @returns true is the matrix is the identity matrix
  84391. */
  84392. isIdentityAs3x2(): boolean;
  84393. /**
  84394. * Gets the determinant of the matrix
  84395. * @returns the matrix determinant
  84396. */
  84397. determinant(): number;
  84398. /**
  84399. * Returns the matrix as a Float32Array or Array<number>
  84400. * @returns the matrix underlying array
  84401. */
  84402. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84403. /**
  84404. * Returns the matrix as a Float32Array or Array<number>
  84405. * @returns the matrix underlying array.
  84406. */
  84407. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84408. /**
  84409. * Inverts the current matrix in place
  84410. * @returns the current inverted matrix
  84411. */
  84412. invert(): Matrix;
  84413. /**
  84414. * Sets all the matrix elements to zero
  84415. * @returns the current matrix
  84416. */
  84417. reset(): Matrix;
  84418. /**
  84419. * Adds the current matrix with a second one
  84420. * @param other defines the matrix to add
  84421. * @returns a new matrix as the addition of the current matrix and the given one
  84422. */
  84423. add(other: DeepImmutable<Matrix>): Matrix;
  84424. /**
  84425. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84426. * @param other defines the matrix to add
  84427. * @param result defines the target matrix
  84428. * @returns the current matrix
  84429. */
  84430. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84431. /**
  84432. * Adds in place the given matrix to the current matrix
  84433. * @param other defines the second operand
  84434. * @returns the current updated matrix
  84435. */
  84436. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84437. /**
  84438. * Sets the given matrix to the current inverted Matrix
  84439. * @param other defines the target matrix
  84440. * @returns the unmodified current matrix
  84441. */
  84442. invertToRef(other: Matrix): Matrix;
  84443. /**
  84444. * add a value at the specified position in the current Matrix
  84445. * @param index the index of the value within the matrix. between 0 and 15.
  84446. * @param value the value to be added
  84447. * @returns the current updated matrix
  84448. */
  84449. addAtIndex(index: number, value: number): Matrix;
  84450. /**
  84451. * mutiply the specified position in the current Matrix by a value
  84452. * @param index the index of the value within the matrix. between 0 and 15.
  84453. * @param value the value to be added
  84454. * @returns the current updated matrix
  84455. */
  84456. multiplyAtIndex(index: number, value: number): Matrix;
  84457. /**
  84458. * Inserts the translation vector (using 3 floats) in the current matrix
  84459. * @param x defines the 1st component of the translation
  84460. * @param y defines the 2nd component of the translation
  84461. * @param z defines the 3rd component of the translation
  84462. * @returns the current updated matrix
  84463. */
  84464. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84465. /**
  84466. * Adds the translation vector (using 3 floats) in the current matrix
  84467. * @param x defines the 1st component of the translation
  84468. * @param y defines the 2nd component of the translation
  84469. * @param z defines the 3rd component of the translation
  84470. * @returns the current updated matrix
  84471. */
  84472. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84473. /**
  84474. * Inserts the translation vector in the current matrix
  84475. * @param vector3 defines the translation to insert
  84476. * @returns the current updated matrix
  84477. */
  84478. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84479. /**
  84480. * Gets the translation value of the current matrix
  84481. * @returns a new Vector3 as the extracted translation from the matrix
  84482. */
  84483. getTranslation(): Vector3;
  84484. /**
  84485. * Fill a Vector3 with the extracted translation from the matrix
  84486. * @param result defines the Vector3 where to store the translation
  84487. * @returns the current matrix
  84488. */
  84489. getTranslationToRef(result: Vector3): Matrix;
  84490. /**
  84491. * Remove rotation and scaling part from the matrix
  84492. * @returns the updated matrix
  84493. */
  84494. removeRotationAndScaling(): Matrix;
  84495. /**
  84496. * Multiply two matrices
  84497. * @param other defines the second operand
  84498. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84499. */
  84500. multiply(other: DeepImmutable<Matrix>): Matrix;
  84501. /**
  84502. * Copy the current matrix from the given one
  84503. * @param other defines the source matrix
  84504. * @returns the current updated matrix
  84505. */
  84506. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84507. /**
  84508. * Populates the given array from the starting index with the current matrix values
  84509. * @param array defines the target array
  84510. * @param offset defines the offset in the target array where to start storing values
  84511. * @returns the current matrix
  84512. */
  84513. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84514. /**
  84515. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84516. * @param other defines the second operand
  84517. * @param result defines the matrix where to store the multiplication
  84518. * @returns the current matrix
  84519. */
  84520. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84521. /**
  84522. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84523. * @param other defines the second operand
  84524. * @param result defines the array where to store the multiplication
  84525. * @param offset defines the offset in the target array where to start storing values
  84526. * @returns the current matrix
  84527. */
  84528. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84529. /**
  84530. * Check equality between this matrix and a second one
  84531. * @param value defines the second matrix to compare
  84532. * @returns true is the current matrix and the given one values are strictly equal
  84533. */
  84534. equals(value: DeepImmutable<Matrix>): boolean;
  84535. /**
  84536. * Clone the current matrix
  84537. * @returns a new matrix from the current matrix
  84538. */
  84539. clone(): Matrix;
  84540. /**
  84541. * Returns the name of the current matrix class
  84542. * @returns the string "Matrix"
  84543. */
  84544. getClassName(): string;
  84545. /**
  84546. * Gets the hash code of the current matrix
  84547. * @returns the hash code
  84548. */
  84549. getHashCode(): number;
  84550. /**
  84551. * Decomposes the current Matrix into a translation, rotation and scaling components
  84552. * @param scale defines the scale vector3 given as a reference to update
  84553. * @param rotation defines the rotation quaternion given as a reference to update
  84554. * @param translation defines the translation vector3 given as a reference to update
  84555. * @returns true if operation was successful
  84556. */
  84557. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84558. /**
  84559. * Gets specific row of the matrix
  84560. * @param index defines the number of the row to get
  84561. * @returns the index-th row of the current matrix as a new Vector4
  84562. */
  84563. getRow(index: number): Nullable<Vector4>;
  84564. /**
  84565. * Sets the index-th row of the current matrix to the vector4 values
  84566. * @param index defines the number of the row to set
  84567. * @param row defines the target vector4
  84568. * @returns the updated current matrix
  84569. */
  84570. setRow(index: number, row: Vector4): Matrix;
  84571. /**
  84572. * Compute the transpose of the matrix
  84573. * @returns the new transposed matrix
  84574. */
  84575. transpose(): Matrix;
  84576. /**
  84577. * Compute the transpose of the matrix and store it in a given matrix
  84578. * @param result defines the target matrix
  84579. * @returns the current matrix
  84580. */
  84581. transposeToRef(result: Matrix): Matrix;
  84582. /**
  84583. * Sets the index-th row of the current matrix with the given 4 x float values
  84584. * @param index defines the row index
  84585. * @param x defines the x component to set
  84586. * @param y defines the y component to set
  84587. * @param z defines the z component to set
  84588. * @param w defines the w component to set
  84589. * @returns the updated current matrix
  84590. */
  84591. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84592. /**
  84593. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84594. * @param scale defines the scale factor
  84595. * @returns a new matrix
  84596. */
  84597. scale(scale: number): Matrix;
  84598. /**
  84599. * Scale the current matrix values by a factor to a given result matrix
  84600. * @param scale defines the scale factor
  84601. * @param result defines the matrix to store the result
  84602. * @returns the current matrix
  84603. */
  84604. scaleToRef(scale: number, result: Matrix): Matrix;
  84605. /**
  84606. * Scale the current matrix values by a factor and add the result to a given matrix
  84607. * @param scale defines the scale factor
  84608. * @param result defines the Matrix to store the result
  84609. * @returns the current matrix
  84610. */
  84611. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84612. /**
  84613. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84614. * @param ref matrix to store the result
  84615. */
  84616. toNormalMatrix(ref: Matrix): void;
  84617. /**
  84618. * Gets only rotation part of the current matrix
  84619. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84620. */
  84621. getRotationMatrix(): Matrix;
  84622. /**
  84623. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84624. * @param result defines the target matrix to store data to
  84625. * @returns the current matrix
  84626. */
  84627. getRotationMatrixToRef(result: Matrix): Matrix;
  84628. /**
  84629. * Toggles model matrix from being right handed to left handed in place and vice versa
  84630. */
  84631. toggleModelMatrixHandInPlace(): void;
  84632. /**
  84633. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84634. */
  84635. toggleProjectionMatrixHandInPlace(): void;
  84636. /**
  84637. * Creates a matrix from an array
  84638. * @param array defines the source array
  84639. * @param offset defines an offset in the source array
  84640. * @returns a new Matrix set from the starting index of the given array
  84641. */
  84642. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84643. /**
  84644. * Copy the content of an array into a given matrix
  84645. * @param array defines the source array
  84646. * @param offset defines an offset in the source array
  84647. * @param result defines the target matrix
  84648. */
  84649. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84650. /**
  84651. * Stores an array into a matrix after having multiplied each component by a given factor
  84652. * @param array defines the source array
  84653. * @param offset defines the offset in the source array
  84654. * @param scale defines the scaling factor
  84655. * @param result defines the target matrix
  84656. */
  84657. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84658. /**
  84659. * Gets an identity matrix that must not be updated
  84660. */
  84661. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84662. /**
  84663. * Stores a list of values (16) inside a given matrix
  84664. * @param initialM11 defines 1st value of 1st row
  84665. * @param initialM12 defines 2nd value of 1st row
  84666. * @param initialM13 defines 3rd value of 1st row
  84667. * @param initialM14 defines 4th value of 1st row
  84668. * @param initialM21 defines 1st value of 2nd row
  84669. * @param initialM22 defines 2nd value of 2nd row
  84670. * @param initialM23 defines 3rd value of 2nd row
  84671. * @param initialM24 defines 4th value of 2nd row
  84672. * @param initialM31 defines 1st value of 3rd row
  84673. * @param initialM32 defines 2nd value of 3rd row
  84674. * @param initialM33 defines 3rd value of 3rd row
  84675. * @param initialM34 defines 4th value of 3rd row
  84676. * @param initialM41 defines 1st value of 4th row
  84677. * @param initialM42 defines 2nd value of 4th row
  84678. * @param initialM43 defines 3rd value of 4th row
  84679. * @param initialM44 defines 4th value of 4th row
  84680. * @param result defines the target matrix
  84681. */
  84682. 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;
  84683. /**
  84684. * Creates new matrix from a list of values (16)
  84685. * @param initialM11 defines 1st value of 1st row
  84686. * @param initialM12 defines 2nd value of 1st row
  84687. * @param initialM13 defines 3rd value of 1st row
  84688. * @param initialM14 defines 4th value of 1st row
  84689. * @param initialM21 defines 1st value of 2nd row
  84690. * @param initialM22 defines 2nd value of 2nd row
  84691. * @param initialM23 defines 3rd value of 2nd row
  84692. * @param initialM24 defines 4th value of 2nd row
  84693. * @param initialM31 defines 1st value of 3rd row
  84694. * @param initialM32 defines 2nd value of 3rd row
  84695. * @param initialM33 defines 3rd value of 3rd row
  84696. * @param initialM34 defines 4th value of 3rd row
  84697. * @param initialM41 defines 1st value of 4th row
  84698. * @param initialM42 defines 2nd value of 4th row
  84699. * @param initialM43 defines 3rd value of 4th row
  84700. * @param initialM44 defines 4th value of 4th row
  84701. * @returns the new matrix
  84702. */
  84703. 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;
  84704. /**
  84705. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84706. * @param scale defines the scale vector3
  84707. * @param rotation defines the rotation quaternion
  84708. * @param translation defines the translation vector3
  84709. * @returns a new matrix
  84710. */
  84711. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84712. /**
  84713. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84714. * @param scale defines the scale vector3
  84715. * @param rotation defines the rotation quaternion
  84716. * @param translation defines the translation vector3
  84717. * @param result defines the target matrix
  84718. */
  84719. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84720. /**
  84721. * Creates a new identity matrix
  84722. * @returns a new identity matrix
  84723. */
  84724. static Identity(): Matrix;
  84725. /**
  84726. * Creates a new identity matrix and stores the result in a given matrix
  84727. * @param result defines the target matrix
  84728. */
  84729. static IdentityToRef(result: Matrix): void;
  84730. /**
  84731. * Creates a new zero matrix
  84732. * @returns a new zero matrix
  84733. */
  84734. static Zero(): Matrix;
  84735. /**
  84736. * Creates a new rotation matrix for "angle" radians around the X axis
  84737. * @param angle defines the angle (in radians) to use
  84738. * @return the new matrix
  84739. */
  84740. static RotationX(angle: number): Matrix;
  84741. /**
  84742. * Creates a new matrix as the invert of a given matrix
  84743. * @param source defines the source matrix
  84744. * @returns the new matrix
  84745. */
  84746. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84747. /**
  84748. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84749. * @param angle defines the angle (in radians) to use
  84750. * @param result defines the target matrix
  84751. */
  84752. static RotationXToRef(angle: number, result: Matrix): void;
  84753. /**
  84754. * Creates a new rotation matrix for "angle" radians around the Y axis
  84755. * @param angle defines the angle (in radians) to use
  84756. * @return the new matrix
  84757. */
  84758. static RotationY(angle: number): Matrix;
  84759. /**
  84760. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84761. * @param angle defines the angle (in radians) to use
  84762. * @param result defines the target matrix
  84763. */
  84764. static RotationYToRef(angle: number, result: Matrix): void;
  84765. /**
  84766. * Creates a new rotation matrix for "angle" radians around the Z axis
  84767. * @param angle defines the angle (in radians) to use
  84768. * @return the new matrix
  84769. */
  84770. static RotationZ(angle: number): Matrix;
  84771. /**
  84772. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84773. * @param angle defines the angle (in radians) to use
  84774. * @param result defines the target matrix
  84775. */
  84776. static RotationZToRef(angle: number, result: Matrix): void;
  84777. /**
  84778. * Creates a new rotation matrix for "angle" radians around the given axis
  84779. * @param axis defines the axis to use
  84780. * @param angle defines the angle (in radians) to use
  84781. * @return the new matrix
  84782. */
  84783. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84784. /**
  84785. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84786. * @param axis defines the axis to use
  84787. * @param angle defines the angle (in radians) to use
  84788. * @param result defines the target matrix
  84789. */
  84790. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84791. /**
  84792. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84793. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84794. * @param from defines the vector to align
  84795. * @param to defines the vector to align to
  84796. * @param result defines the target matrix
  84797. */
  84798. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84799. /**
  84800. * Creates a rotation matrix
  84801. * @param yaw defines the yaw angle in radians (Y axis)
  84802. * @param pitch defines the pitch angle in radians (X axis)
  84803. * @param roll defines the roll angle in radians (Z axis)
  84804. * @returns the new rotation matrix
  84805. */
  84806. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84807. /**
  84808. * Creates a rotation matrix and stores it in a given matrix
  84809. * @param yaw defines the yaw angle in radians (Y axis)
  84810. * @param pitch defines the pitch angle in radians (X axis)
  84811. * @param roll defines the roll angle in radians (Z axis)
  84812. * @param result defines the target matrix
  84813. */
  84814. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84815. /**
  84816. * Creates a scaling matrix
  84817. * @param x defines the scale factor on X axis
  84818. * @param y defines the scale factor on Y axis
  84819. * @param z defines the scale factor on Z axis
  84820. * @returns the new matrix
  84821. */
  84822. static Scaling(x: number, y: number, z: number): Matrix;
  84823. /**
  84824. * Creates a scaling matrix and stores it in a given matrix
  84825. * @param x defines the scale factor on X axis
  84826. * @param y defines the scale factor on Y axis
  84827. * @param z defines the scale factor on Z axis
  84828. * @param result defines the target matrix
  84829. */
  84830. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84831. /**
  84832. * Creates a translation matrix
  84833. * @param x defines the translation on X axis
  84834. * @param y defines the translation on Y axis
  84835. * @param z defines the translationon Z axis
  84836. * @returns the new matrix
  84837. */
  84838. static Translation(x: number, y: number, z: number): Matrix;
  84839. /**
  84840. * Creates a translation matrix and stores it in a given matrix
  84841. * @param x defines the translation on X axis
  84842. * @param y defines the translation on Y axis
  84843. * @param z defines the translationon Z axis
  84844. * @param result defines the target matrix
  84845. */
  84846. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84847. /**
  84848. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84849. * @param startValue defines the start value
  84850. * @param endValue defines the end value
  84851. * @param gradient defines the gradient factor
  84852. * @returns the new matrix
  84853. */
  84854. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84855. /**
  84856. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84857. * @param startValue defines the start value
  84858. * @param endValue defines the end value
  84859. * @param gradient defines the gradient factor
  84860. * @param result defines the Matrix object where to store data
  84861. */
  84862. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84863. /**
  84864. * Builds a new matrix whose values are computed by:
  84865. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84866. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84867. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84868. * @param startValue defines the first matrix
  84869. * @param endValue defines the second matrix
  84870. * @param gradient defines the gradient between the two matrices
  84871. * @returns the new matrix
  84872. */
  84873. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84874. /**
  84875. * Update a matrix to values which are computed by:
  84876. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84877. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84878. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84879. * @param startValue defines the first matrix
  84880. * @param endValue defines the second matrix
  84881. * @param gradient defines the gradient between the two matrices
  84882. * @param result defines the target matrix
  84883. */
  84884. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84885. /**
  84886. * 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"
  84887. * This function works in left handed mode
  84888. * @param eye defines the final position of the entity
  84889. * @param target defines where the entity should look at
  84890. * @param up defines the up vector for the entity
  84891. * @returns the new matrix
  84892. */
  84893. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84894. /**
  84895. * 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".
  84896. * This function works in left handed mode
  84897. * @param eye defines the final position of the entity
  84898. * @param target defines where the entity should look at
  84899. * @param up defines the up vector for the entity
  84900. * @param result defines the target matrix
  84901. */
  84902. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84903. /**
  84904. * 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"
  84905. * This function works in right handed mode
  84906. * @param eye defines the final position of the entity
  84907. * @param target defines where the entity should look at
  84908. * @param up defines the up vector for the entity
  84909. * @returns the new matrix
  84910. */
  84911. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84912. /**
  84913. * 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".
  84914. * This function works in right handed mode
  84915. * @param eye defines the final position of the entity
  84916. * @param target defines where the entity should look at
  84917. * @param up defines the up vector for the entity
  84918. * @param result defines the target matrix
  84919. */
  84920. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84921. /**
  84922. * Create a left-handed orthographic projection matrix
  84923. * @param width defines the viewport width
  84924. * @param height defines the viewport height
  84925. * @param znear defines the near clip plane
  84926. * @param zfar defines the far clip plane
  84927. * @returns a new matrix as a left-handed orthographic projection matrix
  84928. */
  84929. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84930. /**
  84931. * Store a left-handed orthographic projection to a given matrix
  84932. * @param width defines the viewport width
  84933. * @param height defines the viewport height
  84934. * @param znear defines the near clip plane
  84935. * @param zfar defines the far clip plane
  84936. * @param result defines the target matrix
  84937. */
  84938. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84939. /**
  84940. * Create a left-handed orthographic projection matrix
  84941. * @param left defines the viewport left coordinate
  84942. * @param right defines the viewport right coordinate
  84943. * @param bottom defines the viewport bottom coordinate
  84944. * @param top defines the viewport top coordinate
  84945. * @param znear defines the near clip plane
  84946. * @param zfar defines the far clip plane
  84947. * @returns a new matrix as a left-handed orthographic projection matrix
  84948. */
  84949. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84950. /**
  84951. * Stores a left-handed orthographic projection into a given matrix
  84952. * @param left defines the viewport left coordinate
  84953. * @param right defines the viewport right coordinate
  84954. * @param bottom defines the viewport bottom coordinate
  84955. * @param top defines the viewport top coordinate
  84956. * @param znear defines the near clip plane
  84957. * @param zfar defines the far clip plane
  84958. * @param result defines the target matrix
  84959. */
  84960. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84961. /**
  84962. * Creates a right-handed orthographic projection matrix
  84963. * @param left defines the viewport left coordinate
  84964. * @param right defines the viewport right coordinate
  84965. * @param bottom defines the viewport bottom coordinate
  84966. * @param top defines the viewport top coordinate
  84967. * @param znear defines the near clip plane
  84968. * @param zfar defines the far clip plane
  84969. * @returns a new matrix as a right-handed orthographic projection matrix
  84970. */
  84971. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84972. /**
  84973. * Stores a right-handed orthographic projection into a given matrix
  84974. * @param left defines the viewport left coordinate
  84975. * @param right defines the viewport right coordinate
  84976. * @param bottom defines the viewport bottom coordinate
  84977. * @param top defines the viewport top coordinate
  84978. * @param znear defines the near clip plane
  84979. * @param zfar defines the far clip plane
  84980. * @param result defines the target matrix
  84981. */
  84982. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84983. /**
  84984. * Creates a left-handed perspective projection matrix
  84985. * @param width defines the viewport width
  84986. * @param height defines the viewport height
  84987. * @param znear defines the near clip plane
  84988. * @param zfar defines the far clip plane
  84989. * @returns a new matrix as a left-handed perspective projection matrix
  84990. */
  84991. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84992. /**
  84993. * Creates a left-handed perspective projection matrix
  84994. * @param fov defines the horizontal field of view
  84995. * @param aspect defines the aspect ratio
  84996. * @param znear defines the near clip plane
  84997. * @param zfar defines the far clip plane
  84998. * @returns a new matrix as a left-handed perspective projection matrix
  84999. */
  85000. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85001. /**
  85002. * Stores a left-handed perspective projection into a given matrix
  85003. * @param fov defines the horizontal field of view
  85004. * @param aspect defines the aspect ratio
  85005. * @param znear defines the near clip plane
  85006. * @param zfar defines the far clip plane
  85007. * @param result defines the target matrix
  85008. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85009. */
  85010. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85011. /**
  85012. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85013. * @param fov defines the horizontal field of view
  85014. * @param aspect defines the aspect ratio
  85015. * @param znear defines the near clip plane
  85016. * @param zfar not used as infinity is used as far clip
  85017. * @param result defines the target matrix
  85018. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85019. */
  85020. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85021. /**
  85022. * Creates a right-handed perspective projection matrix
  85023. * @param fov defines the horizontal field of view
  85024. * @param aspect defines the aspect ratio
  85025. * @param znear defines the near clip plane
  85026. * @param zfar defines the far clip plane
  85027. * @returns a new matrix as a right-handed perspective projection matrix
  85028. */
  85029. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85030. /**
  85031. * Stores a right-handed perspective projection into a given matrix
  85032. * @param fov defines the horizontal field of view
  85033. * @param aspect defines the aspect ratio
  85034. * @param znear defines the near clip plane
  85035. * @param zfar defines the far clip plane
  85036. * @param result defines the target matrix
  85037. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85038. */
  85039. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85040. /**
  85041. * Stores a right-handed perspective projection into a given matrix
  85042. * @param fov defines the horizontal field of view
  85043. * @param aspect defines the aspect ratio
  85044. * @param znear defines the near clip plane
  85045. * @param zfar not used as infinity is used as far clip
  85046. * @param result defines the target matrix
  85047. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85048. */
  85049. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85050. /**
  85051. * Stores a perspective projection for WebVR info a given matrix
  85052. * @param fov defines the field of view
  85053. * @param znear defines the near clip plane
  85054. * @param zfar defines the far clip plane
  85055. * @param result defines the target matrix
  85056. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85057. */
  85058. static PerspectiveFovWebVRToRef(fov: {
  85059. upDegrees: number;
  85060. downDegrees: number;
  85061. leftDegrees: number;
  85062. rightDegrees: number;
  85063. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85064. /**
  85065. * Computes a complete transformation matrix
  85066. * @param viewport defines the viewport to use
  85067. * @param world defines the world matrix
  85068. * @param view defines the view matrix
  85069. * @param projection defines the projection matrix
  85070. * @param zmin defines the near clip plane
  85071. * @param zmax defines the far clip plane
  85072. * @returns the transformation matrix
  85073. */
  85074. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85075. /**
  85076. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85077. * @param matrix defines the matrix to use
  85078. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85079. */
  85080. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85081. /**
  85082. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85083. * @param matrix defines the matrix to use
  85084. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85085. */
  85086. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85087. /**
  85088. * Compute the transpose of a given matrix
  85089. * @param matrix defines the matrix to transpose
  85090. * @returns the new matrix
  85091. */
  85092. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85093. /**
  85094. * Compute the transpose of a matrix and store it in a target matrix
  85095. * @param matrix defines the matrix to transpose
  85096. * @param result defines the target matrix
  85097. */
  85098. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85099. /**
  85100. * Computes a reflection matrix from a plane
  85101. * @param plane defines the reflection plane
  85102. * @returns a new matrix
  85103. */
  85104. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85105. /**
  85106. * Computes a reflection matrix from a plane
  85107. * @param plane defines the reflection plane
  85108. * @param result defines the target matrix
  85109. */
  85110. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85111. /**
  85112. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85113. * @param xaxis defines the value of the 1st axis
  85114. * @param yaxis defines the value of the 2nd axis
  85115. * @param zaxis defines the value of the 3rd axis
  85116. * @param result defines the target matrix
  85117. */
  85118. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85119. /**
  85120. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85121. * @param quat defines the quaternion to use
  85122. * @param result defines the target matrix
  85123. */
  85124. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85125. }
  85126. /**
  85127. * @hidden
  85128. */
  85129. export class TmpVectors {
  85130. static Vector2: Vector2[];
  85131. static Vector3: Vector3[];
  85132. static Vector4: Vector4[];
  85133. static Quaternion: Quaternion[];
  85134. static Matrix: Matrix[];
  85135. }
  85136. }
  85137. declare module BABYLON {
  85138. /**
  85139. * Defines potential orientation for back face culling
  85140. */
  85141. export enum Orientation {
  85142. /**
  85143. * Clockwise
  85144. */
  85145. CW = 0,
  85146. /** Counter clockwise */
  85147. CCW = 1
  85148. }
  85149. /** Class used to represent a Bezier curve */
  85150. export class BezierCurve {
  85151. /**
  85152. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85153. * @param t defines the time
  85154. * @param x1 defines the left coordinate on X axis
  85155. * @param y1 defines the left coordinate on Y axis
  85156. * @param x2 defines the right coordinate on X axis
  85157. * @param y2 defines the right coordinate on Y axis
  85158. * @returns the interpolated value
  85159. */
  85160. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85161. }
  85162. /**
  85163. * Defines angle representation
  85164. */
  85165. export class Angle {
  85166. private _radians;
  85167. /**
  85168. * Creates an Angle object of "radians" radians (float).
  85169. * @param radians the angle in radians
  85170. */
  85171. constructor(radians: number);
  85172. /**
  85173. * Get value in degrees
  85174. * @returns the Angle value in degrees (float)
  85175. */
  85176. degrees(): number;
  85177. /**
  85178. * Get value in radians
  85179. * @returns the Angle value in radians (float)
  85180. */
  85181. radians(): number;
  85182. /**
  85183. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85184. * @param a defines first point as the origin
  85185. * @param b defines point
  85186. * @returns a new Angle
  85187. */
  85188. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85189. /**
  85190. * Gets a new Angle object from the given float in radians
  85191. * @param radians defines the angle value in radians
  85192. * @returns a new Angle
  85193. */
  85194. static FromRadians(radians: number): Angle;
  85195. /**
  85196. * Gets a new Angle object from the given float in degrees
  85197. * @param degrees defines the angle value in degrees
  85198. * @returns a new Angle
  85199. */
  85200. static FromDegrees(degrees: number): Angle;
  85201. }
  85202. /**
  85203. * This represents an arc in a 2d space.
  85204. */
  85205. export class Arc2 {
  85206. /** Defines the start point of the arc */
  85207. startPoint: Vector2;
  85208. /** Defines the mid point of the arc */
  85209. midPoint: Vector2;
  85210. /** Defines the end point of the arc */
  85211. endPoint: Vector2;
  85212. /**
  85213. * Defines the center point of the arc.
  85214. */
  85215. centerPoint: Vector2;
  85216. /**
  85217. * Defines the radius of the arc.
  85218. */
  85219. radius: number;
  85220. /**
  85221. * Defines the angle of the arc (from mid point to end point).
  85222. */
  85223. angle: Angle;
  85224. /**
  85225. * Defines the start angle of the arc (from start point to middle point).
  85226. */
  85227. startAngle: Angle;
  85228. /**
  85229. * Defines the orientation of the arc (clock wise/counter clock wise).
  85230. */
  85231. orientation: Orientation;
  85232. /**
  85233. * Creates an Arc object from the three given points : start, middle and end.
  85234. * @param startPoint Defines the start point of the arc
  85235. * @param midPoint Defines the midlle point of the arc
  85236. * @param endPoint Defines the end point of the arc
  85237. */
  85238. constructor(
  85239. /** Defines the start point of the arc */
  85240. startPoint: Vector2,
  85241. /** Defines the mid point of the arc */
  85242. midPoint: Vector2,
  85243. /** Defines the end point of the arc */
  85244. endPoint: Vector2);
  85245. }
  85246. /**
  85247. * Represents a 2D path made up of multiple 2D points
  85248. */
  85249. export class Path2 {
  85250. private _points;
  85251. private _length;
  85252. /**
  85253. * If the path start and end point are the same
  85254. */
  85255. closed: boolean;
  85256. /**
  85257. * Creates a Path2 object from the starting 2D coordinates x and y.
  85258. * @param x the starting points x value
  85259. * @param y the starting points y value
  85260. */
  85261. constructor(x: number, y: number);
  85262. /**
  85263. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85264. * @param x the added points x value
  85265. * @param y the added points y value
  85266. * @returns the updated Path2.
  85267. */
  85268. addLineTo(x: number, y: number): Path2;
  85269. /**
  85270. * 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.
  85271. * @param midX middle point x value
  85272. * @param midY middle point y value
  85273. * @param endX end point x value
  85274. * @param endY end point y value
  85275. * @param numberOfSegments (default: 36)
  85276. * @returns the updated Path2.
  85277. */
  85278. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85279. /**
  85280. * Closes the Path2.
  85281. * @returns the Path2.
  85282. */
  85283. close(): Path2;
  85284. /**
  85285. * Gets the sum of the distance between each sequential point in the path
  85286. * @returns the Path2 total length (float).
  85287. */
  85288. length(): number;
  85289. /**
  85290. * Gets the points which construct the path
  85291. * @returns the Path2 internal array of points.
  85292. */
  85293. getPoints(): Vector2[];
  85294. /**
  85295. * Retreives the point at the distance aways from the starting point
  85296. * @param normalizedLengthPosition the length along the path to retreive the point from
  85297. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85298. */
  85299. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85300. /**
  85301. * Creates a new path starting from an x and y position
  85302. * @param x starting x value
  85303. * @param y starting y value
  85304. * @returns a new Path2 starting at the coordinates (x, y).
  85305. */
  85306. static StartingAt(x: number, y: number): Path2;
  85307. }
  85308. /**
  85309. * Represents a 3D path made up of multiple 3D points
  85310. */
  85311. export class Path3D {
  85312. /**
  85313. * an array of Vector3, the curve axis of the Path3D
  85314. */
  85315. path: Vector3[];
  85316. private _curve;
  85317. private _distances;
  85318. private _tangents;
  85319. private _normals;
  85320. private _binormals;
  85321. private _raw;
  85322. private _alignTangentsWithPath;
  85323. private readonly _pointAtData;
  85324. /**
  85325. * new Path3D(path, normal, raw)
  85326. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85327. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85328. * @param path an array of Vector3, the curve axis of the Path3D
  85329. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85330. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85331. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85332. */
  85333. constructor(
  85334. /**
  85335. * an array of Vector3, the curve axis of the Path3D
  85336. */
  85337. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85338. /**
  85339. * Returns the Path3D array of successive Vector3 designing its curve.
  85340. * @returns the Path3D array of successive Vector3 designing its curve.
  85341. */
  85342. getCurve(): Vector3[];
  85343. /**
  85344. * Returns the Path3D array of successive Vector3 designing its curve.
  85345. * @returns the Path3D array of successive Vector3 designing its curve.
  85346. */
  85347. getPoints(): Vector3[];
  85348. /**
  85349. * @returns the computed length (float) of the path.
  85350. */
  85351. length(): number;
  85352. /**
  85353. * Returns an array populated with tangent vectors on each Path3D curve point.
  85354. * @returns an array populated with tangent vectors on each Path3D curve point.
  85355. */
  85356. getTangents(): Vector3[];
  85357. /**
  85358. * Returns an array populated with normal vectors on each Path3D curve point.
  85359. * @returns an array populated with normal vectors on each Path3D curve point.
  85360. */
  85361. getNormals(): Vector3[];
  85362. /**
  85363. * Returns an array populated with binormal vectors on each Path3D curve point.
  85364. * @returns an array populated with binormal vectors on each Path3D curve point.
  85365. */
  85366. getBinormals(): Vector3[];
  85367. /**
  85368. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85369. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85370. */
  85371. getDistances(): number[];
  85372. /**
  85373. * Returns an interpolated point along this path
  85374. * @param position the position of the point along this path, from 0.0 to 1.0
  85375. * @returns a new Vector3 as the point
  85376. */
  85377. getPointAt(position: number): Vector3;
  85378. /**
  85379. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85380. * @param position the position of the point along this path, from 0.0 to 1.0
  85381. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85382. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85383. */
  85384. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85385. /**
  85386. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85387. * @param position the position of the point along this path, from 0.0 to 1.0
  85388. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85389. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85390. */
  85391. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85392. /**
  85393. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85394. * @param position the position of the point along this path, from 0.0 to 1.0
  85395. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85396. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85397. */
  85398. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85399. /**
  85400. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85401. * @param position the position of the point along this path, from 0.0 to 1.0
  85402. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85403. */
  85404. getDistanceAt(position: number): number;
  85405. /**
  85406. * Returns the array index of the previous point of an interpolated point along this path
  85407. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85408. * @returns the array index
  85409. */
  85410. getPreviousPointIndexAt(position: number): number;
  85411. /**
  85412. * 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)
  85413. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85414. * @returns the sub position
  85415. */
  85416. getSubPositionAt(position: number): number;
  85417. /**
  85418. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85419. * @param target the vector of which to get the closest position to
  85420. * @returns the position of the closest virtual point on this path to the target vector
  85421. */
  85422. getClosestPositionTo(target: Vector3): number;
  85423. /**
  85424. * Returns a sub path (slice) of this path
  85425. * @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
  85426. * @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
  85427. * @returns a sub path (slice) of this path
  85428. */
  85429. slice(start?: number, end?: number): Path3D;
  85430. /**
  85431. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85432. * @param path path which all values are copied into the curves points
  85433. * @param firstNormal which should be projected onto the curve
  85434. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85435. * @returns the same object updated.
  85436. */
  85437. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85438. private _compute;
  85439. private _getFirstNonNullVector;
  85440. private _getLastNonNullVector;
  85441. private _normalVector;
  85442. /**
  85443. * Updates the point at data for an interpolated point along this curve
  85444. * @param position the position of the point along this curve, from 0.0 to 1.0
  85445. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85446. * @returns the (updated) point at data
  85447. */
  85448. private _updatePointAtData;
  85449. /**
  85450. * Updates the point at data from the specified parameters
  85451. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85452. * @param point the interpolated point
  85453. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85454. */
  85455. private _setPointAtData;
  85456. /**
  85457. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85458. */
  85459. private _updateInterpolationMatrix;
  85460. }
  85461. /**
  85462. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85463. * A Curve3 is designed from a series of successive Vector3.
  85464. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85465. */
  85466. export class Curve3 {
  85467. private _points;
  85468. private _length;
  85469. /**
  85470. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85471. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85472. * @param v1 (Vector3) the control point
  85473. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85474. * @param nbPoints (integer) the wanted number of points in the curve
  85475. * @returns the created Curve3
  85476. */
  85477. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85478. /**
  85479. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85480. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85481. * @param v1 (Vector3) the first control point
  85482. * @param v2 (Vector3) the second control point
  85483. * @param v3 (Vector3) the end point of the Cubic Bezier
  85484. * @param nbPoints (integer) the wanted number of points in the curve
  85485. * @returns the created Curve3
  85486. */
  85487. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85488. /**
  85489. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85490. * @param p1 (Vector3) the origin point of the Hermite Spline
  85491. * @param t1 (Vector3) the tangent vector at the origin point
  85492. * @param p2 (Vector3) the end point of the Hermite Spline
  85493. * @param t2 (Vector3) the tangent vector at the end point
  85494. * @param nbPoints (integer) the wanted number of points in the curve
  85495. * @returns the created Curve3
  85496. */
  85497. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85498. /**
  85499. * Returns a Curve3 object along a CatmullRom Spline curve :
  85500. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85501. * @param nbPoints (integer) the wanted number of points between each curve control points
  85502. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85503. * @returns the created Curve3
  85504. */
  85505. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85506. /**
  85507. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85508. * A Curve3 is designed from a series of successive Vector3.
  85509. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85510. * @param points points which make up the curve
  85511. */
  85512. constructor(points: Vector3[]);
  85513. /**
  85514. * @returns the Curve3 stored array of successive Vector3
  85515. */
  85516. getPoints(): Vector3[];
  85517. /**
  85518. * @returns the computed length (float) of the curve.
  85519. */
  85520. length(): number;
  85521. /**
  85522. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85523. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85524. * curveA and curveB keep unchanged.
  85525. * @param curve the curve to continue from this curve
  85526. * @returns the newly constructed curve
  85527. */
  85528. continue(curve: DeepImmutable<Curve3>): Curve3;
  85529. private _computeLength;
  85530. }
  85531. }
  85532. declare module BABYLON {
  85533. /**
  85534. * This represents the main contract an easing function should follow.
  85535. * Easing functions are used throughout the animation system.
  85536. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85537. */
  85538. export interface IEasingFunction {
  85539. /**
  85540. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85541. * of the easing function.
  85542. * The link below provides some of the most common examples of easing functions.
  85543. * @see https://easings.net/
  85544. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85545. * @returns the corresponding value on the curve defined by the easing function
  85546. */
  85547. ease(gradient: number): number;
  85548. }
  85549. /**
  85550. * Base class used for every default easing function.
  85551. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85552. */
  85553. export class EasingFunction implements IEasingFunction {
  85554. /**
  85555. * Interpolation follows the mathematical formula associated with the easing function.
  85556. */
  85557. static readonly EASINGMODE_EASEIN: number;
  85558. /**
  85559. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85560. */
  85561. static readonly EASINGMODE_EASEOUT: number;
  85562. /**
  85563. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85564. */
  85565. static readonly EASINGMODE_EASEINOUT: number;
  85566. private _easingMode;
  85567. /**
  85568. * Sets the easing mode of the current function.
  85569. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85570. */
  85571. setEasingMode(easingMode: number): void;
  85572. /**
  85573. * Gets the current easing mode.
  85574. * @returns the easing mode
  85575. */
  85576. getEasingMode(): number;
  85577. /**
  85578. * @hidden
  85579. */
  85580. easeInCore(gradient: number): number;
  85581. /**
  85582. * Given an input gradient between 0 and 1, this returns the corresponding value
  85583. * of the easing function.
  85584. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85585. * @returns the corresponding value on the curve defined by the easing function
  85586. */
  85587. ease(gradient: number): number;
  85588. }
  85589. /**
  85590. * Easing function with a circle shape (see link below).
  85591. * @see https://easings.net/#easeInCirc
  85592. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85593. */
  85594. export class CircleEase extends EasingFunction implements IEasingFunction {
  85595. /** @hidden */
  85596. easeInCore(gradient: number): number;
  85597. }
  85598. /**
  85599. * Easing function with a ease back shape (see link below).
  85600. * @see https://easings.net/#easeInBack
  85601. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85602. */
  85603. export class BackEase extends EasingFunction implements IEasingFunction {
  85604. /** Defines the amplitude of the function */
  85605. amplitude: number;
  85606. /**
  85607. * Instantiates a back ease easing
  85608. * @see https://easings.net/#easeInBack
  85609. * @param amplitude Defines the amplitude of the function
  85610. */
  85611. constructor(
  85612. /** Defines the amplitude of the function */
  85613. amplitude?: number);
  85614. /** @hidden */
  85615. easeInCore(gradient: number): number;
  85616. }
  85617. /**
  85618. * Easing function with a bouncing shape (see link below).
  85619. * @see https://easings.net/#easeInBounce
  85620. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85621. */
  85622. export class BounceEase extends EasingFunction implements IEasingFunction {
  85623. /** Defines the number of bounces */
  85624. bounces: number;
  85625. /** Defines the amplitude of the bounce */
  85626. bounciness: number;
  85627. /**
  85628. * Instantiates a bounce easing
  85629. * @see https://easings.net/#easeInBounce
  85630. * @param bounces Defines the number of bounces
  85631. * @param bounciness Defines the amplitude of the bounce
  85632. */
  85633. constructor(
  85634. /** Defines the number of bounces */
  85635. bounces?: number,
  85636. /** Defines the amplitude of the bounce */
  85637. bounciness?: number);
  85638. /** @hidden */
  85639. easeInCore(gradient: number): number;
  85640. }
  85641. /**
  85642. * Easing function with a power of 3 shape (see link below).
  85643. * @see https://easings.net/#easeInCubic
  85644. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85645. */
  85646. export class CubicEase extends EasingFunction implements IEasingFunction {
  85647. /** @hidden */
  85648. easeInCore(gradient: number): number;
  85649. }
  85650. /**
  85651. * Easing function with an elastic shape (see link below).
  85652. * @see https://easings.net/#easeInElastic
  85653. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85654. */
  85655. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85656. /** Defines the number of oscillations*/
  85657. oscillations: number;
  85658. /** Defines the amplitude of the oscillations*/
  85659. springiness: number;
  85660. /**
  85661. * Instantiates an elastic easing function
  85662. * @see https://easings.net/#easeInElastic
  85663. * @param oscillations Defines the number of oscillations
  85664. * @param springiness Defines the amplitude of the oscillations
  85665. */
  85666. constructor(
  85667. /** Defines the number of oscillations*/
  85668. oscillations?: number,
  85669. /** Defines the amplitude of the oscillations*/
  85670. springiness?: number);
  85671. /** @hidden */
  85672. easeInCore(gradient: number): number;
  85673. }
  85674. /**
  85675. * Easing function with an exponential shape (see link below).
  85676. * @see https://easings.net/#easeInExpo
  85677. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85678. */
  85679. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85680. /** Defines the exponent of the function */
  85681. exponent: number;
  85682. /**
  85683. * Instantiates an exponential easing function
  85684. * @see https://easings.net/#easeInExpo
  85685. * @param exponent Defines the exponent of the function
  85686. */
  85687. constructor(
  85688. /** Defines the exponent of the function */
  85689. exponent?: number);
  85690. /** @hidden */
  85691. easeInCore(gradient: number): number;
  85692. }
  85693. /**
  85694. * Easing function with a power shape (see link below).
  85695. * @see https://easings.net/#easeInQuad
  85696. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85697. */
  85698. export class PowerEase extends EasingFunction implements IEasingFunction {
  85699. /** Defines the power of the function */
  85700. power: number;
  85701. /**
  85702. * Instantiates an power base easing function
  85703. * @see https://easings.net/#easeInQuad
  85704. * @param power Defines the power of the function
  85705. */
  85706. constructor(
  85707. /** Defines the power of the function */
  85708. power?: number);
  85709. /** @hidden */
  85710. easeInCore(gradient: number): number;
  85711. }
  85712. /**
  85713. * Easing function with a power of 2 shape (see link below).
  85714. * @see https://easings.net/#easeInQuad
  85715. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85716. */
  85717. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85718. /** @hidden */
  85719. easeInCore(gradient: number): number;
  85720. }
  85721. /**
  85722. * Easing function with a power of 4 shape (see link below).
  85723. * @see https://easings.net/#easeInQuart
  85724. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85725. */
  85726. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85727. /** @hidden */
  85728. easeInCore(gradient: number): number;
  85729. }
  85730. /**
  85731. * Easing function with a power of 5 shape (see link below).
  85732. * @see https://easings.net/#easeInQuint
  85733. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85734. */
  85735. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85736. /** @hidden */
  85737. easeInCore(gradient: number): number;
  85738. }
  85739. /**
  85740. * Easing function with a sin shape (see link below).
  85741. * @see https://easings.net/#easeInSine
  85742. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85743. */
  85744. export class SineEase extends EasingFunction implements IEasingFunction {
  85745. /** @hidden */
  85746. easeInCore(gradient: number): number;
  85747. }
  85748. /**
  85749. * Easing function with a bezier shape (see link below).
  85750. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85751. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85752. */
  85753. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85754. /** Defines the x component of the start tangent in the bezier curve */
  85755. x1: number;
  85756. /** Defines the y component of the start tangent in the bezier curve */
  85757. y1: number;
  85758. /** Defines the x component of the end tangent in the bezier curve */
  85759. x2: number;
  85760. /** Defines the y component of the end tangent in the bezier curve */
  85761. y2: number;
  85762. /**
  85763. * Instantiates a bezier function
  85764. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85765. * @param x1 Defines the x component of the start tangent in the bezier curve
  85766. * @param y1 Defines the y component of the start tangent in the bezier curve
  85767. * @param x2 Defines the x component of the end tangent in the bezier curve
  85768. * @param y2 Defines the y component of the end tangent in the bezier curve
  85769. */
  85770. constructor(
  85771. /** Defines the x component of the start tangent in the bezier curve */
  85772. x1?: number,
  85773. /** Defines the y component of the start tangent in the bezier curve */
  85774. y1?: number,
  85775. /** Defines the x component of the end tangent in the bezier curve */
  85776. x2?: number,
  85777. /** Defines the y component of the end tangent in the bezier curve */
  85778. y2?: number);
  85779. /** @hidden */
  85780. easeInCore(gradient: number): number;
  85781. }
  85782. }
  85783. declare module BABYLON {
  85784. /**
  85785. * Class used to hold a RBG color
  85786. */
  85787. export class Color3 {
  85788. /**
  85789. * Defines the red component (between 0 and 1, default is 0)
  85790. */
  85791. r: number;
  85792. /**
  85793. * Defines the green component (between 0 and 1, default is 0)
  85794. */
  85795. g: number;
  85796. /**
  85797. * Defines the blue component (between 0 and 1, default is 0)
  85798. */
  85799. b: number;
  85800. /**
  85801. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85802. * @param r defines the red component (between 0 and 1, default is 0)
  85803. * @param g defines the green component (between 0 and 1, default is 0)
  85804. * @param b defines the blue component (between 0 and 1, default is 0)
  85805. */
  85806. constructor(
  85807. /**
  85808. * Defines the red component (between 0 and 1, default is 0)
  85809. */
  85810. r?: number,
  85811. /**
  85812. * Defines the green component (between 0 and 1, default is 0)
  85813. */
  85814. g?: number,
  85815. /**
  85816. * Defines the blue component (between 0 and 1, default is 0)
  85817. */
  85818. b?: number);
  85819. /**
  85820. * Creates a string with the Color3 current values
  85821. * @returns the string representation of the Color3 object
  85822. */
  85823. toString(): string;
  85824. /**
  85825. * Returns the string "Color3"
  85826. * @returns "Color3"
  85827. */
  85828. getClassName(): string;
  85829. /**
  85830. * Compute the Color3 hash code
  85831. * @returns an unique number that can be used to hash Color3 objects
  85832. */
  85833. getHashCode(): number;
  85834. /**
  85835. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85836. * @param array defines the array where to store the r,g,b components
  85837. * @param index defines an optional index in the target array to define where to start storing values
  85838. * @returns the current Color3 object
  85839. */
  85840. toArray(array: FloatArray, index?: number): Color3;
  85841. /**
  85842. * Update the current color with values stored in an array from the starting index of the given array
  85843. * @param array defines the source array
  85844. * @param offset defines an offset in the source array
  85845. * @returns the current Color3 object
  85846. */
  85847. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85848. /**
  85849. * Returns a new Color4 object from the current Color3 and the given alpha
  85850. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85851. * @returns a new Color4 object
  85852. */
  85853. toColor4(alpha?: number): Color4;
  85854. /**
  85855. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85856. * @returns the new array
  85857. */
  85858. asArray(): number[];
  85859. /**
  85860. * Returns the luminance value
  85861. * @returns a float value
  85862. */
  85863. toLuminance(): number;
  85864. /**
  85865. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85866. * @param otherColor defines the second operand
  85867. * @returns the new Color3 object
  85868. */
  85869. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85870. /**
  85871. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85872. * @param otherColor defines the second operand
  85873. * @param result defines the Color3 object where to store the result
  85874. * @returns the current Color3
  85875. */
  85876. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85877. /**
  85878. * Determines equality between Color3 objects
  85879. * @param otherColor defines the second operand
  85880. * @returns true if the rgb values are equal to the given ones
  85881. */
  85882. equals(otherColor: DeepImmutable<Color3>): boolean;
  85883. /**
  85884. * Determines equality between the current Color3 object and a set of r,b,g values
  85885. * @param r defines the red component to check
  85886. * @param g defines the green component to check
  85887. * @param b defines the blue component to check
  85888. * @returns true if the rgb values are equal to the given ones
  85889. */
  85890. equalsFloats(r: number, g: number, b: number): boolean;
  85891. /**
  85892. * Multiplies in place each rgb value by scale
  85893. * @param scale defines the scaling factor
  85894. * @returns the updated Color3
  85895. */
  85896. scale(scale: number): Color3;
  85897. /**
  85898. * Multiplies the rgb values by scale and stores the result into "result"
  85899. * @param scale defines the scaling factor
  85900. * @param result defines the Color3 object where to store the result
  85901. * @returns the unmodified current Color3
  85902. */
  85903. scaleToRef(scale: number, result: Color3): Color3;
  85904. /**
  85905. * Scale the current Color3 values by a factor and add the result to a given Color3
  85906. * @param scale defines the scale factor
  85907. * @param result defines color to store the result into
  85908. * @returns the unmodified current Color3
  85909. */
  85910. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85911. /**
  85912. * Clamps the rgb values by the min and max values and stores the result into "result"
  85913. * @param min defines minimum clamping value (default is 0)
  85914. * @param max defines maximum clamping value (default is 1)
  85915. * @param result defines color to store the result into
  85916. * @returns the original Color3
  85917. */
  85918. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85919. /**
  85920. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85921. * @param otherColor defines the second operand
  85922. * @returns the new Color3
  85923. */
  85924. add(otherColor: DeepImmutable<Color3>): Color3;
  85925. /**
  85926. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85927. * @param otherColor defines the second operand
  85928. * @param result defines Color3 object to store the result into
  85929. * @returns the unmodified current Color3
  85930. */
  85931. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85932. /**
  85933. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85934. * @param otherColor defines the second operand
  85935. * @returns the new Color3
  85936. */
  85937. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85938. /**
  85939. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85940. * @param otherColor defines the second operand
  85941. * @param result defines Color3 object to store the result into
  85942. * @returns the unmodified current Color3
  85943. */
  85944. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85945. /**
  85946. * Copy the current object
  85947. * @returns a new Color3 copied the current one
  85948. */
  85949. clone(): Color3;
  85950. /**
  85951. * Copies the rgb values from the source in the current Color3
  85952. * @param source defines the source Color3 object
  85953. * @returns the updated Color3 object
  85954. */
  85955. copyFrom(source: DeepImmutable<Color3>): Color3;
  85956. /**
  85957. * Updates the Color3 rgb values from the given floats
  85958. * @param r defines the red component to read from
  85959. * @param g defines the green component to read from
  85960. * @param b defines the blue component to read from
  85961. * @returns the current Color3 object
  85962. */
  85963. copyFromFloats(r: number, g: number, b: number): Color3;
  85964. /**
  85965. * Updates the Color3 rgb values from the given floats
  85966. * @param r defines the red component to read from
  85967. * @param g defines the green component to read from
  85968. * @param b defines the blue component to read from
  85969. * @returns the current Color3 object
  85970. */
  85971. set(r: number, g: number, b: number): Color3;
  85972. /**
  85973. * Compute the Color3 hexadecimal code as a string
  85974. * @returns a string containing the hexadecimal representation of the Color3 object
  85975. */
  85976. toHexString(): string;
  85977. /**
  85978. * Computes a new Color3 converted from the current one to linear space
  85979. * @returns a new Color3 object
  85980. */
  85981. toLinearSpace(): Color3;
  85982. /**
  85983. * Converts current color in rgb space to HSV values
  85984. * @returns a new color3 representing the HSV values
  85985. */
  85986. toHSV(): Color3;
  85987. /**
  85988. * Converts current color in rgb space to HSV values
  85989. * @param result defines the Color3 where to store the HSV values
  85990. */
  85991. toHSVToRef(result: Color3): void;
  85992. /**
  85993. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85994. * @param convertedColor defines the Color3 object where to store the linear space version
  85995. * @returns the unmodified Color3
  85996. */
  85997. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85998. /**
  85999. * Computes a new Color3 converted from the current one to gamma space
  86000. * @returns a new Color3 object
  86001. */
  86002. toGammaSpace(): Color3;
  86003. /**
  86004. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86005. * @param convertedColor defines the Color3 object where to store the gamma space version
  86006. * @returns the unmodified Color3
  86007. */
  86008. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86009. private static _BlackReadOnly;
  86010. /**
  86011. * Convert Hue, saturation and value to a Color3 (RGB)
  86012. * @param hue defines the hue
  86013. * @param saturation defines the saturation
  86014. * @param value defines the value
  86015. * @param result defines the Color3 where to store the RGB values
  86016. */
  86017. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86018. /**
  86019. * Creates a new Color3 from the string containing valid hexadecimal values
  86020. * @param hex defines a string containing valid hexadecimal values
  86021. * @returns a new Color3 object
  86022. */
  86023. static FromHexString(hex: string): Color3;
  86024. /**
  86025. * Creates a new Color3 from the starting index of the given array
  86026. * @param array defines the source array
  86027. * @param offset defines an offset in the source array
  86028. * @returns a new Color3 object
  86029. */
  86030. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86031. /**
  86032. * Creates a new Color3 from the starting index element of the given array
  86033. * @param array defines the source array to read from
  86034. * @param offset defines the offset in the source array
  86035. * @param result defines the target Color3 object
  86036. */
  86037. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86038. /**
  86039. * Creates a new Color3 from integer values (< 256)
  86040. * @param r defines the red component to read from (value between 0 and 255)
  86041. * @param g defines the green component to read from (value between 0 and 255)
  86042. * @param b defines the blue component to read from (value between 0 and 255)
  86043. * @returns a new Color3 object
  86044. */
  86045. static FromInts(r: number, g: number, b: number): Color3;
  86046. /**
  86047. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86048. * @param start defines the start Color3 value
  86049. * @param end defines the end Color3 value
  86050. * @param amount defines the gradient value between start and end
  86051. * @returns a new Color3 object
  86052. */
  86053. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86054. /**
  86055. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86056. * @param left defines the start value
  86057. * @param right defines the end value
  86058. * @param amount defines the gradient factor
  86059. * @param result defines the Color3 object where to store the result
  86060. */
  86061. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86062. /**
  86063. * Returns a Color3 value containing a red color
  86064. * @returns a new Color3 object
  86065. */
  86066. static Red(): Color3;
  86067. /**
  86068. * Returns a Color3 value containing a green color
  86069. * @returns a new Color3 object
  86070. */
  86071. static Green(): Color3;
  86072. /**
  86073. * Returns a Color3 value containing a blue color
  86074. * @returns a new Color3 object
  86075. */
  86076. static Blue(): Color3;
  86077. /**
  86078. * Returns a Color3 value containing a black color
  86079. * @returns a new Color3 object
  86080. */
  86081. static Black(): Color3;
  86082. /**
  86083. * Gets a Color3 value containing a black color that must not be updated
  86084. */
  86085. static get BlackReadOnly(): DeepImmutable<Color3>;
  86086. /**
  86087. * Returns a Color3 value containing a white color
  86088. * @returns a new Color3 object
  86089. */
  86090. static White(): Color3;
  86091. /**
  86092. * Returns a Color3 value containing a purple color
  86093. * @returns a new Color3 object
  86094. */
  86095. static Purple(): Color3;
  86096. /**
  86097. * Returns a Color3 value containing a magenta color
  86098. * @returns a new Color3 object
  86099. */
  86100. static Magenta(): Color3;
  86101. /**
  86102. * Returns a Color3 value containing a yellow color
  86103. * @returns a new Color3 object
  86104. */
  86105. static Yellow(): Color3;
  86106. /**
  86107. * Returns a Color3 value containing a gray color
  86108. * @returns a new Color3 object
  86109. */
  86110. static Gray(): Color3;
  86111. /**
  86112. * Returns a Color3 value containing a teal color
  86113. * @returns a new Color3 object
  86114. */
  86115. static Teal(): Color3;
  86116. /**
  86117. * Returns a Color3 value containing a random color
  86118. * @returns a new Color3 object
  86119. */
  86120. static Random(): Color3;
  86121. }
  86122. /**
  86123. * Class used to hold a RBGA color
  86124. */
  86125. export class Color4 {
  86126. /**
  86127. * Defines the red component (between 0 and 1, default is 0)
  86128. */
  86129. r: number;
  86130. /**
  86131. * Defines the green component (between 0 and 1, default is 0)
  86132. */
  86133. g: number;
  86134. /**
  86135. * Defines the blue component (between 0 and 1, default is 0)
  86136. */
  86137. b: number;
  86138. /**
  86139. * Defines the alpha component (between 0 and 1, default is 1)
  86140. */
  86141. a: number;
  86142. /**
  86143. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86144. * @param r defines the red component (between 0 and 1, default is 0)
  86145. * @param g defines the green component (between 0 and 1, default is 0)
  86146. * @param b defines the blue component (between 0 and 1, default is 0)
  86147. * @param a defines the alpha component (between 0 and 1, default is 1)
  86148. */
  86149. constructor(
  86150. /**
  86151. * Defines the red component (between 0 and 1, default is 0)
  86152. */
  86153. r?: number,
  86154. /**
  86155. * Defines the green component (between 0 and 1, default is 0)
  86156. */
  86157. g?: number,
  86158. /**
  86159. * Defines the blue component (between 0 and 1, default is 0)
  86160. */
  86161. b?: number,
  86162. /**
  86163. * Defines the alpha component (between 0 and 1, default is 1)
  86164. */
  86165. a?: number);
  86166. /**
  86167. * Adds in place the given Color4 values to the current Color4 object
  86168. * @param right defines the second operand
  86169. * @returns the current updated Color4 object
  86170. */
  86171. addInPlace(right: DeepImmutable<Color4>): Color4;
  86172. /**
  86173. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86174. * @returns the new array
  86175. */
  86176. asArray(): number[];
  86177. /**
  86178. * Stores from the starting index in the given array the Color4 successive values
  86179. * @param array defines the array where to store the r,g,b components
  86180. * @param index defines an optional index in the target array to define where to start storing values
  86181. * @returns the current Color4 object
  86182. */
  86183. toArray(array: number[], index?: number): Color4;
  86184. /**
  86185. * Update the current color with values stored in an array from the starting index of the given array
  86186. * @param array defines the source array
  86187. * @param offset defines an offset in the source array
  86188. * @returns the current Color4 object
  86189. */
  86190. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86191. /**
  86192. * Determines equality between Color4 objects
  86193. * @param otherColor defines the second operand
  86194. * @returns true if the rgba values are equal to the given ones
  86195. */
  86196. equals(otherColor: DeepImmutable<Color4>): boolean;
  86197. /**
  86198. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86199. * @param right defines the second operand
  86200. * @returns a new Color4 object
  86201. */
  86202. add(right: DeepImmutable<Color4>): Color4;
  86203. /**
  86204. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86205. * @param right defines the second operand
  86206. * @returns a new Color4 object
  86207. */
  86208. subtract(right: DeepImmutable<Color4>): Color4;
  86209. /**
  86210. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86211. * @param right defines the second operand
  86212. * @param result defines the Color4 object where to store the result
  86213. * @returns the current Color4 object
  86214. */
  86215. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86216. /**
  86217. * Creates a new Color4 with the current Color4 values multiplied by scale
  86218. * @param scale defines the scaling factor to apply
  86219. * @returns a new Color4 object
  86220. */
  86221. scale(scale: number): Color4;
  86222. /**
  86223. * Multiplies the current Color4 values by scale and stores the result in "result"
  86224. * @param scale defines the scaling factor to apply
  86225. * @param result defines the Color4 object where to store the result
  86226. * @returns the current unmodified Color4
  86227. */
  86228. scaleToRef(scale: number, result: Color4): Color4;
  86229. /**
  86230. * Scale the current Color4 values by a factor and add the result to a given Color4
  86231. * @param scale defines the scale factor
  86232. * @param result defines the Color4 object where to store the result
  86233. * @returns the unmodified current Color4
  86234. */
  86235. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86236. /**
  86237. * Clamps the rgb values by the min and max values and stores the result into "result"
  86238. * @param min defines minimum clamping value (default is 0)
  86239. * @param max defines maximum clamping value (default is 1)
  86240. * @param result defines color to store the result into.
  86241. * @returns the cuurent Color4
  86242. */
  86243. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86244. /**
  86245. * Multipy an Color4 value by another and return a new Color4 object
  86246. * @param color defines the Color4 value to multiply by
  86247. * @returns a new Color4 object
  86248. */
  86249. multiply(color: Color4): Color4;
  86250. /**
  86251. * Multipy a Color4 value by another and push the result in a reference value
  86252. * @param color defines the Color4 value to multiply by
  86253. * @param result defines the Color4 to fill the result in
  86254. * @returns the result Color4
  86255. */
  86256. multiplyToRef(color: Color4, result: Color4): Color4;
  86257. /**
  86258. * Creates a string with the Color4 current values
  86259. * @returns the string representation of the Color4 object
  86260. */
  86261. toString(): string;
  86262. /**
  86263. * Returns the string "Color4"
  86264. * @returns "Color4"
  86265. */
  86266. getClassName(): string;
  86267. /**
  86268. * Compute the Color4 hash code
  86269. * @returns an unique number that can be used to hash Color4 objects
  86270. */
  86271. getHashCode(): number;
  86272. /**
  86273. * Creates a new Color4 copied from the current one
  86274. * @returns a new Color4 object
  86275. */
  86276. clone(): Color4;
  86277. /**
  86278. * Copies the given Color4 values into the current one
  86279. * @param source defines the source Color4 object
  86280. * @returns the current updated Color4 object
  86281. */
  86282. copyFrom(source: Color4): Color4;
  86283. /**
  86284. * Copies the given float values into the current one
  86285. * @param r defines the red component to read from
  86286. * @param g defines the green component to read from
  86287. * @param b defines the blue component to read from
  86288. * @param a defines the alpha component to read from
  86289. * @returns the current updated Color4 object
  86290. */
  86291. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86292. /**
  86293. * Copies the given float values into the current one
  86294. * @param r defines the red component to read from
  86295. * @param g defines the green component to read from
  86296. * @param b defines the blue component to read from
  86297. * @param a defines the alpha component to read from
  86298. * @returns the current updated Color4 object
  86299. */
  86300. set(r: number, g: number, b: number, a: number): Color4;
  86301. /**
  86302. * Compute the Color4 hexadecimal code as a string
  86303. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86304. * @returns a string containing the hexadecimal representation of the Color4 object
  86305. */
  86306. toHexString(returnAsColor3?: boolean): string;
  86307. /**
  86308. * Computes a new Color4 converted from the current one to linear space
  86309. * @returns a new Color4 object
  86310. */
  86311. toLinearSpace(): Color4;
  86312. /**
  86313. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86314. * @param convertedColor defines the Color4 object where to store the linear space version
  86315. * @returns the unmodified Color4
  86316. */
  86317. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86318. /**
  86319. * Computes a new Color4 converted from the current one to gamma space
  86320. * @returns a new Color4 object
  86321. */
  86322. toGammaSpace(): Color4;
  86323. /**
  86324. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86325. * @param convertedColor defines the Color4 object where to store the gamma space version
  86326. * @returns the unmodified Color4
  86327. */
  86328. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86329. /**
  86330. * Creates a new Color4 from the string containing valid hexadecimal values
  86331. * @param hex defines a string containing valid hexadecimal values
  86332. * @returns a new Color4 object
  86333. */
  86334. static FromHexString(hex: string): Color4;
  86335. /**
  86336. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86337. * @param left defines the start value
  86338. * @param right defines the end value
  86339. * @param amount defines the gradient factor
  86340. * @returns a new Color4 object
  86341. */
  86342. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86343. /**
  86344. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86345. * @param left defines the start value
  86346. * @param right defines the end value
  86347. * @param amount defines the gradient factor
  86348. * @param result defines the Color4 object where to store data
  86349. */
  86350. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86351. /**
  86352. * Creates a new Color4 from a Color3 and an alpha value
  86353. * @param color3 defines the source Color3 to read from
  86354. * @param alpha defines the alpha component (1.0 by default)
  86355. * @returns a new Color4 object
  86356. */
  86357. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86358. /**
  86359. * Creates a new Color4 from the starting index element of the given array
  86360. * @param array defines the source array to read from
  86361. * @param offset defines the offset in the source array
  86362. * @returns a new Color4 object
  86363. */
  86364. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86365. /**
  86366. * Creates a new Color4 from the starting index element of the given array
  86367. * @param array defines the source array to read from
  86368. * @param offset defines the offset in the source array
  86369. * @param result defines the target Color4 object
  86370. */
  86371. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86372. /**
  86373. * Creates a new Color3 from integer values (< 256)
  86374. * @param r defines the red component to read from (value between 0 and 255)
  86375. * @param g defines the green component to read from (value between 0 and 255)
  86376. * @param b defines the blue component to read from (value between 0 and 255)
  86377. * @param a defines the alpha component to read from (value between 0 and 255)
  86378. * @returns a new Color3 object
  86379. */
  86380. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86381. /**
  86382. * Check the content of a given array and convert it to an array containing RGBA data
  86383. * If the original array was already containing count * 4 values then it is returned directly
  86384. * @param colors defines the array to check
  86385. * @param count defines the number of RGBA data to expect
  86386. * @returns an array containing count * 4 values (RGBA)
  86387. */
  86388. static CheckColors4(colors: number[], count: number): number[];
  86389. }
  86390. /**
  86391. * @hidden
  86392. */
  86393. export class TmpColors {
  86394. static Color3: Color3[];
  86395. static Color4: Color4[];
  86396. }
  86397. }
  86398. declare module BABYLON {
  86399. /**
  86400. * Defines an interface which represents an animation key frame
  86401. */
  86402. export interface IAnimationKey {
  86403. /**
  86404. * Frame of the key frame
  86405. */
  86406. frame: number;
  86407. /**
  86408. * Value at the specifies key frame
  86409. */
  86410. value: any;
  86411. /**
  86412. * The input tangent for the cubic hermite spline
  86413. */
  86414. inTangent?: any;
  86415. /**
  86416. * The output tangent for the cubic hermite spline
  86417. */
  86418. outTangent?: any;
  86419. /**
  86420. * The animation interpolation type
  86421. */
  86422. interpolation?: AnimationKeyInterpolation;
  86423. }
  86424. /**
  86425. * Enum for the animation key frame interpolation type
  86426. */
  86427. export enum AnimationKeyInterpolation {
  86428. /**
  86429. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86430. */
  86431. STEP = 1
  86432. }
  86433. }
  86434. declare module BABYLON {
  86435. /**
  86436. * Represents the range of an animation
  86437. */
  86438. export class AnimationRange {
  86439. /**The name of the animation range**/
  86440. name: string;
  86441. /**The starting frame of the animation */
  86442. from: number;
  86443. /**The ending frame of the animation*/
  86444. to: number;
  86445. /**
  86446. * Initializes the range of an animation
  86447. * @param name The name of the animation range
  86448. * @param from The starting frame of the animation
  86449. * @param to The ending frame of the animation
  86450. */
  86451. constructor(
  86452. /**The name of the animation range**/
  86453. name: string,
  86454. /**The starting frame of the animation */
  86455. from: number,
  86456. /**The ending frame of the animation*/
  86457. to: number);
  86458. /**
  86459. * Makes a copy of the animation range
  86460. * @returns A copy of the animation range
  86461. */
  86462. clone(): AnimationRange;
  86463. }
  86464. }
  86465. declare module BABYLON {
  86466. /**
  86467. * Composed of a frame, and an action function
  86468. */
  86469. export class AnimationEvent {
  86470. /** The frame for which the event is triggered **/
  86471. frame: number;
  86472. /** The event to perform when triggered **/
  86473. action: (currentFrame: number) => void;
  86474. /** Specifies if the event should be triggered only once**/
  86475. onlyOnce?: boolean | undefined;
  86476. /**
  86477. * Specifies if the animation event is done
  86478. */
  86479. isDone: boolean;
  86480. /**
  86481. * Initializes the animation event
  86482. * @param frame The frame for which the event is triggered
  86483. * @param action The event to perform when triggered
  86484. * @param onlyOnce Specifies if the event should be triggered only once
  86485. */
  86486. constructor(
  86487. /** The frame for which the event is triggered **/
  86488. frame: number,
  86489. /** The event to perform when triggered **/
  86490. action: (currentFrame: number) => void,
  86491. /** Specifies if the event should be triggered only once**/
  86492. onlyOnce?: boolean | undefined);
  86493. /** @hidden */
  86494. _clone(): AnimationEvent;
  86495. }
  86496. }
  86497. declare module BABYLON {
  86498. /**
  86499. * Interface used to define a behavior
  86500. */
  86501. export interface Behavior<T> {
  86502. /** gets or sets behavior's name */
  86503. name: string;
  86504. /**
  86505. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86506. */
  86507. init(): void;
  86508. /**
  86509. * Called when the behavior is attached to a target
  86510. * @param target defines the target where the behavior is attached to
  86511. */
  86512. attach(target: T): void;
  86513. /**
  86514. * Called when the behavior is detached from its target
  86515. */
  86516. detach(): void;
  86517. }
  86518. /**
  86519. * Interface implemented by classes supporting behaviors
  86520. */
  86521. export interface IBehaviorAware<T> {
  86522. /**
  86523. * Attach a behavior
  86524. * @param behavior defines the behavior to attach
  86525. * @returns the current host
  86526. */
  86527. addBehavior(behavior: Behavior<T>): T;
  86528. /**
  86529. * Remove a behavior from the current object
  86530. * @param behavior defines the behavior to detach
  86531. * @returns the current host
  86532. */
  86533. removeBehavior(behavior: Behavior<T>): T;
  86534. /**
  86535. * Gets a behavior using its name to search
  86536. * @param name defines the name to search
  86537. * @returns the behavior or null if not found
  86538. */
  86539. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86540. }
  86541. }
  86542. declare module BABYLON {
  86543. /**
  86544. * Defines an array and its length.
  86545. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86546. */
  86547. export interface ISmartArrayLike<T> {
  86548. /**
  86549. * The data of the array.
  86550. */
  86551. data: Array<T>;
  86552. /**
  86553. * The active length of the array.
  86554. */
  86555. length: number;
  86556. }
  86557. /**
  86558. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86559. */
  86560. export class SmartArray<T> implements ISmartArrayLike<T> {
  86561. /**
  86562. * The full set of data from the array.
  86563. */
  86564. data: Array<T>;
  86565. /**
  86566. * The active length of the array.
  86567. */
  86568. length: number;
  86569. protected _id: number;
  86570. /**
  86571. * Instantiates a Smart Array.
  86572. * @param capacity defines the default capacity of the array.
  86573. */
  86574. constructor(capacity: number);
  86575. /**
  86576. * Pushes a value at the end of the active data.
  86577. * @param value defines the object to push in the array.
  86578. */
  86579. push(value: T): void;
  86580. /**
  86581. * Iterates over the active data and apply the lambda to them.
  86582. * @param func defines the action to apply on each value.
  86583. */
  86584. forEach(func: (content: T) => void): void;
  86585. /**
  86586. * Sorts the full sets of data.
  86587. * @param compareFn defines the comparison function to apply.
  86588. */
  86589. sort(compareFn: (a: T, b: T) => number): void;
  86590. /**
  86591. * Resets the active data to an empty array.
  86592. */
  86593. reset(): void;
  86594. /**
  86595. * Releases all the data from the array as well as the array.
  86596. */
  86597. dispose(): void;
  86598. /**
  86599. * Concats the active data with a given array.
  86600. * @param array defines the data to concatenate with.
  86601. */
  86602. concat(array: any): void;
  86603. /**
  86604. * Returns the position of a value in the active data.
  86605. * @param value defines the value to find the index for
  86606. * @returns the index if found in the active data otherwise -1
  86607. */
  86608. indexOf(value: T): number;
  86609. /**
  86610. * Returns whether an element is part of the active data.
  86611. * @param value defines the value to look for
  86612. * @returns true if found in the active data otherwise false
  86613. */
  86614. contains(value: T): boolean;
  86615. private static _GlobalId;
  86616. }
  86617. /**
  86618. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86619. * The data in this array can only be present once
  86620. */
  86621. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86622. private _duplicateId;
  86623. /**
  86624. * Pushes a value at the end of the active data.
  86625. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86626. * @param value defines the object to push in the array.
  86627. */
  86628. push(value: T): void;
  86629. /**
  86630. * Pushes a value at the end of the active data.
  86631. * If the data is already present, it won t be added again
  86632. * @param value defines the object to push in the array.
  86633. * @returns true if added false if it was already present
  86634. */
  86635. pushNoDuplicate(value: T): boolean;
  86636. /**
  86637. * Resets the active data to an empty array.
  86638. */
  86639. reset(): void;
  86640. /**
  86641. * Concats the active data with a given array.
  86642. * This ensures no dupplicate will be present in the result.
  86643. * @param array defines the data to concatenate with.
  86644. */
  86645. concatWithNoDuplicate(array: any): void;
  86646. }
  86647. }
  86648. declare module BABYLON {
  86649. /**
  86650. * @ignore
  86651. * This is a list of all the different input types that are available in the application.
  86652. * Fo instance: ArcRotateCameraGamepadInput...
  86653. */
  86654. export var CameraInputTypes: {};
  86655. /**
  86656. * This is the contract to implement in order to create a new input class.
  86657. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86658. */
  86659. export interface ICameraInput<TCamera extends Camera> {
  86660. /**
  86661. * Defines the camera the input is attached to.
  86662. */
  86663. camera: Nullable<TCamera>;
  86664. /**
  86665. * Gets the class name of the current intput.
  86666. * @returns the class name
  86667. */
  86668. getClassName(): string;
  86669. /**
  86670. * Get the friendly name associated with the input class.
  86671. * @returns the input friendly name
  86672. */
  86673. getSimpleName(): string;
  86674. /**
  86675. * Attach the input controls to a specific dom element to get the input from.
  86676. * @param element Defines the element the controls should be listened from
  86677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86678. */
  86679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86680. /**
  86681. * Detach the current controls from the specified dom element.
  86682. * @param element Defines the element to stop listening the inputs from
  86683. */
  86684. detachControl(element: Nullable<HTMLElement>): void;
  86685. /**
  86686. * Update the current camera state depending on the inputs that have been used this frame.
  86687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86688. */
  86689. checkInputs?: () => void;
  86690. }
  86691. /**
  86692. * Represents a map of input types to input instance or input index to input instance.
  86693. */
  86694. export interface CameraInputsMap<TCamera extends Camera> {
  86695. /**
  86696. * Accessor to the input by input type.
  86697. */
  86698. [name: string]: ICameraInput<TCamera>;
  86699. /**
  86700. * Accessor to the input by input index.
  86701. */
  86702. [idx: number]: ICameraInput<TCamera>;
  86703. }
  86704. /**
  86705. * This represents the input manager used within a camera.
  86706. * It helps dealing with all the different kind of input attached to a camera.
  86707. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86708. */
  86709. export class CameraInputsManager<TCamera extends Camera> {
  86710. /**
  86711. * Defines the list of inputs attahed to the camera.
  86712. */
  86713. attached: CameraInputsMap<TCamera>;
  86714. /**
  86715. * Defines the dom element the camera is collecting inputs from.
  86716. * This is null if the controls have not been attached.
  86717. */
  86718. attachedElement: Nullable<HTMLElement>;
  86719. /**
  86720. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86721. */
  86722. noPreventDefault: boolean;
  86723. /**
  86724. * Defined the camera the input manager belongs to.
  86725. */
  86726. camera: TCamera;
  86727. /**
  86728. * Update the current camera state depending on the inputs that have been used this frame.
  86729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86730. */
  86731. checkInputs: () => void;
  86732. /**
  86733. * Instantiate a new Camera Input Manager.
  86734. * @param camera Defines the camera the input manager blongs to
  86735. */
  86736. constructor(camera: TCamera);
  86737. /**
  86738. * Add an input method to a camera
  86739. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86740. * @param input camera input method
  86741. */
  86742. add(input: ICameraInput<TCamera>): void;
  86743. /**
  86744. * Remove a specific input method from a camera
  86745. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86746. * @param inputToRemove camera input method
  86747. */
  86748. remove(inputToRemove: ICameraInput<TCamera>): void;
  86749. /**
  86750. * Remove a specific input type from a camera
  86751. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86752. * @param inputType the type of the input to remove
  86753. */
  86754. removeByType(inputType: string): void;
  86755. private _addCheckInputs;
  86756. /**
  86757. * Attach the input controls to the currently attached dom element to listen the events from.
  86758. * @param input Defines the input to attach
  86759. */
  86760. attachInput(input: ICameraInput<TCamera>): void;
  86761. /**
  86762. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86763. * @param element Defines the dom element to collect the events from
  86764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86765. */
  86766. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86767. /**
  86768. * Detach the current manager inputs controls from a specific dom element.
  86769. * @param element Defines the dom element to collect the events from
  86770. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86771. */
  86772. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86773. /**
  86774. * Rebuild the dynamic inputCheck function from the current list of
  86775. * defined inputs in the manager.
  86776. */
  86777. rebuildInputCheck(): void;
  86778. /**
  86779. * Remove all attached input methods from a camera
  86780. */
  86781. clear(): void;
  86782. /**
  86783. * Serialize the current input manager attached to a camera.
  86784. * This ensures than once parsed,
  86785. * the input associated to the camera will be identical to the current ones
  86786. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86787. */
  86788. serialize(serializedCamera: any): void;
  86789. /**
  86790. * Parses an input manager serialized JSON to restore the previous list of inputs
  86791. * and states associated to a camera.
  86792. * @param parsedCamera Defines the JSON to parse
  86793. */
  86794. parse(parsedCamera: any): void;
  86795. }
  86796. }
  86797. declare module BABYLON {
  86798. /**
  86799. * Class used to store data that will be store in GPU memory
  86800. */
  86801. export class Buffer {
  86802. private _engine;
  86803. private _buffer;
  86804. /** @hidden */
  86805. _data: Nullable<DataArray>;
  86806. private _updatable;
  86807. private _instanced;
  86808. private _divisor;
  86809. /**
  86810. * Gets the byte stride.
  86811. */
  86812. readonly byteStride: number;
  86813. /**
  86814. * Constructor
  86815. * @param engine the engine
  86816. * @param data the data to use for this buffer
  86817. * @param updatable whether the data is updatable
  86818. * @param stride the stride (optional)
  86819. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86820. * @param instanced whether the buffer is instanced (optional)
  86821. * @param useBytes set to true if the stride in in bytes (optional)
  86822. * @param divisor sets an optional divisor for instances (1 by default)
  86823. */
  86824. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86825. /**
  86826. * Create a new VertexBuffer based on the current buffer
  86827. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86828. * @param offset defines offset in the buffer (0 by default)
  86829. * @param size defines the size in floats of attributes (position is 3 for instance)
  86830. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86831. * @param instanced defines if the vertex buffer contains indexed data
  86832. * @param useBytes defines if the offset and stride are in bytes *
  86833. * @param divisor sets an optional divisor for instances (1 by default)
  86834. * @returns the new vertex buffer
  86835. */
  86836. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86837. /**
  86838. * Gets a boolean indicating if the Buffer is updatable?
  86839. * @returns true if the buffer is updatable
  86840. */
  86841. isUpdatable(): boolean;
  86842. /**
  86843. * Gets current buffer's data
  86844. * @returns a DataArray or null
  86845. */
  86846. getData(): Nullable<DataArray>;
  86847. /**
  86848. * Gets underlying native buffer
  86849. * @returns underlying native buffer
  86850. */
  86851. getBuffer(): Nullable<DataBuffer>;
  86852. /**
  86853. * Gets the stride in float32 units (i.e. byte stride / 4).
  86854. * May not be an integer if the byte stride is not divisible by 4.
  86855. * @returns the stride in float32 units
  86856. * @deprecated Please use byteStride instead.
  86857. */
  86858. getStrideSize(): number;
  86859. /**
  86860. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86861. * @param data defines the data to store
  86862. */
  86863. create(data?: Nullable<DataArray>): void;
  86864. /** @hidden */
  86865. _rebuild(): void;
  86866. /**
  86867. * Update current buffer data
  86868. * @param data defines the data to store
  86869. */
  86870. update(data: DataArray): void;
  86871. /**
  86872. * Updates the data directly.
  86873. * @param data the new data
  86874. * @param offset the new offset
  86875. * @param vertexCount the vertex count (optional)
  86876. * @param useBytes set to true if the offset is in bytes
  86877. */
  86878. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86879. /**
  86880. * Release all resources
  86881. */
  86882. dispose(): void;
  86883. }
  86884. /**
  86885. * Specialized buffer used to store vertex data
  86886. */
  86887. export class VertexBuffer {
  86888. /** @hidden */
  86889. _buffer: Buffer;
  86890. private _kind;
  86891. private _size;
  86892. private _ownsBuffer;
  86893. private _instanced;
  86894. private _instanceDivisor;
  86895. /**
  86896. * The byte type.
  86897. */
  86898. static readonly BYTE: number;
  86899. /**
  86900. * The unsigned byte type.
  86901. */
  86902. static readonly UNSIGNED_BYTE: number;
  86903. /**
  86904. * The short type.
  86905. */
  86906. static readonly SHORT: number;
  86907. /**
  86908. * The unsigned short type.
  86909. */
  86910. static readonly UNSIGNED_SHORT: number;
  86911. /**
  86912. * The integer type.
  86913. */
  86914. static readonly INT: number;
  86915. /**
  86916. * The unsigned integer type.
  86917. */
  86918. static readonly UNSIGNED_INT: number;
  86919. /**
  86920. * The float type.
  86921. */
  86922. static readonly FLOAT: number;
  86923. /**
  86924. * Gets or sets the instance divisor when in instanced mode
  86925. */
  86926. get instanceDivisor(): number;
  86927. set instanceDivisor(value: number);
  86928. /**
  86929. * Gets the byte stride.
  86930. */
  86931. readonly byteStride: number;
  86932. /**
  86933. * Gets the byte offset.
  86934. */
  86935. readonly byteOffset: number;
  86936. /**
  86937. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86938. */
  86939. readonly normalized: boolean;
  86940. /**
  86941. * Gets the data type of each component in the array.
  86942. */
  86943. readonly type: number;
  86944. /**
  86945. * Constructor
  86946. * @param engine the engine
  86947. * @param data the data to use for this vertex buffer
  86948. * @param kind the vertex buffer kind
  86949. * @param updatable whether the data is updatable
  86950. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86951. * @param stride the stride (optional)
  86952. * @param instanced whether the buffer is instanced (optional)
  86953. * @param offset the offset of the data (optional)
  86954. * @param size the number of components (optional)
  86955. * @param type the type of the component (optional)
  86956. * @param normalized whether the data contains normalized data (optional)
  86957. * @param useBytes set to true if stride and offset are in bytes (optional)
  86958. * @param divisor defines the instance divisor to use (1 by default)
  86959. */
  86960. 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);
  86961. /** @hidden */
  86962. _rebuild(): void;
  86963. /**
  86964. * Returns the kind of the VertexBuffer (string)
  86965. * @returns a string
  86966. */
  86967. getKind(): string;
  86968. /**
  86969. * Gets a boolean indicating if the VertexBuffer is updatable?
  86970. * @returns true if the buffer is updatable
  86971. */
  86972. isUpdatable(): boolean;
  86973. /**
  86974. * Gets current buffer's data
  86975. * @returns a DataArray or null
  86976. */
  86977. getData(): Nullable<DataArray>;
  86978. /**
  86979. * Gets underlying native buffer
  86980. * @returns underlying native buffer
  86981. */
  86982. getBuffer(): Nullable<DataBuffer>;
  86983. /**
  86984. * Gets the stride in float32 units (i.e. byte stride / 4).
  86985. * May not be an integer if the byte stride is not divisible by 4.
  86986. * @returns the stride in float32 units
  86987. * @deprecated Please use byteStride instead.
  86988. */
  86989. getStrideSize(): number;
  86990. /**
  86991. * Returns the offset as a multiple of the type byte length.
  86992. * @returns the offset in bytes
  86993. * @deprecated Please use byteOffset instead.
  86994. */
  86995. getOffset(): number;
  86996. /**
  86997. * Returns the number of components per vertex attribute (integer)
  86998. * @returns the size in float
  86999. */
  87000. getSize(): number;
  87001. /**
  87002. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87003. * @returns true if this buffer is instanced
  87004. */
  87005. getIsInstanced(): boolean;
  87006. /**
  87007. * Returns the instancing divisor, zero for non-instanced (integer).
  87008. * @returns a number
  87009. */
  87010. getInstanceDivisor(): number;
  87011. /**
  87012. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87013. * @param data defines the data to store
  87014. */
  87015. create(data?: DataArray): void;
  87016. /**
  87017. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87018. * This function will create a new buffer if the current one is not updatable
  87019. * @param data defines the data to store
  87020. */
  87021. update(data: DataArray): void;
  87022. /**
  87023. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87024. * Returns the directly updated WebGLBuffer.
  87025. * @param data the new data
  87026. * @param offset the new offset
  87027. * @param useBytes set to true if the offset is in bytes
  87028. */
  87029. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87030. /**
  87031. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87032. */
  87033. dispose(): void;
  87034. /**
  87035. * Enumerates each value of this vertex buffer as numbers.
  87036. * @param count the number of values to enumerate
  87037. * @param callback the callback function called for each value
  87038. */
  87039. forEach(count: number, callback: (value: number, index: number) => void): void;
  87040. /**
  87041. * Positions
  87042. */
  87043. static readonly PositionKind: string;
  87044. /**
  87045. * Normals
  87046. */
  87047. static readonly NormalKind: string;
  87048. /**
  87049. * Tangents
  87050. */
  87051. static readonly TangentKind: string;
  87052. /**
  87053. * Texture coordinates
  87054. */
  87055. static readonly UVKind: string;
  87056. /**
  87057. * Texture coordinates 2
  87058. */
  87059. static readonly UV2Kind: string;
  87060. /**
  87061. * Texture coordinates 3
  87062. */
  87063. static readonly UV3Kind: string;
  87064. /**
  87065. * Texture coordinates 4
  87066. */
  87067. static readonly UV4Kind: string;
  87068. /**
  87069. * Texture coordinates 5
  87070. */
  87071. static readonly UV5Kind: string;
  87072. /**
  87073. * Texture coordinates 6
  87074. */
  87075. static readonly UV6Kind: string;
  87076. /**
  87077. * Colors
  87078. */
  87079. static readonly ColorKind: string;
  87080. /**
  87081. * Matrix indices (for bones)
  87082. */
  87083. static readonly MatricesIndicesKind: string;
  87084. /**
  87085. * Matrix weights (for bones)
  87086. */
  87087. static readonly MatricesWeightsKind: string;
  87088. /**
  87089. * Additional matrix indices (for bones)
  87090. */
  87091. static readonly MatricesIndicesExtraKind: string;
  87092. /**
  87093. * Additional matrix weights (for bones)
  87094. */
  87095. static readonly MatricesWeightsExtraKind: string;
  87096. /**
  87097. * Deduces the stride given a kind.
  87098. * @param kind The kind string to deduce
  87099. * @returns The deduced stride
  87100. */
  87101. static DeduceStride(kind: string): number;
  87102. /**
  87103. * Gets the byte length of the given type.
  87104. * @param type the type
  87105. * @returns the number of bytes
  87106. */
  87107. static GetTypeByteLength(type: number): number;
  87108. /**
  87109. * Enumerates each value of the given parameters as numbers.
  87110. * @param data the data to enumerate
  87111. * @param byteOffset the byte offset of the data
  87112. * @param byteStride the byte stride of the data
  87113. * @param componentCount the number of components per element
  87114. * @param componentType the type of the component
  87115. * @param count the number of values to enumerate
  87116. * @param normalized whether the data is normalized
  87117. * @param callback the callback function called for each value
  87118. */
  87119. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87120. private static _GetFloatValue;
  87121. }
  87122. }
  87123. declare module BABYLON {
  87124. /**
  87125. * The options Interface for creating a Capsule Mesh
  87126. */
  87127. export interface ICreateCapsuleOptions {
  87128. /** The Orientation of the capsule. Default : Vector3.Up() */
  87129. orientation?: Vector3;
  87130. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87131. subdivisions: number;
  87132. /** Number of cylindrical segments on the capsule. */
  87133. tessellation: number;
  87134. /** Height or Length of the capsule. */
  87135. height: number;
  87136. /** Radius of the capsule. */
  87137. radius: number;
  87138. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87139. capSubdivisions: number;
  87140. /** Overwrite for the top radius. */
  87141. radiusTop?: number;
  87142. /** Overwrite for the bottom radius. */
  87143. radiusBottom?: number;
  87144. /** Overwrite for the top capSubdivisions. */
  87145. topCapSubdivisions?: number;
  87146. /** Overwrite for the bottom capSubdivisions. */
  87147. bottomCapSubdivisions?: number;
  87148. }
  87149. /**
  87150. * Class containing static functions to help procedurally build meshes
  87151. */
  87152. export class CapsuleBuilder {
  87153. /**
  87154. * Creates a capsule or a pill mesh
  87155. * @param name defines the name of the mesh
  87156. * @param options The constructors options.
  87157. * @param scene The scene the mesh is scoped to.
  87158. * @returns Capsule Mesh
  87159. */
  87160. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87161. }
  87162. }
  87163. declare module BABYLON {
  87164. /**
  87165. * @hidden
  87166. */
  87167. export class IntersectionInfo {
  87168. bu: Nullable<number>;
  87169. bv: Nullable<number>;
  87170. distance: number;
  87171. faceId: number;
  87172. subMeshId: number;
  87173. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87174. }
  87175. }
  87176. declare module BABYLON {
  87177. /**
  87178. * Class used to store bounding sphere information
  87179. */
  87180. export class BoundingSphere {
  87181. /**
  87182. * Gets the center of the bounding sphere in local space
  87183. */
  87184. readonly center: Vector3;
  87185. /**
  87186. * Radius of the bounding sphere in local space
  87187. */
  87188. radius: number;
  87189. /**
  87190. * Gets the center of the bounding sphere in world space
  87191. */
  87192. readonly centerWorld: Vector3;
  87193. /**
  87194. * Radius of the bounding sphere in world space
  87195. */
  87196. radiusWorld: number;
  87197. /**
  87198. * Gets the minimum vector in local space
  87199. */
  87200. readonly minimum: Vector3;
  87201. /**
  87202. * Gets the maximum vector in local space
  87203. */
  87204. readonly maximum: Vector3;
  87205. private _worldMatrix;
  87206. private static readonly TmpVector3;
  87207. /**
  87208. * Creates a new bounding sphere
  87209. * @param min defines the minimum vector (in local space)
  87210. * @param max defines the maximum vector (in local space)
  87211. * @param worldMatrix defines the new world matrix
  87212. */
  87213. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87214. /**
  87215. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87216. * @param min defines the new minimum vector (in local space)
  87217. * @param max defines the new maximum vector (in local space)
  87218. * @param worldMatrix defines the new world matrix
  87219. */
  87220. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87221. /**
  87222. * Scale the current bounding sphere by applying a scale factor
  87223. * @param factor defines the scale factor to apply
  87224. * @returns the current bounding box
  87225. */
  87226. scale(factor: number): BoundingSphere;
  87227. /**
  87228. * Gets the world matrix of the bounding box
  87229. * @returns a matrix
  87230. */
  87231. getWorldMatrix(): DeepImmutable<Matrix>;
  87232. /** @hidden */
  87233. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87234. /**
  87235. * Tests if the bounding sphere is intersecting the frustum planes
  87236. * @param frustumPlanes defines the frustum planes to test
  87237. * @returns true if there is an intersection
  87238. */
  87239. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87240. /**
  87241. * Tests if the bounding sphere center is in between the frustum planes.
  87242. * Used for optimistic fast inclusion.
  87243. * @param frustumPlanes defines the frustum planes to test
  87244. * @returns true if the sphere center is in between the frustum planes
  87245. */
  87246. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87247. /**
  87248. * Tests if a point is inside the bounding sphere
  87249. * @param point defines the point to test
  87250. * @returns true if the point is inside the bounding sphere
  87251. */
  87252. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87253. /**
  87254. * Checks if two sphere intersct
  87255. * @param sphere0 sphere 0
  87256. * @param sphere1 sphere 1
  87257. * @returns true if the speres intersect
  87258. */
  87259. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87260. }
  87261. }
  87262. declare module BABYLON {
  87263. /**
  87264. * Class used to store bounding box information
  87265. */
  87266. export class BoundingBox implements ICullable {
  87267. /**
  87268. * Gets the 8 vectors representing the bounding box in local space
  87269. */
  87270. readonly vectors: Vector3[];
  87271. /**
  87272. * Gets the center of the bounding box in local space
  87273. */
  87274. readonly center: Vector3;
  87275. /**
  87276. * Gets the center of the bounding box in world space
  87277. */
  87278. readonly centerWorld: Vector3;
  87279. /**
  87280. * Gets the extend size in local space
  87281. */
  87282. readonly extendSize: Vector3;
  87283. /**
  87284. * Gets the extend size in world space
  87285. */
  87286. readonly extendSizeWorld: Vector3;
  87287. /**
  87288. * Gets the OBB (object bounding box) directions
  87289. */
  87290. readonly directions: Vector3[];
  87291. /**
  87292. * Gets the 8 vectors representing the bounding box in world space
  87293. */
  87294. readonly vectorsWorld: Vector3[];
  87295. /**
  87296. * Gets the minimum vector in world space
  87297. */
  87298. readonly minimumWorld: Vector3;
  87299. /**
  87300. * Gets the maximum vector in world space
  87301. */
  87302. readonly maximumWorld: Vector3;
  87303. /**
  87304. * Gets the minimum vector in local space
  87305. */
  87306. readonly minimum: Vector3;
  87307. /**
  87308. * Gets the maximum vector in local space
  87309. */
  87310. readonly maximum: Vector3;
  87311. private _worldMatrix;
  87312. private static readonly TmpVector3;
  87313. /**
  87314. * @hidden
  87315. */
  87316. _tag: number;
  87317. /**
  87318. * Creates a new bounding box
  87319. * @param min defines the minimum vector (in local space)
  87320. * @param max defines the maximum vector (in local space)
  87321. * @param worldMatrix defines the new world matrix
  87322. */
  87323. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87324. /**
  87325. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87326. * @param min defines the new minimum vector (in local space)
  87327. * @param max defines the new maximum vector (in local space)
  87328. * @param worldMatrix defines the new world matrix
  87329. */
  87330. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87331. /**
  87332. * Scale the current bounding box by applying a scale factor
  87333. * @param factor defines the scale factor to apply
  87334. * @returns the current bounding box
  87335. */
  87336. scale(factor: number): BoundingBox;
  87337. /**
  87338. * Gets the world matrix of the bounding box
  87339. * @returns a matrix
  87340. */
  87341. getWorldMatrix(): DeepImmutable<Matrix>;
  87342. /** @hidden */
  87343. _update(world: DeepImmutable<Matrix>): void;
  87344. /**
  87345. * Tests if the bounding box is intersecting the frustum planes
  87346. * @param frustumPlanes defines the frustum planes to test
  87347. * @returns true if there is an intersection
  87348. */
  87349. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87350. /**
  87351. * Tests if the bounding box is entirely inside the frustum planes
  87352. * @param frustumPlanes defines the frustum planes to test
  87353. * @returns true if there is an inclusion
  87354. */
  87355. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87356. /**
  87357. * Tests if a point is inside the bounding box
  87358. * @param point defines the point to test
  87359. * @returns true if the point is inside the bounding box
  87360. */
  87361. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87362. /**
  87363. * Tests if the bounding box intersects with a bounding sphere
  87364. * @param sphere defines the sphere to test
  87365. * @returns true if there is an intersection
  87366. */
  87367. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87368. /**
  87369. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87370. * @param min defines the min vector to use
  87371. * @param max defines the max vector to use
  87372. * @returns true if there is an intersection
  87373. */
  87374. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87375. /**
  87376. * Tests if two bounding boxes are intersections
  87377. * @param box0 defines the first box to test
  87378. * @param box1 defines the second box to test
  87379. * @returns true if there is an intersection
  87380. */
  87381. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87382. /**
  87383. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87384. * @param minPoint defines the minimum vector of the bounding box
  87385. * @param maxPoint defines the maximum vector of the bounding box
  87386. * @param sphereCenter defines the sphere center
  87387. * @param sphereRadius defines the sphere radius
  87388. * @returns true if there is an intersection
  87389. */
  87390. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87391. /**
  87392. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87393. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87394. * @param frustumPlanes defines the frustum planes to test
  87395. * @return true if there is an inclusion
  87396. */
  87397. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87398. /**
  87399. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87400. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87401. * @param frustumPlanes defines the frustum planes to test
  87402. * @return true if there is an intersection
  87403. */
  87404. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87405. }
  87406. }
  87407. declare module BABYLON {
  87408. /** @hidden */
  87409. export class Collider {
  87410. /** Define if a collision was found */
  87411. collisionFound: boolean;
  87412. /**
  87413. * Define last intersection point in local space
  87414. */
  87415. intersectionPoint: Vector3;
  87416. /**
  87417. * Define last collided mesh
  87418. */
  87419. collidedMesh: Nullable<AbstractMesh>;
  87420. private _collisionPoint;
  87421. private _planeIntersectionPoint;
  87422. private _tempVector;
  87423. private _tempVector2;
  87424. private _tempVector3;
  87425. private _tempVector4;
  87426. private _edge;
  87427. private _baseToVertex;
  87428. private _destinationPoint;
  87429. private _slidePlaneNormal;
  87430. private _displacementVector;
  87431. /** @hidden */
  87432. _radius: Vector3;
  87433. /** @hidden */
  87434. _retry: number;
  87435. private _velocity;
  87436. private _basePoint;
  87437. private _epsilon;
  87438. /** @hidden */
  87439. _velocityWorldLength: number;
  87440. /** @hidden */
  87441. _basePointWorld: Vector3;
  87442. private _velocityWorld;
  87443. private _normalizedVelocity;
  87444. /** @hidden */
  87445. _initialVelocity: Vector3;
  87446. /** @hidden */
  87447. _initialPosition: Vector3;
  87448. private _nearestDistance;
  87449. private _collisionMask;
  87450. get collisionMask(): number;
  87451. set collisionMask(mask: number);
  87452. /**
  87453. * Gets the plane normal used to compute the sliding response (in local space)
  87454. */
  87455. get slidePlaneNormal(): Vector3;
  87456. /** @hidden */
  87457. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87458. /** @hidden */
  87459. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87460. /** @hidden */
  87461. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87462. /** @hidden */
  87463. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87464. /** @hidden */
  87465. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87466. /** @hidden */
  87467. _getResponse(pos: Vector3, vel: Vector3): void;
  87468. }
  87469. }
  87470. declare module BABYLON {
  87471. /**
  87472. * Interface for cullable objects
  87473. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87474. */
  87475. export interface ICullable {
  87476. /**
  87477. * Checks if the object or part of the object is in the frustum
  87478. * @param frustumPlanes Camera near/planes
  87479. * @returns true if the object is in frustum otherwise false
  87480. */
  87481. isInFrustum(frustumPlanes: Plane[]): boolean;
  87482. /**
  87483. * Checks if a cullable object (mesh...) is in the camera frustum
  87484. * Unlike isInFrustum this cheks the full bounding box
  87485. * @param frustumPlanes Camera near/planes
  87486. * @returns true if the object is in frustum otherwise false
  87487. */
  87488. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87489. }
  87490. /**
  87491. * Info for a bounding data of a mesh
  87492. */
  87493. export class BoundingInfo implements ICullable {
  87494. /**
  87495. * Bounding box for the mesh
  87496. */
  87497. readonly boundingBox: BoundingBox;
  87498. /**
  87499. * Bounding sphere for the mesh
  87500. */
  87501. readonly boundingSphere: BoundingSphere;
  87502. private _isLocked;
  87503. private static readonly TmpVector3;
  87504. /**
  87505. * Constructs bounding info
  87506. * @param minimum min vector of the bounding box/sphere
  87507. * @param maximum max vector of the bounding box/sphere
  87508. * @param worldMatrix defines the new world matrix
  87509. */
  87510. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87511. /**
  87512. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87513. * @param min defines the new minimum vector (in local space)
  87514. * @param max defines the new maximum vector (in local space)
  87515. * @param worldMatrix defines the new world matrix
  87516. */
  87517. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87518. /**
  87519. * min vector of the bounding box/sphere
  87520. */
  87521. get minimum(): Vector3;
  87522. /**
  87523. * max vector of the bounding box/sphere
  87524. */
  87525. get maximum(): Vector3;
  87526. /**
  87527. * If the info is locked and won't be updated to avoid perf overhead
  87528. */
  87529. get isLocked(): boolean;
  87530. set isLocked(value: boolean);
  87531. /**
  87532. * Updates the bounding sphere and box
  87533. * @param world world matrix to be used to update
  87534. */
  87535. update(world: DeepImmutable<Matrix>): void;
  87536. /**
  87537. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87538. * @param center New center of the bounding info
  87539. * @param extend New extend of the bounding info
  87540. * @returns the current bounding info
  87541. */
  87542. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87543. /**
  87544. * Scale the current bounding info by applying a scale factor
  87545. * @param factor defines the scale factor to apply
  87546. * @returns the current bounding info
  87547. */
  87548. scale(factor: number): BoundingInfo;
  87549. /**
  87550. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87551. * @param frustumPlanes defines the frustum to test
  87552. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87553. * @returns true if the bounding info is in the frustum planes
  87554. */
  87555. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87556. /**
  87557. * Gets the world distance between the min and max points of the bounding box
  87558. */
  87559. get diagonalLength(): number;
  87560. /**
  87561. * Checks if a cullable object (mesh...) is in the camera frustum
  87562. * Unlike isInFrustum this cheks the full bounding box
  87563. * @param frustumPlanes Camera near/planes
  87564. * @returns true if the object is in frustum otherwise false
  87565. */
  87566. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87567. /** @hidden */
  87568. _checkCollision(collider: Collider): boolean;
  87569. /**
  87570. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87571. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87572. * @param point the point to check intersection with
  87573. * @returns if the point intersects
  87574. */
  87575. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87576. /**
  87577. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87578. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87579. * @param boundingInfo the bounding info to check intersection with
  87580. * @param precise if the intersection should be done using OBB
  87581. * @returns if the bounding info intersects
  87582. */
  87583. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87584. }
  87585. }
  87586. declare module BABYLON {
  87587. /**
  87588. * Extracts minimum and maximum values from a list of indexed positions
  87589. * @param positions defines the positions to use
  87590. * @param indices defines the indices to the positions
  87591. * @param indexStart defines the start index
  87592. * @param indexCount defines the end index
  87593. * @param bias defines bias value to add to the result
  87594. * @return minimum and maximum values
  87595. */
  87596. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87597. minimum: Vector3;
  87598. maximum: Vector3;
  87599. };
  87600. /**
  87601. * Extracts minimum and maximum values from a list of positions
  87602. * @param positions defines the positions to use
  87603. * @param start defines the start index in the positions array
  87604. * @param count defines the number of positions to handle
  87605. * @param bias defines bias value to add to the result
  87606. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87607. * @return minimum and maximum values
  87608. */
  87609. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87610. minimum: Vector3;
  87611. maximum: Vector3;
  87612. };
  87613. }
  87614. declare module BABYLON {
  87615. /** @hidden */
  87616. export class WebGLDataBuffer extends DataBuffer {
  87617. private _buffer;
  87618. constructor(resource: WebGLBuffer);
  87619. get underlyingResource(): any;
  87620. }
  87621. }
  87622. declare module BABYLON {
  87623. /** @hidden */
  87624. export class WebGLPipelineContext implements IPipelineContext {
  87625. engine: ThinEngine;
  87626. program: Nullable<WebGLProgram>;
  87627. context?: WebGLRenderingContext;
  87628. vertexShader?: WebGLShader;
  87629. fragmentShader?: WebGLShader;
  87630. isParallelCompiled: boolean;
  87631. onCompiled?: () => void;
  87632. transformFeedback?: WebGLTransformFeedback | null;
  87633. vertexCompilationError: Nullable<string>;
  87634. fragmentCompilationError: Nullable<string>;
  87635. programLinkError: Nullable<string>;
  87636. programValidationError: Nullable<string>;
  87637. get isAsync(): boolean;
  87638. get isReady(): boolean;
  87639. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87640. _getVertexShaderCode(): string | null;
  87641. _getFragmentShaderCode(): string | null;
  87642. }
  87643. }
  87644. declare module BABYLON {
  87645. interface ThinEngine {
  87646. /**
  87647. * Create an uniform buffer
  87648. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87649. * @param elements defines the content of the uniform buffer
  87650. * @returns the webGL uniform buffer
  87651. */
  87652. createUniformBuffer(elements: FloatArray): DataBuffer;
  87653. /**
  87654. * Create a dynamic uniform buffer
  87655. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87656. * @param elements defines the content of the uniform buffer
  87657. * @returns the webGL uniform buffer
  87658. */
  87659. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87660. /**
  87661. * Update an existing uniform buffer
  87662. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87663. * @param uniformBuffer defines the target uniform buffer
  87664. * @param elements defines the content to update
  87665. * @param offset defines the offset in the uniform buffer where update should start
  87666. * @param count defines the size of the data to update
  87667. */
  87668. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87669. /**
  87670. * Bind an uniform buffer to the current webGL context
  87671. * @param buffer defines the buffer to bind
  87672. */
  87673. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87674. /**
  87675. * Bind a buffer to the current webGL context at a given location
  87676. * @param buffer defines the buffer to bind
  87677. * @param location defines the index where to bind the buffer
  87678. */
  87679. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87680. /**
  87681. * Bind a specific block at a given index in a specific shader program
  87682. * @param pipelineContext defines the pipeline context to use
  87683. * @param blockName defines the block name
  87684. * @param index defines the index where to bind the block
  87685. */
  87686. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87687. }
  87688. }
  87689. declare module BABYLON {
  87690. /**
  87691. * Uniform buffer objects.
  87692. *
  87693. * Handles blocks of uniform on the GPU.
  87694. *
  87695. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87696. *
  87697. * For more information, please refer to :
  87698. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87699. */
  87700. export class UniformBuffer {
  87701. private _engine;
  87702. private _buffer;
  87703. private _data;
  87704. private _bufferData;
  87705. private _dynamic?;
  87706. private _uniformLocations;
  87707. private _uniformSizes;
  87708. private _uniformLocationPointer;
  87709. private _needSync;
  87710. private _noUBO;
  87711. private _currentEffect;
  87712. /** @hidden */
  87713. _alreadyBound: boolean;
  87714. private static _MAX_UNIFORM_SIZE;
  87715. private static _tempBuffer;
  87716. /**
  87717. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87718. * This is dynamic to allow compat with webgl 1 and 2.
  87719. * You will need to pass the name of the uniform as well as the value.
  87720. */
  87721. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87722. /**
  87723. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87724. * This is dynamic to allow compat with webgl 1 and 2.
  87725. * You will need to pass the name of the uniform as well as the value.
  87726. */
  87727. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87728. /**
  87729. * Lambda to Update a single float in a uniform buffer.
  87730. * This is dynamic to allow compat with webgl 1 and 2.
  87731. * You will need to pass the name of the uniform as well as the value.
  87732. */
  87733. updateFloat: (name: string, x: number) => void;
  87734. /**
  87735. * Lambda to Update a vec2 of float in a uniform buffer.
  87736. * This is dynamic to allow compat with webgl 1 and 2.
  87737. * You will need to pass the name of the uniform as well as the value.
  87738. */
  87739. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87740. /**
  87741. * Lambda to Update a vec3 of float in a uniform buffer.
  87742. * This is dynamic to allow compat with webgl 1 and 2.
  87743. * You will need to pass the name of the uniform as well as the value.
  87744. */
  87745. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87746. /**
  87747. * Lambda to Update a vec4 of float in a uniform buffer.
  87748. * This is dynamic to allow compat with webgl 1 and 2.
  87749. * You will need to pass the name of the uniform as well as the value.
  87750. */
  87751. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87752. /**
  87753. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87754. * This is dynamic to allow compat with webgl 1 and 2.
  87755. * You will need to pass the name of the uniform as well as the value.
  87756. */
  87757. updateMatrix: (name: string, mat: Matrix) => void;
  87758. /**
  87759. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87760. * This is dynamic to allow compat with webgl 1 and 2.
  87761. * You will need to pass the name of the uniform as well as the value.
  87762. */
  87763. updateVector3: (name: string, vector: Vector3) => void;
  87764. /**
  87765. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87766. * This is dynamic to allow compat with webgl 1 and 2.
  87767. * You will need to pass the name of the uniform as well as the value.
  87768. */
  87769. updateVector4: (name: string, vector: Vector4) => void;
  87770. /**
  87771. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87772. * This is dynamic to allow compat with webgl 1 and 2.
  87773. * You will need to pass the name of the uniform as well as the value.
  87774. */
  87775. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87776. /**
  87777. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87778. * This is dynamic to allow compat with webgl 1 and 2.
  87779. * You will need to pass the name of the uniform as well as the value.
  87780. */
  87781. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87782. /**
  87783. * Instantiates a new Uniform buffer objects.
  87784. *
  87785. * Handles blocks of uniform on the GPU.
  87786. *
  87787. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87788. *
  87789. * For more information, please refer to :
  87790. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87791. * @param engine Define the engine the buffer is associated with
  87792. * @param data Define the data contained in the buffer
  87793. * @param dynamic Define if the buffer is updatable
  87794. */
  87795. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87796. /**
  87797. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87798. * or just falling back on setUniformXXX calls.
  87799. */
  87800. get useUbo(): boolean;
  87801. /**
  87802. * Indicates if the WebGL underlying uniform buffer is in sync
  87803. * with the javascript cache data.
  87804. */
  87805. get isSync(): boolean;
  87806. /**
  87807. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87808. * Also, a dynamic UniformBuffer will disable cache verification and always
  87809. * update the underlying WebGL uniform buffer to the GPU.
  87810. * @returns if Dynamic, otherwise false
  87811. */
  87812. isDynamic(): boolean;
  87813. /**
  87814. * The data cache on JS side.
  87815. * @returns the underlying data as a float array
  87816. */
  87817. getData(): Float32Array;
  87818. /**
  87819. * The underlying WebGL Uniform buffer.
  87820. * @returns the webgl buffer
  87821. */
  87822. getBuffer(): Nullable<DataBuffer>;
  87823. /**
  87824. * std140 layout specifies how to align data within an UBO structure.
  87825. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87826. * for specs.
  87827. */
  87828. private _fillAlignment;
  87829. /**
  87830. * Adds an uniform in the buffer.
  87831. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87832. * for the layout to be correct !
  87833. * @param name Name of the uniform, as used in the uniform block in the shader.
  87834. * @param size Data size, or data directly.
  87835. */
  87836. addUniform(name: string, size: number | number[]): void;
  87837. /**
  87838. * Adds a Matrix 4x4 to the uniform buffer.
  87839. * @param name Name of the uniform, as used in the uniform block in the shader.
  87840. * @param mat A 4x4 matrix.
  87841. */
  87842. addMatrix(name: string, mat: Matrix): void;
  87843. /**
  87844. * Adds a vec2 to the uniform buffer.
  87845. * @param name Name of the uniform, as used in the uniform block in the shader.
  87846. * @param x Define the x component value of the vec2
  87847. * @param y Define the y component value of the vec2
  87848. */
  87849. addFloat2(name: string, x: number, y: number): void;
  87850. /**
  87851. * Adds a vec3 to the uniform buffer.
  87852. * @param name Name of the uniform, as used in the uniform block in the shader.
  87853. * @param x Define the x component value of the vec3
  87854. * @param y Define the y component value of the vec3
  87855. * @param z Define the z component value of the vec3
  87856. */
  87857. addFloat3(name: string, x: number, y: number, z: number): void;
  87858. /**
  87859. * Adds a vec3 to the uniform buffer.
  87860. * @param name Name of the uniform, as used in the uniform block in the shader.
  87861. * @param color Define the vec3 from a Color
  87862. */
  87863. addColor3(name: string, color: Color3): void;
  87864. /**
  87865. * Adds a vec4 to the uniform buffer.
  87866. * @param name Name of the uniform, as used in the uniform block in the shader.
  87867. * @param color Define the rgb components from a Color
  87868. * @param alpha Define the a component of the vec4
  87869. */
  87870. addColor4(name: string, color: Color3, alpha: number): void;
  87871. /**
  87872. * Adds a vec3 to the uniform buffer.
  87873. * @param name Name of the uniform, as used in the uniform block in the shader.
  87874. * @param vector Define the vec3 components from a Vector
  87875. */
  87876. addVector3(name: string, vector: Vector3): void;
  87877. /**
  87878. * Adds a Matrix 3x3 to the uniform buffer.
  87879. * @param name Name of the uniform, as used in the uniform block in the shader.
  87880. */
  87881. addMatrix3x3(name: string): void;
  87882. /**
  87883. * Adds a Matrix 2x2 to the uniform buffer.
  87884. * @param name Name of the uniform, as used in the uniform block in the shader.
  87885. */
  87886. addMatrix2x2(name: string): void;
  87887. /**
  87888. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87889. */
  87890. create(): void;
  87891. /** @hidden */
  87892. _rebuild(): void;
  87893. /**
  87894. * Updates the WebGL Uniform Buffer on the GPU.
  87895. * If the `dynamic` flag is set to true, no cache comparison is done.
  87896. * Otherwise, the buffer will be updated only if the cache differs.
  87897. */
  87898. update(): void;
  87899. /**
  87900. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87901. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87902. * @param data Define the flattened data
  87903. * @param size Define the size of the data.
  87904. */
  87905. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87906. private _valueCache;
  87907. private _cacheMatrix;
  87908. private _updateMatrix3x3ForUniform;
  87909. private _updateMatrix3x3ForEffect;
  87910. private _updateMatrix2x2ForEffect;
  87911. private _updateMatrix2x2ForUniform;
  87912. private _updateFloatForEffect;
  87913. private _updateFloatForUniform;
  87914. private _updateFloat2ForEffect;
  87915. private _updateFloat2ForUniform;
  87916. private _updateFloat3ForEffect;
  87917. private _updateFloat3ForUniform;
  87918. private _updateFloat4ForEffect;
  87919. private _updateFloat4ForUniform;
  87920. private _updateMatrixForEffect;
  87921. private _updateMatrixForUniform;
  87922. private _updateVector3ForEffect;
  87923. private _updateVector3ForUniform;
  87924. private _updateVector4ForEffect;
  87925. private _updateVector4ForUniform;
  87926. private _updateColor3ForEffect;
  87927. private _updateColor3ForUniform;
  87928. private _updateColor4ForEffect;
  87929. private _updateColor4ForUniform;
  87930. /**
  87931. * Sets a sampler uniform on the effect.
  87932. * @param name Define the name of the sampler.
  87933. * @param texture Define the texture to set in the sampler
  87934. */
  87935. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87936. /**
  87937. * Directly updates the value of the uniform in the cache AND on the GPU.
  87938. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87939. * @param data Define the flattened data
  87940. */
  87941. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87942. /**
  87943. * Binds this uniform buffer to an effect.
  87944. * @param effect Define the effect to bind the buffer to
  87945. * @param name Name of the uniform block in the shader.
  87946. */
  87947. bindToEffect(effect: Effect, name: string): void;
  87948. /**
  87949. * Disposes the uniform buffer.
  87950. */
  87951. dispose(): void;
  87952. }
  87953. }
  87954. declare module BABYLON {
  87955. /**
  87956. * Enum that determines the text-wrapping mode to use.
  87957. */
  87958. export enum InspectableType {
  87959. /**
  87960. * Checkbox for booleans
  87961. */
  87962. Checkbox = 0,
  87963. /**
  87964. * Sliders for numbers
  87965. */
  87966. Slider = 1,
  87967. /**
  87968. * Vector3
  87969. */
  87970. Vector3 = 2,
  87971. /**
  87972. * Quaternions
  87973. */
  87974. Quaternion = 3,
  87975. /**
  87976. * Color3
  87977. */
  87978. Color3 = 4,
  87979. /**
  87980. * String
  87981. */
  87982. String = 5
  87983. }
  87984. /**
  87985. * Interface used to define custom inspectable properties.
  87986. * This interface is used by the inspector to display custom property grids
  87987. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87988. */
  87989. export interface IInspectable {
  87990. /**
  87991. * Gets the label to display
  87992. */
  87993. label: string;
  87994. /**
  87995. * Gets the name of the property to edit
  87996. */
  87997. propertyName: string;
  87998. /**
  87999. * Gets the type of the editor to use
  88000. */
  88001. type: InspectableType;
  88002. /**
  88003. * Gets the minimum value of the property when using in "slider" mode
  88004. */
  88005. min?: number;
  88006. /**
  88007. * Gets the maximum value of the property when using in "slider" mode
  88008. */
  88009. max?: number;
  88010. /**
  88011. * Gets the setp to use when using in "slider" mode
  88012. */
  88013. step?: number;
  88014. }
  88015. }
  88016. declare module BABYLON {
  88017. /**
  88018. * Class used to provide helper for timing
  88019. */
  88020. export class TimingTools {
  88021. /**
  88022. * Polyfill for setImmediate
  88023. * @param action defines the action to execute after the current execution block
  88024. */
  88025. static SetImmediate(action: () => void): void;
  88026. }
  88027. }
  88028. declare module BABYLON {
  88029. /**
  88030. * Class used to enable instatition of objects by class name
  88031. */
  88032. export class InstantiationTools {
  88033. /**
  88034. * Use this object to register external classes like custom textures or material
  88035. * to allow the laoders to instantiate them
  88036. */
  88037. static RegisteredExternalClasses: {
  88038. [key: string]: Object;
  88039. };
  88040. /**
  88041. * Tries to instantiate a new object from a given class name
  88042. * @param className defines the class name to instantiate
  88043. * @returns the new object or null if the system was not able to do the instantiation
  88044. */
  88045. static Instantiate(className: string): any;
  88046. }
  88047. }
  88048. declare module BABYLON {
  88049. /**
  88050. * Define options used to create a depth texture
  88051. */
  88052. export class DepthTextureCreationOptions {
  88053. /** Specifies whether or not a stencil should be allocated in the texture */
  88054. generateStencil?: boolean;
  88055. /** Specifies whether or not bilinear filtering is enable on the texture */
  88056. bilinearFiltering?: boolean;
  88057. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88058. comparisonFunction?: number;
  88059. /** Specifies if the created texture is a cube texture */
  88060. isCube?: boolean;
  88061. }
  88062. }
  88063. declare module BABYLON {
  88064. interface ThinEngine {
  88065. /**
  88066. * Creates a depth stencil cube texture.
  88067. * This is only available in WebGL 2.
  88068. * @param size The size of face edge in the cube texture.
  88069. * @param options The options defining the cube texture.
  88070. * @returns The cube texture
  88071. */
  88072. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88073. /**
  88074. * Creates a cube texture
  88075. * @param rootUrl defines the url where the files to load is located
  88076. * @param scene defines the current scene
  88077. * @param files defines the list of files to load (1 per face)
  88078. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88079. * @param onLoad defines an optional callback raised when the texture is loaded
  88080. * @param onError defines an optional callback raised if there is an issue to load the texture
  88081. * @param format defines the format of the data
  88082. * @param forcedExtension defines the extension to use to pick the right loader
  88083. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88084. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88085. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88086. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88087. * @returns the cube texture as an InternalTexture
  88088. */
  88089. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  88090. /**
  88091. * Creates a cube texture
  88092. * @param rootUrl defines the url where the files to load is located
  88093. * @param scene defines the current scene
  88094. * @param files defines the list of files to load (1 per face)
  88095. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88096. * @param onLoad defines an optional callback raised when the texture is loaded
  88097. * @param onError defines an optional callback raised if there is an issue to load the texture
  88098. * @param format defines the format of the data
  88099. * @param forcedExtension defines the extension to use to pick the right loader
  88100. * @returns the cube texture as an InternalTexture
  88101. */
  88102. 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;
  88103. /**
  88104. * Creates a cube texture
  88105. * @param rootUrl defines the url where the files to load is located
  88106. * @param scene defines the current scene
  88107. * @param files defines the list of files to load (1 per face)
  88108. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88109. * @param onLoad defines an optional callback raised when the texture is loaded
  88110. * @param onError defines an optional callback raised if there is an issue to load the texture
  88111. * @param format defines the format of the data
  88112. * @param forcedExtension defines the extension to use to pick the right loader
  88113. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88114. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88115. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88116. * @returns the cube texture as an InternalTexture
  88117. */
  88118. 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;
  88119. /** @hidden */
  88120. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88121. /** @hidden */
  88122. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88123. /** @hidden */
  88124. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88125. /** @hidden */
  88126. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88127. /**
  88128. * @hidden
  88129. */
  88130. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88131. }
  88132. }
  88133. declare module BABYLON {
  88134. /**
  88135. * Class for creating a cube texture
  88136. */
  88137. export class CubeTexture extends BaseTexture {
  88138. private _delayedOnLoad;
  88139. /**
  88140. * Observable triggered once the texture has been loaded.
  88141. */
  88142. onLoadObservable: Observable<CubeTexture>;
  88143. /**
  88144. * The url of the texture
  88145. */
  88146. url: string;
  88147. /**
  88148. * Gets or sets the center of the bounding box associated with the cube texture.
  88149. * It must define where the camera used to render the texture was set
  88150. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88151. */
  88152. boundingBoxPosition: Vector3;
  88153. private _boundingBoxSize;
  88154. /**
  88155. * Gets or sets the size of the bounding box associated with the cube texture
  88156. * When defined, the cubemap will switch to local mode
  88157. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88158. * @example https://www.babylonjs-playground.com/#RNASML
  88159. */
  88160. set boundingBoxSize(value: Vector3);
  88161. /**
  88162. * Returns the bounding box size
  88163. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88164. */
  88165. get boundingBoxSize(): Vector3;
  88166. protected _rotationY: number;
  88167. /**
  88168. * Sets texture matrix rotation angle around Y axis in radians.
  88169. */
  88170. set rotationY(value: number);
  88171. /**
  88172. * Gets texture matrix rotation angle around Y axis radians.
  88173. */
  88174. get rotationY(): number;
  88175. /**
  88176. * Are mip maps generated for this texture or not.
  88177. */
  88178. get noMipmap(): boolean;
  88179. private _noMipmap;
  88180. private _files;
  88181. protected _forcedExtension: Nullable<string>;
  88182. private _extensions;
  88183. private _textureMatrix;
  88184. private _format;
  88185. private _createPolynomials;
  88186. /**
  88187. * Creates a cube texture from an array of image urls
  88188. * @param files defines an array of image urls
  88189. * @param scene defines the hosting scene
  88190. * @param noMipmap specifies if mip maps are not used
  88191. * @returns a cube texture
  88192. */
  88193. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88194. /**
  88195. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88196. * @param url defines the url of the prefiltered texture
  88197. * @param scene defines the scene the texture is attached to
  88198. * @param forcedExtension defines the extension of the file if different from the url
  88199. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88200. * @return the prefiltered texture
  88201. */
  88202. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88203. /**
  88204. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88205. * as prefiltered data.
  88206. * @param rootUrl defines the url of the texture or the root name of the six images
  88207. * @param null defines the scene or engine the texture is attached to
  88208. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88209. * @param noMipmap defines if mipmaps should be created or not
  88210. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88211. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88212. * @param onError defines a callback triggered in case of error during load
  88213. * @param format defines the internal format to use for the texture once loaded
  88214. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88215. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88216. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88217. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88218. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88219. * @return the cube texture
  88220. */
  88221. 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);
  88222. /**
  88223. * Get the current class name of the texture useful for serialization or dynamic coding.
  88224. * @returns "CubeTexture"
  88225. */
  88226. getClassName(): string;
  88227. /**
  88228. * Update the url (and optional buffer) of this texture if url was null during construction.
  88229. * @param url the url of the texture
  88230. * @param forcedExtension defines the extension to use
  88231. * @param onLoad callback called when the texture is loaded (defaults to null)
  88232. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88233. */
  88234. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88235. /**
  88236. * Delays loading of the cube texture
  88237. * @param forcedExtension defines the extension to use
  88238. */
  88239. delayLoad(forcedExtension?: string): void;
  88240. /**
  88241. * Returns the reflection texture matrix
  88242. * @returns the reflection texture matrix
  88243. */
  88244. getReflectionTextureMatrix(): Matrix;
  88245. /**
  88246. * Sets the reflection texture matrix
  88247. * @param value Reflection texture matrix
  88248. */
  88249. setReflectionTextureMatrix(value: Matrix): void;
  88250. /**
  88251. * Parses text to create a cube texture
  88252. * @param parsedTexture define the serialized text to read from
  88253. * @param scene defines the hosting scene
  88254. * @param rootUrl defines the root url of the cube texture
  88255. * @returns a cube texture
  88256. */
  88257. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88258. /**
  88259. * Makes a clone, or deep copy, of the cube texture
  88260. * @returns a new cube texture
  88261. */
  88262. clone(): CubeTexture;
  88263. }
  88264. }
  88265. declare module BABYLON {
  88266. /**
  88267. * Manages the defines for the Material
  88268. */
  88269. export class MaterialDefines {
  88270. /** @hidden */
  88271. protected _keys: string[];
  88272. private _isDirty;
  88273. /** @hidden */
  88274. _renderId: number;
  88275. /** @hidden */
  88276. _areLightsDirty: boolean;
  88277. /** @hidden */
  88278. _areLightsDisposed: boolean;
  88279. /** @hidden */
  88280. _areAttributesDirty: boolean;
  88281. /** @hidden */
  88282. _areTexturesDirty: boolean;
  88283. /** @hidden */
  88284. _areFresnelDirty: boolean;
  88285. /** @hidden */
  88286. _areMiscDirty: boolean;
  88287. /** @hidden */
  88288. _areImageProcessingDirty: boolean;
  88289. /** @hidden */
  88290. _normals: boolean;
  88291. /** @hidden */
  88292. _uvs: boolean;
  88293. /** @hidden */
  88294. _needNormals: boolean;
  88295. /** @hidden */
  88296. _needUVs: boolean;
  88297. [id: string]: any;
  88298. /**
  88299. * Specifies if the material needs to be re-calculated
  88300. */
  88301. get isDirty(): boolean;
  88302. /**
  88303. * Marks the material to indicate that it has been re-calculated
  88304. */
  88305. markAsProcessed(): void;
  88306. /**
  88307. * Marks the material to indicate that it needs to be re-calculated
  88308. */
  88309. markAsUnprocessed(): void;
  88310. /**
  88311. * Marks the material to indicate all of its defines need to be re-calculated
  88312. */
  88313. markAllAsDirty(): void;
  88314. /**
  88315. * Marks the material to indicate that image processing needs to be re-calculated
  88316. */
  88317. markAsImageProcessingDirty(): void;
  88318. /**
  88319. * Marks the material to indicate the lights need to be re-calculated
  88320. * @param disposed Defines whether the light is dirty due to dispose or not
  88321. */
  88322. markAsLightDirty(disposed?: boolean): void;
  88323. /**
  88324. * Marks the attribute state as changed
  88325. */
  88326. markAsAttributesDirty(): void;
  88327. /**
  88328. * Marks the texture state as changed
  88329. */
  88330. markAsTexturesDirty(): void;
  88331. /**
  88332. * Marks the fresnel state as changed
  88333. */
  88334. markAsFresnelDirty(): void;
  88335. /**
  88336. * Marks the misc state as changed
  88337. */
  88338. markAsMiscDirty(): void;
  88339. /**
  88340. * Rebuilds the material defines
  88341. */
  88342. rebuild(): void;
  88343. /**
  88344. * Specifies if two material defines are equal
  88345. * @param other - A material define instance to compare to
  88346. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88347. */
  88348. isEqual(other: MaterialDefines): boolean;
  88349. /**
  88350. * Clones this instance's defines to another instance
  88351. * @param other - material defines to clone values to
  88352. */
  88353. cloneTo(other: MaterialDefines): void;
  88354. /**
  88355. * Resets the material define values
  88356. */
  88357. reset(): void;
  88358. /**
  88359. * Converts the material define values to a string
  88360. * @returns - String of material define information
  88361. */
  88362. toString(): string;
  88363. }
  88364. }
  88365. declare module BABYLON {
  88366. /**
  88367. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88368. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88369. * 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;
  88370. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88371. */
  88372. export class ColorCurves {
  88373. private _dirty;
  88374. private _tempColor;
  88375. private _globalCurve;
  88376. private _highlightsCurve;
  88377. private _midtonesCurve;
  88378. private _shadowsCurve;
  88379. private _positiveCurve;
  88380. private _negativeCurve;
  88381. private _globalHue;
  88382. private _globalDensity;
  88383. private _globalSaturation;
  88384. private _globalExposure;
  88385. /**
  88386. * Gets the global Hue value.
  88387. * 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).
  88388. */
  88389. get globalHue(): number;
  88390. /**
  88391. * Sets the global Hue value.
  88392. * 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).
  88393. */
  88394. set globalHue(value: number);
  88395. /**
  88396. * Gets the global Density value.
  88397. * 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.
  88398. * Values less than zero provide a filter of opposite hue.
  88399. */
  88400. get globalDensity(): number;
  88401. /**
  88402. * Sets the global Density value.
  88403. * 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.
  88404. * Values less than zero provide a filter of opposite hue.
  88405. */
  88406. set globalDensity(value: number);
  88407. /**
  88408. * Gets the global Saturation value.
  88409. * 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.
  88410. */
  88411. get globalSaturation(): number;
  88412. /**
  88413. * Sets the global Saturation value.
  88414. * 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.
  88415. */
  88416. set globalSaturation(value: number);
  88417. /**
  88418. * Gets the global Exposure value.
  88419. * 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.
  88420. */
  88421. get globalExposure(): number;
  88422. /**
  88423. * Sets the global Exposure value.
  88424. * 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.
  88425. */
  88426. set globalExposure(value: number);
  88427. private _highlightsHue;
  88428. private _highlightsDensity;
  88429. private _highlightsSaturation;
  88430. private _highlightsExposure;
  88431. /**
  88432. * Gets the highlights Hue value.
  88433. * 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).
  88434. */
  88435. get highlightsHue(): number;
  88436. /**
  88437. * Sets the highlights Hue value.
  88438. * 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).
  88439. */
  88440. set highlightsHue(value: number);
  88441. /**
  88442. * Gets the highlights Density value.
  88443. * 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.
  88444. * Values less than zero provide a filter of opposite hue.
  88445. */
  88446. get highlightsDensity(): number;
  88447. /**
  88448. * Sets the highlights Density value.
  88449. * 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.
  88450. * Values less than zero provide a filter of opposite hue.
  88451. */
  88452. set highlightsDensity(value: number);
  88453. /**
  88454. * Gets the highlights Saturation value.
  88455. * 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.
  88456. */
  88457. get highlightsSaturation(): number;
  88458. /**
  88459. * Sets the highlights Saturation value.
  88460. * 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.
  88461. */
  88462. set highlightsSaturation(value: number);
  88463. /**
  88464. * Gets the highlights Exposure value.
  88465. * 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.
  88466. */
  88467. get highlightsExposure(): number;
  88468. /**
  88469. * Sets the highlights Exposure value.
  88470. * 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.
  88471. */
  88472. set highlightsExposure(value: number);
  88473. private _midtonesHue;
  88474. private _midtonesDensity;
  88475. private _midtonesSaturation;
  88476. private _midtonesExposure;
  88477. /**
  88478. * Gets the midtones Hue value.
  88479. * 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).
  88480. */
  88481. get midtonesHue(): number;
  88482. /**
  88483. * Sets the midtones Hue value.
  88484. * 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).
  88485. */
  88486. set midtonesHue(value: number);
  88487. /**
  88488. * Gets the midtones Density value.
  88489. * 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.
  88490. * Values less than zero provide a filter of opposite hue.
  88491. */
  88492. get midtonesDensity(): number;
  88493. /**
  88494. * Sets the midtones Density value.
  88495. * 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.
  88496. * Values less than zero provide a filter of opposite hue.
  88497. */
  88498. set midtonesDensity(value: number);
  88499. /**
  88500. * Gets the midtones Saturation value.
  88501. * 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.
  88502. */
  88503. get midtonesSaturation(): number;
  88504. /**
  88505. * Sets the midtones Saturation value.
  88506. * 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.
  88507. */
  88508. set midtonesSaturation(value: number);
  88509. /**
  88510. * Gets the midtones Exposure value.
  88511. * 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.
  88512. */
  88513. get midtonesExposure(): number;
  88514. /**
  88515. * Sets the midtones Exposure value.
  88516. * 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.
  88517. */
  88518. set midtonesExposure(value: number);
  88519. private _shadowsHue;
  88520. private _shadowsDensity;
  88521. private _shadowsSaturation;
  88522. private _shadowsExposure;
  88523. /**
  88524. * Gets the shadows Hue value.
  88525. * 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).
  88526. */
  88527. get shadowsHue(): number;
  88528. /**
  88529. * Sets the shadows Hue value.
  88530. * 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).
  88531. */
  88532. set shadowsHue(value: number);
  88533. /**
  88534. * Gets the shadows Density value.
  88535. * 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.
  88536. * Values less than zero provide a filter of opposite hue.
  88537. */
  88538. get shadowsDensity(): number;
  88539. /**
  88540. * Sets the shadows Density value.
  88541. * 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.
  88542. * Values less than zero provide a filter of opposite hue.
  88543. */
  88544. set shadowsDensity(value: number);
  88545. /**
  88546. * Gets the shadows Saturation value.
  88547. * 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.
  88548. */
  88549. get shadowsSaturation(): number;
  88550. /**
  88551. * Sets the shadows Saturation value.
  88552. * 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.
  88553. */
  88554. set shadowsSaturation(value: number);
  88555. /**
  88556. * Gets the shadows Exposure value.
  88557. * 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.
  88558. */
  88559. get shadowsExposure(): number;
  88560. /**
  88561. * Sets the shadows Exposure value.
  88562. * 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.
  88563. */
  88564. set shadowsExposure(value: number);
  88565. /**
  88566. * Returns the class name
  88567. * @returns The class name
  88568. */
  88569. getClassName(): string;
  88570. /**
  88571. * Binds the color curves to the shader.
  88572. * @param colorCurves The color curve to bind
  88573. * @param effect The effect to bind to
  88574. * @param positiveUniform The positive uniform shader parameter
  88575. * @param neutralUniform The neutral uniform shader parameter
  88576. * @param negativeUniform The negative uniform shader parameter
  88577. */
  88578. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88579. /**
  88580. * Prepare the list of uniforms associated with the ColorCurves effects.
  88581. * @param uniformsList The list of uniforms used in the effect
  88582. */
  88583. static PrepareUniforms(uniformsList: string[]): void;
  88584. /**
  88585. * Returns color grading data based on a hue, density, saturation and exposure value.
  88586. * @param filterHue The hue of the color filter.
  88587. * @param filterDensity The density of the color filter.
  88588. * @param saturation The saturation.
  88589. * @param exposure The exposure.
  88590. * @param result The result data container.
  88591. */
  88592. private getColorGradingDataToRef;
  88593. /**
  88594. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88595. * @param value The input slider value in range [-100,100].
  88596. * @returns Adjusted value.
  88597. */
  88598. private static applyColorGradingSliderNonlinear;
  88599. /**
  88600. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88601. * @param hue The hue (H) input.
  88602. * @param saturation The saturation (S) input.
  88603. * @param brightness The brightness (B) input.
  88604. * @result An RGBA color represented as Vector4.
  88605. */
  88606. private static fromHSBToRef;
  88607. /**
  88608. * Returns a value clamped between min and max
  88609. * @param value The value to clamp
  88610. * @param min The minimum of value
  88611. * @param max The maximum of value
  88612. * @returns The clamped value.
  88613. */
  88614. private static clamp;
  88615. /**
  88616. * Clones the current color curve instance.
  88617. * @return The cloned curves
  88618. */
  88619. clone(): ColorCurves;
  88620. /**
  88621. * Serializes the current color curve instance to a json representation.
  88622. * @return a JSON representation
  88623. */
  88624. serialize(): any;
  88625. /**
  88626. * Parses the color curve from a json representation.
  88627. * @param source the JSON source to parse
  88628. * @return The parsed curves
  88629. */
  88630. static Parse(source: any): ColorCurves;
  88631. }
  88632. }
  88633. declare module BABYLON {
  88634. /**
  88635. * Interface to follow in your material defines to integrate easily the
  88636. * Image proccessing functions.
  88637. * @hidden
  88638. */
  88639. export interface IImageProcessingConfigurationDefines {
  88640. IMAGEPROCESSING: boolean;
  88641. VIGNETTE: boolean;
  88642. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88643. VIGNETTEBLENDMODEOPAQUE: boolean;
  88644. TONEMAPPING: boolean;
  88645. TONEMAPPING_ACES: boolean;
  88646. CONTRAST: boolean;
  88647. EXPOSURE: boolean;
  88648. COLORCURVES: boolean;
  88649. COLORGRADING: boolean;
  88650. COLORGRADING3D: boolean;
  88651. SAMPLER3DGREENDEPTH: boolean;
  88652. SAMPLER3DBGRMAP: boolean;
  88653. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88654. }
  88655. /**
  88656. * @hidden
  88657. */
  88658. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88659. IMAGEPROCESSING: boolean;
  88660. VIGNETTE: boolean;
  88661. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88662. VIGNETTEBLENDMODEOPAQUE: boolean;
  88663. TONEMAPPING: boolean;
  88664. TONEMAPPING_ACES: boolean;
  88665. CONTRAST: boolean;
  88666. COLORCURVES: boolean;
  88667. COLORGRADING: boolean;
  88668. COLORGRADING3D: boolean;
  88669. SAMPLER3DGREENDEPTH: boolean;
  88670. SAMPLER3DBGRMAP: boolean;
  88671. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88672. EXPOSURE: boolean;
  88673. constructor();
  88674. }
  88675. /**
  88676. * This groups together the common properties used for image processing either in direct forward pass
  88677. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88678. * or not.
  88679. */
  88680. export class ImageProcessingConfiguration {
  88681. /**
  88682. * Default tone mapping applied in BabylonJS.
  88683. */
  88684. static readonly TONEMAPPING_STANDARD: number;
  88685. /**
  88686. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88687. * to other engines rendering to increase portability.
  88688. */
  88689. static readonly TONEMAPPING_ACES: number;
  88690. /**
  88691. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88692. */
  88693. colorCurves: Nullable<ColorCurves>;
  88694. private _colorCurvesEnabled;
  88695. /**
  88696. * Gets wether the color curves effect is enabled.
  88697. */
  88698. get colorCurvesEnabled(): boolean;
  88699. /**
  88700. * Sets wether the color curves effect is enabled.
  88701. */
  88702. set colorCurvesEnabled(value: boolean);
  88703. private _colorGradingTexture;
  88704. /**
  88705. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88706. */
  88707. get colorGradingTexture(): Nullable<BaseTexture>;
  88708. /**
  88709. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88710. */
  88711. set colorGradingTexture(value: Nullable<BaseTexture>);
  88712. private _colorGradingEnabled;
  88713. /**
  88714. * Gets wether the color grading effect is enabled.
  88715. */
  88716. get colorGradingEnabled(): boolean;
  88717. /**
  88718. * Sets wether the color grading effect is enabled.
  88719. */
  88720. set colorGradingEnabled(value: boolean);
  88721. private _colorGradingWithGreenDepth;
  88722. /**
  88723. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88724. */
  88725. get colorGradingWithGreenDepth(): boolean;
  88726. /**
  88727. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88728. */
  88729. set colorGradingWithGreenDepth(value: boolean);
  88730. private _colorGradingBGR;
  88731. /**
  88732. * Gets wether the color grading texture contains BGR values.
  88733. */
  88734. get colorGradingBGR(): boolean;
  88735. /**
  88736. * Sets wether the color grading texture contains BGR values.
  88737. */
  88738. set colorGradingBGR(value: boolean);
  88739. /** @hidden */
  88740. _exposure: number;
  88741. /**
  88742. * Gets the Exposure used in the effect.
  88743. */
  88744. get exposure(): number;
  88745. /**
  88746. * Sets the Exposure used in the effect.
  88747. */
  88748. set exposure(value: number);
  88749. private _toneMappingEnabled;
  88750. /**
  88751. * Gets wether the tone mapping effect is enabled.
  88752. */
  88753. get toneMappingEnabled(): boolean;
  88754. /**
  88755. * Sets wether the tone mapping effect is enabled.
  88756. */
  88757. set toneMappingEnabled(value: boolean);
  88758. private _toneMappingType;
  88759. /**
  88760. * Gets the type of tone mapping effect.
  88761. */
  88762. get toneMappingType(): number;
  88763. /**
  88764. * Sets the type of tone mapping effect used in BabylonJS.
  88765. */
  88766. set toneMappingType(value: number);
  88767. protected _contrast: number;
  88768. /**
  88769. * Gets the contrast used in the effect.
  88770. */
  88771. get contrast(): number;
  88772. /**
  88773. * Sets the contrast used in the effect.
  88774. */
  88775. set contrast(value: number);
  88776. /**
  88777. * Vignette stretch size.
  88778. */
  88779. vignetteStretch: number;
  88780. /**
  88781. * Vignette centre X Offset.
  88782. */
  88783. vignetteCentreX: number;
  88784. /**
  88785. * Vignette centre Y Offset.
  88786. */
  88787. vignetteCentreY: number;
  88788. /**
  88789. * Vignette weight or intensity of the vignette effect.
  88790. */
  88791. vignetteWeight: number;
  88792. /**
  88793. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88794. * if vignetteEnabled is set to true.
  88795. */
  88796. vignetteColor: Color4;
  88797. /**
  88798. * Camera field of view used by the Vignette effect.
  88799. */
  88800. vignetteCameraFov: number;
  88801. private _vignetteBlendMode;
  88802. /**
  88803. * Gets the vignette blend mode allowing different kind of effect.
  88804. */
  88805. get vignetteBlendMode(): number;
  88806. /**
  88807. * Sets the vignette blend mode allowing different kind of effect.
  88808. */
  88809. set vignetteBlendMode(value: number);
  88810. private _vignetteEnabled;
  88811. /**
  88812. * Gets wether the vignette effect is enabled.
  88813. */
  88814. get vignetteEnabled(): boolean;
  88815. /**
  88816. * Sets wether the vignette effect is enabled.
  88817. */
  88818. set vignetteEnabled(value: boolean);
  88819. private _applyByPostProcess;
  88820. /**
  88821. * Gets wether the image processing is applied through a post process or not.
  88822. */
  88823. get applyByPostProcess(): boolean;
  88824. /**
  88825. * Sets wether the image processing is applied through a post process or not.
  88826. */
  88827. set applyByPostProcess(value: boolean);
  88828. private _isEnabled;
  88829. /**
  88830. * Gets wether the image processing is enabled or not.
  88831. */
  88832. get isEnabled(): boolean;
  88833. /**
  88834. * Sets wether the image processing is enabled or not.
  88835. */
  88836. set isEnabled(value: boolean);
  88837. /**
  88838. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88839. */
  88840. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88841. /**
  88842. * Method called each time the image processing information changes requires to recompile the effect.
  88843. */
  88844. protected _updateParameters(): void;
  88845. /**
  88846. * Gets the current class name.
  88847. * @return "ImageProcessingConfiguration"
  88848. */
  88849. getClassName(): string;
  88850. /**
  88851. * Prepare the list of uniforms associated with the Image Processing effects.
  88852. * @param uniforms The list of uniforms used in the effect
  88853. * @param defines the list of defines currently in use
  88854. */
  88855. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88856. /**
  88857. * Prepare the list of samplers associated with the Image Processing effects.
  88858. * @param samplersList The list of uniforms used in the effect
  88859. * @param defines the list of defines currently in use
  88860. */
  88861. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88862. /**
  88863. * Prepare the list of defines associated to the shader.
  88864. * @param defines the list of defines to complete
  88865. * @param forPostProcess Define if we are currently in post process mode or not
  88866. */
  88867. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88868. /**
  88869. * Returns true if all the image processing information are ready.
  88870. * @returns True if ready, otherwise, false
  88871. */
  88872. isReady(): boolean;
  88873. /**
  88874. * Binds the image processing to the shader.
  88875. * @param effect The effect to bind to
  88876. * @param overrideAspectRatio Override the aspect ratio of the effect
  88877. */
  88878. bind(effect: Effect, overrideAspectRatio?: number): void;
  88879. /**
  88880. * Clones the current image processing instance.
  88881. * @return The cloned image processing
  88882. */
  88883. clone(): ImageProcessingConfiguration;
  88884. /**
  88885. * Serializes the current image processing instance to a json representation.
  88886. * @return a JSON representation
  88887. */
  88888. serialize(): any;
  88889. /**
  88890. * Parses the image processing from a json representation.
  88891. * @param source the JSON source to parse
  88892. * @return The parsed image processing
  88893. */
  88894. static Parse(source: any): ImageProcessingConfiguration;
  88895. private static _VIGNETTEMODE_MULTIPLY;
  88896. private static _VIGNETTEMODE_OPAQUE;
  88897. /**
  88898. * Used to apply the vignette as a mix with the pixel color.
  88899. */
  88900. static get VIGNETTEMODE_MULTIPLY(): number;
  88901. /**
  88902. * Used to apply the vignette as a replacement of the pixel color.
  88903. */
  88904. static get VIGNETTEMODE_OPAQUE(): number;
  88905. }
  88906. }
  88907. declare module BABYLON {
  88908. /** @hidden */
  88909. export var postprocessVertexShader: {
  88910. name: string;
  88911. shader: string;
  88912. };
  88913. }
  88914. declare module BABYLON {
  88915. /**
  88916. * Type used to define a render target texture size (either with a number or with a rect width and height)
  88917. */
  88918. export type RenderTargetTextureSize = number | {
  88919. width: number;
  88920. height: number;
  88921. layers?: number;
  88922. };
  88923. interface ThinEngine {
  88924. /**
  88925. * Creates a new render target texture
  88926. * @param size defines the size of the texture
  88927. * @param options defines the options used to create the texture
  88928. * @returns a new render target texture stored in an InternalTexture
  88929. */
  88930. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88931. /**
  88932. * Creates a depth stencil texture.
  88933. * This is only available in WebGL 2 or with the depth texture extension available.
  88934. * @param size The size of face edge in the texture.
  88935. * @param options The options defining the texture.
  88936. * @returns The texture
  88937. */
  88938. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88939. /** @hidden */
  88940. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88941. }
  88942. }
  88943. declare module BABYLON {
  88944. /**
  88945. * Defines the kind of connection point for node based material
  88946. */
  88947. export enum NodeMaterialBlockConnectionPointTypes {
  88948. /** Float */
  88949. Float = 1,
  88950. /** Int */
  88951. Int = 2,
  88952. /** Vector2 */
  88953. Vector2 = 4,
  88954. /** Vector3 */
  88955. Vector3 = 8,
  88956. /** Vector4 */
  88957. Vector4 = 16,
  88958. /** Color3 */
  88959. Color3 = 32,
  88960. /** Color4 */
  88961. Color4 = 64,
  88962. /** Matrix */
  88963. Matrix = 128,
  88964. /** Custom object */
  88965. Object = 256,
  88966. /** Detect type based on connection */
  88967. AutoDetect = 1024,
  88968. /** Output type that will be defined by input type */
  88969. BasedOnInput = 2048
  88970. }
  88971. }
  88972. declare module BABYLON {
  88973. /**
  88974. * Enum used to define the target of a block
  88975. */
  88976. export enum NodeMaterialBlockTargets {
  88977. /** Vertex shader */
  88978. Vertex = 1,
  88979. /** Fragment shader */
  88980. Fragment = 2,
  88981. /** Neutral */
  88982. Neutral = 4,
  88983. /** Vertex and Fragment */
  88984. VertexAndFragment = 3
  88985. }
  88986. }
  88987. declare module BABYLON {
  88988. /**
  88989. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88990. */
  88991. export enum NodeMaterialBlockConnectionPointMode {
  88992. /** Value is an uniform */
  88993. Uniform = 0,
  88994. /** Value is a mesh attribute */
  88995. Attribute = 1,
  88996. /** Value is a varying between vertex and fragment shaders */
  88997. Varying = 2,
  88998. /** Mode is undefined */
  88999. Undefined = 3
  89000. }
  89001. }
  89002. declare module BABYLON {
  89003. /**
  89004. * Enum used to define system values e.g. values automatically provided by the system
  89005. */
  89006. export enum NodeMaterialSystemValues {
  89007. /** World */
  89008. World = 1,
  89009. /** View */
  89010. View = 2,
  89011. /** Projection */
  89012. Projection = 3,
  89013. /** ViewProjection */
  89014. ViewProjection = 4,
  89015. /** WorldView */
  89016. WorldView = 5,
  89017. /** WorldViewProjection */
  89018. WorldViewProjection = 6,
  89019. /** CameraPosition */
  89020. CameraPosition = 7,
  89021. /** Fog Color */
  89022. FogColor = 8,
  89023. /** Delta time */
  89024. DeltaTime = 9
  89025. }
  89026. }
  89027. declare module BABYLON {
  89028. /** Defines supported spaces */
  89029. export enum Space {
  89030. /** Local (object) space */
  89031. LOCAL = 0,
  89032. /** World space */
  89033. WORLD = 1,
  89034. /** Bone space */
  89035. BONE = 2
  89036. }
  89037. /** Defines the 3 main axes */
  89038. export class Axis {
  89039. /** X axis */
  89040. static X: Vector3;
  89041. /** Y axis */
  89042. static Y: Vector3;
  89043. /** Z axis */
  89044. static Z: Vector3;
  89045. }
  89046. }
  89047. declare module BABYLON {
  89048. /**
  89049. * Represents a camera frustum
  89050. */
  89051. export class Frustum {
  89052. /**
  89053. * Gets the planes representing the frustum
  89054. * @param transform matrix to be applied to the returned planes
  89055. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89056. */
  89057. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89058. /**
  89059. * Gets the near frustum plane transformed by the transform matrix
  89060. * @param transform transformation matrix to be applied to the resulting frustum plane
  89061. * @param frustumPlane the resuling frustum plane
  89062. */
  89063. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89064. /**
  89065. * Gets the far frustum plane transformed by the transform matrix
  89066. * @param transform transformation matrix to be applied to the resulting frustum plane
  89067. * @param frustumPlane the resuling frustum plane
  89068. */
  89069. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89070. /**
  89071. * Gets the left frustum plane transformed by the transform matrix
  89072. * @param transform transformation matrix to be applied to the resulting frustum plane
  89073. * @param frustumPlane the resuling frustum plane
  89074. */
  89075. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89076. /**
  89077. * Gets the right frustum plane transformed by the transform matrix
  89078. * @param transform transformation matrix to be applied to the resulting frustum plane
  89079. * @param frustumPlane the resuling frustum plane
  89080. */
  89081. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89082. /**
  89083. * Gets the top frustum plane transformed by the transform matrix
  89084. * @param transform transformation matrix to be applied to the resulting frustum plane
  89085. * @param frustumPlane the resuling frustum plane
  89086. */
  89087. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89088. /**
  89089. * Gets the bottom frustum plane transformed by the transform matrix
  89090. * @param transform transformation matrix to be applied to the resulting frustum plane
  89091. * @param frustumPlane the resuling frustum plane
  89092. */
  89093. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89094. /**
  89095. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89096. * @param transform transformation matrix to be applied to the resulting frustum planes
  89097. * @param frustumPlanes the resuling frustum planes
  89098. */
  89099. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89100. }
  89101. }
  89102. declare module BABYLON {
  89103. /**
  89104. * Interface for the size containing width and height
  89105. */
  89106. export interface ISize {
  89107. /**
  89108. * Width
  89109. */
  89110. width: number;
  89111. /**
  89112. * Heighht
  89113. */
  89114. height: number;
  89115. }
  89116. /**
  89117. * Size containing widht and height
  89118. */
  89119. export class Size implements ISize {
  89120. /**
  89121. * Width
  89122. */
  89123. width: number;
  89124. /**
  89125. * Height
  89126. */
  89127. height: number;
  89128. /**
  89129. * Creates a Size object from the given width and height (floats).
  89130. * @param width width of the new size
  89131. * @param height height of the new size
  89132. */
  89133. constructor(width: number, height: number);
  89134. /**
  89135. * Returns a string with the Size width and height
  89136. * @returns a string with the Size width and height
  89137. */
  89138. toString(): string;
  89139. /**
  89140. * "Size"
  89141. * @returns the string "Size"
  89142. */
  89143. getClassName(): string;
  89144. /**
  89145. * Returns the Size hash code.
  89146. * @returns a hash code for a unique width and height
  89147. */
  89148. getHashCode(): number;
  89149. /**
  89150. * Updates the current size from the given one.
  89151. * @param src the given size
  89152. */
  89153. copyFrom(src: Size): void;
  89154. /**
  89155. * Updates in place the current Size from the given floats.
  89156. * @param width width of the new size
  89157. * @param height height of the new size
  89158. * @returns the updated Size.
  89159. */
  89160. copyFromFloats(width: number, height: number): Size;
  89161. /**
  89162. * Updates in place the current Size from the given floats.
  89163. * @param width width to set
  89164. * @param height height to set
  89165. * @returns the updated Size.
  89166. */
  89167. set(width: number, height: number): Size;
  89168. /**
  89169. * Multiplies the width and height by numbers
  89170. * @param w factor to multiple the width by
  89171. * @param h factor to multiple the height by
  89172. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89173. */
  89174. multiplyByFloats(w: number, h: number): Size;
  89175. /**
  89176. * Clones the size
  89177. * @returns a new Size copied from the given one.
  89178. */
  89179. clone(): Size;
  89180. /**
  89181. * True if the current Size and the given one width and height are strictly equal.
  89182. * @param other the other size to compare against
  89183. * @returns True if the current Size and the given one width and height are strictly equal.
  89184. */
  89185. equals(other: Size): boolean;
  89186. /**
  89187. * The surface of the Size : width * height (float).
  89188. */
  89189. get surface(): number;
  89190. /**
  89191. * Create a new size of zero
  89192. * @returns a new Size set to (0.0, 0.0)
  89193. */
  89194. static Zero(): Size;
  89195. /**
  89196. * Sums the width and height of two sizes
  89197. * @param otherSize size to add to this size
  89198. * @returns a new Size set as the addition result of the current Size and the given one.
  89199. */
  89200. add(otherSize: Size): Size;
  89201. /**
  89202. * Subtracts the width and height of two
  89203. * @param otherSize size to subtract to this size
  89204. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89205. */
  89206. subtract(otherSize: Size): Size;
  89207. /**
  89208. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89209. * @param start starting size to lerp between
  89210. * @param end end size to lerp between
  89211. * @param amount amount to lerp between the start and end values
  89212. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89213. */
  89214. static Lerp(start: Size, end: Size, amount: number): Size;
  89215. }
  89216. }
  89217. declare module BABYLON {
  89218. /**
  89219. * Contains position and normal vectors for a vertex
  89220. */
  89221. export class PositionNormalVertex {
  89222. /** the position of the vertex (defaut: 0,0,0) */
  89223. position: Vector3;
  89224. /** the normal of the vertex (defaut: 0,1,0) */
  89225. normal: Vector3;
  89226. /**
  89227. * Creates a PositionNormalVertex
  89228. * @param position the position of the vertex (defaut: 0,0,0)
  89229. * @param normal the normal of the vertex (defaut: 0,1,0)
  89230. */
  89231. constructor(
  89232. /** the position of the vertex (defaut: 0,0,0) */
  89233. position?: Vector3,
  89234. /** the normal of the vertex (defaut: 0,1,0) */
  89235. normal?: Vector3);
  89236. /**
  89237. * Clones the PositionNormalVertex
  89238. * @returns the cloned PositionNormalVertex
  89239. */
  89240. clone(): PositionNormalVertex;
  89241. }
  89242. /**
  89243. * Contains position, normal and uv vectors for a vertex
  89244. */
  89245. export class PositionNormalTextureVertex {
  89246. /** the position of the vertex (defaut: 0,0,0) */
  89247. position: Vector3;
  89248. /** the normal of the vertex (defaut: 0,1,0) */
  89249. normal: Vector3;
  89250. /** the uv of the vertex (default: 0,0) */
  89251. uv: Vector2;
  89252. /**
  89253. * Creates a PositionNormalTextureVertex
  89254. * @param position the position of the vertex (defaut: 0,0,0)
  89255. * @param normal the normal of the vertex (defaut: 0,1,0)
  89256. * @param uv the uv of the vertex (default: 0,0)
  89257. */
  89258. constructor(
  89259. /** the position of the vertex (defaut: 0,0,0) */
  89260. position?: Vector3,
  89261. /** the normal of the vertex (defaut: 0,1,0) */
  89262. normal?: Vector3,
  89263. /** the uv of the vertex (default: 0,0) */
  89264. uv?: Vector2);
  89265. /**
  89266. * Clones the PositionNormalTextureVertex
  89267. * @returns the cloned PositionNormalTextureVertex
  89268. */
  89269. clone(): PositionNormalTextureVertex;
  89270. }
  89271. }
  89272. declare module BABYLON {
  89273. /**
  89274. * Enum defining the type of animations supported by InputBlock
  89275. */
  89276. export enum AnimatedInputBlockTypes {
  89277. /** No animation */
  89278. None = 0,
  89279. /** Time based animation. Will only work for floats */
  89280. Time = 1
  89281. }
  89282. }
  89283. declare module BABYLON {
  89284. /**
  89285. * Interface describing all the common properties and methods a shadow light needs to implement.
  89286. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89287. * as well as binding the different shadow properties to the effects.
  89288. */
  89289. export interface IShadowLight extends Light {
  89290. /**
  89291. * The light id in the scene (used in scene.findLighById for instance)
  89292. */
  89293. id: string;
  89294. /**
  89295. * The position the shdow will be casted from.
  89296. */
  89297. position: Vector3;
  89298. /**
  89299. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89300. */
  89301. direction: Vector3;
  89302. /**
  89303. * The transformed position. Position of the light in world space taking parenting in account.
  89304. */
  89305. transformedPosition: Vector3;
  89306. /**
  89307. * The transformed direction. Direction of the light in world space taking parenting in account.
  89308. */
  89309. transformedDirection: Vector3;
  89310. /**
  89311. * The friendly name of the light in the scene.
  89312. */
  89313. name: string;
  89314. /**
  89315. * Defines the shadow projection clipping minimum z value.
  89316. */
  89317. shadowMinZ: number;
  89318. /**
  89319. * Defines the shadow projection clipping maximum z value.
  89320. */
  89321. shadowMaxZ: number;
  89322. /**
  89323. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89324. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89325. */
  89326. computeTransformedInformation(): boolean;
  89327. /**
  89328. * Gets the scene the light belongs to.
  89329. * @returns The scene
  89330. */
  89331. getScene(): Scene;
  89332. /**
  89333. * Callback defining a custom Projection Matrix Builder.
  89334. * This can be used to override the default projection matrix computation.
  89335. */
  89336. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89337. /**
  89338. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89339. * @param matrix The materix to updated with the projection information
  89340. * @param viewMatrix The transform matrix of the light
  89341. * @param renderList The list of mesh to render in the map
  89342. * @returns The current light
  89343. */
  89344. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89345. /**
  89346. * Gets the current depth scale used in ESM.
  89347. * @returns The scale
  89348. */
  89349. getDepthScale(): number;
  89350. /**
  89351. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89352. * @returns true if a cube texture needs to be use
  89353. */
  89354. needCube(): boolean;
  89355. /**
  89356. * Detects if the projection matrix requires to be recomputed this frame.
  89357. * @returns true if it requires to be recomputed otherwise, false.
  89358. */
  89359. needProjectionMatrixCompute(): boolean;
  89360. /**
  89361. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89362. */
  89363. forceProjectionMatrixCompute(): void;
  89364. /**
  89365. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89366. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89367. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89368. */
  89369. getShadowDirection(faceIndex?: number): Vector3;
  89370. /**
  89371. * Gets the minZ used for shadow according to both the scene and the light.
  89372. * @param activeCamera The camera we are returning the min for
  89373. * @returns the depth min z
  89374. */
  89375. getDepthMinZ(activeCamera: Camera): number;
  89376. /**
  89377. * Gets the maxZ used for shadow according to both the scene and the light.
  89378. * @param activeCamera The camera we are returning the max for
  89379. * @returns the depth max z
  89380. */
  89381. getDepthMaxZ(activeCamera: Camera): number;
  89382. }
  89383. /**
  89384. * Base implementation IShadowLight
  89385. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89386. */
  89387. export abstract class ShadowLight extends Light implements IShadowLight {
  89388. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89389. protected _position: Vector3;
  89390. protected _setPosition(value: Vector3): void;
  89391. /**
  89392. * Sets the position the shadow will be casted from. Also use as the light position for both
  89393. * point and spot lights.
  89394. */
  89395. get position(): Vector3;
  89396. /**
  89397. * Sets the position the shadow will be casted from. Also use as the light position for both
  89398. * point and spot lights.
  89399. */
  89400. set position(value: Vector3);
  89401. protected _direction: Vector3;
  89402. protected _setDirection(value: Vector3): void;
  89403. /**
  89404. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89405. * Also use as the light direction on spot and directional lights.
  89406. */
  89407. get direction(): Vector3;
  89408. /**
  89409. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89410. * Also use as the light direction on spot and directional lights.
  89411. */
  89412. set direction(value: Vector3);
  89413. protected _shadowMinZ: number;
  89414. /**
  89415. * Gets the shadow projection clipping minimum z value.
  89416. */
  89417. get shadowMinZ(): number;
  89418. /**
  89419. * Sets the shadow projection clipping minimum z value.
  89420. */
  89421. set shadowMinZ(value: number);
  89422. protected _shadowMaxZ: number;
  89423. /**
  89424. * Sets the shadow projection clipping maximum z value.
  89425. */
  89426. get shadowMaxZ(): number;
  89427. /**
  89428. * Gets the shadow projection clipping maximum z value.
  89429. */
  89430. set shadowMaxZ(value: number);
  89431. /**
  89432. * Callback defining a custom Projection Matrix Builder.
  89433. * This can be used to override the default projection matrix computation.
  89434. */
  89435. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89436. /**
  89437. * The transformed position. Position of the light in world space taking parenting in account.
  89438. */
  89439. transformedPosition: Vector3;
  89440. /**
  89441. * The transformed direction. Direction of the light in world space taking parenting in account.
  89442. */
  89443. transformedDirection: Vector3;
  89444. private _needProjectionMatrixCompute;
  89445. /**
  89446. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89447. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89448. */
  89449. computeTransformedInformation(): boolean;
  89450. /**
  89451. * Return the depth scale used for the shadow map.
  89452. * @returns the depth scale.
  89453. */
  89454. getDepthScale(): number;
  89455. /**
  89456. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89457. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89458. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89459. */
  89460. getShadowDirection(faceIndex?: number): Vector3;
  89461. /**
  89462. * Returns the ShadowLight absolute position in the World.
  89463. * @returns the position vector in world space
  89464. */
  89465. getAbsolutePosition(): Vector3;
  89466. /**
  89467. * Sets the ShadowLight direction toward the passed target.
  89468. * @param target The point to target in local space
  89469. * @returns the updated ShadowLight direction
  89470. */
  89471. setDirectionToTarget(target: Vector3): Vector3;
  89472. /**
  89473. * Returns the light rotation in euler definition.
  89474. * @returns the x y z rotation in local space.
  89475. */
  89476. getRotation(): Vector3;
  89477. /**
  89478. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89479. * @returns true if a cube texture needs to be use
  89480. */
  89481. needCube(): boolean;
  89482. /**
  89483. * Detects if the projection matrix requires to be recomputed this frame.
  89484. * @returns true if it requires to be recomputed otherwise, false.
  89485. */
  89486. needProjectionMatrixCompute(): boolean;
  89487. /**
  89488. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89489. */
  89490. forceProjectionMatrixCompute(): void;
  89491. /** @hidden */
  89492. _initCache(): void;
  89493. /** @hidden */
  89494. _isSynchronized(): boolean;
  89495. /**
  89496. * Computes the world matrix of the node
  89497. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89498. * @returns the world matrix
  89499. */
  89500. computeWorldMatrix(force?: boolean): Matrix;
  89501. /**
  89502. * Gets the minZ used for shadow according to both the scene and the light.
  89503. * @param activeCamera The camera we are returning the min for
  89504. * @returns the depth min z
  89505. */
  89506. getDepthMinZ(activeCamera: Camera): number;
  89507. /**
  89508. * Gets the maxZ used for shadow according to both the scene and the light.
  89509. * @param activeCamera The camera we are returning the max for
  89510. * @returns the depth max z
  89511. */
  89512. getDepthMaxZ(activeCamera: Camera): number;
  89513. /**
  89514. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89515. * @param matrix The materix to updated with the projection information
  89516. * @param viewMatrix The transform matrix of the light
  89517. * @param renderList The list of mesh to render in the map
  89518. * @returns The current light
  89519. */
  89520. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89521. }
  89522. }
  89523. declare module BABYLON {
  89524. /** @hidden */
  89525. export var packingFunctions: {
  89526. name: string;
  89527. shader: string;
  89528. };
  89529. }
  89530. declare module BABYLON {
  89531. /** @hidden */
  89532. export var bayerDitherFunctions: {
  89533. name: string;
  89534. shader: string;
  89535. };
  89536. }
  89537. declare module BABYLON {
  89538. /** @hidden */
  89539. export var shadowMapFragmentDeclaration: {
  89540. name: string;
  89541. shader: string;
  89542. };
  89543. }
  89544. declare module BABYLON {
  89545. /** @hidden */
  89546. export var clipPlaneFragmentDeclaration: {
  89547. name: string;
  89548. shader: string;
  89549. };
  89550. }
  89551. declare module BABYLON {
  89552. /** @hidden */
  89553. export var clipPlaneFragment: {
  89554. name: string;
  89555. shader: string;
  89556. };
  89557. }
  89558. declare module BABYLON {
  89559. /** @hidden */
  89560. export var shadowMapFragment: {
  89561. name: string;
  89562. shader: string;
  89563. };
  89564. }
  89565. declare module BABYLON {
  89566. /** @hidden */
  89567. export var shadowMapPixelShader: {
  89568. name: string;
  89569. shader: string;
  89570. };
  89571. }
  89572. declare module BABYLON {
  89573. /** @hidden */
  89574. export var bonesDeclaration: {
  89575. name: string;
  89576. shader: string;
  89577. };
  89578. }
  89579. declare module BABYLON {
  89580. /** @hidden */
  89581. export var morphTargetsVertexGlobalDeclaration: {
  89582. name: string;
  89583. shader: string;
  89584. };
  89585. }
  89586. declare module BABYLON {
  89587. /** @hidden */
  89588. export var morphTargetsVertexDeclaration: {
  89589. name: string;
  89590. shader: string;
  89591. };
  89592. }
  89593. declare module BABYLON {
  89594. /** @hidden */
  89595. export var instancesDeclaration: {
  89596. name: string;
  89597. shader: string;
  89598. };
  89599. }
  89600. declare module BABYLON {
  89601. /** @hidden */
  89602. export var helperFunctions: {
  89603. name: string;
  89604. shader: string;
  89605. };
  89606. }
  89607. declare module BABYLON {
  89608. /** @hidden */
  89609. export var shadowMapVertexDeclaration: {
  89610. name: string;
  89611. shader: string;
  89612. };
  89613. }
  89614. declare module BABYLON {
  89615. /** @hidden */
  89616. export var clipPlaneVertexDeclaration: {
  89617. name: string;
  89618. shader: string;
  89619. };
  89620. }
  89621. declare module BABYLON {
  89622. /** @hidden */
  89623. export var morphTargetsVertex: {
  89624. name: string;
  89625. shader: string;
  89626. };
  89627. }
  89628. declare module BABYLON {
  89629. /** @hidden */
  89630. export var instancesVertex: {
  89631. name: string;
  89632. shader: string;
  89633. };
  89634. }
  89635. declare module BABYLON {
  89636. /** @hidden */
  89637. export var bonesVertex: {
  89638. name: string;
  89639. shader: string;
  89640. };
  89641. }
  89642. declare module BABYLON {
  89643. /** @hidden */
  89644. export var shadowMapVertexNormalBias: {
  89645. name: string;
  89646. shader: string;
  89647. };
  89648. }
  89649. declare module BABYLON {
  89650. /** @hidden */
  89651. export var shadowMapVertexMetric: {
  89652. name: string;
  89653. shader: string;
  89654. };
  89655. }
  89656. declare module BABYLON {
  89657. /** @hidden */
  89658. export var clipPlaneVertex: {
  89659. name: string;
  89660. shader: string;
  89661. };
  89662. }
  89663. declare module BABYLON {
  89664. /** @hidden */
  89665. export var shadowMapVertexShader: {
  89666. name: string;
  89667. shader: string;
  89668. };
  89669. }
  89670. declare module BABYLON {
  89671. /** @hidden */
  89672. export var depthBoxBlurPixelShader: {
  89673. name: string;
  89674. shader: string;
  89675. };
  89676. }
  89677. declare module BABYLON {
  89678. /** @hidden */
  89679. export var shadowMapFragmentSoftTransparentShadow: {
  89680. name: string;
  89681. shader: string;
  89682. };
  89683. }
  89684. declare module BABYLON {
  89685. /**
  89686. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89687. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89688. */
  89689. export class EffectFallbacks implements IEffectFallbacks {
  89690. private _defines;
  89691. private _currentRank;
  89692. private _maxRank;
  89693. private _mesh;
  89694. /**
  89695. * Removes the fallback from the bound mesh.
  89696. */
  89697. unBindMesh(): void;
  89698. /**
  89699. * Adds a fallback on the specified property.
  89700. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89701. * @param define The name of the define in the shader
  89702. */
  89703. addFallback(rank: number, define: string): void;
  89704. /**
  89705. * Sets the mesh to use CPU skinning when needing to fallback.
  89706. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89707. * @param mesh The mesh to use the fallbacks.
  89708. */
  89709. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89710. /**
  89711. * Checks to see if more fallbacks are still availible.
  89712. */
  89713. get hasMoreFallbacks(): boolean;
  89714. /**
  89715. * Removes the defines that should be removed when falling back.
  89716. * @param currentDefines defines the current define statements for the shader.
  89717. * @param effect defines the current effect we try to compile
  89718. * @returns The resulting defines with defines of the current rank removed.
  89719. */
  89720. reduce(currentDefines: string, effect: Effect): string;
  89721. }
  89722. }
  89723. declare module BABYLON {
  89724. /**
  89725. * Interface used to define Action
  89726. */
  89727. export interface IAction {
  89728. /**
  89729. * Trigger for the action
  89730. */
  89731. trigger: number;
  89732. /** Options of the trigger */
  89733. triggerOptions: any;
  89734. /**
  89735. * Gets the trigger parameters
  89736. * @returns the trigger parameters
  89737. */
  89738. getTriggerParameter(): any;
  89739. /**
  89740. * Internal only - executes current action event
  89741. * @hidden
  89742. */
  89743. _executeCurrent(evt?: ActionEvent): void;
  89744. /**
  89745. * Serialize placeholder for child classes
  89746. * @param parent of child
  89747. * @returns the serialized object
  89748. */
  89749. serialize(parent: any): any;
  89750. /**
  89751. * Internal only
  89752. * @hidden
  89753. */
  89754. _prepare(): void;
  89755. /**
  89756. * Internal only - manager for action
  89757. * @hidden
  89758. */
  89759. _actionManager: Nullable<AbstractActionManager>;
  89760. /**
  89761. * Adds action to chain of actions, may be a DoNothingAction
  89762. * @param action defines the next action to execute
  89763. * @returns The action passed in
  89764. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89765. */
  89766. then(action: IAction): IAction;
  89767. }
  89768. /**
  89769. * The action to be carried out following a trigger
  89770. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89771. */
  89772. export class Action implements IAction {
  89773. /** the trigger, with or without parameters, for the action */
  89774. triggerOptions: any;
  89775. /**
  89776. * Trigger for the action
  89777. */
  89778. trigger: number;
  89779. /**
  89780. * Internal only - manager for action
  89781. * @hidden
  89782. */
  89783. _actionManager: ActionManager;
  89784. private _nextActiveAction;
  89785. private _child;
  89786. private _condition?;
  89787. private _triggerParameter;
  89788. /**
  89789. * An event triggered prior to action being executed.
  89790. */
  89791. onBeforeExecuteObservable: Observable<Action>;
  89792. /**
  89793. * Creates a new Action
  89794. * @param triggerOptions the trigger, with or without parameters, for the action
  89795. * @param condition an optional determinant of action
  89796. */
  89797. constructor(
  89798. /** the trigger, with or without parameters, for the action */
  89799. triggerOptions: any, condition?: Condition);
  89800. /**
  89801. * Internal only
  89802. * @hidden
  89803. */
  89804. _prepare(): void;
  89805. /**
  89806. * Gets the trigger parameters
  89807. * @returns the trigger parameters
  89808. */
  89809. getTriggerParameter(): any;
  89810. /**
  89811. * Internal only - executes current action event
  89812. * @hidden
  89813. */
  89814. _executeCurrent(evt?: ActionEvent): void;
  89815. /**
  89816. * Execute placeholder for child classes
  89817. * @param evt optional action event
  89818. */
  89819. execute(evt?: ActionEvent): void;
  89820. /**
  89821. * Skips to next active action
  89822. */
  89823. skipToNextActiveAction(): void;
  89824. /**
  89825. * Adds action to chain of actions, may be a DoNothingAction
  89826. * @param action defines the next action to execute
  89827. * @returns The action passed in
  89828. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89829. */
  89830. then(action: Action): Action;
  89831. /**
  89832. * Internal only
  89833. * @hidden
  89834. */
  89835. _getProperty(propertyPath: string): string;
  89836. /**
  89837. * Internal only
  89838. * @hidden
  89839. */
  89840. _getEffectiveTarget(target: any, propertyPath: string): any;
  89841. /**
  89842. * Serialize placeholder for child classes
  89843. * @param parent of child
  89844. * @returns the serialized object
  89845. */
  89846. serialize(parent: any): any;
  89847. /**
  89848. * Internal only called by serialize
  89849. * @hidden
  89850. */
  89851. protected _serialize(serializedAction: any, parent?: any): any;
  89852. /**
  89853. * Internal only
  89854. * @hidden
  89855. */
  89856. static _SerializeValueAsString: (value: any) => string;
  89857. /**
  89858. * Internal only
  89859. * @hidden
  89860. */
  89861. static _GetTargetProperty: (target: Scene | Node) => {
  89862. name: string;
  89863. targetType: string;
  89864. value: string;
  89865. };
  89866. }
  89867. }
  89868. declare module BABYLON {
  89869. /**
  89870. * A Condition applied to an Action
  89871. */
  89872. export class Condition {
  89873. /**
  89874. * Internal only - manager for action
  89875. * @hidden
  89876. */
  89877. _actionManager: ActionManager;
  89878. /**
  89879. * Internal only
  89880. * @hidden
  89881. */
  89882. _evaluationId: number;
  89883. /**
  89884. * Internal only
  89885. * @hidden
  89886. */
  89887. _currentResult: boolean;
  89888. /**
  89889. * Creates a new Condition
  89890. * @param actionManager the manager of the action the condition is applied to
  89891. */
  89892. constructor(actionManager: ActionManager);
  89893. /**
  89894. * Check if the current condition is valid
  89895. * @returns a boolean
  89896. */
  89897. isValid(): boolean;
  89898. /**
  89899. * Internal only
  89900. * @hidden
  89901. */
  89902. _getProperty(propertyPath: string): string;
  89903. /**
  89904. * Internal only
  89905. * @hidden
  89906. */
  89907. _getEffectiveTarget(target: any, propertyPath: string): any;
  89908. /**
  89909. * Serialize placeholder for child classes
  89910. * @returns the serialized object
  89911. */
  89912. serialize(): any;
  89913. /**
  89914. * Internal only
  89915. * @hidden
  89916. */
  89917. protected _serialize(serializedCondition: any): any;
  89918. }
  89919. /**
  89920. * Defines specific conditional operators as extensions of Condition
  89921. */
  89922. export class ValueCondition extends Condition {
  89923. /** path to specify the property of the target the conditional operator uses */
  89924. propertyPath: string;
  89925. /** the value compared by the conditional operator against the current value of the property */
  89926. value: any;
  89927. /** the conditional operator, default ValueCondition.IsEqual */
  89928. operator: number;
  89929. /**
  89930. * Internal only
  89931. * @hidden
  89932. */
  89933. private static _IsEqual;
  89934. /**
  89935. * Internal only
  89936. * @hidden
  89937. */
  89938. private static _IsDifferent;
  89939. /**
  89940. * Internal only
  89941. * @hidden
  89942. */
  89943. private static _IsGreater;
  89944. /**
  89945. * Internal only
  89946. * @hidden
  89947. */
  89948. private static _IsLesser;
  89949. /**
  89950. * returns the number for IsEqual
  89951. */
  89952. static get IsEqual(): number;
  89953. /**
  89954. * Returns the number for IsDifferent
  89955. */
  89956. static get IsDifferent(): number;
  89957. /**
  89958. * Returns the number for IsGreater
  89959. */
  89960. static get IsGreater(): number;
  89961. /**
  89962. * Returns the number for IsLesser
  89963. */
  89964. static get IsLesser(): number;
  89965. /**
  89966. * Internal only The action manager for the condition
  89967. * @hidden
  89968. */
  89969. _actionManager: ActionManager;
  89970. /**
  89971. * Internal only
  89972. * @hidden
  89973. */
  89974. private _target;
  89975. /**
  89976. * Internal only
  89977. * @hidden
  89978. */
  89979. private _effectiveTarget;
  89980. /**
  89981. * Internal only
  89982. * @hidden
  89983. */
  89984. private _property;
  89985. /**
  89986. * Creates a new ValueCondition
  89987. * @param actionManager manager for the action the condition applies to
  89988. * @param target for the action
  89989. * @param propertyPath path to specify the property of the target the conditional operator uses
  89990. * @param value the value compared by the conditional operator against the current value of the property
  89991. * @param operator the conditional operator, default ValueCondition.IsEqual
  89992. */
  89993. constructor(actionManager: ActionManager, target: any,
  89994. /** path to specify the property of the target the conditional operator uses */
  89995. propertyPath: string,
  89996. /** the value compared by the conditional operator against the current value of the property */
  89997. value: any,
  89998. /** the conditional operator, default ValueCondition.IsEqual */
  89999. operator?: number);
  90000. /**
  90001. * Compares the given value with the property value for the specified conditional operator
  90002. * @returns the result of the comparison
  90003. */
  90004. isValid(): boolean;
  90005. /**
  90006. * Serialize the ValueCondition into a JSON compatible object
  90007. * @returns serialization object
  90008. */
  90009. serialize(): any;
  90010. /**
  90011. * Gets the name of the conditional operator for the ValueCondition
  90012. * @param operator the conditional operator
  90013. * @returns the name
  90014. */
  90015. static GetOperatorName(operator: number): string;
  90016. }
  90017. /**
  90018. * Defines a predicate condition as an extension of Condition
  90019. */
  90020. export class PredicateCondition extends Condition {
  90021. /** defines the predicate function used to validate the condition */
  90022. predicate: () => boolean;
  90023. /**
  90024. * Internal only - manager for action
  90025. * @hidden
  90026. */
  90027. _actionManager: ActionManager;
  90028. /**
  90029. * Creates a new PredicateCondition
  90030. * @param actionManager manager for the action the condition applies to
  90031. * @param predicate defines the predicate function used to validate the condition
  90032. */
  90033. constructor(actionManager: ActionManager,
  90034. /** defines the predicate function used to validate the condition */
  90035. predicate: () => boolean);
  90036. /**
  90037. * @returns the validity of the predicate condition
  90038. */
  90039. isValid(): boolean;
  90040. }
  90041. /**
  90042. * Defines a state condition as an extension of Condition
  90043. */
  90044. export class StateCondition extends Condition {
  90045. /** Value to compare with target state */
  90046. value: string;
  90047. /**
  90048. * Internal only - manager for action
  90049. * @hidden
  90050. */
  90051. _actionManager: ActionManager;
  90052. /**
  90053. * Internal only
  90054. * @hidden
  90055. */
  90056. private _target;
  90057. /**
  90058. * Creates a new StateCondition
  90059. * @param actionManager manager for the action the condition applies to
  90060. * @param target of the condition
  90061. * @param value to compare with target state
  90062. */
  90063. constructor(actionManager: ActionManager, target: any,
  90064. /** Value to compare with target state */
  90065. value: string);
  90066. /**
  90067. * Gets a boolean indicating if the current condition is met
  90068. * @returns the validity of the state
  90069. */
  90070. isValid(): boolean;
  90071. /**
  90072. * Serialize the StateCondition into a JSON compatible object
  90073. * @returns serialization object
  90074. */
  90075. serialize(): any;
  90076. }
  90077. }
  90078. declare module BABYLON {
  90079. /**
  90080. * This defines an action responsible to toggle a boolean once triggered.
  90081. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90082. */
  90083. export class SwitchBooleanAction extends Action {
  90084. /**
  90085. * The path to the boolean property in the target object
  90086. */
  90087. propertyPath: string;
  90088. private _target;
  90089. private _effectiveTarget;
  90090. private _property;
  90091. /**
  90092. * Instantiate the action
  90093. * @param triggerOptions defines the trigger options
  90094. * @param target defines the object containing the boolean
  90095. * @param propertyPath defines the path to the boolean property in the target object
  90096. * @param condition defines the trigger related conditions
  90097. */
  90098. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90099. /** @hidden */
  90100. _prepare(): void;
  90101. /**
  90102. * Execute the action toggle the boolean value.
  90103. */
  90104. execute(): void;
  90105. /**
  90106. * Serializes the actions and its related information.
  90107. * @param parent defines the object to serialize in
  90108. * @returns the serialized object
  90109. */
  90110. serialize(parent: any): any;
  90111. }
  90112. /**
  90113. * This defines an action responsible to set a the state field of the target
  90114. * to a desired value once triggered.
  90115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90116. */
  90117. export class SetStateAction extends Action {
  90118. /**
  90119. * The value to store in the state field.
  90120. */
  90121. value: string;
  90122. private _target;
  90123. /**
  90124. * Instantiate the action
  90125. * @param triggerOptions defines the trigger options
  90126. * @param target defines the object containing the state property
  90127. * @param value defines the value to store in the state field
  90128. * @param condition defines the trigger related conditions
  90129. */
  90130. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90131. /**
  90132. * Execute the action and store the value on the target state property.
  90133. */
  90134. execute(): void;
  90135. /**
  90136. * Serializes the actions and its related information.
  90137. * @param parent defines the object to serialize in
  90138. * @returns the serialized object
  90139. */
  90140. serialize(parent: any): any;
  90141. }
  90142. /**
  90143. * This defines an action responsible to set a property of the target
  90144. * to a desired value once triggered.
  90145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90146. */
  90147. export class SetValueAction extends Action {
  90148. /**
  90149. * The path of the property to set in the target.
  90150. */
  90151. propertyPath: string;
  90152. /**
  90153. * The value to set in the property
  90154. */
  90155. value: any;
  90156. private _target;
  90157. private _effectiveTarget;
  90158. private _property;
  90159. /**
  90160. * Instantiate the action
  90161. * @param triggerOptions defines the trigger options
  90162. * @param target defines the object containing the property
  90163. * @param propertyPath defines the path of the property to set in the target
  90164. * @param value defines the value to set in the property
  90165. * @param condition defines the trigger related conditions
  90166. */
  90167. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90168. /** @hidden */
  90169. _prepare(): void;
  90170. /**
  90171. * Execute the action and set the targetted property to the desired value.
  90172. */
  90173. execute(): void;
  90174. /**
  90175. * Serializes the actions and its related information.
  90176. * @param parent defines the object to serialize in
  90177. * @returns the serialized object
  90178. */
  90179. serialize(parent: any): any;
  90180. }
  90181. /**
  90182. * This defines an action responsible to increment the target value
  90183. * to a desired value once triggered.
  90184. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90185. */
  90186. export class IncrementValueAction extends Action {
  90187. /**
  90188. * The path of the property to increment in the target.
  90189. */
  90190. propertyPath: string;
  90191. /**
  90192. * The value we should increment the property by.
  90193. */
  90194. value: any;
  90195. private _target;
  90196. private _effectiveTarget;
  90197. private _property;
  90198. /**
  90199. * Instantiate the action
  90200. * @param triggerOptions defines the trigger options
  90201. * @param target defines the object containing the property
  90202. * @param propertyPath defines the path of the property to increment in the target
  90203. * @param value defines the value value we should increment the property by
  90204. * @param condition defines the trigger related conditions
  90205. */
  90206. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90207. /** @hidden */
  90208. _prepare(): void;
  90209. /**
  90210. * Execute the action and increment the target of the value amount.
  90211. */
  90212. execute(): void;
  90213. /**
  90214. * Serializes the actions and its related information.
  90215. * @param parent defines the object to serialize in
  90216. * @returns the serialized object
  90217. */
  90218. serialize(parent: any): any;
  90219. }
  90220. /**
  90221. * This defines an action responsible to start an animation once triggered.
  90222. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90223. */
  90224. export class PlayAnimationAction extends Action {
  90225. /**
  90226. * Where the animation should start (animation frame)
  90227. */
  90228. from: number;
  90229. /**
  90230. * Where the animation should stop (animation frame)
  90231. */
  90232. to: number;
  90233. /**
  90234. * Define if the animation should loop or stop after the first play.
  90235. */
  90236. loop?: boolean;
  90237. private _target;
  90238. /**
  90239. * Instantiate the action
  90240. * @param triggerOptions defines the trigger options
  90241. * @param target defines the target animation or animation name
  90242. * @param from defines from where the animation should start (animation frame)
  90243. * @param end defines where the animation should stop (animation frame)
  90244. * @param loop defines if the animation should loop or stop after the first play
  90245. * @param condition defines the trigger related conditions
  90246. */
  90247. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90248. /** @hidden */
  90249. _prepare(): void;
  90250. /**
  90251. * Execute the action and play the animation.
  90252. */
  90253. execute(): void;
  90254. /**
  90255. * Serializes the actions and its related information.
  90256. * @param parent defines the object to serialize in
  90257. * @returns the serialized object
  90258. */
  90259. serialize(parent: any): any;
  90260. }
  90261. /**
  90262. * This defines an action responsible to stop an animation once triggered.
  90263. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90264. */
  90265. export class StopAnimationAction extends Action {
  90266. private _target;
  90267. /**
  90268. * Instantiate the action
  90269. * @param triggerOptions defines the trigger options
  90270. * @param target defines the target animation or animation name
  90271. * @param condition defines the trigger related conditions
  90272. */
  90273. constructor(triggerOptions: any, target: any, condition?: Condition);
  90274. /** @hidden */
  90275. _prepare(): void;
  90276. /**
  90277. * Execute the action and stop the animation.
  90278. */
  90279. execute(): void;
  90280. /**
  90281. * Serializes the actions and its related information.
  90282. * @param parent defines the object to serialize in
  90283. * @returns the serialized object
  90284. */
  90285. serialize(parent: any): any;
  90286. }
  90287. /**
  90288. * This defines an action responsible that does nothing once triggered.
  90289. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90290. */
  90291. export class DoNothingAction extends Action {
  90292. /**
  90293. * Instantiate the action
  90294. * @param triggerOptions defines the trigger options
  90295. * @param condition defines the trigger related conditions
  90296. */
  90297. constructor(triggerOptions?: any, condition?: Condition);
  90298. /**
  90299. * Execute the action and do nothing.
  90300. */
  90301. execute(): void;
  90302. /**
  90303. * Serializes the actions and its related information.
  90304. * @param parent defines the object to serialize in
  90305. * @returns the serialized object
  90306. */
  90307. serialize(parent: any): any;
  90308. }
  90309. /**
  90310. * This defines an action responsible to trigger several actions once triggered.
  90311. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90312. */
  90313. export class CombineAction extends Action {
  90314. /**
  90315. * The list of aggregated animations to run.
  90316. */
  90317. children: Action[];
  90318. /**
  90319. * Instantiate the action
  90320. * @param triggerOptions defines the trigger options
  90321. * @param children defines the list of aggregated animations to run
  90322. * @param condition defines the trigger related conditions
  90323. */
  90324. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90325. /** @hidden */
  90326. _prepare(): void;
  90327. /**
  90328. * Execute the action and executes all the aggregated actions.
  90329. */
  90330. execute(evt: ActionEvent): void;
  90331. /**
  90332. * Serializes the actions and its related information.
  90333. * @param parent defines the object to serialize in
  90334. * @returns the serialized object
  90335. */
  90336. serialize(parent: any): any;
  90337. }
  90338. /**
  90339. * This defines an action responsible to run code (external event) once triggered.
  90340. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90341. */
  90342. export class ExecuteCodeAction extends Action {
  90343. /**
  90344. * The callback function to run.
  90345. */
  90346. func: (evt: ActionEvent) => void;
  90347. /**
  90348. * Instantiate the action
  90349. * @param triggerOptions defines the trigger options
  90350. * @param func defines the callback function to run
  90351. * @param condition defines the trigger related conditions
  90352. */
  90353. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90354. /**
  90355. * Execute the action and run the attached code.
  90356. */
  90357. execute(evt: ActionEvent): void;
  90358. }
  90359. /**
  90360. * This defines an action responsible to set the parent property of the target once triggered.
  90361. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90362. */
  90363. export class SetParentAction extends Action {
  90364. private _parent;
  90365. private _target;
  90366. /**
  90367. * Instantiate the action
  90368. * @param triggerOptions defines the trigger options
  90369. * @param target defines the target containing the parent property
  90370. * @param parent defines from where the animation should start (animation frame)
  90371. * @param condition defines the trigger related conditions
  90372. */
  90373. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90374. /** @hidden */
  90375. _prepare(): void;
  90376. /**
  90377. * Execute the action and set the parent property.
  90378. */
  90379. execute(): void;
  90380. /**
  90381. * Serializes the actions and its related information.
  90382. * @param parent defines the object to serialize in
  90383. * @returns the serialized object
  90384. */
  90385. serialize(parent: any): any;
  90386. }
  90387. }
  90388. declare module BABYLON {
  90389. /**
  90390. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90391. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90392. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90393. */
  90394. export class ActionManager extends AbstractActionManager {
  90395. /**
  90396. * Nothing
  90397. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90398. */
  90399. static readonly NothingTrigger: number;
  90400. /**
  90401. * On pick
  90402. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90403. */
  90404. static readonly OnPickTrigger: number;
  90405. /**
  90406. * On left pick
  90407. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90408. */
  90409. static readonly OnLeftPickTrigger: number;
  90410. /**
  90411. * On right pick
  90412. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90413. */
  90414. static readonly OnRightPickTrigger: number;
  90415. /**
  90416. * On center pick
  90417. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90418. */
  90419. static readonly OnCenterPickTrigger: number;
  90420. /**
  90421. * On pick down
  90422. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90423. */
  90424. static readonly OnPickDownTrigger: number;
  90425. /**
  90426. * On double pick
  90427. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90428. */
  90429. static readonly OnDoublePickTrigger: number;
  90430. /**
  90431. * On pick up
  90432. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90433. */
  90434. static readonly OnPickUpTrigger: number;
  90435. /**
  90436. * On pick out.
  90437. * This trigger will only be raised if you also declared a OnPickDown
  90438. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90439. */
  90440. static readonly OnPickOutTrigger: number;
  90441. /**
  90442. * On long press
  90443. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90444. */
  90445. static readonly OnLongPressTrigger: number;
  90446. /**
  90447. * On pointer over
  90448. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90449. */
  90450. static readonly OnPointerOverTrigger: number;
  90451. /**
  90452. * On pointer out
  90453. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90454. */
  90455. static readonly OnPointerOutTrigger: number;
  90456. /**
  90457. * On every frame
  90458. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90459. */
  90460. static readonly OnEveryFrameTrigger: number;
  90461. /**
  90462. * On intersection enter
  90463. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90464. */
  90465. static readonly OnIntersectionEnterTrigger: number;
  90466. /**
  90467. * On intersection exit
  90468. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90469. */
  90470. static readonly OnIntersectionExitTrigger: number;
  90471. /**
  90472. * On key down
  90473. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90474. */
  90475. static readonly OnKeyDownTrigger: number;
  90476. /**
  90477. * On key up
  90478. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90479. */
  90480. static readonly OnKeyUpTrigger: number;
  90481. private _scene;
  90482. /**
  90483. * Creates a new action manager
  90484. * @param scene defines the hosting scene
  90485. */
  90486. constructor(scene: Scene);
  90487. /**
  90488. * Releases all associated resources
  90489. */
  90490. dispose(): void;
  90491. /**
  90492. * Gets hosting scene
  90493. * @returns the hosting scene
  90494. */
  90495. getScene(): Scene;
  90496. /**
  90497. * Does this action manager handles actions of any of the given triggers
  90498. * @param triggers defines the triggers to be tested
  90499. * @return a boolean indicating whether one (or more) of the triggers is handled
  90500. */
  90501. hasSpecificTriggers(triggers: number[]): boolean;
  90502. /**
  90503. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90504. * speed.
  90505. * @param triggerA defines the trigger to be tested
  90506. * @param triggerB defines the trigger to be tested
  90507. * @return a boolean indicating whether one (or more) of the triggers is handled
  90508. */
  90509. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90510. /**
  90511. * Does this action manager handles actions of a given trigger
  90512. * @param trigger defines the trigger to be tested
  90513. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90514. * @return whether the trigger is handled
  90515. */
  90516. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90517. /**
  90518. * Does this action manager has pointer triggers
  90519. */
  90520. get hasPointerTriggers(): boolean;
  90521. /**
  90522. * Does this action manager has pick triggers
  90523. */
  90524. get hasPickTriggers(): boolean;
  90525. /**
  90526. * Registers an action to this action manager
  90527. * @param action defines the action to be registered
  90528. * @return the action amended (prepared) after registration
  90529. */
  90530. registerAction(action: IAction): Nullable<IAction>;
  90531. /**
  90532. * Unregisters an action to this action manager
  90533. * @param action defines the action to be unregistered
  90534. * @return a boolean indicating whether the action has been unregistered
  90535. */
  90536. unregisterAction(action: IAction): Boolean;
  90537. /**
  90538. * Process a specific trigger
  90539. * @param trigger defines the trigger to process
  90540. * @param evt defines the event details to be processed
  90541. */
  90542. processTrigger(trigger: number, evt?: IActionEvent): void;
  90543. /** @hidden */
  90544. _getEffectiveTarget(target: any, propertyPath: string): any;
  90545. /** @hidden */
  90546. _getProperty(propertyPath: string): string;
  90547. /**
  90548. * Serialize this manager to a JSON object
  90549. * @param name defines the property name to store this manager
  90550. * @returns a JSON representation of this manager
  90551. */
  90552. serialize(name: string): any;
  90553. /**
  90554. * Creates a new ActionManager from a JSON data
  90555. * @param parsedActions defines the JSON data to read from
  90556. * @param object defines the hosting mesh
  90557. * @param scene defines the hosting scene
  90558. */
  90559. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90560. /**
  90561. * Get a trigger name by index
  90562. * @param trigger defines the trigger index
  90563. * @returns a trigger name
  90564. */
  90565. static GetTriggerName(trigger: number): string;
  90566. }
  90567. }
  90568. declare module BABYLON {
  90569. /**
  90570. * Class used to represent a sprite
  90571. * @see https://doc.babylonjs.com/babylon101/sprites
  90572. */
  90573. export class Sprite implements IAnimatable {
  90574. /** defines the name */
  90575. name: string;
  90576. /** Gets or sets the current world position */
  90577. position: Vector3;
  90578. /** Gets or sets the main color */
  90579. color: Color4;
  90580. /** Gets or sets the width */
  90581. width: number;
  90582. /** Gets or sets the height */
  90583. height: number;
  90584. /** Gets or sets rotation angle */
  90585. angle: number;
  90586. /** Gets or sets the cell index in the sprite sheet */
  90587. cellIndex: number;
  90588. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90589. cellRef: string;
  90590. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90591. invertU: boolean;
  90592. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90593. invertV: boolean;
  90594. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90595. disposeWhenFinishedAnimating: boolean;
  90596. /** Gets the list of attached animations */
  90597. animations: Nullable<Array<Animation>>;
  90598. /** Gets or sets a boolean indicating if the sprite can be picked */
  90599. isPickable: boolean;
  90600. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90601. useAlphaForPicking: boolean;
  90602. /** @hidden */
  90603. _xOffset: number;
  90604. /** @hidden */
  90605. _yOffset: number;
  90606. /** @hidden */
  90607. _xSize: number;
  90608. /** @hidden */
  90609. _ySize: number;
  90610. /**
  90611. * Gets or sets the associated action manager
  90612. */
  90613. actionManager: Nullable<ActionManager>;
  90614. /**
  90615. * An event triggered when the control has been disposed
  90616. */
  90617. onDisposeObservable: Observable<Sprite>;
  90618. private _animationStarted;
  90619. private _loopAnimation;
  90620. private _fromIndex;
  90621. private _toIndex;
  90622. private _delay;
  90623. private _direction;
  90624. private _manager;
  90625. private _time;
  90626. private _onAnimationEnd;
  90627. /**
  90628. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90629. */
  90630. isVisible: boolean;
  90631. /**
  90632. * Gets or sets the sprite size
  90633. */
  90634. get size(): number;
  90635. set size(value: number);
  90636. /**
  90637. * Returns a boolean indicating if the animation is started
  90638. */
  90639. get animationStarted(): boolean;
  90640. /**
  90641. * Gets or sets the unique id of the sprite
  90642. */
  90643. uniqueId: number;
  90644. /**
  90645. * Gets the manager of this sprite
  90646. */
  90647. get manager(): ISpriteManager;
  90648. /**
  90649. * Creates a new Sprite
  90650. * @param name defines the name
  90651. * @param manager defines the manager
  90652. */
  90653. constructor(
  90654. /** defines the name */
  90655. name: string, manager: ISpriteManager);
  90656. /**
  90657. * Returns the string "Sprite"
  90658. * @returns "Sprite"
  90659. */
  90660. getClassName(): string;
  90661. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90662. get fromIndex(): number;
  90663. set fromIndex(value: number);
  90664. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90665. get toIndex(): number;
  90666. set toIndex(value: number);
  90667. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90668. get loopAnimation(): boolean;
  90669. set loopAnimation(value: boolean);
  90670. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90671. get delay(): number;
  90672. set delay(value: number);
  90673. /**
  90674. * Starts an animation
  90675. * @param from defines the initial key
  90676. * @param to defines the end key
  90677. * @param loop defines if the animation must loop
  90678. * @param delay defines the start delay (in ms)
  90679. * @param onAnimationEnd defines a callback to call when animation ends
  90680. */
  90681. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90682. /** Stops current animation (if any) */
  90683. stopAnimation(): void;
  90684. /** @hidden */
  90685. _animate(deltaTime: number): void;
  90686. /** Release associated resources */
  90687. dispose(): void;
  90688. /**
  90689. * Serializes the sprite to a JSON object
  90690. * @returns the JSON object
  90691. */
  90692. serialize(): any;
  90693. /**
  90694. * Parses a JSON object to create a new sprite
  90695. * @param parsedSprite The JSON object to parse
  90696. * @param manager defines the hosting manager
  90697. * @returns the new sprite
  90698. */
  90699. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90700. }
  90701. }
  90702. declare module BABYLON {
  90703. /**
  90704. * Information about the result of picking within a scene
  90705. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90706. */
  90707. export class PickingInfo {
  90708. /** @hidden */
  90709. _pickingUnavailable: boolean;
  90710. /**
  90711. * If the pick collided with an object
  90712. */
  90713. hit: boolean;
  90714. /**
  90715. * Distance away where the pick collided
  90716. */
  90717. distance: number;
  90718. /**
  90719. * The location of pick collision
  90720. */
  90721. pickedPoint: Nullable<Vector3>;
  90722. /**
  90723. * The mesh corresponding the the pick collision
  90724. */
  90725. pickedMesh: Nullable<AbstractMesh>;
  90726. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90727. bu: number;
  90728. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90729. bv: number;
  90730. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90731. faceId: number;
  90732. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90733. subMeshFaceId: number;
  90734. /** Id of the the submesh that was picked */
  90735. subMeshId: number;
  90736. /** If a sprite was picked, this will be the sprite the pick collided with */
  90737. pickedSprite: Nullable<Sprite>;
  90738. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90739. thinInstanceIndex: number;
  90740. /**
  90741. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90742. */
  90743. originMesh: Nullable<AbstractMesh>;
  90744. /**
  90745. * The ray that was used to perform the picking.
  90746. */
  90747. ray: Nullable<Ray>;
  90748. /**
  90749. * Gets the normal correspodning to the face the pick collided with
  90750. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90751. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90752. * @returns The normal correspodning to the face the pick collided with
  90753. */
  90754. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90755. /**
  90756. * Gets the texture coordinates of where the pick occured
  90757. * @returns the vector containing the coordnates of the texture
  90758. */
  90759. getTextureCoordinates(): Nullable<Vector2>;
  90760. }
  90761. }
  90762. declare module BABYLON {
  90763. /**
  90764. * Class representing a ray with position and direction
  90765. */
  90766. export class Ray {
  90767. /** origin point */
  90768. origin: Vector3;
  90769. /** direction */
  90770. direction: Vector3;
  90771. /** length of the ray */
  90772. length: number;
  90773. private static readonly _TmpVector3;
  90774. private _tmpRay;
  90775. /**
  90776. * Creates a new ray
  90777. * @param origin origin point
  90778. * @param direction direction
  90779. * @param length length of the ray
  90780. */
  90781. constructor(
  90782. /** origin point */
  90783. origin: Vector3,
  90784. /** direction */
  90785. direction: Vector3,
  90786. /** length of the ray */
  90787. length?: number);
  90788. /**
  90789. * Checks if the ray intersects a box
  90790. * This does not account for the ray lenght by design to improve perfs.
  90791. * @param minimum bound of the box
  90792. * @param maximum bound of the box
  90793. * @param intersectionTreshold extra extend to be added to the box in all direction
  90794. * @returns if the box was hit
  90795. */
  90796. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90797. /**
  90798. * Checks if the ray intersects a box
  90799. * This does not account for the ray lenght by design to improve perfs.
  90800. * @param box the bounding box to check
  90801. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90802. * @returns if the box was hit
  90803. */
  90804. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90805. /**
  90806. * If the ray hits a sphere
  90807. * @param sphere the bounding sphere to check
  90808. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90809. * @returns true if it hits the sphere
  90810. */
  90811. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90812. /**
  90813. * If the ray hits a triange
  90814. * @param vertex0 triangle vertex
  90815. * @param vertex1 triangle vertex
  90816. * @param vertex2 triangle vertex
  90817. * @returns intersection information if hit
  90818. */
  90819. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90820. /**
  90821. * Checks if ray intersects a plane
  90822. * @param plane the plane to check
  90823. * @returns the distance away it was hit
  90824. */
  90825. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90826. /**
  90827. * Calculate the intercept of a ray on a given axis
  90828. * @param axis to check 'x' | 'y' | 'z'
  90829. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90830. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90831. */
  90832. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90833. /**
  90834. * Checks if ray intersects a mesh
  90835. * @param mesh the mesh to check
  90836. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90837. * @returns picking info of the intersecton
  90838. */
  90839. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90840. /**
  90841. * Checks if ray intersects a mesh
  90842. * @param meshes the meshes to check
  90843. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90844. * @param results array to store result in
  90845. * @returns Array of picking infos
  90846. */
  90847. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90848. private _comparePickingInfo;
  90849. private static smallnum;
  90850. private static rayl;
  90851. /**
  90852. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90853. * @param sega the first point of the segment to test the intersection against
  90854. * @param segb the second point of the segment to test the intersection against
  90855. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90856. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90857. */
  90858. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90859. /**
  90860. * Update the ray from viewport position
  90861. * @param x position
  90862. * @param y y position
  90863. * @param viewportWidth viewport width
  90864. * @param viewportHeight viewport height
  90865. * @param world world matrix
  90866. * @param view view matrix
  90867. * @param projection projection matrix
  90868. * @returns this ray updated
  90869. */
  90870. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90871. /**
  90872. * Creates a ray with origin and direction of 0,0,0
  90873. * @returns the new ray
  90874. */
  90875. static Zero(): Ray;
  90876. /**
  90877. * Creates a new ray from screen space and viewport
  90878. * @param x position
  90879. * @param y y position
  90880. * @param viewportWidth viewport width
  90881. * @param viewportHeight viewport height
  90882. * @param world world matrix
  90883. * @param view view matrix
  90884. * @param projection projection matrix
  90885. * @returns new ray
  90886. */
  90887. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90888. /**
  90889. * 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
  90890. * transformed to the given world matrix.
  90891. * @param origin The origin point
  90892. * @param end The end point
  90893. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90894. * @returns the new ray
  90895. */
  90896. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90897. /**
  90898. * Transforms a ray by a matrix
  90899. * @param ray ray to transform
  90900. * @param matrix matrix to apply
  90901. * @returns the resulting new ray
  90902. */
  90903. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90904. /**
  90905. * Transforms a ray by a matrix
  90906. * @param ray ray to transform
  90907. * @param matrix matrix to apply
  90908. * @param result ray to store result in
  90909. */
  90910. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90911. /**
  90912. * Unproject a ray from screen space to object space
  90913. * @param sourceX defines the screen space x coordinate to use
  90914. * @param sourceY defines the screen space y coordinate to use
  90915. * @param viewportWidth defines the current width of the viewport
  90916. * @param viewportHeight defines the current height of the viewport
  90917. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90918. * @param view defines the view matrix to use
  90919. * @param projection defines the projection matrix to use
  90920. */
  90921. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90922. }
  90923. /**
  90924. * Type used to define predicate used to select faces when a mesh intersection is detected
  90925. */
  90926. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90927. interface Scene {
  90928. /** @hidden */
  90929. _tempPickingRay: Nullable<Ray>;
  90930. /** @hidden */
  90931. _cachedRayForTransform: Ray;
  90932. /** @hidden */
  90933. _pickWithRayInverseMatrix: Matrix;
  90934. /** @hidden */
  90935. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90936. /** @hidden */
  90937. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90938. /** @hidden */
  90939. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90940. }
  90941. }
  90942. declare module BABYLON {
  90943. /**
  90944. * Groups all the scene component constants in one place to ease maintenance.
  90945. * @hidden
  90946. */
  90947. export class SceneComponentConstants {
  90948. static readonly NAME_EFFECTLAYER: string;
  90949. static readonly NAME_LAYER: string;
  90950. static readonly NAME_LENSFLARESYSTEM: string;
  90951. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90952. static readonly NAME_PARTICLESYSTEM: string;
  90953. static readonly NAME_GAMEPAD: string;
  90954. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90955. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90956. static readonly NAME_PREPASSRENDERER: string;
  90957. static readonly NAME_DEPTHRENDERER: string;
  90958. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90959. static readonly NAME_SPRITE: string;
  90960. static readonly NAME_SUBSURFACE: string;
  90961. static readonly NAME_OUTLINERENDERER: string;
  90962. static readonly NAME_PROCEDURALTEXTURE: string;
  90963. static readonly NAME_SHADOWGENERATOR: string;
  90964. static readonly NAME_OCTREE: string;
  90965. static readonly NAME_PHYSICSENGINE: string;
  90966. static readonly NAME_AUDIO: string;
  90967. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90968. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90969. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90970. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90971. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90972. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90973. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90974. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90975. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90976. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90977. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90978. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90979. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90980. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90981. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90982. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90983. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90984. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90985. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90986. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90987. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90988. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90989. static readonly STEP_AFTERRENDER_AUDIO: number;
  90990. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90991. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90992. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90993. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90994. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90995. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90996. static readonly STEP_POINTERMOVE_SPRITE: number;
  90997. static readonly STEP_POINTERDOWN_SPRITE: number;
  90998. static readonly STEP_POINTERUP_SPRITE: number;
  90999. }
  91000. /**
  91001. * This represents a scene component.
  91002. *
  91003. * This is used to decouple the dependency the scene is having on the different workloads like
  91004. * layers, post processes...
  91005. */
  91006. export interface ISceneComponent {
  91007. /**
  91008. * The name of the component. Each component must have a unique name.
  91009. */
  91010. name: string;
  91011. /**
  91012. * The scene the component belongs to.
  91013. */
  91014. scene: Scene;
  91015. /**
  91016. * Register the component to one instance of a scene.
  91017. */
  91018. register(): void;
  91019. /**
  91020. * Rebuilds the elements related to this component in case of
  91021. * context lost for instance.
  91022. */
  91023. rebuild(): void;
  91024. /**
  91025. * Disposes the component and the associated ressources.
  91026. */
  91027. dispose(): void;
  91028. }
  91029. /**
  91030. * This represents a SERIALIZABLE scene component.
  91031. *
  91032. * This extends Scene Component to add Serialization methods on top.
  91033. */
  91034. export interface ISceneSerializableComponent extends ISceneComponent {
  91035. /**
  91036. * Adds all the elements from the container to the scene
  91037. * @param container the container holding the elements
  91038. */
  91039. addFromContainer(container: AbstractScene): void;
  91040. /**
  91041. * Removes all the elements in the container from the scene
  91042. * @param container contains the elements to remove
  91043. * @param dispose if the removed element should be disposed (default: false)
  91044. */
  91045. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91046. /**
  91047. * Serializes the component data to the specified json object
  91048. * @param serializationObject The object to serialize to
  91049. */
  91050. serialize(serializationObject: any): void;
  91051. }
  91052. /**
  91053. * Strong typing of a Mesh related stage step action
  91054. */
  91055. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91056. /**
  91057. * Strong typing of a Evaluate Sub Mesh related stage step action
  91058. */
  91059. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91060. /**
  91061. * Strong typing of a Active Mesh related stage step action
  91062. */
  91063. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91064. /**
  91065. * Strong typing of a Camera related stage step action
  91066. */
  91067. export type CameraStageAction = (camera: Camera) => void;
  91068. /**
  91069. * Strong typing of a Camera Frame buffer related stage step action
  91070. */
  91071. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91072. /**
  91073. * Strong typing of a Render Target related stage step action
  91074. */
  91075. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91076. /**
  91077. * Strong typing of a RenderingGroup related stage step action
  91078. */
  91079. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91080. /**
  91081. * Strong typing of a Mesh Render related stage step action
  91082. */
  91083. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91084. /**
  91085. * Strong typing of a simple stage step action
  91086. */
  91087. export type SimpleStageAction = () => void;
  91088. /**
  91089. * Strong typing of a render target action.
  91090. */
  91091. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91092. /**
  91093. * Strong typing of a pointer move action.
  91094. */
  91095. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91096. /**
  91097. * Strong typing of a pointer up/down action.
  91098. */
  91099. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91100. /**
  91101. * Representation of a stage in the scene (Basically a list of ordered steps)
  91102. * @hidden
  91103. */
  91104. export class Stage<T extends Function> extends Array<{
  91105. index: number;
  91106. component: ISceneComponent;
  91107. action: T;
  91108. }> {
  91109. /**
  91110. * Hide ctor from the rest of the world.
  91111. * @param items The items to add.
  91112. */
  91113. private constructor();
  91114. /**
  91115. * Creates a new Stage.
  91116. * @returns A new instance of a Stage
  91117. */
  91118. static Create<T extends Function>(): Stage<T>;
  91119. /**
  91120. * Registers a step in an ordered way in the targeted stage.
  91121. * @param index Defines the position to register the step in
  91122. * @param component Defines the component attached to the step
  91123. * @param action Defines the action to launch during the step
  91124. */
  91125. registerStep(index: number, component: ISceneComponent, action: T): void;
  91126. /**
  91127. * Clears all the steps from the stage.
  91128. */
  91129. clear(): void;
  91130. }
  91131. }
  91132. declare module BABYLON {
  91133. interface Scene {
  91134. /** @hidden */
  91135. _pointerOverSprite: Nullable<Sprite>;
  91136. /** @hidden */
  91137. _pickedDownSprite: Nullable<Sprite>;
  91138. /** @hidden */
  91139. _tempSpritePickingRay: Nullable<Ray>;
  91140. /**
  91141. * All of the sprite managers added to this scene
  91142. * @see https://doc.babylonjs.com/babylon101/sprites
  91143. */
  91144. spriteManagers: Array<ISpriteManager>;
  91145. /**
  91146. * An event triggered when sprites rendering is about to start
  91147. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91148. */
  91149. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91150. /**
  91151. * An event triggered when sprites rendering is done
  91152. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91153. */
  91154. onAfterSpritesRenderingObservable: Observable<Scene>;
  91155. /** @hidden */
  91156. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91157. /** Launch a ray to try to pick a sprite in the scene
  91158. * @param x position on screen
  91159. * @param y position on screen
  91160. * @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
  91161. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91162. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91163. * @returns a PickingInfo
  91164. */
  91165. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91166. /** Use the given ray to pick a sprite in the scene
  91167. * @param ray The ray (in world space) to use to pick meshes
  91168. * @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
  91169. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91170. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91171. * @returns a PickingInfo
  91172. */
  91173. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91174. /** @hidden */
  91175. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91176. /** Launch a ray to try to pick sprites in the scene
  91177. * @param x position on screen
  91178. * @param y position on screen
  91179. * @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
  91180. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91181. * @returns a PickingInfo array
  91182. */
  91183. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91184. /** Use the given ray to pick sprites in the scene
  91185. * @param ray The ray (in world space) to use to pick meshes
  91186. * @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
  91187. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91188. * @returns a PickingInfo array
  91189. */
  91190. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91191. /**
  91192. * Force the sprite under the pointer
  91193. * @param sprite defines the sprite to use
  91194. */
  91195. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91196. /**
  91197. * Gets the sprite under the pointer
  91198. * @returns a Sprite or null if no sprite is under the pointer
  91199. */
  91200. getPointerOverSprite(): Nullable<Sprite>;
  91201. }
  91202. /**
  91203. * Defines the sprite scene component responsible to manage sprites
  91204. * in a given scene.
  91205. */
  91206. export class SpriteSceneComponent implements ISceneComponent {
  91207. /**
  91208. * The component name helpfull to identify the component in the list of scene components.
  91209. */
  91210. readonly name: string;
  91211. /**
  91212. * The scene the component belongs to.
  91213. */
  91214. scene: Scene;
  91215. /** @hidden */
  91216. private _spritePredicate;
  91217. /**
  91218. * Creates a new instance of the component for the given scene
  91219. * @param scene Defines the scene to register the component in
  91220. */
  91221. constructor(scene: Scene);
  91222. /**
  91223. * Registers the component in a given scene
  91224. */
  91225. register(): void;
  91226. /**
  91227. * Rebuilds the elements related to this component in case of
  91228. * context lost for instance.
  91229. */
  91230. rebuild(): void;
  91231. /**
  91232. * Disposes the component and the associated ressources.
  91233. */
  91234. dispose(): void;
  91235. private _pickSpriteButKeepRay;
  91236. private _pointerMove;
  91237. private _pointerDown;
  91238. private _pointerUp;
  91239. }
  91240. }
  91241. declare module BABYLON {
  91242. /** @hidden */
  91243. export var fogFragmentDeclaration: {
  91244. name: string;
  91245. shader: string;
  91246. };
  91247. }
  91248. declare module BABYLON {
  91249. /** @hidden */
  91250. export var fogFragment: {
  91251. name: string;
  91252. shader: string;
  91253. };
  91254. }
  91255. declare module BABYLON {
  91256. /** @hidden */
  91257. export var spritesPixelShader: {
  91258. name: string;
  91259. shader: string;
  91260. };
  91261. }
  91262. declare module BABYLON {
  91263. /** @hidden */
  91264. export var fogVertexDeclaration: {
  91265. name: string;
  91266. shader: string;
  91267. };
  91268. }
  91269. declare module BABYLON {
  91270. /** @hidden */
  91271. export var spritesVertexShader: {
  91272. name: string;
  91273. shader: string;
  91274. };
  91275. }
  91276. declare module BABYLON {
  91277. /**
  91278. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91279. */
  91280. export interface ISpriteManager extends IDisposable {
  91281. /**
  91282. * Gets manager's name
  91283. */
  91284. name: string;
  91285. /**
  91286. * Restricts the camera to viewing objects with the same layerMask.
  91287. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91288. */
  91289. layerMask: number;
  91290. /**
  91291. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91292. */
  91293. isPickable: boolean;
  91294. /**
  91295. * Gets the hosting scene
  91296. */
  91297. scene: Scene;
  91298. /**
  91299. * Specifies the rendering group id for this mesh (0 by default)
  91300. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91301. */
  91302. renderingGroupId: number;
  91303. /**
  91304. * Defines the list of sprites managed by the manager.
  91305. */
  91306. sprites: Array<Sprite>;
  91307. /**
  91308. * Gets or sets the spritesheet texture
  91309. */
  91310. texture: Texture;
  91311. /** Defines the default width of a cell in the spritesheet */
  91312. cellWidth: number;
  91313. /** Defines the default height of a cell in the spritesheet */
  91314. cellHeight: number;
  91315. /**
  91316. * Tests the intersection of a sprite with a specific ray.
  91317. * @param ray The ray we are sending to test the collision
  91318. * @param camera The camera space we are sending rays in
  91319. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91320. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91321. * @returns picking info or null.
  91322. */
  91323. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91324. /**
  91325. * Intersects the sprites with a ray
  91326. * @param ray defines the ray to intersect with
  91327. * @param camera defines the current active camera
  91328. * @param predicate defines a predicate used to select candidate sprites
  91329. * @returns null if no hit or a PickingInfo array
  91330. */
  91331. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91332. /**
  91333. * Renders the list of sprites on screen.
  91334. */
  91335. render(): void;
  91336. }
  91337. /**
  91338. * Class used to manage multiple sprites on the same spritesheet
  91339. * @see https://doc.babylonjs.com/babylon101/sprites
  91340. */
  91341. export class SpriteManager implements ISpriteManager {
  91342. /** defines the manager's name */
  91343. name: string;
  91344. /** Define the Url to load snippets */
  91345. static SnippetUrl: string;
  91346. /** Snippet ID if the manager was created from the snippet server */
  91347. snippetId: string;
  91348. /** Gets the list of sprites */
  91349. sprites: Sprite[];
  91350. /** Gets or sets the rendering group id (0 by default) */
  91351. renderingGroupId: number;
  91352. /** Gets or sets camera layer mask */
  91353. layerMask: number;
  91354. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91355. fogEnabled: boolean;
  91356. /** Gets or sets a boolean indicating if the sprites are pickable */
  91357. isPickable: boolean;
  91358. /** Defines the default width of a cell in the spritesheet */
  91359. cellWidth: number;
  91360. /** Defines the default height of a cell in the spritesheet */
  91361. cellHeight: number;
  91362. /** Associative array from JSON sprite data file */
  91363. private _cellData;
  91364. /** Array of sprite names from JSON sprite data file */
  91365. private _spriteMap;
  91366. /** True when packed cell data from JSON file is ready*/
  91367. private _packedAndReady;
  91368. private _textureContent;
  91369. private _useInstancing;
  91370. /**
  91371. * An event triggered when the manager is disposed.
  91372. */
  91373. onDisposeObservable: Observable<SpriteManager>;
  91374. private _onDisposeObserver;
  91375. /**
  91376. * Callback called when the manager is disposed
  91377. */
  91378. set onDispose(callback: () => void);
  91379. private _capacity;
  91380. private _fromPacked;
  91381. private _spriteTexture;
  91382. private _epsilon;
  91383. private _scene;
  91384. private _vertexData;
  91385. private _buffer;
  91386. private _vertexBuffers;
  91387. private _spriteBuffer;
  91388. private _indexBuffer;
  91389. private _effectBase;
  91390. private _effectFog;
  91391. private _vertexBufferSize;
  91392. /**
  91393. * Gets or sets the unique id of the sprite
  91394. */
  91395. uniqueId: number;
  91396. /**
  91397. * Gets the array of sprites
  91398. */
  91399. get children(): Sprite[];
  91400. /**
  91401. * Gets the hosting scene
  91402. */
  91403. get scene(): Scene;
  91404. /**
  91405. * Gets the capacity of the manager
  91406. */
  91407. get capacity(): number;
  91408. /**
  91409. * Gets or sets the spritesheet texture
  91410. */
  91411. get texture(): Texture;
  91412. set texture(value: Texture);
  91413. private _blendMode;
  91414. /**
  91415. * Blend mode use to render the particle, it can be any of
  91416. * the static Constants.ALPHA_x properties provided in this class.
  91417. * Default value is Constants.ALPHA_COMBINE
  91418. */
  91419. get blendMode(): number;
  91420. set blendMode(blendMode: number);
  91421. /** Disables writing to the depth buffer when rendering the sprites.
  91422. * It can be handy to disable depth writing when using textures without alpha channel
  91423. * and setting some specific blend modes.
  91424. */
  91425. disableDepthWrite: boolean;
  91426. /**
  91427. * Creates a new sprite manager
  91428. * @param name defines the manager's name
  91429. * @param imgUrl defines the sprite sheet url
  91430. * @param capacity defines the maximum allowed number of sprites
  91431. * @param cellSize defines the size of a sprite cell
  91432. * @param scene defines the hosting scene
  91433. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91434. * @param samplingMode defines the smapling mode to use with spritesheet
  91435. * @param fromPacked set to false; do not alter
  91436. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91437. */
  91438. constructor(
  91439. /** defines the manager's name */
  91440. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91441. /**
  91442. * Returns the string "SpriteManager"
  91443. * @returns "SpriteManager"
  91444. */
  91445. getClassName(): string;
  91446. private _makePacked;
  91447. private _appendSpriteVertex;
  91448. private _checkTextureAlpha;
  91449. /**
  91450. * Intersects the sprites with a ray
  91451. * @param ray defines the ray to intersect with
  91452. * @param camera defines the current active camera
  91453. * @param predicate defines a predicate used to select candidate sprites
  91454. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91455. * @returns null if no hit or a PickingInfo
  91456. */
  91457. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91458. /**
  91459. * Intersects the sprites with a ray
  91460. * @param ray defines the ray to intersect with
  91461. * @param camera defines the current active camera
  91462. * @param predicate defines a predicate used to select candidate sprites
  91463. * @returns null if no hit or a PickingInfo array
  91464. */
  91465. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91466. /**
  91467. * Render all child sprites
  91468. */
  91469. render(): void;
  91470. /**
  91471. * Release associated resources
  91472. */
  91473. dispose(): void;
  91474. /**
  91475. * Serializes the sprite manager to a JSON object
  91476. * @param serializeTexture defines if the texture must be serialized as well
  91477. * @returns the JSON object
  91478. */
  91479. serialize(serializeTexture?: boolean): any;
  91480. /**
  91481. * Parses a JSON object to create a new sprite manager.
  91482. * @param parsedManager The JSON object to parse
  91483. * @param scene The scene to create the sprite managerin
  91484. * @param rootUrl The root url to use to load external dependencies like texture
  91485. * @returns the new sprite manager
  91486. */
  91487. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91488. /**
  91489. * Creates a sprite manager from a snippet saved in a remote file
  91490. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91491. * @param url defines the url to load from
  91492. * @param scene defines the hosting scene
  91493. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91494. * @returns a promise that will resolve to the new sprite manager
  91495. */
  91496. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91497. /**
  91498. * Creates a sprite manager from a snippet saved by the sprite editor
  91499. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91500. * @param scene defines the hosting scene
  91501. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91502. * @returns a promise that will resolve to the new sprite manager
  91503. */
  91504. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91505. }
  91506. }
  91507. declare module BABYLON {
  91508. /** Interface used by value gradients (color, factor, ...) */
  91509. export interface IValueGradient {
  91510. /**
  91511. * Gets or sets the gradient value (between 0 and 1)
  91512. */
  91513. gradient: number;
  91514. }
  91515. /** Class used to store color4 gradient */
  91516. export class ColorGradient implements IValueGradient {
  91517. /**
  91518. * Gets or sets the gradient value (between 0 and 1)
  91519. */
  91520. gradient: number;
  91521. /**
  91522. * Gets or sets first associated color
  91523. */
  91524. color1: Color4;
  91525. /**
  91526. * Gets or sets second associated color
  91527. */
  91528. color2?: Color4 | undefined;
  91529. /**
  91530. * Creates a new color4 gradient
  91531. * @param gradient gets or sets the gradient value (between 0 and 1)
  91532. * @param color1 gets or sets first associated color
  91533. * @param color2 gets or sets first second color
  91534. */
  91535. constructor(
  91536. /**
  91537. * Gets or sets the gradient value (between 0 and 1)
  91538. */
  91539. gradient: number,
  91540. /**
  91541. * Gets or sets first associated color
  91542. */
  91543. color1: Color4,
  91544. /**
  91545. * Gets or sets second associated color
  91546. */
  91547. color2?: Color4 | undefined);
  91548. /**
  91549. * Will get a color picked randomly between color1 and color2.
  91550. * If color2 is undefined then color1 will be used
  91551. * @param result defines the target Color4 to store the result in
  91552. */
  91553. getColorToRef(result: Color4): void;
  91554. }
  91555. /** Class used to store color 3 gradient */
  91556. export class Color3Gradient implements IValueGradient {
  91557. /**
  91558. * Gets or sets the gradient value (between 0 and 1)
  91559. */
  91560. gradient: number;
  91561. /**
  91562. * Gets or sets the associated color
  91563. */
  91564. color: Color3;
  91565. /**
  91566. * Creates a new color3 gradient
  91567. * @param gradient gets or sets the gradient value (between 0 and 1)
  91568. * @param color gets or sets associated color
  91569. */
  91570. constructor(
  91571. /**
  91572. * Gets or sets the gradient value (between 0 and 1)
  91573. */
  91574. gradient: number,
  91575. /**
  91576. * Gets or sets the associated color
  91577. */
  91578. color: Color3);
  91579. }
  91580. /** Class used to store factor gradient */
  91581. export class FactorGradient implements IValueGradient {
  91582. /**
  91583. * Gets or sets the gradient value (between 0 and 1)
  91584. */
  91585. gradient: number;
  91586. /**
  91587. * Gets or sets first associated factor
  91588. */
  91589. factor1: number;
  91590. /**
  91591. * Gets or sets second associated factor
  91592. */
  91593. factor2?: number | undefined;
  91594. /**
  91595. * Creates a new factor gradient
  91596. * @param gradient gets or sets the gradient value (between 0 and 1)
  91597. * @param factor1 gets or sets first associated factor
  91598. * @param factor2 gets or sets second associated factor
  91599. */
  91600. constructor(
  91601. /**
  91602. * Gets or sets the gradient value (between 0 and 1)
  91603. */
  91604. gradient: number,
  91605. /**
  91606. * Gets or sets first associated factor
  91607. */
  91608. factor1: number,
  91609. /**
  91610. * Gets or sets second associated factor
  91611. */
  91612. factor2?: number | undefined);
  91613. /**
  91614. * Will get a number picked randomly between factor1 and factor2.
  91615. * If factor2 is undefined then factor1 will be used
  91616. * @returns the picked number
  91617. */
  91618. getFactor(): number;
  91619. }
  91620. /**
  91621. * Helper used to simplify some generic gradient tasks
  91622. */
  91623. export class GradientHelper {
  91624. /**
  91625. * Gets the current gradient from an array of IValueGradient
  91626. * @param ratio defines the current ratio to get
  91627. * @param gradients defines the array of IValueGradient
  91628. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91629. */
  91630. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91631. }
  91632. }
  91633. declare module BABYLON {
  91634. interface ThinEngine {
  91635. /**
  91636. * Creates a raw texture
  91637. * @param data defines the data to store in the texture
  91638. * @param width defines the width of the texture
  91639. * @param height defines the height of the texture
  91640. * @param format defines the format of the data
  91641. * @param generateMipMaps defines if the engine should generate the mip levels
  91642. * @param invertY defines if data must be stored with Y axis inverted
  91643. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91644. * @param compression defines the compression used (null by default)
  91645. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91646. * @returns the raw texture inside an InternalTexture
  91647. */
  91648. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91649. /**
  91650. * Update a raw texture
  91651. * @param texture defines the texture to update
  91652. * @param data defines the data to store in the texture
  91653. * @param format defines the format of the data
  91654. * @param invertY defines if data must be stored with Y axis inverted
  91655. */
  91656. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91657. /**
  91658. * Update a raw texture
  91659. * @param texture defines the texture to update
  91660. * @param data defines the data to store in the texture
  91661. * @param format defines the format of the data
  91662. * @param invertY defines if data must be stored with Y axis inverted
  91663. * @param compression defines the compression used (null by default)
  91664. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91665. */
  91666. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91667. /**
  91668. * Creates a new raw cube texture
  91669. * @param data defines the array of data to use to create each face
  91670. * @param size defines the size of the textures
  91671. * @param format defines the format of the data
  91672. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91673. * @param generateMipMaps defines if the engine should generate the mip levels
  91674. * @param invertY defines if data must be stored with Y axis inverted
  91675. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91676. * @param compression defines the compression used (null by default)
  91677. * @returns the cube texture as an InternalTexture
  91678. */
  91679. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91680. /**
  91681. * Update a raw cube texture
  91682. * @param texture defines the texture to udpdate
  91683. * @param data defines the data to store
  91684. * @param format defines the data format
  91685. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91686. * @param invertY defines if data must be stored with Y axis inverted
  91687. */
  91688. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91689. /**
  91690. * Update a raw cube texture
  91691. * @param texture defines the texture to udpdate
  91692. * @param data defines the data to store
  91693. * @param format defines the data format
  91694. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91695. * @param invertY defines if data must be stored with Y axis inverted
  91696. * @param compression defines the compression used (null by default)
  91697. */
  91698. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91699. /**
  91700. * Update a raw cube texture
  91701. * @param texture defines the texture to udpdate
  91702. * @param data defines the data to store
  91703. * @param format defines the data format
  91704. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91705. * @param invertY defines if data must be stored with Y axis inverted
  91706. * @param compression defines the compression used (null by default)
  91707. * @param level defines which level of the texture to update
  91708. */
  91709. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91710. /**
  91711. * Creates a new raw cube texture from a specified url
  91712. * @param url defines the url where the data is located
  91713. * @param scene defines the current scene
  91714. * @param size defines the size of the textures
  91715. * @param format defines the format of the data
  91716. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91717. * @param noMipmap defines if the engine should avoid generating the mip levels
  91718. * @param callback defines a callback used to extract texture data from loaded data
  91719. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91720. * @param onLoad defines a callback called when texture is loaded
  91721. * @param onError defines a callback called if there is an error
  91722. * @returns the cube texture as an InternalTexture
  91723. */
  91724. 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;
  91725. /**
  91726. * Creates a new raw cube texture from a specified url
  91727. * @param url defines the url where the data is located
  91728. * @param scene defines the current scene
  91729. * @param size defines the size of the textures
  91730. * @param format defines the format of the data
  91731. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91732. * @param noMipmap defines if the engine should avoid generating the mip levels
  91733. * @param callback defines a callback used to extract texture data from loaded data
  91734. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91735. * @param onLoad defines a callback called when texture is loaded
  91736. * @param onError defines a callback called if there is an error
  91737. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91738. * @param invertY defines if data must be stored with Y axis inverted
  91739. * @returns the cube texture as an InternalTexture
  91740. */
  91741. 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;
  91742. /**
  91743. * Creates a new raw 3D texture
  91744. * @param data defines the data used to create the texture
  91745. * @param width defines the width of the texture
  91746. * @param height defines the height of the texture
  91747. * @param depth defines the depth of the texture
  91748. * @param format defines the format of the texture
  91749. * @param generateMipMaps defines if the engine must generate mip levels
  91750. * @param invertY defines if data must be stored with Y axis inverted
  91751. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91752. * @param compression defines the compressed used (can be null)
  91753. * @param textureType defines the compressed used (can be null)
  91754. * @returns a new raw 3D texture (stored in an InternalTexture)
  91755. */
  91756. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91757. /**
  91758. * Update a raw 3D texture
  91759. * @param texture defines the texture to update
  91760. * @param data defines the data to store
  91761. * @param format defines the data format
  91762. * @param invertY defines if data must be stored with Y axis inverted
  91763. */
  91764. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91765. /**
  91766. * Update a raw 3D texture
  91767. * @param texture defines the texture to update
  91768. * @param data defines the data to store
  91769. * @param format defines the data format
  91770. * @param invertY defines if data must be stored with Y axis inverted
  91771. * @param compression defines the used compression (can be null)
  91772. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91773. */
  91774. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91775. /**
  91776. * Creates a new raw 2D array texture
  91777. * @param data defines the data used to create the texture
  91778. * @param width defines the width of the texture
  91779. * @param height defines the height of the texture
  91780. * @param depth defines the number of layers of the texture
  91781. * @param format defines the format of the texture
  91782. * @param generateMipMaps defines if the engine must generate mip levels
  91783. * @param invertY defines if data must be stored with Y axis inverted
  91784. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91785. * @param compression defines the compressed used (can be null)
  91786. * @param textureType defines the compressed used (can be null)
  91787. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91788. */
  91789. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91790. /**
  91791. * Update a raw 2D array texture
  91792. * @param texture defines the texture to update
  91793. * @param data defines the data to store
  91794. * @param format defines the data format
  91795. * @param invertY defines if data must be stored with Y axis inverted
  91796. */
  91797. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91798. /**
  91799. * Update a raw 2D array texture
  91800. * @param texture defines the texture to update
  91801. * @param data defines the data to store
  91802. * @param format defines the data format
  91803. * @param invertY defines if data must be stored with Y axis inverted
  91804. * @param compression defines the used compression (can be null)
  91805. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91806. */
  91807. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91808. }
  91809. }
  91810. declare module BABYLON {
  91811. /**
  91812. * Raw texture can help creating a texture directly from an array of data.
  91813. * This can be super useful if you either get the data from an uncompressed source or
  91814. * if you wish to create your texture pixel by pixel.
  91815. */
  91816. export class RawTexture extends Texture {
  91817. /**
  91818. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91819. */
  91820. format: number;
  91821. /**
  91822. * Instantiates a new RawTexture.
  91823. * Raw texture can help creating a texture directly from an array of data.
  91824. * This can be super useful if you either get the data from an uncompressed source or
  91825. * if you wish to create your texture pixel by pixel.
  91826. * @param data define the array of data to use to create the texture
  91827. * @param width define the width of the texture
  91828. * @param height define the height of the texture
  91829. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91830. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91831. * @param generateMipMaps define whether mip maps should be generated or not
  91832. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91833. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91834. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91835. */
  91836. constructor(data: ArrayBufferView, width: number, height: number,
  91837. /**
  91838. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91839. */
  91840. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91841. /**
  91842. * Updates the texture underlying data.
  91843. * @param data Define the new data of the texture
  91844. */
  91845. update(data: ArrayBufferView): void;
  91846. /**
  91847. * Creates a luminance texture from some data.
  91848. * @param data Define the texture data
  91849. * @param width Define the width of the texture
  91850. * @param height Define the height of the texture
  91851. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91852. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91853. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91854. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91855. * @returns the luminance texture
  91856. */
  91857. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91858. /**
  91859. * Creates a luminance alpha texture from some data.
  91860. * @param data Define the texture data
  91861. * @param width Define the width of the texture
  91862. * @param height Define the height of the texture
  91863. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91864. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91865. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91866. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91867. * @returns the luminance alpha texture
  91868. */
  91869. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91870. /**
  91871. * Creates an alpha texture from some data.
  91872. * @param data Define the texture data
  91873. * @param width Define the width of the texture
  91874. * @param height Define the height of the texture
  91875. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91876. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91877. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91878. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91879. * @returns the alpha texture
  91880. */
  91881. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91882. /**
  91883. * Creates a RGB texture from some data.
  91884. * @param data Define the texture data
  91885. * @param width Define the width of the texture
  91886. * @param height Define the height of the texture
  91887. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91888. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91889. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91890. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91891. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91892. * @returns the RGB alpha texture
  91893. */
  91894. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91895. /**
  91896. * Creates a RGBA texture from some data.
  91897. * @param data Define the texture data
  91898. * @param width Define the width of the texture
  91899. * @param height Define the height of the texture
  91900. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91901. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91904. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91905. * @returns the RGBA texture
  91906. */
  91907. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91908. /**
  91909. * Creates a R texture from some data.
  91910. * @param data Define the texture data
  91911. * @param width Define the width of the texture
  91912. * @param height Define the height of the texture
  91913. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91914. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91915. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91916. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91917. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91918. * @returns the R texture
  91919. */
  91920. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91921. }
  91922. }
  91923. declare module BABYLON {
  91924. interface ThinEngine {
  91925. /**
  91926. * Update a dynamic index buffer
  91927. * @param indexBuffer defines the target index buffer
  91928. * @param indices defines the data to update
  91929. * @param offset defines the offset in the target index buffer where update should start
  91930. */
  91931. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91932. /**
  91933. * Updates a dynamic vertex buffer.
  91934. * @param vertexBuffer the vertex buffer to update
  91935. * @param data the data used to update the vertex buffer
  91936. * @param byteOffset the byte offset of the data
  91937. * @param byteLength the byte length of the data
  91938. */
  91939. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91940. }
  91941. }
  91942. declare module BABYLON {
  91943. interface AbstractScene {
  91944. /**
  91945. * The list of procedural textures added to the scene
  91946. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91947. */
  91948. proceduralTextures: Array<ProceduralTexture>;
  91949. }
  91950. /**
  91951. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91952. * in a given scene.
  91953. */
  91954. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91955. /**
  91956. * The component name helpfull to identify the component in the list of scene components.
  91957. */
  91958. readonly name: string;
  91959. /**
  91960. * The scene the component belongs to.
  91961. */
  91962. scene: Scene;
  91963. /**
  91964. * Creates a new instance of the component for the given scene
  91965. * @param scene Defines the scene to register the component in
  91966. */
  91967. constructor(scene: Scene);
  91968. /**
  91969. * Registers the component in a given scene
  91970. */
  91971. register(): void;
  91972. /**
  91973. * Rebuilds the elements related to this component in case of
  91974. * context lost for instance.
  91975. */
  91976. rebuild(): void;
  91977. /**
  91978. * Disposes the component and the associated ressources.
  91979. */
  91980. dispose(): void;
  91981. private _beforeClear;
  91982. }
  91983. }
  91984. declare module BABYLON {
  91985. interface ThinEngine {
  91986. /**
  91987. * Creates a new render target cube texture
  91988. * @param size defines the size of the texture
  91989. * @param options defines the options used to create the texture
  91990. * @returns a new render target cube texture stored in an InternalTexture
  91991. */
  91992. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91993. }
  91994. }
  91995. declare module BABYLON {
  91996. /** @hidden */
  91997. export var proceduralVertexShader: {
  91998. name: string;
  91999. shader: string;
  92000. };
  92001. }
  92002. declare module BABYLON {
  92003. /**
  92004. * 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.
  92005. * This is the base class of any Procedural texture and contains most of the shareable code.
  92006. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92007. */
  92008. export class ProceduralTexture extends Texture {
  92009. /**
  92010. * Define if the texture is enabled or not (disabled texture will not render)
  92011. */
  92012. isEnabled: boolean;
  92013. /**
  92014. * Define if the texture must be cleared before rendering (default is true)
  92015. */
  92016. autoClear: boolean;
  92017. /**
  92018. * Callback called when the texture is generated
  92019. */
  92020. onGenerated: () => void;
  92021. /**
  92022. * Event raised when the texture is generated
  92023. */
  92024. onGeneratedObservable: Observable<ProceduralTexture>;
  92025. /**
  92026. * Event raised before the texture is generated
  92027. */
  92028. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92029. /**
  92030. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92031. */
  92032. nodeMaterialSource: Nullable<NodeMaterial>;
  92033. /** @hidden */
  92034. _generateMipMaps: boolean;
  92035. /** @hidden **/
  92036. _effect: Effect;
  92037. /** @hidden */
  92038. _textures: {
  92039. [key: string]: Texture;
  92040. };
  92041. /** @hidden */
  92042. protected _fallbackTexture: Nullable<Texture>;
  92043. private _size;
  92044. private _currentRefreshId;
  92045. private _frameId;
  92046. private _refreshRate;
  92047. private _vertexBuffers;
  92048. private _indexBuffer;
  92049. private _uniforms;
  92050. private _samplers;
  92051. private _fragment;
  92052. private _floats;
  92053. private _ints;
  92054. private _floatsArrays;
  92055. private _colors3;
  92056. private _colors4;
  92057. private _vectors2;
  92058. private _vectors3;
  92059. private _matrices;
  92060. private _fallbackTextureUsed;
  92061. private _fullEngine;
  92062. private _cachedDefines;
  92063. private _contentUpdateId;
  92064. private _contentData;
  92065. /**
  92066. * Instantiates a new procedural texture.
  92067. * 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.
  92068. * This is the base class of any Procedural texture and contains most of the shareable code.
  92069. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92070. * @param name Define the name of the texture
  92071. * @param size Define the size of the texture to create
  92072. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92073. * @param scene Define the scene the texture belongs to
  92074. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92075. * @param generateMipMaps Define if the texture should creates mip maps or not
  92076. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92077. */
  92078. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  92079. /**
  92080. * The effect that is created when initializing the post process.
  92081. * @returns The created effect corresponding the the postprocess.
  92082. */
  92083. getEffect(): Effect;
  92084. /**
  92085. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92086. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92087. */
  92088. getContent(): Nullable<ArrayBufferView>;
  92089. private _createIndexBuffer;
  92090. /** @hidden */
  92091. _rebuild(): void;
  92092. /**
  92093. * Resets the texture in order to recreate its associated resources.
  92094. * This can be called in case of context loss
  92095. */
  92096. reset(): void;
  92097. protected _getDefines(): string;
  92098. /**
  92099. * Is the texture ready to be used ? (rendered at least once)
  92100. * @returns true if ready, otherwise, false.
  92101. */
  92102. isReady(): boolean;
  92103. /**
  92104. * Resets the refresh counter of the texture and start bak from scratch.
  92105. * Could be useful to regenerate the texture if it is setup to render only once.
  92106. */
  92107. resetRefreshCounter(): void;
  92108. /**
  92109. * Set the fragment shader to use in order to render the texture.
  92110. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92111. */
  92112. setFragment(fragment: any): void;
  92113. /**
  92114. * Define the refresh rate of the texture or the rendering frequency.
  92115. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92116. */
  92117. get refreshRate(): number;
  92118. set refreshRate(value: number);
  92119. /** @hidden */
  92120. _shouldRender(): boolean;
  92121. /**
  92122. * Get the size the texture is rendering at.
  92123. * @returns the size (on cube texture it is always squared)
  92124. */
  92125. getRenderSize(): RenderTargetTextureSize;
  92126. /**
  92127. * Resize the texture to new value.
  92128. * @param size Define the new size the texture should have
  92129. * @param generateMipMaps Define whether the new texture should create mip maps
  92130. */
  92131. resize(size: number, generateMipMaps: boolean): void;
  92132. private _checkUniform;
  92133. /**
  92134. * Set a texture in the shader program used to render.
  92135. * @param name Define the name of the uniform samplers as defined in the shader
  92136. * @param texture Define the texture to bind to this sampler
  92137. * @return the texture itself allowing "fluent" like uniform updates
  92138. */
  92139. setTexture(name: string, texture: Texture): ProceduralTexture;
  92140. /**
  92141. * Set a float in the shader.
  92142. * @param name Define the name of the uniform as defined in the shader
  92143. * @param value Define the value to give to the uniform
  92144. * @return the texture itself allowing "fluent" like uniform updates
  92145. */
  92146. setFloat(name: string, value: number): ProceduralTexture;
  92147. /**
  92148. * Set a int in the shader.
  92149. * @param name Define the name of the uniform as defined in the shader
  92150. * @param value Define the value to give to the uniform
  92151. * @return the texture itself allowing "fluent" like uniform updates
  92152. */
  92153. setInt(name: string, value: number): ProceduralTexture;
  92154. /**
  92155. * Set an array of floats in the shader.
  92156. * @param name Define the name of the uniform as defined in the shader
  92157. * @param value Define the value to give to the uniform
  92158. * @return the texture itself allowing "fluent" like uniform updates
  92159. */
  92160. setFloats(name: string, value: number[]): ProceduralTexture;
  92161. /**
  92162. * Set a vec3 in the shader from a Color3.
  92163. * @param name Define the name of the uniform as defined in the shader
  92164. * @param value Define the value to give to the uniform
  92165. * @return the texture itself allowing "fluent" like uniform updates
  92166. */
  92167. setColor3(name: string, value: Color3): ProceduralTexture;
  92168. /**
  92169. * Set a vec4 in the shader from a Color4.
  92170. * @param name Define the name of the uniform as defined in the shader
  92171. * @param value Define the value to give to the uniform
  92172. * @return the texture itself allowing "fluent" like uniform updates
  92173. */
  92174. setColor4(name: string, value: Color4): ProceduralTexture;
  92175. /**
  92176. * Set a vec2 in the shader from a Vector2.
  92177. * @param name Define the name of the uniform as defined in the shader
  92178. * @param value Define the value to give to the uniform
  92179. * @return the texture itself allowing "fluent" like uniform updates
  92180. */
  92181. setVector2(name: string, value: Vector2): ProceduralTexture;
  92182. /**
  92183. * Set a vec3 in the shader from a Vector3.
  92184. * @param name Define the name of the uniform as defined in the shader
  92185. * @param value Define the value to give to the uniform
  92186. * @return the texture itself allowing "fluent" like uniform updates
  92187. */
  92188. setVector3(name: string, value: Vector3): ProceduralTexture;
  92189. /**
  92190. * Set a mat4 in the shader from a MAtrix.
  92191. * @param name Define the name of the uniform as defined in the shader
  92192. * @param value Define the value to give to the uniform
  92193. * @return the texture itself allowing "fluent" like uniform updates
  92194. */
  92195. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92196. /**
  92197. * Render the texture to its associated render target.
  92198. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92199. */
  92200. render(useCameraPostProcess?: boolean): void;
  92201. /**
  92202. * Clone the texture.
  92203. * @returns the cloned texture
  92204. */
  92205. clone(): ProceduralTexture;
  92206. /**
  92207. * Dispose the texture and release its asoociated resources.
  92208. */
  92209. dispose(): void;
  92210. }
  92211. }
  92212. declare module BABYLON {
  92213. /**
  92214. * This represents the base class for particle system in Babylon.
  92215. * 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.
  92216. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92217. * @example https://doc.babylonjs.com/babylon101/particles
  92218. */
  92219. export class BaseParticleSystem {
  92220. /**
  92221. * Source color is added to the destination color without alpha affecting the result
  92222. */
  92223. static BLENDMODE_ONEONE: number;
  92224. /**
  92225. * Blend current color and particle color using particle’s alpha
  92226. */
  92227. static BLENDMODE_STANDARD: number;
  92228. /**
  92229. * Add current color and particle color multiplied by particle’s alpha
  92230. */
  92231. static BLENDMODE_ADD: number;
  92232. /**
  92233. * Multiply current color with particle color
  92234. */
  92235. static BLENDMODE_MULTIPLY: number;
  92236. /**
  92237. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92238. */
  92239. static BLENDMODE_MULTIPLYADD: number;
  92240. /**
  92241. * List of animations used by the particle system.
  92242. */
  92243. animations: Animation[];
  92244. /**
  92245. * Gets or sets the unique id of the particle system
  92246. */
  92247. uniqueId: number;
  92248. /**
  92249. * The id of the Particle system.
  92250. */
  92251. id: string;
  92252. /**
  92253. * The friendly name of the Particle system.
  92254. */
  92255. name: string;
  92256. /**
  92257. * Snippet ID if the particle system was created from the snippet server
  92258. */
  92259. snippetId: string;
  92260. /**
  92261. * The rendering group used by the Particle system to chose when to render.
  92262. */
  92263. renderingGroupId: number;
  92264. /**
  92265. * The emitter represents the Mesh or position we are attaching the particle system to.
  92266. */
  92267. emitter: Nullable<AbstractMesh | Vector3>;
  92268. /**
  92269. * The maximum number of particles to emit per frame
  92270. */
  92271. emitRate: number;
  92272. /**
  92273. * If you want to launch only a few particles at once, that can be done, as well.
  92274. */
  92275. manualEmitCount: number;
  92276. /**
  92277. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92278. */
  92279. updateSpeed: number;
  92280. /**
  92281. * The amount of time the particle system is running (depends of the overall update speed).
  92282. */
  92283. targetStopDuration: number;
  92284. /**
  92285. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92286. */
  92287. disposeOnStop: boolean;
  92288. /**
  92289. * Minimum power of emitting particles.
  92290. */
  92291. minEmitPower: number;
  92292. /**
  92293. * Maximum power of emitting particles.
  92294. */
  92295. maxEmitPower: number;
  92296. /**
  92297. * Minimum life time of emitting particles.
  92298. */
  92299. minLifeTime: number;
  92300. /**
  92301. * Maximum life time of emitting particles.
  92302. */
  92303. maxLifeTime: number;
  92304. /**
  92305. * Minimum Size of emitting particles.
  92306. */
  92307. minSize: number;
  92308. /**
  92309. * Maximum Size of emitting particles.
  92310. */
  92311. maxSize: number;
  92312. /**
  92313. * Minimum scale of emitting particles on X axis.
  92314. */
  92315. minScaleX: number;
  92316. /**
  92317. * Maximum scale of emitting particles on X axis.
  92318. */
  92319. maxScaleX: number;
  92320. /**
  92321. * Minimum scale of emitting particles on Y axis.
  92322. */
  92323. minScaleY: number;
  92324. /**
  92325. * Maximum scale of emitting particles on Y axis.
  92326. */
  92327. maxScaleY: number;
  92328. /**
  92329. * Gets or sets the minimal initial rotation in radians.
  92330. */
  92331. minInitialRotation: number;
  92332. /**
  92333. * Gets or sets the maximal initial rotation in radians.
  92334. */
  92335. maxInitialRotation: number;
  92336. /**
  92337. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92338. */
  92339. minAngularSpeed: number;
  92340. /**
  92341. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92342. */
  92343. maxAngularSpeed: number;
  92344. /**
  92345. * The texture used to render each particle. (this can be a spritesheet)
  92346. */
  92347. particleTexture: Nullable<BaseTexture>;
  92348. /**
  92349. * The layer mask we are rendering the particles through.
  92350. */
  92351. layerMask: number;
  92352. /**
  92353. * This can help using your own shader to render the particle system.
  92354. * The according effect will be created
  92355. */
  92356. customShader: any;
  92357. /**
  92358. * By default particle system starts as soon as they are created. This prevents the
  92359. * automatic start to happen and let you decide when to start emitting particles.
  92360. */
  92361. preventAutoStart: boolean;
  92362. private _noiseTexture;
  92363. /**
  92364. * Gets or sets a texture used to add random noise to particle positions
  92365. */
  92366. get noiseTexture(): Nullable<ProceduralTexture>;
  92367. set noiseTexture(value: Nullable<ProceduralTexture>);
  92368. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92369. noiseStrength: Vector3;
  92370. /**
  92371. * Callback triggered when the particle animation is ending.
  92372. */
  92373. onAnimationEnd: Nullable<() => void>;
  92374. /**
  92375. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92376. */
  92377. blendMode: number;
  92378. /**
  92379. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92380. * to override the particles.
  92381. */
  92382. forceDepthWrite: boolean;
  92383. /** 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 */
  92384. preWarmCycles: number;
  92385. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92386. preWarmStepOffset: number;
  92387. /**
  92388. * 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)
  92389. */
  92390. spriteCellChangeSpeed: number;
  92391. /**
  92392. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92393. */
  92394. startSpriteCellID: number;
  92395. /**
  92396. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92397. */
  92398. endSpriteCellID: number;
  92399. /**
  92400. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92401. */
  92402. spriteCellWidth: number;
  92403. /**
  92404. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92405. */
  92406. spriteCellHeight: number;
  92407. /**
  92408. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92409. */
  92410. spriteRandomStartCell: boolean;
  92411. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92412. translationPivot: Vector2;
  92413. /** @hidden */
  92414. protected _isAnimationSheetEnabled: boolean;
  92415. /**
  92416. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92417. */
  92418. beginAnimationOnStart: boolean;
  92419. /**
  92420. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92421. */
  92422. beginAnimationFrom: number;
  92423. /**
  92424. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92425. */
  92426. beginAnimationTo: number;
  92427. /**
  92428. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92429. */
  92430. beginAnimationLoop: boolean;
  92431. /**
  92432. * Gets or sets a world offset applied to all particles
  92433. */
  92434. worldOffset: Vector3;
  92435. /**
  92436. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92437. */
  92438. get isAnimationSheetEnabled(): boolean;
  92439. set isAnimationSheetEnabled(value: boolean);
  92440. /**
  92441. * Get hosting scene
  92442. * @returns the scene
  92443. */
  92444. getScene(): Nullable<Scene>;
  92445. /**
  92446. * You can use gravity if you want to give an orientation to your particles.
  92447. */
  92448. gravity: Vector3;
  92449. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92450. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92451. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92452. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92453. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92454. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92455. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92456. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92457. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92458. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92459. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92460. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92461. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92462. /**
  92463. * Defines the delay in milliseconds before starting the system (0 by default)
  92464. */
  92465. startDelay: number;
  92466. /**
  92467. * Gets the current list of drag gradients.
  92468. * You must use addDragGradient and removeDragGradient to udpate this list
  92469. * @returns the list of drag gradients
  92470. */
  92471. getDragGradients(): Nullable<Array<FactorGradient>>;
  92472. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92473. limitVelocityDamping: number;
  92474. /**
  92475. * Gets the current list of limit velocity gradients.
  92476. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92477. * @returns the list of limit velocity gradients
  92478. */
  92479. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92480. /**
  92481. * Gets the current list of color gradients.
  92482. * You must use addColorGradient and removeColorGradient to udpate this list
  92483. * @returns the list of color gradients
  92484. */
  92485. getColorGradients(): Nullable<Array<ColorGradient>>;
  92486. /**
  92487. * Gets the current list of size gradients.
  92488. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92489. * @returns the list of size gradients
  92490. */
  92491. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92492. /**
  92493. * Gets the current list of color remap gradients.
  92494. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92495. * @returns the list of color remap gradients
  92496. */
  92497. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92498. /**
  92499. * Gets the current list of alpha remap gradients.
  92500. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92501. * @returns the list of alpha remap gradients
  92502. */
  92503. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92504. /**
  92505. * Gets the current list of life time gradients.
  92506. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92507. * @returns the list of life time gradients
  92508. */
  92509. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92510. /**
  92511. * Gets the current list of angular speed gradients.
  92512. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92513. * @returns the list of angular speed gradients
  92514. */
  92515. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92516. /**
  92517. * Gets the current list of velocity gradients.
  92518. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92519. * @returns the list of velocity gradients
  92520. */
  92521. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92522. /**
  92523. * Gets the current list of start size gradients.
  92524. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92525. * @returns the list of start size gradients
  92526. */
  92527. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92528. /**
  92529. * Gets the current list of emit rate gradients.
  92530. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92531. * @returns the list of emit rate gradients
  92532. */
  92533. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92534. /**
  92535. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92536. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92537. */
  92538. get direction1(): Vector3;
  92539. set direction1(value: Vector3);
  92540. /**
  92541. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92542. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92543. */
  92544. get direction2(): Vector3;
  92545. set direction2(value: Vector3);
  92546. /**
  92547. * 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.
  92548. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92549. */
  92550. get minEmitBox(): Vector3;
  92551. set minEmitBox(value: Vector3);
  92552. /**
  92553. * 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.
  92554. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92555. */
  92556. get maxEmitBox(): Vector3;
  92557. set maxEmitBox(value: Vector3);
  92558. /**
  92559. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92560. */
  92561. color1: Color4;
  92562. /**
  92563. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92564. */
  92565. color2: Color4;
  92566. /**
  92567. * Color the particle will have at the end of its lifetime
  92568. */
  92569. colorDead: Color4;
  92570. /**
  92571. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92572. */
  92573. textureMask: Color4;
  92574. /**
  92575. * The particle emitter type defines the emitter used by the particle system.
  92576. * It can be for example box, sphere, or cone...
  92577. */
  92578. particleEmitterType: IParticleEmitterType;
  92579. /** @hidden */
  92580. _isSubEmitter: boolean;
  92581. /**
  92582. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92583. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92584. */
  92585. billboardMode: number;
  92586. protected _isBillboardBased: boolean;
  92587. /**
  92588. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92589. */
  92590. get isBillboardBased(): boolean;
  92591. set isBillboardBased(value: boolean);
  92592. /**
  92593. * The scene the particle system belongs to.
  92594. */
  92595. protected _scene: Nullable<Scene>;
  92596. /**
  92597. * The engine the particle system belongs to.
  92598. */
  92599. protected _engine: ThinEngine;
  92600. /**
  92601. * Local cache of defines for image processing.
  92602. */
  92603. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92604. /**
  92605. * Default configuration related to image processing available in the standard Material.
  92606. */
  92607. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92608. /**
  92609. * Gets the image processing configuration used either in this material.
  92610. */
  92611. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92612. /**
  92613. * Sets the Default image processing configuration used either in the this material.
  92614. *
  92615. * If sets to null, the scene one is in use.
  92616. */
  92617. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92618. /**
  92619. * Attaches a new image processing configuration to the Standard Material.
  92620. * @param configuration
  92621. */
  92622. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92623. /** @hidden */
  92624. protected _reset(): void;
  92625. /** @hidden */
  92626. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92627. /**
  92628. * Instantiates a particle system.
  92629. * 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.
  92630. * @param name The name of the particle system
  92631. */
  92632. constructor(name: string);
  92633. /**
  92634. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92635. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92636. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92637. * @returns the emitter
  92638. */
  92639. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92640. /**
  92641. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92642. * @param radius The radius of the hemisphere to emit from
  92643. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92644. * @returns the emitter
  92645. */
  92646. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92647. /**
  92648. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92649. * @param radius The radius of the sphere to emit from
  92650. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92651. * @returns the emitter
  92652. */
  92653. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92654. /**
  92655. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92656. * @param radius The radius of the sphere to emit from
  92657. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92658. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92659. * @returns the emitter
  92660. */
  92661. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92662. /**
  92663. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92664. * @param radius The radius of the emission cylinder
  92665. * @param height The height of the emission cylinder
  92666. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92667. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92668. * @returns the emitter
  92669. */
  92670. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92671. /**
  92672. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92673. * @param radius The radius of the cylinder to emit from
  92674. * @param height The height of the emission cylinder
  92675. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92676. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92677. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92678. * @returns the emitter
  92679. */
  92680. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92681. /**
  92682. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92683. * @param radius The radius of the cone to emit from
  92684. * @param angle The base angle of the cone
  92685. * @returns the emitter
  92686. */
  92687. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92688. /**
  92689. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92690. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92691. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92692. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92693. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92694. * @returns the emitter
  92695. */
  92696. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92697. }
  92698. }
  92699. declare module BABYLON {
  92700. /**
  92701. * Type of sub emitter
  92702. */
  92703. export enum SubEmitterType {
  92704. /**
  92705. * Attached to the particle over it's lifetime
  92706. */
  92707. ATTACHED = 0,
  92708. /**
  92709. * Created when the particle dies
  92710. */
  92711. END = 1
  92712. }
  92713. /**
  92714. * Sub emitter class used to emit particles from an existing particle
  92715. */
  92716. export class SubEmitter {
  92717. /**
  92718. * the particle system to be used by the sub emitter
  92719. */
  92720. particleSystem: ParticleSystem;
  92721. /**
  92722. * Type of the submitter (Default: END)
  92723. */
  92724. type: SubEmitterType;
  92725. /**
  92726. * 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)
  92727. * Note: This only is supported when using an emitter of type Mesh
  92728. */
  92729. inheritDirection: boolean;
  92730. /**
  92731. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92732. */
  92733. inheritedVelocityAmount: number;
  92734. /**
  92735. * Creates a sub emitter
  92736. * @param particleSystem the particle system to be used by the sub emitter
  92737. */
  92738. constructor(
  92739. /**
  92740. * the particle system to be used by the sub emitter
  92741. */
  92742. particleSystem: ParticleSystem);
  92743. /**
  92744. * Clones the sub emitter
  92745. * @returns the cloned sub emitter
  92746. */
  92747. clone(): SubEmitter;
  92748. /**
  92749. * Serialize current object to a JSON object
  92750. * @returns the serialized object
  92751. */
  92752. serialize(): any;
  92753. /** @hidden */
  92754. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92755. /**
  92756. * Creates a new SubEmitter from a serialized JSON version
  92757. * @param serializationObject defines the JSON object to read from
  92758. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92759. * @param rootUrl defines the rootUrl for data loading
  92760. * @returns a new SubEmitter
  92761. */
  92762. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92763. /** Release associated resources */
  92764. dispose(): void;
  92765. }
  92766. }
  92767. declare module BABYLON {
  92768. /** @hidden */
  92769. export var imageProcessingDeclaration: {
  92770. name: string;
  92771. shader: string;
  92772. };
  92773. }
  92774. declare module BABYLON {
  92775. /** @hidden */
  92776. export var imageProcessingFunctions: {
  92777. name: string;
  92778. shader: string;
  92779. };
  92780. }
  92781. declare module BABYLON {
  92782. /** @hidden */
  92783. export var particlesPixelShader: {
  92784. name: string;
  92785. shader: string;
  92786. };
  92787. }
  92788. declare module BABYLON {
  92789. /** @hidden */
  92790. export var particlesVertexShader: {
  92791. name: string;
  92792. shader: string;
  92793. };
  92794. }
  92795. declare module BABYLON {
  92796. /**
  92797. * Interface used to define entities containing multiple clip planes
  92798. */
  92799. export interface IClipPlanesHolder {
  92800. /**
  92801. * Gets or sets the active clipplane 1
  92802. */
  92803. clipPlane: Nullable<Plane>;
  92804. /**
  92805. * Gets or sets the active clipplane 2
  92806. */
  92807. clipPlane2: Nullable<Plane>;
  92808. /**
  92809. * Gets or sets the active clipplane 3
  92810. */
  92811. clipPlane3: Nullable<Plane>;
  92812. /**
  92813. * Gets or sets the active clipplane 4
  92814. */
  92815. clipPlane4: Nullable<Plane>;
  92816. /**
  92817. * Gets or sets the active clipplane 5
  92818. */
  92819. clipPlane5: Nullable<Plane>;
  92820. /**
  92821. * Gets or sets the active clipplane 6
  92822. */
  92823. clipPlane6: Nullable<Plane>;
  92824. }
  92825. }
  92826. declare module BABYLON {
  92827. /**
  92828. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92829. *
  92830. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92831. *
  92832. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92833. */
  92834. export class ThinMaterialHelper {
  92835. /**
  92836. * Binds the clip plane information from the holder to the effect.
  92837. * @param effect The effect we are binding the data to
  92838. * @param holder The entity containing the clip plane information
  92839. */
  92840. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92841. }
  92842. }
  92843. declare module BABYLON {
  92844. interface ThinEngine {
  92845. /**
  92846. * Sets alpha constants used by some alpha blending modes
  92847. * @param r defines the red component
  92848. * @param g defines the green component
  92849. * @param b defines the blue component
  92850. * @param a defines the alpha component
  92851. */
  92852. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92853. /**
  92854. * Sets the current alpha mode
  92855. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92856. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92857. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92858. */
  92859. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92860. /**
  92861. * Gets the current alpha mode
  92862. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92863. * @returns the current alpha mode
  92864. */
  92865. getAlphaMode(): number;
  92866. /**
  92867. * Sets the current alpha equation
  92868. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92869. */
  92870. setAlphaEquation(equation: number): void;
  92871. /**
  92872. * Gets the current alpha equation.
  92873. * @returns the current alpha equation
  92874. */
  92875. getAlphaEquation(): number;
  92876. }
  92877. }
  92878. declare module BABYLON {
  92879. /**
  92880. * This represents a particle system in Babylon.
  92881. * 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.
  92882. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92883. * @example https://doc.babylonjs.com/babylon101/particles
  92884. */
  92885. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92886. /**
  92887. * Billboard mode will only apply to Y axis
  92888. */
  92889. static readonly BILLBOARDMODE_Y: number;
  92890. /**
  92891. * Billboard mode will apply to all axes
  92892. */
  92893. static readonly BILLBOARDMODE_ALL: number;
  92894. /**
  92895. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92896. */
  92897. static readonly BILLBOARDMODE_STRETCHED: number;
  92898. /**
  92899. * This function can be defined to provide custom update for active particles.
  92900. * This function will be called instead of regular update (age, position, color, etc.).
  92901. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92902. */
  92903. updateFunction: (particles: Particle[]) => void;
  92904. private _emitterWorldMatrix;
  92905. /**
  92906. * This function can be defined to specify initial direction for every new particle.
  92907. * It by default use the emitterType defined function
  92908. */
  92909. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92910. /**
  92911. * This function can be defined to specify initial position for every new particle.
  92912. * It by default use the emitterType defined function
  92913. */
  92914. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92915. /**
  92916. * @hidden
  92917. */
  92918. _inheritedVelocityOffset: Vector3;
  92919. /**
  92920. * An event triggered when the system is disposed
  92921. */
  92922. onDisposeObservable: Observable<IParticleSystem>;
  92923. private _onDisposeObserver;
  92924. /**
  92925. * Sets a callback that will be triggered when the system is disposed
  92926. */
  92927. set onDispose(callback: () => void);
  92928. private _particles;
  92929. private _epsilon;
  92930. private _capacity;
  92931. private _stockParticles;
  92932. private _newPartsExcess;
  92933. private _vertexData;
  92934. private _vertexBuffer;
  92935. private _vertexBuffers;
  92936. private _spriteBuffer;
  92937. private _indexBuffer;
  92938. private _effect;
  92939. private _customEffect;
  92940. private _cachedDefines;
  92941. private _scaledColorStep;
  92942. private _colorDiff;
  92943. private _scaledDirection;
  92944. private _scaledGravity;
  92945. private _currentRenderId;
  92946. private _alive;
  92947. private _useInstancing;
  92948. private _started;
  92949. private _stopped;
  92950. private _actualFrame;
  92951. private _scaledUpdateSpeed;
  92952. private _vertexBufferSize;
  92953. /** @hidden */
  92954. _currentEmitRateGradient: Nullable<FactorGradient>;
  92955. /** @hidden */
  92956. _currentEmitRate1: number;
  92957. /** @hidden */
  92958. _currentEmitRate2: number;
  92959. /** @hidden */
  92960. _currentStartSizeGradient: Nullable<FactorGradient>;
  92961. /** @hidden */
  92962. _currentStartSize1: number;
  92963. /** @hidden */
  92964. _currentStartSize2: number;
  92965. private readonly _rawTextureWidth;
  92966. private _rampGradientsTexture;
  92967. private _useRampGradients;
  92968. /** Gets or sets a matrix to use to compute projection */
  92969. defaultProjectionMatrix: Matrix;
  92970. /** Gets or sets a matrix to use to compute view */
  92971. defaultViewMatrix: Matrix;
  92972. /** Gets or sets a boolean indicating that ramp gradients must be used
  92973. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92974. */
  92975. get useRampGradients(): boolean;
  92976. set useRampGradients(value: boolean);
  92977. /**
  92978. * 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.
  92979. * 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: [])
  92980. */
  92981. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92982. private _subEmitters;
  92983. /**
  92984. * @hidden
  92985. * If the particle systems emitter should be disposed when the particle system is disposed
  92986. */
  92987. _disposeEmitterOnDispose: boolean;
  92988. /**
  92989. * The current active Sub-systems, this property is used by the root particle system only.
  92990. */
  92991. activeSubSystems: Array<ParticleSystem>;
  92992. /**
  92993. * Specifies if the particles are updated in emitter local space or world space
  92994. */
  92995. isLocal: boolean;
  92996. private _rootParticleSystem;
  92997. /**
  92998. * Gets the current list of active particles
  92999. */
  93000. get particles(): Particle[];
  93001. /**
  93002. * Gets the number of particles active at the same time.
  93003. * @returns The number of active particles.
  93004. */
  93005. getActiveCount(): number;
  93006. /**
  93007. * Returns the string "ParticleSystem"
  93008. * @returns a string containing the class name
  93009. */
  93010. getClassName(): string;
  93011. /**
  93012. * Gets a boolean indicating that the system is stopping
  93013. * @returns true if the system is currently stopping
  93014. */
  93015. isStopping(): boolean;
  93016. /**
  93017. * Gets the custom effect used to render the particles
  93018. * @param blendMode Blend mode for which the effect should be retrieved
  93019. * @returns The effect
  93020. */
  93021. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93022. /**
  93023. * Sets the custom effect used to render the particles
  93024. * @param effect The effect to set
  93025. * @param blendMode Blend mode for which the effect should be set
  93026. */
  93027. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93028. /** @hidden */
  93029. private _onBeforeDrawParticlesObservable;
  93030. /**
  93031. * Observable that will be called just before the particles are drawn
  93032. */
  93033. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93034. /**
  93035. * Gets the name of the particle vertex shader
  93036. */
  93037. get vertexShaderName(): string;
  93038. /**
  93039. * Instantiates a particle system.
  93040. * 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.
  93041. * @param name The name of the particle system
  93042. * @param capacity The max number of particles alive at the same time
  93043. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93044. * @param customEffect a custom effect used to change the way particles are rendered by default
  93045. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93046. * @param epsilon Offset used to render the particles
  93047. */
  93048. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93049. private _addFactorGradient;
  93050. private _removeFactorGradient;
  93051. /**
  93052. * Adds a new life time gradient
  93053. * @param gradient defines the gradient to use (between 0 and 1)
  93054. * @param factor defines the life time factor to affect to the specified gradient
  93055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93056. * @returns the current particle system
  93057. */
  93058. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93059. /**
  93060. * Remove a specific life time gradient
  93061. * @param gradient defines the gradient to remove
  93062. * @returns the current particle system
  93063. */
  93064. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93065. /**
  93066. * Adds a new size gradient
  93067. * @param gradient defines the gradient to use (between 0 and 1)
  93068. * @param factor defines the size factor to affect to the specified gradient
  93069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93070. * @returns the current particle system
  93071. */
  93072. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93073. /**
  93074. * Remove a specific size gradient
  93075. * @param gradient defines the gradient to remove
  93076. * @returns the current particle system
  93077. */
  93078. removeSizeGradient(gradient: number): IParticleSystem;
  93079. /**
  93080. * Adds a new color remap gradient
  93081. * @param gradient defines the gradient to use (between 0 and 1)
  93082. * @param min defines the color remap minimal range
  93083. * @param max defines the color remap maximal range
  93084. * @returns the current particle system
  93085. */
  93086. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93087. /**
  93088. * Remove a specific color remap gradient
  93089. * @param gradient defines the gradient to remove
  93090. * @returns the current particle system
  93091. */
  93092. removeColorRemapGradient(gradient: number): IParticleSystem;
  93093. /**
  93094. * Adds a new alpha remap gradient
  93095. * @param gradient defines the gradient to use (between 0 and 1)
  93096. * @param min defines the alpha remap minimal range
  93097. * @param max defines the alpha remap maximal range
  93098. * @returns the current particle system
  93099. */
  93100. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93101. /**
  93102. * Remove a specific alpha remap gradient
  93103. * @param gradient defines the gradient to remove
  93104. * @returns the current particle system
  93105. */
  93106. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93107. /**
  93108. * Adds a new angular speed gradient
  93109. * @param gradient defines the gradient to use (between 0 and 1)
  93110. * @param factor defines the angular speed to affect to the specified gradient
  93111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93112. * @returns the current particle system
  93113. */
  93114. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93115. /**
  93116. * Remove a specific angular speed gradient
  93117. * @param gradient defines the gradient to remove
  93118. * @returns the current particle system
  93119. */
  93120. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93121. /**
  93122. * Adds a new velocity gradient
  93123. * @param gradient defines the gradient to use (between 0 and 1)
  93124. * @param factor defines the velocity to affect to the specified gradient
  93125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93126. * @returns the current particle system
  93127. */
  93128. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93129. /**
  93130. * Remove a specific velocity gradient
  93131. * @param gradient defines the gradient to remove
  93132. * @returns the current particle system
  93133. */
  93134. removeVelocityGradient(gradient: number): IParticleSystem;
  93135. /**
  93136. * Adds a new limit velocity gradient
  93137. * @param gradient defines the gradient to use (between 0 and 1)
  93138. * @param factor defines the limit velocity value to affect to the specified gradient
  93139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93140. * @returns the current particle system
  93141. */
  93142. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93143. /**
  93144. * Remove a specific limit velocity gradient
  93145. * @param gradient defines the gradient to remove
  93146. * @returns the current particle system
  93147. */
  93148. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93149. /**
  93150. * Adds a new drag gradient
  93151. * @param gradient defines the gradient to use (between 0 and 1)
  93152. * @param factor defines the drag value to affect to the specified gradient
  93153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93154. * @returns the current particle system
  93155. */
  93156. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93157. /**
  93158. * Remove a specific drag gradient
  93159. * @param gradient defines the gradient to remove
  93160. * @returns the current particle system
  93161. */
  93162. removeDragGradient(gradient: number): IParticleSystem;
  93163. /**
  93164. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93165. * @param gradient defines the gradient to use (between 0 and 1)
  93166. * @param factor defines the emit rate value to affect to the specified gradient
  93167. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93168. * @returns the current particle system
  93169. */
  93170. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93171. /**
  93172. * Remove a specific emit rate gradient
  93173. * @param gradient defines the gradient to remove
  93174. * @returns the current particle system
  93175. */
  93176. removeEmitRateGradient(gradient: number): IParticleSystem;
  93177. /**
  93178. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93179. * @param gradient defines the gradient to use (between 0 and 1)
  93180. * @param factor defines the start size value to affect to the specified gradient
  93181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93182. * @returns the current particle system
  93183. */
  93184. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93185. /**
  93186. * Remove a specific start size gradient
  93187. * @param gradient defines the gradient to remove
  93188. * @returns the current particle system
  93189. */
  93190. removeStartSizeGradient(gradient: number): IParticleSystem;
  93191. private _createRampGradientTexture;
  93192. /**
  93193. * Gets the current list of ramp gradients.
  93194. * You must use addRampGradient and removeRampGradient to udpate this list
  93195. * @returns the list of ramp gradients
  93196. */
  93197. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93198. /** Force the system to rebuild all gradients that need to be resync */
  93199. forceRefreshGradients(): void;
  93200. private _syncRampGradientTexture;
  93201. /**
  93202. * Adds a new ramp gradient used to remap particle colors
  93203. * @param gradient defines the gradient to use (between 0 and 1)
  93204. * @param color defines the color to affect to the specified gradient
  93205. * @returns the current particle system
  93206. */
  93207. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93208. /**
  93209. * Remove a specific ramp gradient
  93210. * @param gradient defines the gradient to remove
  93211. * @returns the current particle system
  93212. */
  93213. removeRampGradient(gradient: number): ParticleSystem;
  93214. /**
  93215. * Adds a new color gradient
  93216. * @param gradient defines the gradient to use (between 0 and 1)
  93217. * @param color1 defines the color to affect to the specified gradient
  93218. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93219. * @returns this particle system
  93220. */
  93221. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93222. /**
  93223. * Remove a specific color gradient
  93224. * @param gradient defines the gradient to remove
  93225. * @returns this particle system
  93226. */
  93227. removeColorGradient(gradient: number): IParticleSystem;
  93228. private _fetchR;
  93229. protected _reset(): void;
  93230. private _resetEffect;
  93231. private _createVertexBuffers;
  93232. private _createIndexBuffer;
  93233. /**
  93234. * Gets the maximum number of particles active at the same time.
  93235. * @returns The max number of active particles.
  93236. */
  93237. getCapacity(): number;
  93238. /**
  93239. * Gets whether there are still active particles in the system.
  93240. * @returns True if it is alive, otherwise false.
  93241. */
  93242. isAlive(): boolean;
  93243. /**
  93244. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93245. * @returns True if it has been started, otherwise false.
  93246. */
  93247. isStarted(): boolean;
  93248. private _prepareSubEmitterInternalArray;
  93249. /**
  93250. * Starts the particle system and begins to emit
  93251. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93252. */
  93253. start(delay?: number): void;
  93254. /**
  93255. * Stops the particle system.
  93256. * @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.
  93257. */
  93258. stop(stopSubEmitters?: boolean): void;
  93259. /**
  93260. * Remove all active particles
  93261. */
  93262. reset(): void;
  93263. /**
  93264. * @hidden (for internal use only)
  93265. */
  93266. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93267. /**
  93268. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93269. * Its lifetime will start back at 0.
  93270. */
  93271. recycleParticle: (particle: Particle) => void;
  93272. private _stopSubEmitters;
  93273. private _createParticle;
  93274. private _removeFromRoot;
  93275. private _emitFromParticle;
  93276. private _update;
  93277. /** @hidden */
  93278. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93279. /** @hidden */
  93280. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93281. /**
  93282. * Fill the defines array according to the current settings of the particle system
  93283. * @param defines Array to be updated
  93284. * @param blendMode blend mode to take into account when updating the array
  93285. */
  93286. fillDefines(defines: Array<string>, blendMode: number): void;
  93287. /**
  93288. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93289. * @param uniforms Uniforms array to fill
  93290. * @param attributes Attributes array to fill
  93291. * @param samplers Samplers array to fill
  93292. */
  93293. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93294. /** @hidden */
  93295. private _getEffect;
  93296. /**
  93297. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93298. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93299. */
  93300. animate(preWarmOnly?: boolean): void;
  93301. private _appendParticleVertices;
  93302. /**
  93303. * Rebuilds the particle system.
  93304. */
  93305. rebuild(): void;
  93306. /**
  93307. * Is this system ready to be used/rendered
  93308. * @return true if the system is ready
  93309. */
  93310. isReady(): boolean;
  93311. private _render;
  93312. /**
  93313. * Renders the particle system in its current state.
  93314. * @returns the current number of particles
  93315. */
  93316. render(): number;
  93317. /**
  93318. * Disposes the particle system and free the associated resources
  93319. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93320. */
  93321. dispose(disposeTexture?: boolean): void;
  93322. /**
  93323. * Clones the particle system.
  93324. * @param name The name of the cloned object
  93325. * @param newEmitter The new emitter to use
  93326. * @returns the cloned particle system
  93327. */
  93328. clone(name: string, newEmitter: any): ParticleSystem;
  93329. /**
  93330. * Serializes the particle system to a JSON object
  93331. * @param serializeTexture defines if the texture must be serialized as well
  93332. * @returns the JSON object
  93333. */
  93334. serialize(serializeTexture?: boolean): any;
  93335. /** @hidden */
  93336. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93337. /** @hidden */
  93338. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93339. /**
  93340. * Parses a JSON object to create a particle system.
  93341. * @param parsedParticleSystem The JSON object to parse
  93342. * @param sceneOrEngine The scene or the engine to create the particle system in
  93343. * @param rootUrl The root url to use to load external dependencies like texture
  93344. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93345. * @returns the Parsed particle system
  93346. */
  93347. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93348. }
  93349. }
  93350. declare module BABYLON {
  93351. /**
  93352. * A particle represents one of the element emitted by a particle system.
  93353. * This is mainly define by its coordinates, direction, velocity and age.
  93354. */
  93355. export class Particle {
  93356. /**
  93357. * The particle system the particle belongs to.
  93358. */
  93359. particleSystem: ParticleSystem;
  93360. private static _Count;
  93361. /**
  93362. * Unique ID of the particle
  93363. */
  93364. id: number;
  93365. /**
  93366. * The world position of the particle in the scene.
  93367. */
  93368. position: Vector3;
  93369. /**
  93370. * The world direction of the particle in the scene.
  93371. */
  93372. direction: Vector3;
  93373. /**
  93374. * The color of the particle.
  93375. */
  93376. color: Color4;
  93377. /**
  93378. * The color change of the particle per step.
  93379. */
  93380. colorStep: Color4;
  93381. /**
  93382. * Defines how long will the life of the particle be.
  93383. */
  93384. lifeTime: number;
  93385. /**
  93386. * The current age of the particle.
  93387. */
  93388. age: number;
  93389. /**
  93390. * The current size of the particle.
  93391. */
  93392. size: number;
  93393. /**
  93394. * The current scale of the particle.
  93395. */
  93396. scale: Vector2;
  93397. /**
  93398. * The current angle of the particle.
  93399. */
  93400. angle: number;
  93401. /**
  93402. * Defines how fast is the angle changing.
  93403. */
  93404. angularSpeed: number;
  93405. /**
  93406. * Defines the cell index used by the particle to be rendered from a sprite.
  93407. */
  93408. cellIndex: number;
  93409. /**
  93410. * The information required to support color remapping
  93411. */
  93412. remapData: Vector4;
  93413. /** @hidden */
  93414. _randomCellOffset?: number;
  93415. /** @hidden */
  93416. _initialDirection: Nullable<Vector3>;
  93417. /** @hidden */
  93418. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93419. /** @hidden */
  93420. _initialStartSpriteCellID: number;
  93421. /** @hidden */
  93422. _initialEndSpriteCellID: number;
  93423. /** @hidden */
  93424. _currentColorGradient: Nullable<ColorGradient>;
  93425. /** @hidden */
  93426. _currentColor1: Color4;
  93427. /** @hidden */
  93428. _currentColor2: Color4;
  93429. /** @hidden */
  93430. _currentSizeGradient: Nullable<FactorGradient>;
  93431. /** @hidden */
  93432. _currentSize1: number;
  93433. /** @hidden */
  93434. _currentSize2: number;
  93435. /** @hidden */
  93436. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93437. /** @hidden */
  93438. _currentAngularSpeed1: number;
  93439. /** @hidden */
  93440. _currentAngularSpeed2: number;
  93441. /** @hidden */
  93442. _currentVelocityGradient: Nullable<FactorGradient>;
  93443. /** @hidden */
  93444. _currentVelocity1: number;
  93445. /** @hidden */
  93446. _currentVelocity2: number;
  93447. /** @hidden */
  93448. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93449. /** @hidden */
  93450. _currentLimitVelocity1: number;
  93451. /** @hidden */
  93452. _currentLimitVelocity2: number;
  93453. /** @hidden */
  93454. _currentDragGradient: Nullable<FactorGradient>;
  93455. /** @hidden */
  93456. _currentDrag1: number;
  93457. /** @hidden */
  93458. _currentDrag2: number;
  93459. /** @hidden */
  93460. _randomNoiseCoordinates1: Vector3;
  93461. /** @hidden */
  93462. _randomNoiseCoordinates2: Vector3;
  93463. /** @hidden */
  93464. _localPosition?: Vector3;
  93465. /**
  93466. * Creates a new instance Particle
  93467. * @param particleSystem the particle system the particle belongs to
  93468. */
  93469. constructor(
  93470. /**
  93471. * The particle system the particle belongs to.
  93472. */
  93473. particleSystem: ParticleSystem);
  93474. private updateCellInfoFromSystem;
  93475. /**
  93476. * Defines how the sprite cell index is updated for the particle
  93477. */
  93478. updateCellIndex(): void;
  93479. /** @hidden */
  93480. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93481. /** @hidden */
  93482. _inheritParticleInfoToSubEmitters(): void;
  93483. /** @hidden */
  93484. _reset(): void;
  93485. /**
  93486. * Copy the properties of particle to another one.
  93487. * @param other the particle to copy the information to.
  93488. */
  93489. copyTo(other: Particle): void;
  93490. }
  93491. }
  93492. declare module BABYLON {
  93493. /**
  93494. * Particle emitter represents a volume emitting particles.
  93495. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93496. */
  93497. export interface IParticleEmitterType {
  93498. /**
  93499. * Called by the particle System when the direction is computed for the created particle.
  93500. * @param worldMatrix is the world matrix of the particle system
  93501. * @param directionToUpdate is the direction vector to update with the result
  93502. * @param particle is the particle we are computed the direction for
  93503. * @param isLocal defines if the direction should be set in local space
  93504. */
  93505. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93506. /**
  93507. * Called by the particle System when the position is computed for the created particle.
  93508. * @param worldMatrix is the world matrix of the particle system
  93509. * @param positionToUpdate is the position vector to update with the result
  93510. * @param particle is the particle we are computed the position for
  93511. * @param isLocal defines if the position should be set in local space
  93512. */
  93513. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93514. /**
  93515. * Clones the current emitter and returns a copy of it
  93516. * @returns the new emitter
  93517. */
  93518. clone(): IParticleEmitterType;
  93519. /**
  93520. * Called by the GPUParticleSystem to setup the update shader
  93521. * @param effect defines the update shader
  93522. */
  93523. applyToShader(effect: Effect): void;
  93524. /**
  93525. * Returns a string to use to update the GPU particles update shader
  93526. * @returns the effect defines string
  93527. */
  93528. getEffectDefines(): string;
  93529. /**
  93530. * Returns a string representing the class name
  93531. * @returns a string containing the class name
  93532. */
  93533. getClassName(): string;
  93534. /**
  93535. * Serializes the particle system to a JSON object.
  93536. * @returns the JSON object
  93537. */
  93538. serialize(): any;
  93539. /**
  93540. * Parse properties from a JSON object
  93541. * @param serializationObject defines the JSON object
  93542. * @param scene defines the hosting scene
  93543. */
  93544. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93545. }
  93546. }
  93547. declare module BABYLON {
  93548. /**
  93549. * Particle emitter emitting particles from the inside of a box.
  93550. * It emits the particles randomly between 2 given directions.
  93551. */
  93552. export class BoxParticleEmitter implements IParticleEmitterType {
  93553. /**
  93554. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93555. */
  93556. direction1: Vector3;
  93557. /**
  93558. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93559. */
  93560. direction2: Vector3;
  93561. /**
  93562. * 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.
  93563. */
  93564. minEmitBox: Vector3;
  93565. /**
  93566. * 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.
  93567. */
  93568. maxEmitBox: Vector3;
  93569. /**
  93570. * Creates a new instance BoxParticleEmitter
  93571. */
  93572. constructor();
  93573. /**
  93574. * Called by the particle System when the direction is computed for the created particle.
  93575. * @param worldMatrix is the world matrix of the particle system
  93576. * @param directionToUpdate is the direction vector to update with the result
  93577. * @param particle is the particle we are computed the direction for
  93578. * @param isLocal defines if the direction should be set in local space
  93579. */
  93580. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93581. /**
  93582. * Called by the particle System when the position is computed for the created particle.
  93583. * @param worldMatrix is the world matrix of the particle system
  93584. * @param positionToUpdate is the position vector to update with the result
  93585. * @param particle is the particle we are computed the position for
  93586. * @param isLocal defines if the position should be set in local space
  93587. */
  93588. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93589. /**
  93590. * Clones the current emitter and returns a copy of it
  93591. * @returns the new emitter
  93592. */
  93593. clone(): BoxParticleEmitter;
  93594. /**
  93595. * Called by the GPUParticleSystem to setup the update shader
  93596. * @param effect defines the update shader
  93597. */
  93598. applyToShader(effect: Effect): void;
  93599. /**
  93600. * Returns a string to use to update the GPU particles update shader
  93601. * @returns a string containng the defines string
  93602. */
  93603. getEffectDefines(): string;
  93604. /**
  93605. * Returns the string "BoxParticleEmitter"
  93606. * @returns a string containing the class name
  93607. */
  93608. getClassName(): string;
  93609. /**
  93610. * Serializes the particle system to a JSON object.
  93611. * @returns the JSON object
  93612. */
  93613. serialize(): any;
  93614. /**
  93615. * Parse properties from a JSON object
  93616. * @param serializationObject defines the JSON object
  93617. */
  93618. parse(serializationObject: any): void;
  93619. }
  93620. }
  93621. declare module BABYLON {
  93622. /**
  93623. * Particle emitter emitting particles from the inside of a cone.
  93624. * It emits the particles alongside the cone volume from the base to the particle.
  93625. * The emission direction might be randomized.
  93626. */
  93627. export class ConeParticleEmitter implements IParticleEmitterType {
  93628. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93629. directionRandomizer: number;
  93630. private _radius;
  93631. private _angle;
  93632. private _height;
  93633. /**
  93634. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93635. */
  93636. radiusRange: number;
  93637. /**
  93638. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93639. */
  93640. heightRange: number;
  93641. /**
  93642. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93643. */
  93644. emitFromSpawnPointOnly: boolean;
  93645. /**
  93646. * Gets or sets the radius of the emission cone
  93647. */
  93648. get radius(): number;
  93649. set radius(value: number);
  93650. /**
  93651. * Gets or sets the angle of the emission cone
  93652. */
  93653. get angle(): number;
  93654. set angle(value: number);
  93655. private _buildHeight;
  93656. /**
  93657. * Creates a new instance ConeParticleEmitter
  93658. * @param radius the radius of the emission cone (1 by default)
  93659. * @param angle the cone base angle (PI by default)
  93660. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93661. */
  93662. constructor(radius?: number, angle?: number,
  93663. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93664. directionRandomizer?: number);
  93665. /**
  93666. * Called by the particle System when the direction is computed for the created particle.
  93667. * @param worldMatrix is the world matrix of the particle system
  93668. * @param directionToUpdate is the direction vector to update with the result
  93669. * @param particle is the particle we are computed the direction for
  93670. * @param isLocal defines if the direction should be set in local space
  93671. */
  93672. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93673. /**
  93674. * Called by the particle System when the position is computed for the created particle.
  93675. * @param worldMatrix is the world matrix of the particle system
  93676. * @param positionToUpdate is the position vector to update with the result
  93677. * @param particle is the particle we are computed the position for
  93678. * @param isLocal defines if the position should be set in local space
  93679. */
  93680. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93681. /**
  93682. * Clones the current emitter and returns a copy of it
  93683. * @returns the new emitter
  93684. */
  93685. clone(): ConeParticleEmitter;
  93686. /**
  93687. * Called by the GPUParticleSystem to setup the update shader
  93688. * @param effect defines the update shader
  93689. */
  93690. applyToShader(effect: Effect): void;
  93691. /**
  93692. * Returns a string to use to update the GPU particles update shader
  93693. * @returns a string containng the defines string
  93694. */
  93695. getEffectDefines(): string;
  93696. /**
  93697. * Returns the string "ConeParticleEmitter"
  93698. * @returns a string containing the class name
  93699. */
  93700. getClassName(): string;
  93701. /**
  93702. * Serializes the particle system to a JSON object.
  93703. * @returns the JSON object
  93704. */
  93705. serialize(): any;
  93706. /**
  93707. * Parse properties from a JSON object
  93708. * @param serializationObject defines the JSON object
  93709. */
  93710. parse(serializationObject: any): void;
  93711. }
  93712. }
  93713. declare module BABYLON {
  93714. /**
  93715. * Particle emitter emitting particles from the inside of a cylinder.
  93716. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93717. */
  93718. export class CylinderParticleEmitter implements IParticleEmitterType {
  93719. /**
  93720. * The radius of the emission cylinder.
  93721. */
  93722. radius: number;
  93723. /**
  93724. * The height of the emission cylinder.
  93725. */
  93726. height: number;
  93727. /**
  93728. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93729. */
  93730. radiusRange: number;
  93731. /**
  93732. * How much to randomize the particle direction [0-1].
  93733. */
  93734. directionRandomizer: number;
  93735. /**
  93736. * Creates a new instance CylinderParticleEmitter
  93737. * @param radius the radius of the emission cylinder (1 by default)
  93738. * @param height the height of the emission cylinder (1 by default)
  93739. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93740. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93741. */
  93742. constructor(
  93743. /**
  93744. * The radius of the emission cylinder.
  93745. */
  93746. radius?: number,
  93747. /**
  93748. * The height of the emission cylinder.
  93749. */
  93750. height?: number,
  93751. /**
  93752. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93753. */
  93754. radiusRange?: number,
  93755. /**
  93756. * How much to randomize the particle direction [0-1].
  93757. */
  93758. directionRandomizer?: number);
  93759. /**
  93760. * Called by the particle System when the direction is computed for the created particle.
  93761. * @param worldMatrix is the world matrix of the particle system
  93762. * @param directionToUpdate is the direction vector to update with the result
  93763. * @param particle is the particle we are computed the direction for
  93764. * @param isLocal defines if the direction should be set in local space
  93765. */
  93766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93767. /**
  93768. * Called by the particle System when the position is computed for the created particle.
  93769. * @param worldMatrix is the world matrix of the particle system
  93770. * @param positionToUpdate is the position vector to update with the result
  93771. * @param particle is the particle we are computed the position for
  93772. * @param isLocal defines if the position should be set in local space
  93773. */
  93774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93775. /**
  93776. * Clones the current emitter and returns a copy of it
  93777. * @returns the new emitter
  93778. */
  93779. clone(): CylinderParticleEmitter;
  93780. /**
  93781. * Called by the GPUParticleSystem to setup the update shader
  93782. * @param effect defines the update shader
  93783. */
  93784. applyToShader(effect: Effect): void;
  93785. /**
  93786. * Returns a string to use to update the GPU particles update shader
  93787. * @returns a string containng the defines string
  93788. */
  93789. getEffectDefines(): string;
  93790. /**
  93791. * Returns the string "CylinderParticleEmitter"
  93792. * @returns a string containing the class name
  93793. */
  93794. getClassName(): string;
  93795. /**
  93796. * Serializes the particle system to a JSON object.
  93797. * @returns the JSON object
  93798. */
  93799. serialize(): any;
  93800. /**
  93801. * Parse properties from a JSON object
  93802. * @param serializationObject defines the JSON object
  93803. */
  93804. parse(serializationObject: any): void;
  93805. }
  93806. /**
  93807. * Particle emitter emitting particles from the inside of a cylinder.
  93808. * It emits the particles randomly between two vectors.
  93809. */
  93810. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93811. /**
  93812. * The min limit of the emission direction.
  93813. */
  93814. direction1: Vector3;
  93815. /**
  93816. * The max limit of the emission direction.
  93817. */
  93818. direction2: Vector3;
  93819. /**
  93820. * Creates a new instance CylinderDirectedParticleEmitter
  93821. * @param radius the radius of the emission cylinder (1 by default)
  93822. * @param height the height of the emission cylinder (1 by default)
  93823. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93824. * @param direction1 the min limit of the emission direction (up vector by default)
  93825. * @param direction2 the max limit of the emission direction (up vector by default)
  93826. */
  93827. constructor(radius?: number, height?: number, radiusRange?: number,
  93828. /**
  93829. * The min limit of the emission direction.
  93830. */
  93831. direction1?: Vector3,
  93832. /**
  93833. * The max limit of the emission direction.
  93834. */
  93835. direction2?: Vector3);
  93836. /**
  93837. * Called by the particle System when the direction is computed for the created particle.
  93838. * @param worldMatrix is the world matrix of the particle system
  93839. * @param directionToUpdate is the direction vector to update with the result
  93840. * @param particle is the particle we are computed the direction for
  93841. */
  93842. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93843. /**
  93844. * Clones the current emitter and returns a copy of it
  93845. * @returns the new emitter
  93846. */
  93847. clone(): CylinderDirectedParticleEmitter;
  93848. /**
  93849. * Called by the GPUParticleSystem to setup the update shader
  93850. * @param effect defines the update shader
  93851. */
  93852. applyToShader(effect: Effect): void;
  93853. /**
  93854. * Returns a string to use to update the GPU particles update shader
  93855. * @returns a string containng the defines string
  93856. */
  93857. getEffectDefines(): string;
  93858. /**
  93859. * Returns the string "CylinderDirectedParticleEmitter"
  93860. * @returns a string containing the class name
  93861. */
  93862. getClassName(): string;
  93863. /**
  93864. * Serializes the particle system to a JSON object.
  93865. * @returns the JSON object
  93866. */
  93867. serialize(): any;
  93868. /**
  93869. * Parse properties from a JSON object
  93870. * @param serializationObject defines the JSON object
  93871. */
  93872. parse(serializationObject: any): void;
  93873. }
  93874. }
  93875. declare module BABYLON {
  93876. /**
  93877. * Particle emitter emitting particles from the inside of a hemisphere.
  93878. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93879. */
  93880. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93881. /**
  93882. * The radius of the emission hemisphere.
  93883. */
  93884. radius: number;
  93885. /**
  93886. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93887. */
  93888. radiusRange: number;
  93889. /**
  93890. * How much to randomize the particle direction [0-1].
  93891. */
  93892. directionRandomizer: number;
  93893. /**
  93894. * Creates a new instance HemisphericParticleEmitter
  93895. * @param radius the radius of the emission hemisphere (1 by default)
  93896. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93897. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93898. */
  93899. constructor(
  93900. /**
  93901. * The radius of the emission hemisphere.
  93902. */
  93903. radius?: number,
  93904. /**
  93905. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93906. */
  93907. radiusRange?: number,
  93908. /**
  93909. * How much to randomize the particle direction [0-1].
  93910. */
  93911. directionRandomizer?: number);
  93912. /**
  93913. * Called by the particle System when the direction is computed for the created particle.
  93914. * @param worldMatrix is the world matrix of the particle system
  93915. * @param directionToUpdate is the direction vector to update with the result
  93916. * @param particle is the particle we are computed the direction for
  93917. * @param isLocal defines if the direction should be set in local space
  93918. */
  93919. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93920. /**
  93921. * Called by the particle System when the position is computed for the created particle.
  93922. * @param worldMatrix is the world matrix of the particle system
  93923. * @param positionToUpdate is the position vector to update with the result
  93924. * @param particle is the particle we are computed the position for
  93925. * @param isLocal defines if the position should be set in local space
  93926. */
  93927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93928. /**
  93929. * Clones the current emitter and returns a copy of it
  93930. * @returns the new emitter
  93931. */
  93932. clone(): HemisphericParticleEmitter;
  93933. /**
  93934. * Called by the GPUParticleSystem to setup the update shader
  93935. * @param effect defines the update shader
  93936. */
  93937. applyToShader(effect: Effect): void;
  93938. /**
  93939. * Returns a string to use to update the GPU particles update shader
  93940. * @returns a string containng the defines string
  93941. */
  93942. getEffectDefines(): string;
  93943. /**
  93944. * Returns the string "HemisphericParticleEmitter"
  93945. * @returns a string containing the class name
  93946. */
  93947. getClassName(): string;
  93948. /**
  93949. * Serializes the particle system to a JSON object.
  93950. * @returns the JSON object
  93951. */
  93952. serialize(): any;
  93953. /**
  93954. * Parse properties from a JSON object
  93955. * @param serializationObject defines the JSON object
  93956. */
  93957. parse(serializationObject: any): void;
  93958. }
  93959. }
  93960. declare module BABYLON {
  93961. /**
  93962. * Particle emitter emitting particles from a point.
  93963. * It emits the particles randomly between 2 given directions.
  93964. */
  93965. export class PointParticleEmitter implements IParticleEmitterType {
  93966. /**
  93967. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93968. */
  93969. direction1: Vector3;
  93970. /**
  93971. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93972. */
  93973. direction2: Vector3;
  93974. /**
  93975. * Creates a new instance PointParticleEmitter
  93976. */
  93977. constructor();
  93978. /**
  93979. * Called by the particle System when the direction is computed for the created particle.
  93980. * @param worldMatrix is the world matrix of the particle system
  93981. * @param directionToUpdate is the direction vector to update with the result
  93982. * @param particle is the particle we are computed the direction for
  93983. * @param isLocal defines if the direction should be set in local space
  93984. */
  93985. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93986. /**
  93987. * Called by the particle System when the position is computed for the created particle.
  93988. * @param worldMatrix is the world matrix of the particle system
  93989. * @param positionToUpdate is the position vector to update with the result
  93990. * @param particle is the particle we are computed the position for
  93991. * @param isLocal defines if the position should be set in local space
  93992. */
  93993. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93994. /**
  93995. * Clones the current emitter and returns a copy of it
  93996. * @returns the new emitter
  93997. */
  93998. clone(): PointParticleEmitter;
  93999. /**
  94000. * Called by the GPUParticleSystem to setup the update shader
  94001. * @param effect defines the update shader
  94002. */
  94003. applyToShader(effect: Effect): void;
  94004. /**
  94005. * Returns a string to use to update the GPU particles update shader
  94006. * @returns a string containng the defines string
  94007. */
  94008. getEffectDefines(): string;
  94009. /**
  94010. * Returns the string "PointParticleEmitter"
  94011. * @returns a string containing the class name
  94012. */
  94013. getClassName(): string;
  94014. /**
  94015. * Serializes the particle system to a JSON object.
  94016. * @returns the JSON object
  94017. */
  94018. serialize(): any;
  94019. /**
  94020. * Parse properties from a JSON object
  94021. * @param serializationObject defines the JSON object
  94022. */
  94023. parse(serializationObject: any): void;
  94024. }
  94025. }
  94026. declare module BABYLON {
  94027. /**
  94028. * Particle emitter emitting particles from the inside of a sphere.
  94029. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94030. */
  94031. export class SphereParticleEmitter implements IParticleEmitterType {
  94032. /**
  94033. * The radius of the emission sphere.
  94034. */
  94035. radius: number;
  94036. /**
  94037. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94038. */
  94039. radiusRange: number;
  94040. /**
  94041. * How much to randomize the particle direction [0-1].
  94042. */
  94043. directionRandomizer: number;
  94044. /**
  94045. * Creates a new instance SphereParticleEmitter
  94046. * @param radius the radius of the emission sphere (1 by default)
  94047. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94048. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94049. */
  94050. constructor(
  94051. /**
  94052. * The radius of the emission sphere.
  94053. */
  94054. radius?: number,
  94055. /**
  94056. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94057. */
  94058. radiusRange?: number,
  94059. /**
  94060. * How much to randomize the particle direction [0-1].
  94061. */
  94062. directionRandomizer?: number);
  94063. /**
  94064. * Called by the particle System when the direction is computed for the created particle.
  94065. * @param worldMatrix is the world matrix of the particle system
  94066. * @param directionToUpdate is the direction vector to update with the result
  94067. * @param particle is the particle we are computed the direction for
  94068. * @param isLocal defines if the direction should be set in local space
  94069. */
  94070. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94071. /**
  94072. * Called by the particle System when the position is computed for the created particle.
  94073. * @param worldMatrix is the world matrix of the particle system
  94074. * @param positionToUpdate is the position vector to update with the result
  94075. * @param particle is the particle we are computed the position for
  94076. * @param isLocal defines if the position should be set in local space
  94077. */
  94078. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94079. /**
  94080. * Clones the current emitter and returns a copy of it
  94081. * @returns the new emitter
  94082. */
  94083. clone(): SphereParticleEmitter;
  94084. /**
  94085. * Called by the GPUParticleSystem to setup the update shader
  94086. * @param effect defines the update shader
  94087. */
  94088. applyToShader(effect: Effect): void;
  94089. /**
  94090. * Returns a string to use to update the GPU particles update shader
  94091. * @returns a string containng the defines string
  94092. */
  94093. getEffectDefines(): string;
  94094. /**
  94095. * Returns the string "SphereParticleEmitter"
  94096. * @returns a string containing the class name
  94097. */
  94098. getClassName(): string;
  94099. /**
  94100. * Serializes the particle system to a JSON object.
  94101. * @returns the JSON object
  94102. */
  94103. serialize(): any;
  94104. /**
  94105. * Parse properties from a JSON object
  94106. * @param serializationObject defines the JSON object
  94107. */
  94108. parse(serializationObject: any): void;
  94109. }
  94110. /**
  94111. * Particle emitter emitting particles from the inside of a sphere.
  94112. * It emits the particles randomly between two vectors.
  94113. */
  94114. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94115. /**
  94116. * The min limit of the emission direction.
  94117. */
  94118. direction1: Vector3;
  94119. /**
  94120. * The max limit of the emission direction.
  94121. */
  94122. direction2: Vector3;
  94123. /**
  94124. * Creates a new instance SphereDirectedParticleEmitter
  94125. * @param radius the radius of the emission sphere (1 by default)
  94126. * @param direction1 the min limit of the emission direction (up vector by default)
  94127. * @param direction2 the max limit of the emission direction (up vector by default)
  94128. */
  94129. constructor(radius?: number,
  94130. /**
  94131. * The min limit of the emission direction.
  94132. */
  94133. direction1?: Vector3,
  94134. /**
  94135. * The max limit of the emission direction.
  94136. */
  94137. direction2?: Vector3);
  94138. /**
  94139. * Called by the particle System when the direction is computed for the created particle.
  94140. * @param worldMatrix is the world matrix of the particle system
  94141. * @param directionToUpdate is the direction vector to update with the result
  94142. * @param particle is the particle we are computed the direction for
  94143. */
  94144. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94145. /**
  94146. * Clones the current emitter and returns a copy of it
  94147. * @returns the new emitter
  94148. */
  94149. clone(): SphereDirectedParticleEmitter;
  94150. /**
  94151. * Called by the GPUParticleSystem to setup the update shader
  94152. * @param effect defines the update shader
  94153. */
  94154. applyToShader(effect: Effect): void;
  94155. /**
  94156. * Returns a string to use to update the GPU particles update shader
  94157. * @returns a string containng the defines string
  94158. */
  94159. getEffectDefines(): string;
  94160. /**
  94161. * Returns the string "SphereDirectedParticleEmitter"
  94162. * @returns a string containing the class name
  94163. */
  94164. getClassName(): string;
  94165. /**
  94166. * Serializes the particle system to a JSON object.
  94167. * @returns the JSON object
  94168. */
  94169. serialize(): any;
  94170. /**
  94171. * Parse properties from a JSON object
  94172. * @param serializationObject defines the JSON object
  94173. */
  94174. parse(serializationObject: any): void;
  94175. }
  94176. }
  94177. declare module BABYLON {
  94178. /**
  94179. * Particle emitter emitting particles from a custom list of positions.
  94180. */
  94181. export class CustomParticleEmitter implements IParticleEmitterType {
  94182. /**
  94183. * Gets or sets the position generator that will create the inital position of each particle.
  94184. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94185. */
  94186. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94187. /**
  94188. * Gets or sets the destination generator that will create the final destination of each particle.
  94189. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94190. */
  94191. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94192. /**
  94193. * Creates a new instance CustomParticleEmitter
  94194. */
  94195. constructor();
  94196. /**
  94197. * Called by the particle System when the direction is computed for the created particle.
  94198. * @param worldMatrix is the world matrix of the particle system
  94199. * @param directionToUpdate is the direction vector to update with the result
  94200. * @param particle is the particle we are computed the direction for
  94201. * @param isLocal defines if the direction should be set in local space
  94202. */
  94203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94204. /**
  94205. * Called by the particle System when the position is computed for the created particle.
  94206. * @param worldMatrix is the world matrix of the particle system
  94207. * @param positionToUpdate is the position vector to update with the result
  94208. * @param particle is the particle we are computed the position for
  94209. * @param isLocal defines if the position should be set in local space
  94210. */
  94211. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94212. /**
  94213. * Clones the current emitter and returns a copy of it
  94214. * @returns the new emitter
  94215. */
  94216. clone(): CustomParticleEmitter;
  94217. /**
  94218. * Called by the GPUParticleSystem to setup the update shader
  94219. * @param effect defines the update shader
  94220. */
  94221. applyToShader(effect: Effect): void;
  94222. /**
  94223. * Returns a string to use to update the GPU particles update shader
  94224. * @returns a string containng the defines string
  94225. */
  94226. getEffectDefines(): string;
  94227. /**
  94228. * Returns the string "PointParticleEmitter"
  94229. * @returns a string containing the class name
  94230. */
  94231. getClassName(): string;
  94232. /**
  94233. * Serializes the particle system to a JSON object.
  94234. * @returns the JSON object
  94235. */
  94236. serialize(): any;
  94237. /**
  94238. * Parse properties from a JSON object
  94239. * @param serializationObject defines the JSON object
  94240. */
  94241. parse(serializationObject: any): void;
  94242. }
  94243. }
  94244. declare module BABYLON {
  94245. /**
  94246. * Particle emitter emitting particles from the inside of a box.
  94247. * It emits the particles randomly between 2 given directions.
  94248. */
  94249. export class MeshParticleEmitter implements IParticleEmitterType {
  94250. private _indices;
  94251. private _positions;
  94252. private _normals;
  94253. private _storedNormal;
  94254. private _mesh;
  94255. /**
  94256. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94257. */
  94258. direction1: Vector3;
  94259. /**
  94260. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94261. */
  94262. direction2: Vector3;
  94263. /**
  94264. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94265. */
  94266. useMeshNormalsForDirection: boolean;
  94267. /** Defines the mesh to use as source */
  94268. get mesh(): Nullable<AbstractMesh>;
  94269. set mesh(value: Nullable<AbstractMesh>);
  94270. /**
  94271. * Creates a new instance MeshParticleEmitter
  94272. * @param mesh defines the mesh to use as source
  94273. */
  94274. constructor(mesh?: Nullable<AbstractMesh>);
  94275. /**
  94276. * Called by the particle System when the direction is computed for the created particle.
  94277. * @param worldMatrix is the world matrix of the particle system
  94278. * @param directionToUpdate is the direction vector to update with the result
  94279. * @param particle is the particle we are computed the direction for
  94280. * @param isLocal defines if the direction should be set in local space
  94281. */
  94282. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94283. /**
  94284. * Called by the particle System when the position is computed for the created particle.
  94285. * @param worldMatrix is the world matrix of the particle system
  94286. * @param positionToUpdate is the position vector to update with the result
  94287. * @param particle is the particle we are computed the position for
  94288. * @param isLocal defines if the position should be set in local space
  94289. */
  94290. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94291. /**
  94292. * Clones the current emitter and returns a copy of it
  94293. * @returns the new emitter
  94294. */
  94295. clone(): MeshParticleEmitter;
  94296. /**
  94297. * Called by the GPUParticleSystem to setup the update shader
  94298. * @param effect defines the update shader
  94299. */
  94300. applyToShader(effect: Effect): void;
  94301. /**
  94302. * Returns a string to use to update the GPU particles update shader
  94303. * @returns a string containng the defines string
  94304. */
  94305. getEffectDefines(): string;
  94306. /**
  94307. * Returns the string "BoxParticleEmitter"
  94308. * @returns a string containing the class name
  94309. */
  94310. getClassName(): string;
  94311. /**
  94312. * Serializes the particle system to a JSON object.
  94313. * @returns the JSON object
  94314. */
  94315. serialize(): any;
  94316. /**
  94317. * Parse properties from a JSON object
  94318. * @param serializationObject defines the JSON object
  94319. * @param scene defines the hosting scene
  94320. */
  94321. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94322. }
  94323. }
  94324. declare module BABYLON {
  94325. /**
  94326. * Interface representing a particle system in Babylon.js.
  94327. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94328. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94329. */
  94330. export interface IParticleSystem {
  94331. /**
  94332. * List of animations used by the particle system.
  94333. */
  94334. animations: Animation[];
  94335. /**
  94336. * The id of the Particle system.
  94337. */
  94338. id: string;
  94339. /**
  94340. * The name of the Particle system.
  94341. */
  94342. name: string;
  94343. /**
  94344. * The emitter represents the Mesh or position we are attaching the particle system to.
  94345. */
  94346. emitter: Nullable<AbstractMesh | Vector3>;
  94347. /**
  94348. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94349. */
  94350. isBillboardBased: boolean;
  94351. /**
  94352. * The rendering group used by the Particle system to chose when to render.
  94353. */
  94354. renderingGroupId: number;
  94355. /**
  94356. * The layer mask we are rendering the particles through.
  94357. */
  94358. layerMask: number;
  94359. /**
  94360. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94361. */
  94362. updateSpeed: number;
  94363. /**
  94364. * The amount of time the particle system is running (depends of the overall update speed).
  94365. */
  94366. targetStopDuration: number;
  94367. /**
  94368. * The texture used to render each particle. (this can be a spritesheet)
  94369. */
  94370. particleTexture: Nullable<BaseTexture>;
  94371. /**
  94372. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94373. */
  94374. blendMode: number;
  94375. /**
  94376. * Minimum life time of emitting particles.
  94377. */
  94378. minLifeTime: number;
  94379. /**
  94380. * Maximum life time of emitting particles.
  94381. */
  94382. maxLifeTime: number;
  94383. /**
  94384. * Minimum Size of emitting particles.
  94385. */
  94386. minSize: number;
  94387. /**
  94388. * Maximum Size of emitting particles.
  94389. */
  94390. maxSize: number;
  94391. /**
  94392. * Minimum scale of emitting particles on X axis.
  94393. */
  94394. minScaleX: number;
  94395. /**
  94396. * Maximum scale of emitting particles on X axis.
  94397. */
  94398. maxScaleX: number;
  94399. /**
  94400. * Minimum scale of emitting particles on Y axis.
  94401. */
  94402. minScaleY: number;
  94403. /**
  94404. * Maximum scale of emitting particles on Y axis.
  94405. */
  94406. maxScaleY: number;
  94407. /**
  94408. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94409. */
  94410. color1: Color4;
  94411. /**
  94412. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94413. */
  94414. color2: Color4;
  94415. /**
  94416. * Color the particle will have at the end of its lifetime.
  94417. */
  94418. colorDead: Color4;
  94419. /**
  94420. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94421. */
  94422. emitRate: number;
  94423. /**
  94424. * You can use gravity if you want to give an orientation to your particles.
  94425. */
  94426. gravity: Vector3;
  94427. /**
  94428. * Minimum power of emitting particles.
  94429. */
  94430. minEmitPower: number;
  94431. /**
  94432. * Maximum power of emitting particles.
  94433. */
  94434. maxEmitPower: number;
  94435. /**
  94436. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94437. */
  94438. minAngularSpeed: number;
  94439. /**
  94440. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94441. */
  94442. maxAngularSpeed: number;
  94443. /**
  94444. * Gets or sets the minimal initial rotation in radians.
  94445. */
  94446. minInitialRotation: number;
  94447. /**
  94448. * Gets or sets the maximal initial rotation in radians.
  94449. */
  94450. maxInitialRotation: number;
  94451. /**
  94452. * The particle emitter type defines the emitter used by the particle system.
  94453. * It can be for example box, sphere, or cone...
  94454. */
  94455. particleEmitterType: Nullable<IParticleEmitterType>;
  94456. /**
  94457. * Defines the delay in milliseconds before starting the system (0 by default)
  94458. */
  94459. startDelay: number;
  94460. /**
  94461. * 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
  94462. */
  94463. preWarmCycles: number;
  94464. /**
  94465. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94466. */
  94467. preWarmStepOffset: number;
  94468. /**
  94469. * 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)
  94470. */
  94471. spriteCellChangeSpeed: number;
  94472. /**
  94473. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94474. */
  94475. startSpriteCellID: number;
  94476. /**
  94477. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94478. */
  94479. endSpriteCellID: number;
  94480. /**
  94481. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94482. */
  94483. spriteCellWidth: number;
  94484. /**
  94485. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94486. */
  94487. spriteCellHeight: number;
  94488. /**
  94489. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94490. */
  94491. spriteRandomStartCell: boolean;
  94492. /**
  94493. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94494. */
  94495. isAnimationSheetEnabled: boolean;
  94496. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94497. translationPivot: Vector2;
  94498. /**
  94499. * Gets or sets a texture used to add random noise to particle positions
  94500. */
  94501. noiseTexture: Nullable<BaseTexture>;
  94502. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94503. noiseStrength: Vector3;
  94504. /**
  94505. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94506. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94507. */
  94508. billboardMode: number;
  94509. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94510. limitVelocityDamping: number;
  94511. /**
  94512. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94513. */
  94514. beginAnimationOnStart: boolean;
  94515. /**
  94516. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94517. */
  94518. beginAnimationFrom: number;
  94519. /**
  94520. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94521. */
  94522. beginAnimationTo: number;
  94523. /**
  94524. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94525. */
  94526. beginAnimationLoop: boolean;
  94527. /**
  94528. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94529. */
  94530. disposeOnStop: boolean;
  94531. /**
  94532. * Specifies if the particles are updated in emitter local space or world space
  94533. */
  94534. isLocal: boolean;
  94535. /** Snippet ID if the particle system was created from the snippet server */
  94536. snippetId: string;
  94537. /** Gets or sets a matrix to use to compute projection */
  94538. defaultProjectionMatrix: Matrix;
  94539. /**
  94540. * Gets the maximum number of particles active at the same time.
  94541. * @returns The max number of active particles.
  94542. */
  94543. getCapacity(): number;
  94544. /**
  94545. * Gets the number of particles active at the same time.
  94546. * @returns The number of active particles.
  94547. */
  94548. getActiveCount(): number;
  94549. /**
  94550. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94551. * @returns True if it has been started, otherwise false.
  94552. */
  94553. isStarted(): boolean;
  94554. /**
  94555. * Animates the particle system for this frame.
  94556. */
  94557. animate(): void;
  94558. /**
  94559. * Renders the particle system in its current state.
  94560. * @returns the current number of particles
  94561. */
  94562. render(): number;
  94563. /**
  94564. * Dispose the particle system and frees its associated resources.
  94565. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94566. */
  94567. dispose(disposeTexture?: boolean): void;
  94568. /**
  94569. * An event triggered when the system is disposed
  94570. */
  94571. onDisposeObservable: Observable<IParticleSystem>;
  94572. /**
  94573. * Clones the particle system.
  94574. * @param name The name of the cloned object
  94575. * @param newEmitter The new emitter to use
  94576. * @returns the cloned particle system
  94577. */
  94578. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94579. /**
  94580. * Serializes the particle system to a JSON object
  94581. * @param serializeTexture defines if the texture must be serialized as well
  94582. * @returns the JSON object
  94583. */
  94584. serialize(serializeTexture: boolean): any;
  94585. /**
  94586. * Rebuild the particle system
  94587. */
  94588. rebuild(): void;
  94589. /** Force the system to rebuild all gradients that need to be resync */
  94590. forceRefreshGradients(): void;
  94591. /**
  94592. * Starts the particle system and begins to emit
  94593. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94594. */
  94595. start(delay?: number): void;
  94596. /**
  94597. * Stops the particle system.
  94598. */
  94599. stop(): void;
  94600. /**
  94601. * Remove all active particles
  94602. */
  94603. reset(): void;
  94604. /**
  94605. * Gets a boolean indicating that the system is stopping
  94606. * @returns true if the system is currently stopping
  94607. */
  94608. isStopping(): boolean;
  94609. /**
  94610. * Is this system ready to be used/rendered
  94611. * @return true if the system is ready
  94612. */
  94613. isReady(): boolean;
  94614. /**
  94615. * Returns the string "ParticleSystem"
  94616. * @returns a string containing the class name
  94617. */
  94618. getClassName(): string;
  94619. /**
  94620. * Gets the custom effect used to render the particles
  94621. * @param blendMode Blend mode for which the effect should be retrieved
  94622. * @returns The effect
  94623. */
  94624. getCustomEffect(blendMode: number): Nullable<Effect>;
  94625. /**
  94626. * Sets the custom effect used to render the particles
  94627. * @param effect The effect to set
  94628. * @param blendMode Blend mode for which the effect should be set
  94629. */
  94630. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94631. /**
  94632. * Fill the defines array according to the current settings of the particle system
  94633. * @param defines Array to be updated
  94634. * @param blendMode blend mode to take into account when updating the array
  94635. */
  94636. fillDefines(defines: Array<string>, blendMode: number): void;
  94637. /**
  94638. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94639. * @param uniforms Uniforms array to fill
  94640. * @param attributes Attributes array to fill
  94641. * @param samplers Samplers array to fill
  94642. */
  94643. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94644. /**
  94645. * Observable that will be called just before the particles are drawn
  94646. */
  94647. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94648. /**
  94649. * Gets the name of the particle vertex shader
  94650. */
  94651. vertexShaderName: string;
  94652. /**
  94653. * Adds a new color gradient
  94654. * @param gradient defines the gradient to use (between 0 and 1)
  94655. * @param color1 defines the color to affect to the specified gradient
  94656. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94657. * @returns the current particle system
  94658. */
  94659. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94660. /**
  94661. * Remove a specific color gradient
  94662. * @param gradient defines the gradient to remove
  94663. * @returns the current particle system
  94664. */
  94665. removeColorGradient(gradient: number): IParticleSystem;
  94666. /**
  94667. * Adds a new size gradient
  94668. * @param gradient defines the gradient to use (between 0 and 1)
  94669. * @param factor defines the size factor to affect to the specified gradient
  94670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94671. * @returns the current particle system
  94672. */
  94673. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94674. /**
  94675. * Remove a specific size gradient
  94676. * @param gradient defines the gradient to remove
  94677. * @returns the current particle system
  94678. */
  94679. removeSizeGradient(gradient: number): IParticleSystem;
  94680. /**
  94681. * Gets the current list of color gradients.
  94682. * You must use addColorGradient and removeColorGradient to udpate this list
  94683. * @returns the list of color gradients
  94684. */
  94685. getColorGradients(): Nullable<Array<ColorGradient>>;
  94686. /**
  94687. * Gets the current list of size gradients.
  94688. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94689. * @returns the list of size gradients
  94690. */
  94691. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94692. /**
  94693. * Gets the current list of angular speed gradients.
  94694. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94695. * @returns the list of angular speed gradients
  94696. */
  94697. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94698. /**
  94699. * Adds a new angular speed gradient
  94700. * @param gradient defines the gradient to use (between 0 and 1)
  94701. * @param factor defines the angular speed to affect to the specified gradient
  94702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94703. * @returns the current particle system
  94704. */
  94705. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94706. /**
  94707. * Remove a specific angular speed gradient
  94708. * @param gradient defines the gradient to remove
  94709. * @returns the current particle system
  94710. */
  94711. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94712. /**
  94713. * Gets the current list of velocity gradients.
  94714. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94715. * @returns the list of velocity gradients
  94716. */
  94717. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94718. /**
  94719. * Adds a new velocity gradient
  94720. * @param gradient defines the gradient to use (between 0 and 1)
  94721. * @param factor defines the velocity to affect to the specified gradient
  94722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94723. * @returns the current particle system
  94724. */
  94725. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94726. /**
  94727. * Remove a specific velocity gradient
  94728. * @param gradient defines the gradient to remove
  94729. * @returns the current particle system
  94730. */
  94731. removeVelocityGradient(gradient: number): IParticleSystem;
  94732. /**
  94733. * Gets the current list of limit velocity gradients.
  94734. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94735. * @returns the list of limit velocity gradients
  94736. */
  94737. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94738. /**
  94739. * Adds a new limit velocity gradient
  94740. * @param gradient defines the gradient to use (between 0 and 1)
  94741. * @param factor defines the limit velocity to affect to the specified gradient
  94742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94743. * @returns the current particle system
  94744. */
  94745. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94746. /**
  94747. * Remove a specific limit velocity gradient
  94748. * @param gradient defines the gradient to remove
  94749. * @returns the current particle system
  94750. */
  94751. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94752. /**
  94753. * Adds a new drag gradient
  94754. * @param gradient defines the gradient to use (between 0 and 1)
  94755. * @param factor defines the drag to affect to the specified gradient
  94756. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94757. * @returns the current particle system
  94758. */
  94759. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94760. /**
  94761. * Remove a specific drag gradient
  94762. * @param gradient defines the gradient to remove
  94763. * @returns the current particle system
  94764. */
  94765. removeDragGradient(gradient: number): IParticleSystem;
  94766. /**
  94767. * Gets the current list of drag gradients.
  94768. * You must use addDragGradient and removeDragGradient to udpate this list
  94769. * @returns the list of drag gradients
  94770. */
  94771. getDragGradients(): Nullable<Array<FactorGradient>>;
  94772. /**
  94773. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94774. * @param gradient defines the gradient to use (between 0 and 1)
  94775. * @param factor defines the emit rate to affect to the specified gradient
  94776. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94777. * @returns the current particle system
  94778. */
  94779. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94780. /**
  94781. * Remove a specific emit rate gradient
  94782. * @param gradient defines the gradient to remove
  94783. * @returns the current particle system
  94784. */
  94785. removeEmitRateGradient(gradient: number): IParticleSystem;
  94786. /**
  94787. * Gets the current list of emit rate gradients.
  94788. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94789. * @returns the list of emit rate gradients
  94790. */
  94791. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94792. /**
  94793. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94794. * @param gradient defines the gradient to use (between 0 and 1)
  94795. * @param factor defines the start size to affect to the specified gradient
  94796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94797. * @returns the current particle system
  94798. */
  94799. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94800. /**
  94801. * Remove a specific start size gradient
  94802. * @param gradient defines the gradient to remove
  94803. * @returns the current particle system
  94804. */
  94805. removeStartSizeGradient(gradient: number): IParticleSystem;
  94806. /**
  94807. * Gets the current list of start size gradients.
  94808. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94809. * @returns the list of start size gradients
  94810. */
  94811. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94812. /**
  94813. * Adds a new life time gradient
  94814. * @param gradient defines the gradient to use (between 0 and 1)
  94815. * @param factor defines the life time factor to affect to the specified gradient
  94816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94817. * @returns the current particle system
  94818. */
  94819. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94820. /**
  94821. * Remove a specific life time gradient
  94822. * @param gradient defines the gradient to remove
  94823. * @returns the current particle system
  94824. */
  94825. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94826. /**
  94827. * Gets the current list of life time gradients.
  94828. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94829. * @returns the list of life time gradients
  94830. */
  94831. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94832. /**
  94833. * Gets the current list of color gradients.
  94834. * You must use addColorGradient and removeColorGradient to udpate this list
  94835. * @returns the list of color gradients
  94836. */
  94837. getColorGradients(): Nullable<Array<ColorGradient>>;
  94838. /**
  94839. * Adds a new ramp gradient used to remap particle colors
  94840. * @param gradient defines the gradient to use (between 0 and 1)
  94841. * @param color defines the color to affect to the specified gradient
  94842. * @returns the current particle system
  94843. */
  94844. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94845. /**
  94846. * Gets the current list of ramp gradients.
  94847. * You must use addRampGradient and removeRampGradient to udpate this list
  94848. * @returns the list of ramp gradients
  94849. */
  94850. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94851. /** Gets or sets a boolean indicating that ramp gradients must be used
  94852. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94853. */
  94854. useRampGradients: boolean;
  94855. /**
  94856. * Adds a new color remap gradient
  94857. * @param gradient defines the gradient to use (between 0 and 1)
  94858. * @param min defines the color remap minimal range
  94859. * @param max defines the color remap maximal range
  94860. * @returns the current particle system
  94861. */
  94862. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94863. /**
  94864. * Gets the current list of color remap gradients.
  94865. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94866. * @returns the list of color remap gradients
  94867. */
  94868. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94869. /**
  94870. * Adds a new alpha remap gradient
  94871. * @param gradient defines the gradient to use (between 0 and 1)
  94872. * @param min defines the alpha remap minimal range
  94873. * @param max defines the alpha remap maximal range
  94874. * @returns the current particle system
  94875. */
  94876. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94877. /**
  94878. * Gets the current list of alpha remap gradients.
  94879. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94880. * @returns the list of alpha remap gradients
  94881. */
  94882. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94883. /**
  94884. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94885. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94886. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94887. * @returns the emitter
  94888. */
  94889. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94890. /**
  94891. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94892. * @param radius The radius of the hemisphere to emit from
  94893. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94894. * @returns the emitter
  94895. */
  94896. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94897. /**
  94898. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94899. * @param radius The radius of the sphere to emit from
  94900. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94901. * @returns the emitter
  94902. */
  94903. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94904. /**
  94905. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94906. * @param radius The radius of the sphere to emit from
  94907. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94908. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94909. * @returns the emitter
  94910. */
  94911. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94912. /**
  94913. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94914. * @param radius The radius of the emission cylinder
  94915. * @param height The height of the emission cylinder
  94916. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94917. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94918. * @returns the emitter
  94919. */
  94920. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94921. /**
  94922. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94923. * @param radius The radius of the cylinder to emit from
  94924. * @param height The height of the emission cylinder
  94925. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94926. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94927. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94928. * @returns the emitter
  94929. */
  94930. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94931. /**
  94932. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94933. * @param radius The radius of the cone to emit from
  94934. * @param angle The base angle of the cone
  94935. * @returns the emitter
  94936. */
  94937. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94938. /**
  94939. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94940. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94941. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94942. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94943. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94944. * @returns the emitter
  94945. */
  94946. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94947. /**
  94948. * Get hosting scene
  94949. * @returns the scene
  94950. */
  94951. getScene(): Nullable<Scene>;
  94952. }
  94953. }
  94954. declare module BABYLON {
  94955. /**
  94956. * 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.
  94957. * @see https://doc.babylonjs.com/how_to/transformnode
  94958. */
  94959. export class TransformNode extends Node {
  94960. /**
  94961. * Object will not rotate to face the camera
  94962. */
  94963. static BILLBOARDMODE_NONE: number;
  94964. /**
  94965. * Object will rotate to face the camera but only on the x axis
  94966. */
  94967. static BILLBOARDMODE_X: number;
  94968. /**
  94969. * Object will rotate to face the camera but only on the y axis
  94970. */
  94971. static BILLBOARDMODE_Y: number;
  94972. /**
  94973. * Object will rotate to face the camera but only on the z axis
  94974. */
  94975. static BILLBOARDMODE_Z: number;
  94976. /**
  94977. * Object will rotate to face the camera
  94978. */
  94979. static BILLBOARDMODE_ALL: number;
  94980. /**
  94981. * Object will rotate to face the camera's position instead of orientation
  94982. */
  94983. static BILLBOARDMODE_USE_POSITION: number;
  94984. private static _TmpRotation;
  94985. private static _TmpScaling;
  94986. private static _TmpTranslation;
  94987. private _forward;
  94988. private _forwardInverted;
  94989. private _up;
  94990. private _right;
  94991. private _rightInverted;
  94992. private _position;
  94993. private _rotation;
  94994. private _rotationQuaternion;
  94995. protected _scaling: Vector3;
  94996. protected _isDirty: boolean;
  94997. private _transformToBoneReferal;
  94998. private _isAbsoluteSynced;
  94999. private _billboardMode;
  95000. /**
  95001. * Gets or sets the billboard mode. Default is 0.
  95002. *
  95003. * | Value | Type | Description |
  95004. * | --- | --- | --- |
  95005. * | 0 | BILLBOARDMODE_NONE | |
  95006. * | 1 | BILLBOARDMODE_X | |
  95007. * | 2 | BILLBOARDMODE_Y | |
  95008. * | 4 | BILLBOARDMODE_Z | |
  95009. * | 7 | BILLBOARDMODE_ALL | |
  95010. *
  95011. */
  95012. get billboardMode(): number;
  95013. set billboardMode(value: number);
  95014. private _preserveParentRotationForBillboard;
  95015. /**
  95016. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95017. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95018. */
  95019. get preserveParentRotationForBillboard(): boolean;
  95020. set preserveParentRotationForBillboard(value: boolean);
  95021. /**
  95022. * 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
  95023. */
  95024. scalingDeterminant: number;
  95025. private _infiniteDistance;
  95026. /**
  95027. * Gets or sets the distance of the object to max, often used by skybox
  95028. */
  95029. get infiniteDistance(): boolean;
  95030. set infiniteDistance(value: boolean);
  95031. /**
  95032. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95033. * By default the system will update normals to compensate
  95034. */
  95035. ignoreNonUniformScaling: boolean;
  95036. /**
  95037. * 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
  95038. */
  95039. reIntegrateRotationIntoRotationQuaternion: boolean;
  95040. /** @hidden */
  95041. _poseMatrix: Nullable<Matrix>;
  95042. /** @hidden */
  95043. _localMatrix: Matrix;
  95044. private _usePivotMatrix;
  95045. private _absolutePosition;
  95046. private _absoluteScaling;
  95047. private _absoluteRotationQuaternion;
  95048. private _pivotMatrix;
  95049. private _pivotMatrixInverse;
  95050. /** @hidden */
  95051. _postMultiplyPivotMatrix: boolean;
  95052. protected _isWorldMatrixFrozen: boolean;
  95053. /** @hidden */
  95054. _indexInSceneTransformNodesArray: number;
  95055. /**
  95056. * An event triggered after the world matrix is updated
  95057. */
  95058. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95059. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95060. /**
  95061. * Gets a string identifying the name of the class
  95062. * @returns "TransformNode" string
  95063. */
  95064. getClassName(): string;
  95065. /**
  95066. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95067. */
  95068. get position(): Vector3;
  95069. set position(newPosition: Vector3);
  95070. /**
  95071. * 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)).
  95072. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95073. */
  95074. get rotation(): Vector3;
  95075. set rotation(newRotation: Vector3);
  95076. /**
  95077. * 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)).
  95078. */
  95079. get scaling(): Vector3;
  95080. set scaling(newScaling: Vector3);
  95081. /**
  95082. * 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).
  95083. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95084. */
  95085. get rotationQuaternion(): Nullable<Quaternion>;
  95086. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95087. /**
  95088. * The forward direction of that transform in world space.
  95089. */
  95090. get forward(): Vector3;
  95091. /**
  95092. * The up direction of that transform in world space.
  95093. */
  95094. get up(): Vector3;
  95095. /**
  95096. * The right direction of that transform in world space.
  95097. */
  95098. get right(): Vector3;
  95099. /**
  95100. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95101. * @param matrix the matrix to copy the pose from
  95102. * @returns this TransformNode.
  95103. */
  95104. updatePoseMatrix(matrix: Matrix): TransformNode;
  95105. /**
  95106. * Returns the mesh Pose matrix.
  95107. * @returns the pose matrix
  95108. */
  95109. getPoseMatrix(): Matrix;
  95110. /** @hidden */
  95111. _isSynchronized(): boolean;
  95112. /** @hidden */
  95113. _initCache(): void;
  95114. /**
  95115. * Flag the transform node as dirty (Forcing it to update everything)
  95116. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95117. * @returns this transform node
  95118. */
  95119. markAsDirty(property: string): TransformNode;
  95120. /**
  95121. * Returns the current mesh absolute position.
  95122. * Returns a Vector3.
  95123. */
  95124. get absolutePosition(): Vector3;
  95125. /**
  95126. * Returns the current mesh absolute scaling.
  95127. * Returns a Vector3.
  95128. */
  95129. get absoluteScaling(): Vector3;
  95130. /**
  95131. * Returns the current mesh absolute rotation.
  95132. * Returns a Quaternion.
  95133. */
  95134. get absoluteRotationQuaternion(): Quaternion;
  95135. /**
  95136. * Sets a new matrix to apply before all other transformation
  95137. * @param matrix defines the transform matrix
  95138. * @returns the current TransformNode
  95139. */
  95140. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95141. /**
  95142. * Sets a new pivot matrix to the current node
  95143. * @param matrix defines the new pivot matrix to use
  95144. * @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
  95145. * @returns the current TransformNode
  95146. */
  95147. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95148. /**
  95149. * Returns the mesh pivot matrix.
  95150. * Default : Identity.
  95151. * @returns the matrix
  95152. */
  95153. getPivotMatrix(): Matrix;
  95154. /**
  95155. * Instantiate (when possible) or clone that node with its hierarchy
  95156. * @param newParent defines the new parent to use for the instance (or clone)
  95157. * @param options defines options to configure how copy is done
  95158. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95159. * @returns an instance (or a clone) of the current node with its hiearchy
  95160. */
  95161. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95162. doNotInstantiate: boolean;
  95163. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95164. /**
  95165. * Prevents the World matrix to be computed any longer
  95166. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95167. * @returns the TransformNode.
  95168. */
  95169. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95170. /**
  95171. * Allows back the World matrix computation.
  95172. * @returns the TransformNode.
  95173. */
  95174. unfreezeWorldMatrix(): this;
  95175. /**
  95176. * True if the World matrix has been frozen.
  95177. */
  95178. get isWorldMatrixFrozen(): boolean;
  95179. /**
  95180. * Retuns the mesh absolute position in the World.
  95181. * @returns a Vector3.
  95182. */
  95183. getAbsolutePosition(): Vector3;
  95184. /**
  95185. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95186. * @param absolutePosition the absolute position to set
  95187. * @returns the TransformNode.
  95188. */
  95189. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95190. /**
  95191. * Sets the mesh position in its local space.
  95192. * @param vector3 the position to set in localspace
  95193. * @returns the TransformNode.
  95194. */
  95195. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95196. /**
  95197. * Returns the mesh position in the local space from the current World matrix values.
  95198. * @returns a new Vector3.
  95199. */
  95200. getPositionExpressedInLocalSpace(): Vector3;
  95201. /**
  95202. * Translates the mesh along the passed Vector3 in its local space.
  95203. * @param vector3 the distance to translate in localspace
  95204. * @returns the TransformNode.
  95205. */
  95206. locallyTranslate(vector3: Vector3): TransformNode;
  95207. private static _lookAtVectorCache;
  95208. /**
  95209. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95210. * @param targetPoint the position (must be in same space as current mesh) to look at
  95211. * @param yawCor optional yaw (y-axis) correction in radians
  95212. * @param pitchCor optional pitch (x-axis) correction in radians
  95213. * @param rollCor optional roll (z-axis) correction in radians
  95214. * @param space the choosen space of the target
  95215. * @returns the TransformNode.
  95216. */
  95217. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95218. /**
  95219. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95220. * This Vector3 is expressed in the World space.
  95221. * @param localAxis axis to rotate
  95222. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95223. */
  95224. getDirection(localAxis: Vector3): Vector3;
  95225. /**
  95226. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95227. * localAxis is expressed in the mesh local space.
  95228. * result is computed in the Wordl space from the mesh World matrix.
  95229. * @param localAxis axis to rotate
  95230. * @param result the resulting transformnode
  95231. * @returns this TransformNode.
  95232. */
  95233. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95234. /**
  95235. * Sets this transform node rotation to the given local axis.
  95236. * @param localAxis the axis in local space
  95237. * @param yawCor optional yaw (y-axis) correction in radians
  95238. * @param pitchCor optional pitch (x-axis) correction in radians
  95239. * @param rollCor optional roll (z-axis) correction in radians
  95240. * @returns this TransformNode
  95241. */
  95242. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95243. /**
  95244. * Sets a new pivot point to the current node
  95245. * @param point defines the new pivot point to use
  95246. * @param space defines if the point is in world or local space (local by default)
  95247. * @returns the current TransformNode
  95248. */
  95249. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95250. /**
  95251. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95252. * @returns the pivot point
  95253. */
  95254. getPivotPoint(): Vector3;
  95255. /**
  95256. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95257. * @param result the vector3 to store the result
  95258. * @returns this TransformNode.
  95259. */
  95260. getPivotPointToRef(result: Vector3): TransformNode;
  95261. /**
  95262. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95263. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95264. */
  95265. getAbsolutePivotPoint(): Vector3;
  95266. /**
  95267. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95268. * @param result vector3 to store the result
  95269. * @returns this TransformNode.
  95270. */
  95271. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95272. /**
  95273. * Defines the passed node as the parent of the current node.
  95274. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95275. * @see https://doc.babylonjs.com/how_to/parenting
  95276. * @param node the node ot set as the parent
  95277. * @returns this TransformNode.
  95278. */
  95279. setParent(node: Nullable<Node>): TransformNode;
  95280. private _nonUniformScaling;
  95281. /**
  95282. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95283. */
  95284. get nonUniformScaling(): boolean;
  95285. /** @hidden */
  95286. _updateNonUniformScalingState(value: boolean): boolean;
  95287. /**
  95288. * Attach the current TransformNode to another TransformNode associated with a bone
  95289. * @param bone Bone affecting the TransformNode
  95290. * @param affectedTransformNode TransformNode associated with the bone
  95291. * @returns this object
  95292. */
  95293. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95294. /**
  95295. * Detach the transform node if its associated with a bone
  95296. * @returns this object
  95297. */
  95298. detachFromBone(): TransformNode;
  95299. private static _rotationAxisCache;
  95300. /**
  95301. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95302. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95303. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95304. * The passed axis is also normalized.
  95305. * @param axis the axis to rotate around
  95306. * @param amount the amount to rotate in radians
  95307. * @param space Space to rotate in (Default: local)
  95308. * @returns the TransformNode.
  95309. */
  95310. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95311. /**
  95312. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95313. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95314. * The passed axis is also normalized. .
  95315. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95316. * @param point the point to rotate around
  95317. * @param axis the axis to rotate around
  95318. * @param amount the amount to rotate in radians
  95319. * @returns the TransformNode
  95320. */
  95321. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95322. /**
  95323. * Translates the mesh along the axis vector for the passed distance in the given space.
  95324. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95325. * @param axis the axis to translate in
  95326. * @param distance the distance to translate
  95327. * @param space Space to rotate in (Default: local)
  95328. * @returns the TransformNode.
  95329. */
  95330. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95331. /**
  95332. * Adds a rotation step to the mesh current rotation.
  95333. * x, y, z are Euler angles expressed in radians.
  95334. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95335. * This means this rotation is made in the mesh local space only.
  95336. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95337. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95338. * ```javascript
  95339. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95340. * ```
  95341. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95342. * 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.
  95343. * @param x Rotation to add
  95344. * @param y Rotation to add
  95345. * @param z Rotation to add
  95346. * @returns the TransformNode.
  95347. */
  95348. addRotation(x: number, y: number, z: number): TransformNode;
  95349. /**
  95350. * @hidden
  95351. */
  95352. protected _getEffectiveParent(): Nullable<Node>;
  95353. /**
  95354. * Computes the world matrix of the node
  95355. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95356. * @returns the world matrix
  95357. */
  95358. computeWorldMatrix(force?: boolean): Matrix;
  95359. /**
  95360. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95361. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95362. */
  95363. resetLocalMatrix(independentOfChildren?: boolean): void;
  95364. protected _afterComputeWorldMatrix(): void;
  95365. /**
  95366. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95367. * @param func callback function to add
  95368. *
  95369. * @returns the TransformNode.
  95370. */
  95371. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95372. /**
  95373. * Removes a registered callback function.
  95374. * @param func callback function to remove
  95375. * @returns the TransformNode.
  95376. */
  95377. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95378. /**
  95379. * Gets the position of the current mesh in camera space
  95380. * @param camera defines the camera to use
  95381. * @returns a position
  95382. */
  95383. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95384. /**
  95385. * Returns the distance from the mesh to the active camera
  95386. * @param camera defines the camera to use
  95387. * @returns the distance
  95388. */
  95389. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95390. /**
  95391. * Clone the current transform node
  95392. * @param name Name of the new clone
  95393. * @param newParent New parent for the clone
  95394. * @param doNotCloneChildren Do not clone children hierarchy
  95395. * @returns the new transform node
  95396. */
  95397. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95398. /**
  95399. * Serializes the objects information.
  95400. * @param currentSerializationObject defines the object to serialize in
  95401. * @returns the serialized object
  95402. */
  95403. serialize(currentSerializationObject?: any): any;
  95404. /**
  95405. * Returns a new TransformNode object parsed from the source provided.
  95406. * @param parsedTransformNode is the source.
  95407. * @param scene the scne the object belongs to
  95408. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95409. * @returns a new TransformNode object parsed from the source provided.
  95410. */
  95411. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95412. /**
  95413. * Get all child-transformNodes of this node
  95414. * @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
  95415. * @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
  95416. * @returns an array of TransformNode
  95417. */
  95418. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95419. /**
  95420. * Releases resources associated with this transform node.
  95421. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95422. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95423. */
  95424. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95425. /**
  95426. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95427. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95428. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95429. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95430. * @returns the current mesh
  95431. */
  95432. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95433. private _syncAbsoluteScalingAndRotation;
  95434. }
  95435. }
  95436. declare module BABYLON {
  95437. /**
  95438. * Class used to override all child animations of a given target
  95439. */
  95440. export class AnimationPropertiesOverride {
  95441. /**
  95442. * Gets or sets a value indicating if animation blending must be used
  95443. */
  95444. enableBlending: boolean;
  95445. /**
  95446. * Gets or sets the blending speed to use when enableBlending is true
  95447. */
  95448. blendingSpeed: number;
  95449. /**
  95450. * Gets or sets the default loop mode to use
  95451. */
  95452. loopMode: number;
  95453. }
  95454. }
  95455. declare module BABYLON {
  95456. /**
  95457. * Class used to store bone information
  95458. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95459. */
  95460. export class Bone extends Node {
  95461. /**
  95462. * defines the bone name
  95463. */
  95464. name: string;
  95465. private static _tmpVecs;
  95466. private static _tmpQuat;
  95467. private static _tmpMats;
  95468. /**
  95469. * Gets the list of child bones
  95470. */
  95471. children: Bone[];
  95472. /** Gets the animations associated with this bone */
  95473. animations: Animation[];
  95474. /**
  95475. * Gets or sets bone length
  95476. */
  95477. length: number;
  95478. /**
  95479. * @hidden Internal only
  95480. * Set this value to map this bone to a different index in the transform matrices
  95481. * Set this value to -1 to exclude the bone from the transform matrices
  95482. */
  95483. _index: Nullable<number>;
  95484. private _skeleton;
  95485. private _localMatrix;
  95486. private _restPose;
  95487. private _bindPose;
  95488. private _baseMatrix;
  95489. private _absoluteTransform;
  95490. private _invertedAbsoluteTransform;
  95491. private _parent;
  95492. private _scalingDeterminant;
  95493. private _worldTransform;
  95494. private _localScaling;
  95495. private _localRotation;
  95496. private _localPosition;
  95497. private _needToDecompose;
  95498. private _needToCompose;
  95499. /** @hidden */
  95500. _linkedTransformNode: Nullable<TransformNode>;
  95501. /** @hidden */
  95502. _waitingTransformNodeId: Nullable<string>;
  95503. /** @hidden */
  95504. get _matrix(): Matrix;
  95505. /** @hidden */
  95506. set _matrix(value: Matrix);
  95507. /**
  95508. * Create a new bone
  95509. * @param name defines the bone name
  95510. * @param skeleton defines the parent skeleton
  95511. * @param parentBone defines the parent (can be null if the bone is the root)
  95512. * @param localMatrix defines the local matrix
  95513. * @param restPose defines the rest pose matrix
  95514. * @param baseMatrix defines the base matrix
  95515. * @param index defines index of the bone in the hiearchy
  95516. */
  95517. constructor(
  95518. /**
  95519. * defines the bone name
  95520. */
  95521. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95522. /**
  95523. * Gets the current object class name.
  95524. * @return the class name
  95525. */
  95526. getClassName(): string;
  95527. /**
  95528. * Gets the parent skeleton
  95529. * @returns a skeleton
  95530. */
  95531. getSkeleton(): Skeleton;
  95532. /**
  95533. * Gets parent bone
  95534. * @returns a bone or null if the bone is the root of the bone hierarchy
  95535. */
  95536. getParent(): Nullable<Bone>;
  95537. /**
  95538. * Returns an array containing the root bones
  95539. * @returns an array containing the root bones
  95540. */
  95541. getChildren(): Array<Bone>;
  95542. /**
  95543. * Gets the node index in matrix array generated for rendering
  95544. * @returns the node index
  95545. */
  95546. getIndex(): number;
  95547. /**
  95548. * Sets the parent bone
  95549. * @param parent defines the parent (can be null if the bone is the root)
  95550. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95551. */
  95552. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95553. /**
  95554. * Gets the local matrix
  95555. * @returns a matrix
  95556. */
  95557. getLocalMatrix(): Matrix;
  95558. /**
  95559. * Gets the base matrix (initial matrix which remains unchanged)
  95560. * @returns a matrix
  95561. */
  95562. getBaseMatrix(): Matrix;
  95563. /**
  95564. * Gets the rest pose matrix
  95565. * @returns a matrix
  95566. */
  95567. getRestPose(): Matrix;
  95568. /**
  95569. * Sets the rest pose matrix
  95570. * @param matrix the local-space rest pose to set for this bone
  95571. */
  95572. setRestPose(matrix: Matrix): void;
  95573. /**
  95574. * Gets the bind pose matrix
  95575. * @returns the bind pose matrix
  95576. */
  95577. getBindPose(): Matrix;
  95578. /**
  95579. * Sets the bind pose matrix
  95580. * @param matrix the local-space bind pose to set for this bone
  95581. */
  95582. setBindPose(matrix: Matrix): void;
  95583. /**
  95584. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95585. */
  95586. getWorldMatrix(): Matrix;
  95587. /**
  95588. * Sets the local matrix to rest pose matrix
  95589. */
  95590. returnToRest(): void;
  95591. /**
  95592. * Gets the inverse of the absolute transform matrix.
  95593. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95594. * @returns a matrix
  95595. */
  95596. getInvertedAbsoluteTransform(): Matrix;
  95597. /**
  95598. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95599. * @returns a matrix
  95600. */
  95601. getAbsoluteTransform(): Matrix;
  95602. /**
  95603. * Links with the given transform node.
  95604. * The local matrix of this bone is copied from the transform node every frame.
  95605. * @param transformNode defines the transform node to link to
  95606. */
  95607. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95608. /**
  95609. * Gets the node used to drive the bone's transformation
  95610. * @returns a transform node or null
  95611. */
  95612. getTransformNode(): Nullable<TransformNode>;
  95613. /** Gets or sets current position (in local space) */
  95614. get position(): Vector3;
  95615. set position(newPosition: Vector3);
  95616. /** Gets or sets current rotation (in local space) */
  95617. get rotation(): Vector3;
  95618. set rotation(newRotation: Vector3);
  95619. /** Gets or sets current rotation quaternion (in local space) */
  95620. get rotationQuaternion(): Quaternion;
  95621. set rotationQuaternion(newRotation: Quaternion);
  95622. /** Gets or sets current scaling (in local space) */
  95623. get scaling(): Vector3;
  95624. set scaling(newScaling: Vector3);
  95625. /**
  95626. * Gets the animation properties override
  95627. */
  95628. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95629. private _decompose;
  95630. private _compose;
  95631. /**
  95632. * Update the base and local matrices
  95633. * @param matrix defines the new base or local matrix
  95634. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95635. * @param updateLocalMatrix defines if the local matrix should be updated
  95636. */
  95637. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95638. /** @hidden */
  95639. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95640. /**
  95641. * Flag the bone as dirty (Forcing it to update everything)
  95642. */
  95643. markAsDirty(): void;
  95644. /** @hidden */
  95645. _markAsDirtyAndCompose(): void;
  95646. private _markAsDirtyAndDecompose;
  95647. /**
  95648. * Translate the bone in local or world space
  95649. * @param vec The amount to translate the bone
  95650. * @param space The space that the translation is in
  95651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95652. */
  95653. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95654. /**
  95655. * Set the postion of the bone in local or world space
  95656. * @param position The position to set the bone
  95657. * @param space The space that the position is in
  95658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95659. */
  95660. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95661. /**
  95662. * Set the absolute position of the bone (world space)
  95663. * @param position The position to set the bone
  95664. * @param mesh The mesh that this bone is attached to
  95665. */
  95666. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95667. /**
  95668. * Scale the bone on the x, y and z axes (in local space)
  95669. * @param x The amount to scale the bone on the x axis
  95670. * @param y The amount to scale the bone on the y axis
  95671. * @param z The amount to scale the bone on the z axis
  95672. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95673. */
  95674. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95675. /**
  95676. * Set the bone scaling in local space
  95677. * @param scale defines the scaling vector
  95678. */
  95679. setScale(scale: Vector3): void;
  95680. /**
  95681. * Gets the current scaling in local space
  95682. * @returns the current scaling vector
  95683. */
  95684. getScale(): Vector3;
  95685. /**
  95686. * Gets the current scaling in local space and stores it in a target vector
  95687. * @param result defines the target vector
  95688. */
  95689. getScaleToRef(result: Vector3): void;
  95690. /**
  95691. * Set the yaw, pitch, and roll of the bone in local or world space
  95692. * @param yaw The rotation of the bone on the y axis
  95693. * @param pitch The rotation of the bone on the x axis
  95694. * @param roll The rotation of the bone on the z axis
  95695. * @param space The space that the axes of rotation are in
  95696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95697. */
  95698. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95699. /**
  95700. * Add a rotation to the bone on an axis in local or world space
  95701. * @param axis The axis to rotate the bone on
  95702. * @param amount The amount to rotate the bone
  95703. * @param space The space that the axis is in
  95704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95705. */
  95706. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95707. /**
  95708. * Set the rotation of the bone to a particular axis angle in local or world space
  95709. * @param axis The axis to rotate the bone on
  95710. * @param angle The angle that the bone should be rotated to
  95711. * @param space The space that the axis is in
  95712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95713. */
  95714. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95715. /**
  95716. * Set the euler rotation of the bone in local or world space
  95717. * @param rotation The euler rotation that the bone should be set to
  95718. * @param space The space that the rotation is in
  95719. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95720. */
  95721. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95722. /**
  95723. * Set the quaternion rotation of the bone in local or world space
  95724. * @param quat The quaternion rotation that the bone should be set to
  95725. * @param space The space that the rotation is in
  95726. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95727. */
  95728. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95729. /**
  95730. * Set the rotation matrix of the bone in local or world space
  95731. * @param rotMat The rotation matrix that the bone should be set to
  95732. * @param space The space that the rotation is in
  95733. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95734. */
  95735. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95736. private _rotateWithMatrix;
  95737. private _getNegativeRotationToRef;
  95738. /**
  95739. * Get the position of the bone in local or world space
  95740. * @param space The space that the returned position is in
  95741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95742. * @returns The position of the bone
  95743. */
  95744. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95745. /**
  95746. * Copy the position of the bone to a vector3 in local or world space
  95747. * @param space The space that the returned position is in
  95748. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95749. * @param result The vector3 to copy the position to
  95750. */
  95751. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95752. /**
  95753. * Get the absolute position of the bone (world space)
  95754. * @param mesh The mesh that this bone is attached to
  95755. * @returns The absolute position of the bone
  95756. */
  95757. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95758. /**
  95759. * Copy the absolute position of the bone (world space) to the result param
  95760. * @param mesh The mesh that this bone is attached to
  95761. * @param result The vector3 to copy the absolute position to
  95762. */
  95763. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95764. /**
  95765. * Compute the absolute transforms of this bone and its children
  95766. */
  95767. computeAbsoluteTransforms(): void;
  95768. /**
  95769. * Get the world direction from an axis that is in the local space of the bone
  95770. * @param localAxis The local direction that is used to compute the world direction
  95771. * @param mesh The mesh that this bone is attached to
  95772. * @returns The world direction
  95773. */
  95774. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95775. /**
  95776. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95777. * @param localAxis The local direction that is used to compute the world direction
  95778. * @param mesh The mesh that this bone is attached to
  95779. * @param result The vector3 that the world direction will be copied to
  95780. */
  95781. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95782. /**
  95783. * Get the euler rotation of the bone in local or world space
  95784. * @param space The space that the rotation should be in
  95785. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95786. * @returns The euler rotation
  95787. */
  95788. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95789. /**
  95790. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95791. * @param space The space that the rotation should be in
  95792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95793. * @param result The vector3 that the rotation should be copied to
  95794. */
  95795. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95796. /**
  95797. * Get the quaternion rotation of the bone in either local or world space
  95798. * @param space The space that the rotation should be in
  95799. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95800. * @returns The quaternion rotation
  95801. */
  95802. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95803. /**
  95804. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95805. * @param space The space that the rotation should be in
  95806. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95807. * @param result The quaternion that the rotation should be copied to
  95808. */
  95809. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95810. /**
  95811. * Get the rotation matrix of the bone in local or world space
  95812. * @param space The space that the rotation should be in
  95813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95814. * @returns The rotation matrix
  95815. */
  95816. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95817. /**
  95818. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95819. * @param space The space that the rotation should be in
  95820. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95821. * @param result The quaternion that the rotation should be copied to
  95822. */
  95823. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95824. /**
  95825. * Get the world position of a point that is in the local space of the bone
  95826. * @param position The local position
  95827. * @param mesh The mesh that this bone is attached to
  95828. * @returns The world position
  95829. */
  95830. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95831. /**
  95832. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95833. * @param position The local position
  95834. * @param mesh The mesh that this bone is attached to
  95835. * @param result The vector3 that the world position should be copied to
  95836. */
  95837. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95838. /**
  95839. * Get the local position of a point that is in world space
  95840. * @param position The world position
  95841. * @param mesh The mesh that this bone is attached to
  95842. * @returns The local position
  95843. */
  95844. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95845. /**
  95846. * Get the local position of a point that is in world space and copy it to the result param
  95847. * @param position The world position
  95848. * @param mesh The mesh that this bone is attached to
  95849. * @param result The vector3 that the local position should be copied to
  95850. */
  95851. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95852. /**
  95853. * Set the current local matrix as the restPose for this bone.
  95854. */
  95855. setCurrentPoseAsRest(): void;
  95856. }
  95857. }
  95858. declare module BABYLON {
  95859. /**
  95860. * Defines a runtime animation
  95861. */
  95862. export class RuntimeAnimation {
  95863. private _events;
  95864. /**
  95865. * The current frame of the runtime animation
  95866. */
  95867. private _currentFrame;
  95868. /**
  95869. * The animation used by the runtime animation
  95870. */
  95871. private _animation;
  95872. /**
  95873. * The target of the runtime animation
  95874. */
  95875. private _target;
  95876. /**
  95877. * The initiating animatable
  95878. */
  95879. private _host;
  95880. /**
  95881. * The original value of the runtime animation
  95882. */
  95883. private _originalValue;
  95884. /**
  95885. * The original blend value of the runtime animation
  95886. */
  95887. private _originalBlendValue;
  95888. /**
  95889. * The offsets cache of the runtime animation
  95890. */
  95891. private _offsetsCache;
  95892. /**
  95893. * The high limits cache of the runtime animation
  95894. */
  95895. private _highLimitsCache;
  95896. /**
  95897. * Specifies if the runtime animation has been stopped
  95898. */
  95899. private _stopped;
  95900. /**
  95901. * The blending factor of the runtime animation
  95902. */
  95903. private _blendingFactor;
  95904. /**
  95905. * The BabylonJS scene
  95906. */
  95907. private _scene;
  95908. /**
  95909. * The current value of the runtime animation
  95910. */
  95911. private _currentValue;
  95912. /** @hidden */
  95913. _animationState: _IAnimationState;
  95914. /**
  95915. * The active target of the runtime animation
  95916. */
  95917. private _activeTargets;
  95918. private _currentActiveTarget;
  95919. private _directTarget;
  95920. /**
  95921. * The target path of the runtime animation
  95922. */
  95923. private _targetPath;
  95924. /**
  95925. * The weight of the runtime animation
  95926. */
  95927. private _weight;
  95928. /**
  95929. * The ratio offset of the runtime animation
  95930. */
  95931. private _ratioOffset;
  95932. /**
  95933. * The previous delay of the runtime animation
  95934. */
  95935. private _previousDelay;
  95936. /**
  95937. * The previous ratio of the runtime animation
  95938. */
  95939. private _previousRatio;
  95940. private _enableBlending;
  95941. private _keys;
  95942. private _minFrame;
  95943. private _maxFrame;
  95944. private _minValue;
  95945. private _maxValue;
  95946. private _targetIsArray;
  95947. /**
  95948. * Gets the current frame of the runtime animation
  95949. */
  95950. get currentFrame(): number;
  95951. /**
  95952. * Gets the weight of the runtime animation
  95953. */
  95954. get weight(): number;
  95955. /**
  95956. * Gets the current value of the runtime animation
  95957. */
  95958. get currentValue(): any;
  95959. /**
  95960. * Gets the target path of the runtime animation
  95961. */
  95962. get targetPath(): string;
  95963. /**
  95964. * Gets the actual target of the runtime animation
  95965. */
  95966. get target(): any;
  95967. /**
  95968. * Gets the additive state of the runtime animation
  95969. */
  95970. get isAdditive(): boolean;
  95971. /** @hidden */
  95972. _onLoop: () => void;
  95973. /**
  95974. * Create a new RuntimeAnimation object
  95975. * @param target defines the target of the animation
  95976. * @param animation defines the source animation object
  95977. * @param scene defines the hosting scene
  95978. * @param host defines the initiating Animatable
  95979. */
  95980. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95981. private _preparePath;
  95982. /**
  95983. * Gets the animation from the runtime animation
  95984. */
  95985. get animation(): Animation;
  95986. /**
  95987. * Resets the runtime animation to the beginning
  95988. * @param restoreOriginal defines whether to restore the target property to the original value
  95989. */
  95990. reset(restoreOriginal?: boolean): void;
  95991. /**
  95992. * Specifies if the runtime animation is stopped
  95993. * @returns Boolean specifying if the runtime animation is stopped
  95994. */
  95995. isStopped(): boolean;
  95996. /**
  95997. * Disposes of the runtime animation
  95998. */
  95999. dispose(): void;
  96000. /**
  96001. * Apply the interpolated value to the target
  96002. * @param currentValue defines the value computed by the animation
  96003. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96004. */
  96005. setValue(currentValue: any, weight: number): void;
  96006. private _getOriginalValues;
  96007. private _setValue;
  96008. /**
  96009. * Gets the loop pmode of the runtime animation
  96010. * @returns Loop Mode
  96011. */
  96012. private _getCorrectLoopMode;
  96013. /**
  96014. * Move the current animation to a given frame
  96015. * @param frame defines the frame to move to
  96016. */
  96017. goToFrame(frame: number): void;
  96018. /**
  96019. * @hidden Internal use only
  96020. */
  96021. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96022. /**
  96023. * Execute the current animation
  96024. * @param delay defines the delay to add to the current frame
  96025. * @param from defines the lower bound of the animation range
  96026. * @param to defines the upper bound of the animation range
  96027. * @param loop defines if the current animation must loop
  96028. * @param speedRatio defines the current speed ratio
  96029. * @param weight defines the weight of the animation (default is -1 so no weight)
  96030. * @param onLoop optional callback called when animation loops
  96031. * @returns a boolean indicating if the animation is running
  96032. */
  96033. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96034. }
  96035. }
  96036. declare module BABYLON {
  96037. /**
  96038. * Class used to store an actual running animation
  96039. */
  96040. export class Animatable {
  96041. /** defines the target object */
  96042. target: any;
  96043. /** defines the starting frame number (default is 0) */
  96044. fromFrame: number;
  96045. /** defines the ending frame number (default is 100) */
  96046. toFrame: number;
  96047. /** defines if the animation must loop (default is false) */
  96048. loopAnimation: boolean;
  96049. /** defines a callback to call when animation ends if it is not looping */
  96050. onAnimationEnd?: (() => void) | null | undefined;
  96051. /** defines a callback to call when animation loops */
  96052. onAnimationLoop?: (() => void) | null | undefined;
  96053. /** defines whether the animation should be evaluated additively */
  96054. isAdditive: boolean;
  96055. private _localDelayOffset;
  96056. private _pausedDelay;
  96057. private _runtimeAnimations;
  96058. private _paused;
  96059. private _scene;
  96060. private _speedRatio;
  96061. private _weight;
  96062. private _syncRoot;
  96063. /**
  96064. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96065. * This will only apply for non looping animation (default is true)
  96066. */
  96067. disposeOnEnd: boolean;
  96068. /**
  96069. * Gets a boolean indicating if the animation has started
  96070. */
  96071. animationStarted: boolean;
  96072. /**
  96073. * Observer raised when the animation ends
  96074. */
  96075. onAnimationEndObservable: Observable<Animatable>;
  96076. /**
  96077. * Observer raised when the animation loops
  96078. */
  96079. onAnimationLoopObservable: Observable<Animatable>;
  96080. /**
  96081. * Gets the root Animatable used to synchronize and normalize animations
  96082. */
  96083. get syncRoot(): Nullable<Animatable>;
  96084. /**
  96085. * Gets the current frame of the first RuntimeAnimation
  96086. * Used to synchronize Animatables
  96087. */
  96088. get masterFrame(): number;
  96089. /**
  96090. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96091. */
  96092. get weight(): number;
  96093. set weight(value: number);
  96094. /**
  96095. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96096. */
  96097. get speedRatio(): number;
  96098. set speedRatio(value: number);
  96099. /**
  96100. * Creates a new Animatable
  96101. * @param scene defines the hosting scene
  96102. * @param target defines the target object
  96103. * @param fromFrame defines the starting frame number (default is 0)
  96104. * @param toFrame defines the ending frame number (default is 100)
  96105. * @param loopAnimation defines if the animation must loop (default is false)
  96106. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96107. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96108. * @param animations defines a group of animation to add to the new Animatable
  96109. * @param onAnimationLoop defines a callback to call when animation loops
  96110. * @param isAdditive defines whether the animation should be evaluated additively
  96111. */
  96112. constructor(scene: Scene,
  96113. /** defines the target object */
  96114. target: any,
  96115. /** defines the starting frame number (default is 0) */
  96116. fromFrame?: number,
  96117. /** defines the ending frame number (default is 100) */
  96118. toFrame?: number,
  96119. /** defines if the animation must loop (default is false) */
  96120. loopAnimation?: boolean, speedRatio?: number,
  96121. /** defines a callback to call when animation ends if it is not looping */
  96122. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96123. /** defines a callback to call when animation loops */
  96124. onAnimationLoop?: (() => void) | null | undefined,
  96125. /** defines whether the animation should be evaluated additively */
  96126. isAdditive?: boolean);
  96127. /**
  96128. * Synchronize and normalize current Animatable with a source Animatable
  96129. * This is useful when using animation weights and when animations are not of the same length
  96130. * @param root defines the root Animatable to synchronize with
  96131. * @returns the current Animatable
  96132. */
  96133. syncWith(root: Animatable): Animatable;
  96134. /**
  96135. * Gets the list of runtime animations
  96136. * @returns an array of RuntimeAnimation
  96137. */
  96138. getAnimations(): RuntimeAnimation[];
  96139. /**
  96140. * Adds more animations to the current animatable
  96141. * @param target defines the target of the animations
  96142. * @param animations defines the new animations to add
  96143. */
  96144. appendAnimations(target: any, animations: Animation[]): void;
  96145. /**
  96146. * Gets the source animation for a specific property
  96147. * @param property defines the propertyu to look for
  96148. * @returns null or the source animation for the given property
  96149. */
  96150. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96151. /**
  96152. * Gets the runtime animation for a specific property
  96153. * @param property defines the propertyu to look for
  96154. * @returns null or the runtime animation for the given property
  96155. */
  96156. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96157. /**
  96158. * Resets the animatable to its original state
  96159. */
  96160. reset(): void;
  96161. /**
  96162. * Allows the animatable to blend with current running animations
  96163. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96164. * @param blendingSpeed defines the blending speed to use
  96165. */
  96166. enableBlending(blendingSpeed: number): void;
  96167. /**
  96168. * Disable animation blending
  96169. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96170. */
  96171. disableBlending(): void;
  96172. /**
  96173. * Jump directly to a given frame
  96174. * @param frame defines the frame to jump to
  96175. */
  96176. goToFrame(frame: number): void;
  96177. /**
  96178. * Pause the animation
  96179. */
  96180. pause(): void;
  96181. /**
  96182. * Restart the animation
  96183. */
  96184. restart(): void;
  96185. private _raiseOnAnimationEnd;
  96186. /**
  96187. * Stop and delete the current animation
  96188. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96189. * @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)
  96190. */
  96191. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96192. /**
  96193. * Wait asynchronously for the animation to end
  96194. * @returns a promise which will be fullfilled when the animation ends
  96195. */
  96196. waitAsync(): Promise<Animatable>;
  96197. /** @hidden */
  96198. _animate(delay: number): boolean;
  96199. }
  96200. interface Scene {
  96201. /** @hidden */
  96202. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96203. /** @hidden */
  96204. _processLateAnimationBindingsForMatrices(holder: {
  96205. totalWeight: number;
  96206. totalAdditiveWeight: number;
  96207. animations: RuntimeAnimation[];
  96208. additiveAnimations: RuntimeAnimation[];
  96209. originalValue: Matrix;
  96210. }): any;
  96211. /** @hidden */
  96212. _processLateAnimationBindingsForQuaternions(holder: {
  96213. totalWeight: number;
  96214. totalAdditiveWeight: number;
  96215. animations: RuntimeAnimation[];
  96216. additiveAnimations: RuntimeAnimation[];
  96217. originalValue: Quaternion;
  96218. }, refQuaternion: Quaternion): Quaternion;
  96219. /** @hidden */
  96220. _processLateAnimationBindings(): void;
  96221. /**
  96222. * Will start the animation sequence of a given target
  96223. * @param target defines the target
  96224. * @param from defines from which frame should animation start
  96225. * @param to defines until which frame should animation run.
  96226. * @param weight defines the weight to apply to the animation (1.0 by default)
  96227. * @param loop defines if the animation loops
  96228. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96229. * @param onAnimationEnd defines the function to be executed when the animation ends
  96230. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96231. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96232. * @param onAnimationLoop defines the callback to call when an animation loops
  96233. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96234. * @returns the animatable object created for this animation
  96235. */
  96236. 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;
  96237. /**
  96238. * Will start the animation sequence of a given target
  96239. * @param target defines the target
  96240. * @param from defines from which frame should animation start
  96241. * @param to defines until which frame should animation run.
  96242. * @param loop defines if the animation loops
  96243. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96244. * @param onAnimationEnd defines the function to be executed when the animation ends
  96245. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96246. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96247. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96248. * @param onAnimationLoop defines the callback to call when an animation loops
  96249. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96250. * @returns the animatable object created for this animation
  96251. */
  96252. 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;
  96253. /**
  96254. * Will start the animation sequence of a given target and its hierarchy
  96255. * @param target defines the target
  96256. * @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.
  96257. * @param from defines from which frame should animation start
  96258. * @param to defines until which frame should animation run.
  96259. * @param loop defines if the animation loops
  96260. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96261. * @param onAnimationEnd defines the function to be executed when the animation ends
  96262. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96263. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96264. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96265. * @param onAnimationLoop defines the callback to call when an animation loops
  96266. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96267. * @returns the list of created animatables
  96268. */
  96269. 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[];
  96270. /**
  96271. * Begin a new animation on a given node
  96272. * @param target defines the target where the animation will take place
  96273. * @param animations defines the list of animations to start
  96274. * @param from defines the initial value
  96275. * @param to defines the final value
  96276. * @param loop defines if you want animation to loop (off by default)
  96277. * @param speedRatio defines the speed ratio to apply to all animations
  96278. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96279. * @param onAnimationLoop defines the callback to call when an animation loops
  96280. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96281. * @returns the list of created animatables
  96282. */
  96283. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96284. /**
  96285. * Begin a new animation on a given node and its hierarchy
  96286. * @param target defines the root node where the animation will take place
  96287. * @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.
  96288. * @param animations defines the list of animations to start
  96289. * @param from defines the initial value
  96290. * @param to defines the final value
  96291. * @param loop defines if you want animation to loop (off by default)
  96292. * @param speedRatio defines the speed ratio to apply to all animations
  96293. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96294. * @param onAnimationLoop defines the callback to call when an animation loops
  96295. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96296. * @returns the list of animatables created for all nodes
  96297. */
  96298. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96299. /**
  96300. * Gets the animatable associated with a specific target
  96301. * @param target defines the target of the animatable
  96302. * @returns the required animatable if found
  96303. */
  96304. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96305. /**
  96306. * Gets all animatables associated with a given target
  96307. * @param target defines the target to look animatables for
  96308. * @returns an array of Animatables
  96309. */
  96310. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96311. /**
  96312. * Stops and removes all animations that have been applied to the scene
  96313. */
  96314. stopAllAnimations(): void;
  96315. /**
  96316. * Gets the current delta time used by animation engine
  96317. */
  96318. deltaTime: number;
  96319. }
  96320. interface Bone {
  96321. /**
  96322. * Copy an animation range from another bone
  96323. * @param source defines the source bone
  96324. * @param rangeName defines the range name to copy
  96325. * @param frameOffset defines the frame offset
  96326. * @param rescaleAsRequired defines if rescaling must be applied if required
  96327. * @param skelDimensionsRatio defines the scaling ratio
  96328. * @returns true if operation was successful
  96329. */
  96330. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96331. }
  96332. }
  96333. declare module BABYLON {
  96334. /**
  96335. * Class used to handle skinning animations
  96336. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96337. */
  96338. export class Skeleton implements IAnimatable {
  96339. /** defines the skeleton name */
  96340. name: string;
  96341. /** defines the skeleton Id */
  96342. id: string;
  96343. /**
  96344. * Defines the list of child bones
  96345. */
  96346. bones: Bone[];
  96347. /**
  96348. * Defines an estimate of the dimension of the skeleton at rest
  96349. */
  96350. dimensionsAtRest: Vector3;
  96351. /**
  96352. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96353. */
  96354. needInitialSkinMatrix: boolean;
  96355. /**
  96356. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96357. */
  96358. overrideMesh: Nullable<AbstractMesh>;
  96359. /**
  96360. * Gets the list of animations attached to this skeleton
  96361. */
  96362. animations: Array<Animation>;
  96363. private _scene;
  96364. private _isDirty;
  96365. private _transformMatrices;
  96366. private _transformMatrixTexture;
  96367. private _meshesWithPoseMatrix;
  96368. private _animatables;
  96369. private _identity;
  96370. private _synchronizedWithMesh;
  96371. private _ranges;
  96372. private _lastAbsoluteTransformsUpdateId;
  96373. private _canUseTextureForBones;
  96374. private _uniqueId;
  96375. /** @hidden */
  96376. _numBonesWithLinkedTransformNode: number;
  96377. /** @hidden */
  96378. _hasWaitingData: Nullable<boolean>;
  96379. /** @hidden */
  96380. _waitingOverrideMeshId: Nullable<string>;
  96381. /**
  96382. * Specifies if the skeleton should be serialized
  96383. */
  96384. doNotSerialize: boolean;
  96385. private _useTextureToStoreBoneMatrices;
  96386. /**
  96387. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96388. * Please note that this option is not available if the hardware does not support it
  96389. */
  96390. get useTextureToStoreBoneMatrices(): boolean;
  96391. set useTextureToStoreBoneMatrices(value: boolean);
  96392. private _animationPropertiesOverride;
  96393. /**
  96394. * Gets or sets the animation properties override
  96395. */
  96396. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96397. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96398. /**
  96399. * List of inspectable custom properties (used by the Inspector)
  96400. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96401. */
  96402. inspectableCustomProperties: IInspectable[];
  96403. /**
  96404. * An observable triggered before computing the skeleton's matrices
  96405. */
  96406. onBeforeComputeObservable: Observable<Skeleton>;
  96407. /**
  96408. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96409. */
  96410. get isUsingTextureForMatrices(): boolean;
  96411. /**
  96412. * Gets the unique ID of this skeleton
  96413. */
  96414. get uniqueId(): number;
  96415. /**
  96416. * Creates a new skeleton
  96417. * @param name defines the skeleton name
  96418. * @param id defines the skeleton Id
  96419. * @param scene defines the hosting scene
  96420. */
  96421. constructor(
  96422. /** defines the skeleton name */
  96423. name: string,
  96424. /** defines the skeleton Id */
  96425. id: string, scene: Scene);
  96426. /**
  96427. * Gets the current object class name.
  96428. * @return the class name
  96429. */
  96430. getClassName(): string;
  96431. /**
  96432. * Returns an array containing the root bones
  96433. * @returns an array containing the root bones
  96434. */
  96435. getChildren(): Array<Bone>;
  96436. /**
  96437. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96438. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96439. * @returns a Float32Array containing matrices data
  96440. */
  96441. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96442. /**
  96443. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96444. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96445. * @returns a raw texture containing the data
  96446. */
  96447. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96448. /**
  96449. * Gets the current hosting scene
  96450. * @returns a scene object
  96451. */
  96452. getScene(): Scene;
  96453. /**
  96454. * Gets a string representing the current skeleton data
  96455. * @param fullDetails defines a boolean indicating if we want a verbose version
  96456. * @returns a string representing the current skeleton data
  96457. */
  96458. toString(fullDetails?: boolean): string;
  96459. /**
  96460. * Get bone's index searching by name
  96461. * @param name defines bone's name to search for
  96462. * @return the indice of the bone. Returns -1 if not found
  96463. */
  96464. getBoneIndexByName(name: string): number;
  96465. /**
  96466. * Creater a new animation range
  96467. * @param name defines the name of the range
  96468. * @param from defines the start key
  96469. * @param to defines the end key
  96470. */
  96471. createAnimationRange(name: string, from: number, to: number): void;
  96472. /**
  96473. * Delete a specific animation range
  96474. * @param name defines the name of the range
  96475. * @param deleteFrames defines if frames must be removed as well
  96476. */
  96477. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96478. /**
  96479. * Gets a specific animation range
  96480. * @param name defines the name of the range to look for
  96481. * @returns the requested animation range or null if not found
  96482. */
  96483. getAnimationRange(name: string): Nullable<AnimationRange>;
  96484. /**
  96485. * Gets the list of all animation ranges defined on this skeleton
  96486. * @returns an array
  96487. */
  96488. getAnimationRanges(): Nullable<AnimationRange>[];
  96489. /**
  96490. * Copy animation range from a source skeleton.
  96491. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96492. * @param source defines the source skeleton
  96493. * @param name defines the name of the range to copy
  96494. * @param rescaleAsRequired defines if rescaling must be applied if required
  96495. * @returns true if operation was successful
  96496. */
  96497. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96498. /**
  96499. * Forces the skeleton to go to rest pose
  96500. */
  96501. returnToRest(): void;
  96502. private _getHighestAnimationFrame;
  96503. /**
  96504. * Begin a specific animation range
  96505. * @param name defines the name of the range to start
  96506. * @param loop defines if looping must be turned on (false by default)
  96507. * @param speedRatio defines the speed ratio to apply (1 by default)
  96508. * @param onAnimationEnd defines a callback which will be called when animation will end
  96509. * @returns a new animatable
  96510. */
  96511. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96512. /**
  96513. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96514. * @param skeleton defines the Skeleton containing the animation range to convert
  96515. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96516. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96517. * @returns the original skeleton
  96518. */
  96519. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96520. /** @hidden */
  96521. _markAsDirty(): void;
  96522. /** @hidden */
  96523. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96524. /** @hidden */
  96525. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96526. private _computeTransformMatrices;
  96527. /**
  96528. * Build all resources required to render a skeleton
  96529. */
  96530. prepare(): void;
  96531. /**
  96532. * Gets the list of animatables currently running for this skeleton
  96533. * @returns an array of animatables
  96534. */
  96535. getAnimatables(): IAnimatable[];
  96536. /**
  96537. * Clone the current skeleton
  96538. * @param name defines the name of the new skeleton
  96539. * @param id defines the id of the new skeleton
  96540. * @returns the new skeleton
  96541. */
  96542. clone(name: string, id?: string): Skeleton;
  96543. /**
  96544. * Enable animation blending for this skeleton
  96545. * @param blendingSpeed defines the blending speed to apply
  96546. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96547. */
  96548. enableBlending(blendingSpeed?: number): void;
  96549. /**
  96550. * Releases all resources associated with the current skeleton
  96551. */
  96552. dispose(): void;
  96553. /**
  96554. * Serialize the skeleton in a JSON object
  96555. * @returns a JSON object
  96556. */
  96557. serialize(): any;
  96558. /**
  96559. * Creates a new skeleton from serialized data
  96560. * @param parsedSkeleton defines the serialized data
  96561. * @param scene defines the hosting scene
  96562. * @returns a new skeleton
  96563. */
  96564. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96565. /**
  96566. * Compute all node absolute transforms
  96567. * @param forceUpdate defines if computation must be done even if cache is up to date
  96568. */
  96569. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96570. /**
  96571. * Gets the root pose matrix
  96572. * @returns a matrix
  96573. */
  96574. getPoseMatrix(): Nullable<Matrix>;
  96575. /**
  96576. * Sorts bones per internal index
  96577. */
  96578. sortBones(): void;
  96579. private _sortBones;
  96580. /**
  96581. * Set the current local matrix as the restPose for all bones in the skeleton.
  96582. */
  96583. setCurrentPoseAsRest(): void;
  96584. }
  96585. }
  96586. declare module BABYLON {
  96587. /**
  96588. * Creates an instance based on a source mesh.
  96589. */
  96590. export class InstancedMesh extends AbstractMesh {
  96591. private _sourceMesh;
  96592. private _currentLOD;
  96593. /** @hidden */
  96594. _indexInSourceMeshInstanceArray: number;
  96595. constructor(name: string, source: Mesh);
  96596. /**
  96597. * Returns the string "InstancedMesh".
  96598. */
  96599. getClassName(): string;
  96600. /** Gets the list of lights affecting that mesh */
  96601. get lightSources(): Light[];
  96602. _resyncLightSources(): void;
  96603. _resyncLightSource(light: Light): void;
  96604. _removeLightSource(light: Light, dispose: boolean): void;
  96605. /**
  96606. * If the source mesh receives shadows
  96607. */
  96608. get receiveShadows(): boolean;
  96609. /**
  96610. * The material of the source mesh
  96611. */
  96612. get material(): Nullable<Material>;
  96613. /**
  96614. * Visibility of the source mesh
  96615. */
  96616. get visibility(): number;
  96617. /**
  96618. * Skeleton of the source mesh
  96619. */
  96620. get skeleton(): Nullable<Skeleton>;
  96621. /**
  96622. * Rendering ground id of the source mesh
  96623. */
  96624. get renderingGroupId(): number;
  96625. set renderingGroupId(value: number);
  96626. /**
  96627. * Returns the total number of vertices (integer).
  96628. */
  96629. getTotalVertices(): number;
  96630. /**
  96631. * Returns a positive integer : the total number of indices in this mesh geometry.
  96632. * @returns the numner of indices or zero if the mesh has no geometry.
  96633. */
  96634. getTotalIndices(): number;
  96635. /**
  96636. * The source mesh of the instance
  96637. */
  96638. get sourceMesh(): Mesh;
  96639. /**
  96640. * Creates a new InstancedMesh object from the mesh model.
  96641. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96642. * @param name defines the name of the new instance
  96643. * @returns a new InstancedMesh
  96644. */
  96645. createInstance(name: string): InstancedMesh;
  96646. /**
  96647. * Is this node ready to be used/rendered
  96648. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96649. * @return {boolean} is it ready
  96650. */
  96651. isReady(completeCheck?: boolean): boolean;
  96652. /**
  96653. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96654. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96655. * @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.
  96656. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96657. */
  96658. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96659. /**
  96660. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96661. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96662. * The `data` are either a numeric array either a Float32Array.
  96663. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96664. * 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).
  96665. * Note that a new underlying VertexBuffer object is created each call.
  96666. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96667. *
  96668. * Possible `kind` values :
  96669. * - VertexBuffer.PositionKind
  96670. * - VertexBuffer.UVKind
  96671. * - VertexBuffer.UV2Kind
  96672. * - VertexBuffer.UV3Kind
  96673. * - VertexBuffer.UV4Kind
  96674. * - VertexBuffer.UV5Kind
  96675. * - VertexBuffer.UV6Kind
  96676. * - VertexBuffer.ColorKind
  96677. * - VertexBuffer.MatricesIndicesKind
  96678. * - VertexBuffer.MatricesIndicesExtraKind
  96679. * - VertexBuffer.MatricesWeightsKind
  96680. * - VertexBuffer.MatricesWeightsExtraKind
  96681. *
  96682. * Returns the Mesh.
  96683. */
  96684. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96685. /**
  96686. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96687. * If the mesh has no geometry, it is simply returned as it is.
  96688. * The `data` are either a numeric array either a Float32Array.
  96689. * No new underlying VertexBuffer object is created.
  96690. * 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.
  96691. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96692. *
  96693. * Possible `kind` values :
  96694. * - VertexBuffer.PositionKind
  96695. * - VertexBuffer.UVKind
  96696. * - VertexBuffer.UV2Kind
  96697. * - VertexBuffer.UV3Kind
  96698. * - VertexBuffer.UV4Kind
  96699. * - VertexBuffer.UV5Kind
  96700. * - VertexBuffer.UV6Kind
  96701. * - VertexBuffer.ColorKind
  96702. * - VertexBuffer.MatricesIndicesKind
  96703. * - VertexBuffer.MatricesIndicesExtraKind
  96704. * - VertexBuffer.MatricesWeightsKind
  96705. * - VertexBuffer.MatricesWeightsExtraKind
  96706. *
  96707. * Returns the Mesh.
  96708. */
  96709. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96710. /**
  96711. * Sets the mesh indices.
  96712. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96713. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96714. * This method creates a new index buffer each call.
  96715. * Returns the Mesh.
  96716. */
  96717. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96718. /**
  96719. * Boolean : True if the mesh owns the requested kind of data.
  96720. */
  96721. isVerticesDataPresent(kind: string): boolean;
  96722. /**
  96723. * Returns an array of indices (IndicesArray).
  96724. */
  96725. getIndices(): Nullable<IndicesArray>;
  96726. get _positions(): Nullable<Vector3[]>;
  96727. /**
  96728. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96729. * This means the mesh underlying bounding box and sphere are recomputed.
  96730. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96731. * @returns the current mesh
  96732. */
  96733. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96734. /** @hidden */
  96735. _preActivate(): InstancedMesh;
  96736. /** @hidden */
  96737. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96738. /** @hidden */
  96739. _postActivate(): void;
  96740. getWorldMatrix(): Matrix;
  96741. get isAnInstance(): boolean;
  96742. /**
  96743. * Returns the current associated LOD AbstractMesh.
  96744. */
  96745. getLOD(camera: Camera): AbstractMesh;
  96746. /** @hidden */
  96747. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96748. /** @hidden */
  96749. _syncSubMeshes(): InstancedMesh;
  96750. /** @hidden */
  96751. _generatePointsArray(): boolean;
  96752. /** @hidden */
  96753. _updateBoundingInfo(): AbstractMesh;
  96754. /**
  96755. * Creates a new InstancedMesh from the current mesh.
  96756. * - name (string) : the cloned mesh name
  96757. * - newParent (optional Node) : the optional Node to parent the clone to.
  96758. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96759. *
  96760. * Returns the clone.
  96761. */
  96762. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96763. /**
  96764. * Disposes the InstancedMesh.
  96765. * Returns nothing.
  96766. */
  96767. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96768. }
  96769. interface Mesh {
  96770. /**
  96771. * Register a custom buffer that will be instanced
  96772. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96773. * @param kind defines the buffer kind
  96774. * @param stride defines the stride in floats
  96775. */
  96776. registerInstancedBuffer(kind: string, stride: number): void;
  96777. /**
  96778. * true to use the edge renderer for all instances of this mesh
  96779. */
  96780. edgesShareWithInstances: boolean;
  96781. /** @hidden */
  96782. _userInstancedBuffersStorage: {
  96783. data: {
  96784. [key: string]: Float32Array;
  96785. };
  96786. sizes: {
  96787. [key: string]: number;
  96788. };
  96789. vertexBuffers: {
  96790. [key: string]: Nullable<VertexBuffer>;
  96791. };
  96792. strides: {
  96793. [key: string]: number;
  96794. };
  96795. };
  96796. }
  96797. interface AbstractMesh {
  96798. /**
  96799. * Object used to store instanced buffers defined by user
  96800. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96801. */
  96802. instancedBuffers: {
  96803. [key: string]: any;
  96804. };
  96805. }
  96806. }
  96807. declare module BABYLON {
  96808. /**
  96809. * Defines the options associated with the creation of a shader material.
  96810. */
  96811. export interface IShaderMaterialOptions {
  96812. /**
  96813. * Does the material work in alpha blend mode
  96814. */
  96815. needAlphaBlending: boolean;
  96816. /**
  96817. * Does the material work in alpha test mode
  96818. */
  96819. needAlphaTesting: boolean;
  96820. /**
  96821. * The list of attribute names used in the shader
  96822. */
  96823. attributes: string[];
  96824. /**
  96825. * The list of unifrom names used in the shader
  96826. */
  96827. uniforms: string[];
  96828. /**
  96829. * The list of UBO names used in the shader
  96830. */
  96831. uniformBuffers: string[];
  96832. /**
  96833. * The list of sampler names used in the shader
  96834. */
  96835. samplers: string[];
  96836. /**
  96837. * The list of defines used in the shader
  96838. */
  96839. defines: string[];
  96840. }
  96841. /**
  96842. * 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.
  96843. *
  96844. * This returned material effects how the mesh will look based on the code in the shaders.
  96845. *
  96846. * @see https://doc.babylonjs.com/how_to/shader_material
  96847. */
  96848. export class ShaderMaterial extends Material {
  96849. private _shaderPath;
  96850. private _options;
  96851. private _textures;
  96852. private _textureArrays;
  96853. private _floats;
  96854. private _ints;
  96855. private _floatsArrays;
  96856. private _colors3;
  96857. private _colors3Arrays;
  96858. private _colors4;
  96859. private _colors4Arrays;
  96860. private _vectors2;
  96861. private _vectors3;
  96862. private _vectors4;
  96863. private _matrices;
  96864. private _matrixArrays;
  96865. private _matrices3x3;
  96866. private _matrices2x2;
  96867. private _vectors2Arrays;
  96868. private _vectors3Arrays;
  96869. private _vectors4Arrays;
  96870. private _cachedWorldViewMatrix;
  96871. private _cachedWorldViewProjectionMatrix;
  96872. private _renderId;
  96873. private _multiview;
  96874. private _cachedDefines;
  96875. /** Define the Url to load snippets */
  96876. static SnippetUrl: string;
  96877. /** Snippet ID if the material was created from the snippet server */
  96878. snippetId: string;
  96879. /**
  96880. * Instantiate a new shader material.
  96881. * 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.
  96882. * This returned material effects how the mesh will look based on the code in the shaders.
  96883. * @see https://doc.babylonjs.com/how_to/shader_material
  96884. * @param name Define the name of the material in the scene
  96885. * @param scene Define the scene the material belongs to
  96886. * @param shaderPath Defines the route to the shader code in one of three ways:
  96887. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96888. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96889. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96890. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96891. * @param options Define the options used to create the shader
  96892. */
  96893. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96894. /**
  96895. * Gets the shader path used to define the shader code
  96896. * It can be modified to trigger a new compilation
  96897. */
  96898. get shaderPath(): any;
  96899. /**
  96900. * Sets the shader path used to define the shader code
  96901. * It can be modified to trigger a new compilation
  96902. */
  96903. set shaderPath(shaderPath: any);
  96904. /**
  96905. * Gets the options used to compile the shader.
  96906. * They can be modified to trigger a new compilation
  96907. */
  96908. get options(): IShaderMaterialOptions;
  96909. /**
  96910. * Gets the current class name of the material e.g. "ShaderMaterial"
  96911. * Mainly use in serialization.
  96912. * @returns the class name
  96913. */
  96914. getClassName(): string;
  96915. /**
  96916. * Specifies if the material will require alpha blending
  96917. * @returns a boolean specifying if alpha blending is needed
  96918. */
  96919. needAlphaBlending(): boolean;
  96920. /**
  96921. * Specifies if this material should be rendered in alpha test mode
  96922. * @returns a boolean specifying if an alpha test is needed.
  96923. */
  96924. needAlphaTesting(): boolean;
  96925. private _checkUniform;
  96926. /**
  96927. * Set a texture in the shader.
  96928. * @param name Define the name of the uniform samplers as defined in the shader
  96929. * @param texture Define the texture to bind to this sampler
  96930. * @return the material itself allowing "fluent" like uniform updates
  96931. */
  96932. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96933. /**
  96934. * Set a texture array in the shader.
  96935. * @param name Define the name of the uniform sampler array as defined in the shader
  96936. * @param textures Define the list of textures to bind to this sampler
  96937. * @return the material itself allowing "fluent" like uniform updates
  96938. */
  96939. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96940. /**
  96941. * Set a float in the shader.
  96942. * @param name Define the name of the uniform as defined in the shader
  96943. * @param value Define the value to give to the uniform
  96944. * @return the material itself allowing "fluent" like uniform updates
  96945. */
  96946. setFloat(name: string, value: number): ShaderMaterial;
  96947. /**
  96948. * Set a int in the shader.
  96949. * @param name Define the name of the uniform as defined in the shader
  96950. * @param value Define the value to give to the uniform
  96951. * @return the material itself allowing "fluent" like uniform updates
  96952. */
  96953. setInt(name: string, value: number): ShaderMaterial;
  96954. /**
  96955. * Set an array of floats in the shader.
  96956. * @param name Define the name of the uniform as defined in the shader
  96957. * @param value Define the value to give to the uniform
  96958. * @return the material itself allowing "fluent" like uniform updates
  96959. */
  96960. setFloats(name: string, value: number[]): ShaderMaterial;
  96961. /**
  96962. * Set a vec3 in the shader from a Color3.
  96963. * @param name Define the name of the uniform as defined in the shader
  96964. * @param value Define the value to give to the uniform
  96965. * @return the material itself allowing "fluent" like uniform updates
  96966. */
  96967. setColor3(name: string, value: Color3): ShaderMaterial;
  96968. /**
  96969. * Set a vec3 array in the shader from a Color3 array.
  96970. * @param name Define the name of the uniform as defined in the shader
  96971. * @param value Define the value to give to the uniform
  96972. * @return the material itself allowing "fluent" like uniform updates
  96973. */
  96974. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96975. /**
  96976. * Set a vec4 in the shader from a Color4.
  96977. * @param name Define the name of the uniform as defined in the shader
  96978. * @param value Define the value to give to the uniform
  96979. * @return the material itself allowing "fluent" like uniform updates
  96980. */
  96981. setColor4(name: string, value: Color4): ShaderMaterial;
  96982. /**
  96983. * Set a vec4 array in the shader from a Color4 array.
  96984. * @param name Define the name of the uniform as defined in the shader
  96985. * @param value Define the value to give to the uniform
  96986. * @return the material itself allowing "fluent" like uniform updates
  96987. */
  96988. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96989. /**
  96990. * Set a vec2 in the shader from a Vector2.
  96991. * @param name Define the name of the uniform as defined in the shader
  96992. * @param value Define the value to give to the uniform
  96993. * @return the material itself allowing "fluent" like uniform updates
  96994. */
  96995. setVector2(name: string, value: Vector2): ShaderMaterial;
  96996. /**
  96997. * Set a vec3 in the shader from a Vector3.
  96998. * @param name Define the name of the uniform as defined in the shader
  96999. * @param value Define the value to give to the uniform
  97000. * @return the material itself allowing "fluent" like uniform updates
  97001. */
  97002. setVector3(name: string, value: Vector3): ShaderMaterial;
  97003. /**
  97004. * Set a vec4 in the shader from a Vector4.
  97005. * @param name Define the name of the uniform as defined in the shader
  97006. * @param value Define the value to give to the uniform
  97007. * @return the material itself allowing "fluent" like uniform updates
  97008. */
  97009. setVector4(name: string, value: Vector4): ShaderMaterial;
  97010. /**
  97011. * Set a mat4 in the shader from a Matrix.
  97012. * @param name Define the name of the uniform as defined in the shader
  97013. * @param value Define the value to give to the uniform
  97014. * @return the material itself allowing "fluent" like uniform updates
  97015. */
  97016. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97017. /**
  97018. * Set a float32Array in the shader from a matrix array.
  97019. * @param name Define the name of the uniform as defined in the shader
  97020. * @param value Define the value to give to the uniform
  97021. * @return the material itself allowing "fluent" like uniform updates
  97022. */
  97023. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97024. /**
  97025. * Set a mat3 in the shader from a Float32Array.
  97026. * @param name Define the name of the uniform as defined in the shader
  97027. * @param value Define the value to give to the uniform
  97028. * @return the material itself allowing "fluent" like uniform updates
  97029. */
  97030. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97031. /**
  97032. * Set a mat2 in the shader from a Float32Array.
  97033. * @param name Define the name of the uniform as defined in the shader
  97034. * @param value Define the value to give to the uniform
  97035. * @return the material itself allowing "fluent" like uniform updates
  97036. */
  97037. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97038. /**
  97039. * Set a vec2 array in the shader from a number array.
  97040. * @param name Define the name of the uniform as defined in the shader
  97041. * @param value Define the value to give to the uniform
  97042. * @return the material itself allowing "fluent" like uniform updates
  97043. */
  97044. setArray2(name: string, value: number[]): ShaderMaterial;
  97045. /**
  97046. * Set a vec3 array in the shader from a number array.
  97047. * @param name Define the name of the uniform as defined in the shader
  97048. * @param value Define the value to give to the uniform
  97049. * @return the material itself allowing "fluent" like uniform updates
  97050. */
  97051. setArray3(name: string, value: number[]): ShaderMaterial;
  97052. /**
  97053. * Set a vec4 array in the shader from a number array.
  97054. * @param name Define the name of the uniform as defined in the shader
  97055. * @param value Define the value to give to the uniform
  97056. * @return the material itself allowing "fluent" like uniform updates
  97057. */
  97058. setArray4(name: string, value: number[]): ShaderMaterial;
  97059. private _checkCache;
  97060. /**
  97061. * Specifies that the submesh is ready to be used
  97062. * @param mesh defines the mesh to check
  97063. * @param subMesh defines which submesh to check
  97064. * @param useInstances specifies that instances should be used
  97065. * @returns a boolean indicating that the submesh is ready or not
  97066. */
  97067. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97068. /**
  97069. * Checks if the material is ready to render the requested mesh
  97070. * @param mesh Define the mesh to render
  97071. * @param useInstances Define whether or not the material is used with instances
  97072. * @returns true if ready, otherwise false
  97073. */
  97074. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97075. /**
  97076. * Binds the world matrix to the material
  97077. * @param world defines the world transformation matrix
  97078. * @param effectOverride - If provided, use this effect instead of internal effect
  97079. */
  97080. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97081. /**
  97082. * Binds the submesh to this material by preparing the effect and shader to draw
  97083. * @param world defines the world transformation matrix
  97084. * @param mesh defines the mesh containing the submesh
  97085. * @param subMesh defines the submesh to bind the material to
  97086. */
  97087. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97088. /**
  97089. * Binds the material to the mesh
  97090. * @param world defines the world transformation matrix
  97091. * @param mesh defines the mesh to bind the material to
  97092. * @param effectOverride - If provided, use this effect instead of internal effect
  97093. */
  97094. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97095. protected _afterBind(mesh?: Mesh): void;
  97096. /**
  97097. * Gets the active textures from the material
  97098. * @returns an array of textures
  97099. */
  97100. getActiveTextures(): BaseTexture[];
  97101. /**
  97102. * Specifies if the material uses a texture
  97103. * @param texture defines the texture to check against the material
  97104. * @returns a boolean specifying if the material uses the texture
  97105. */
  97106. hasTexture(texture: BaseTexture): boolean;
  97107. /**
  97108. * Makes a duplicate of the material, and gives it a new name
  97109. * @param name defines the new name for the duplicated material
  97110. * @returns the cloned material
  97111. */
  97112. clone(name: string): ShaderMaterial;
  97113. /**
  97114. * Disposes the material
  97115. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97116. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97117. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97118. */
  97119. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97120. /**
  97121. * Serializes this material in a JSON representation
  97122. * @returns the serialized material object
  97123. */
  97124. serialize(): any;
  97125. /**
  97126. * Creates a shader material from parsed shader material data
  97127. * @param source defines the JSON represnetation of the material
  97128. * @param scene defines the hosting scene
  97129. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97130. * @returns a new material
  97131. */
  97132. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97133. /**
  97134. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97135. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97136. * @param url defines the url to load from
  97137. * @param scene defines the hosting scene
  97138. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97139. * @returns a promise that will resolve to the new ShaderMaterial
  97140. */
  97141. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97142. /**
  97143. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97144. * @param snippetId defines the snippet to load
  97145. * @param scene defines the hosting scene
  97146. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97147. * @returns a promise that will resolve to the new ShaderMaterial
  97148. */
  97149. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97150. }
  97151. }
  97152. declare module BABYLON {
  97153. /** @hidden */
  97154. export var colorPixelShader: {
  97155. name: string;
  97156. shader: string;
  97157. };
  97158. }
  97159. declare module BABYLON {
  97160. /** @hidden */
  97161. export var colorVertexShader: {
  97162. name: string;
  97163. shader: string;
  97164. };
  97165. }
  97166. declare module BABYLON {
  97167. /**
  97168. * Line mesh
  97169. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97170. */
  97171. export class LinesMesh extends Mesh {
  97172. /**
  97173. * If vertex color should be applied to the mesh
  97174. */
  97175. readonly useVertexColor?: boolean | undefined;
  97176. /**
  97177. * If vertex alpha should be applied to the mesh
  97178. */
  97179. readonly useVertexAlpha?: boolean | undefined;
  97180. /**
  97181. * Color of the line (Default: White)
  97182. */
  97183. color: Color3;
  97184. /**
  97185. * Alpha of the line (Default: 1)
  97186. */
  97187. alpha: number;
  97188. /**
  97189. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97190. * This margin is expressed in world space coordinates, so its value may vary.
  97191. * Default value is 0.1
  97192. */
  97193. intersectionThreshold: number;
  97194. private _colorShader;
  97195. private color4;
  97196. /**
  97197. * Creates a new LinesMesh
  97198. * @param name defines the name
  97199. * @param scene defines the hosting scene
  97200. * @param parent defines the parent mesh if any
  97201. * @param source defines the optional source LinesMesh used to clone data from
  97202. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97203. * When false, achieved by calling a clone(), also passing False.
  97204. * This will make creation of children, recursive.
  97205. * @param useVertexColor defines if this LinesMesh supports vertex color
  97206. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97207. */
  97208. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97209. /**
  97210. * If vertex color should be applied to the mesh
  97211. */
  97212. useVertexColor?: boolean | undefined,
  97213. /**
  97214. * If vertex alpha should be applied to the mesh
  97215. */
  97216. useVertexAlpha?: boolean | undefined);
  97217. private _addClipPlaneDefine;
  97218. private _removeClipPlaneDefine;
  97219. isReady(): boolean;
  97220. /**
  97221. * Returns the string "LineMesh"
  97222. */
  97223. getClassName(): string;
  97224. /**
  97225. * @hidden
  97226. */
  97227. get material(): Material;
  97228. /**
  97229. * @hidden
  97230. */
  97231. set material(value: Material);
  97232. /**
  97233. * @hidden
  97234. */
  97235. get checkCollisions(): boolean;
  97236. /** @hidden */
  97237. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97238. /** @hidden */
  97239. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97240. /**
  97241. * Disposes of the line mesh
  97242. * @param doNotRecurse If children should be disposed
  97243. */
  97244. dispose(doNotRecurse?: boolean): void;
  97245. /**
  97246. * Returns a new LineMesh object cloned from the current one.
  97247. */
  97248. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97249. /**
  97250. * Creates a new InstancedLinesMesh object from the mesh model.
  97251. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97252. * @param name defines the name of the new instance
  97253. * @returns a new InstancedLinesMesh
  97254. */
  97255. createInstance(name: string): InstancedLinesMesh;
  97256. }
  97257. /**
  97258. * Creates an instance based on a source LinesMesh
  97259. */
  97260. export class InstancedLinesMesh extends InstancedMesh {
  97261. /**
  97262. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97263. * This margin is expressed in world space coordinates, so its value may vary.
  97264. * Initilized with the intersectionThreshold value of the source LinesMesh
  97265. */
  97266. intersectionThreshold: number;
  97267. constructor(name: string, source: LinesMesh);
  97268. /**
  97269. * Returns the string "InstancedLinesMesh".
  97270. */
  97271. getClassName(): string;
  97272. }
  97273. }
  97274. declare module BABYLON {
  97275. /** @hidden */
  97276. export var linePixelShader: {
  97277. name: string;
  97278. shader: string;
  97279. };
  97280. }
  97281. declare module BABYLON {
  97282. /** @hidden */
  97283. export var lineVertexShader: {
  97284. name: string;
  97285. shader: string;
  97286. };
  97287. }
  97288. declare module BABYLON {
  97289. interface Scene {
  97290. /** @hidden */
  97291. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97292. }
  97293. interface AbstractMesh {
  97294. /**
  97295. * Gets the edgesRenderer associated with the mesh
  97296. */
  97297. edgesRenderer: Nullable<EdgesRenderer>;
  97298. }
  97299. interface LinesMesh {
  97300. /**
  97301. * Enables the edge rendering mode on the mesh.
  97302. * This mode makes the mesh edges visible
  97303. * @param epsilon defines the maximal distance between two angles to detect a face
  97304. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97305. * @returns the currentAbstractMesh
  97306. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97307. */
  97308. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97309. }
  97310. interface InstancedLinesMesh {
  97311. /**
  97312. * Enables the edge rendering mode on the mesh.
  97313. * This mode makes the mesh edges visible
  97314. * @param epsilon defines the maximal distance between two angles to detect a face
  97315. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97316. * @returns the current InstancedLinesMesh
  97317. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97318. */
  97319. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97320. }
  97321. /**
  97322. * Defines the minimum contract an Edges renderer should follow.
  97323. */
  97324. export interface IEdgesRenderer extends IDisposable {
  97325. /**
  97326. * Gets or sets a boolean indicating if the edgesRenderer is active
  97327. */
  97328. isEnabled: boolean;
  97329. /**
  97330. * Renders the edges of the attached mesh,
  97331. */
  97332. render(): void;
  97333. /**
  97334. * Checks wether or not the edges renderer is ready to render.
  97335. * @return true if ready, otherwise false.
  97336. */
  97337. isReady(): boolean;
  97338. /**
  97339. * List of instances to render in case the source mesh has instances
  97340. */
  97341. customInstances: SmartArray<Matrix>;
  97342. }
  97343. /**
  97344. * Defines the additional options of the edges renderer
  97345. */
  97346. export interface IEdgesRendererOptions {
  97347. /**
  97348. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97349. * If not defined, the default value is true
  97350. */
  97351. useAlternateEdgeFinder?: boolean;
  97352. /**
  97353. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97354. * If not defined, the default value is true.
  97355. * 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)
  97356. * This option is used only if useAlternateEdgeFinder = true
  97357. */
  97358. useFastVertexMerger?: boolean;
  97359. /**
  97360. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97361. * The default value is 1e-6
  97362. * This option is used only if useAlternateEdgeFinder = true
  97363. */
  97364. epsilonVertexMerge?: number;
  97365. /**
  97366. * 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
  97367. * 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.
  97368. * This option is used only if useAlternateEdgeFinder = true
  97369. */
  97370. applyTessellation?: boolean;
  97371. /**
  97372. * 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
  97373. * The default value is 1e-6
  97374. * This option is used only if useAlternateEdgeFinder = true
  97375. */
  97376. epsilonVertexAligned?: number;
  97377. }
  97378. /**
  97379. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97380. */
  97381. export class EdgesRenderer implements IEdgesRenderer {
  97382. /**
  97383. * Define the size of the edges with an orthographic camera
  97384. */
  97385. edgesWidthScalerForOrthographic: number;
  97386. /**
  97387. * Define the size of the edges with a perspective camera
  97388. */
  97389. edgesWidthScalerForPerspective: number;
  97390. protected _source: AbstractMesh;
  97391. protected _linesPositions: number[];
  97392. protected _linesNormals: number[];
  97393. protected _linesIndices: number[];
  97394. protected _epsilon: number;
  97395. protected _indicesCount: number;
  97396. protected _lineShader: ShaderMaterial;
  97397. protected _ib: DataBuffer;
  97398. protected _buffers: {
  97399. [key: string]: Nullable<VertexBuffer>;
  97400. };
  97401. protected _buffersForInstances: {
  97402. [key: string]: Nullable<VertexBuffer>;
  97403. };
  97404. protected _checkVerticesInsteadOfIndices: boolean;
  97405. protected _options: Nullable<IEdgesRendererOptions>;
  97406. private _meshRebuildObserver;
  97407. private _meshDisposeObserver;
  97408. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97409. isEnabled: boolean;
  97410. /**
  97411. * List of instances to render in case the source mesh has instances
  97412. */
  97413. customInstances: SmartArray<Matrix>;
  97414. private static GetShader;
  97415. /**
  97416. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97417. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97418. * @param source Mesh used to create edges
  97419. * @param epsilon sum of angles in adjacency to check for edge
  97420. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97421. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97422. * @param options The options to apply when generating the edges
  97423. */
  97424. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97425. protected _prepareRessources(): void;
  97426. /** @hidden */
  97427. _rebuild(): void;
  97428. /**
  97429. * Releases the required resources for the edges renderer
  97430. */
  97431. dispose(): void;
  97432. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97433. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97434. /**
  97435. * Checks if the pair of p0 and p1 is en edge
  97436. * @param faceIndex
  97437. * @param edge
  97438. * @param faceNormals
  97439. * @param p0
  97440. * @param p1
  97441. * @private
  97442. */
  97443. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97444. /**
  97445. * push line into the position, normal and index buffer
  97446. * @protected
  97447. */
  97448. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97449. /**
  97450. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97451. */
  97452. private _tessellateTriangle;
  97453. private _generateEdgesLinesAlternate;
  97454. /**
  97455. * Generates lines edges from adjacencjes
  97456. * @private
  97457. */
  97458. _generateEdgesLines(): void;
  97459. /**
  97460. * Checks wether or not the edges renderer is ready to render.
  97461. * @return true if ready, otherwise false.
  97462. */
  97463. isReady(): boolean;
  97464. /**
  97465. * Renders the edges of the attached mesh,
  97466. */
  97467. render(): void;
  97468. }
  97469. /**
  97470. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97471. */
  97472. export class LineEdgesRenderer extends EdgesRenderer {
  97473. /**
  97474. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97475. * @param source LineMesh used to generate edges
  97476. * @param epsilon not important (specified angle for edge detection)
  97477. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97478. */
  97479. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97480. /**
  97481. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97482. */
  97483. _generateEdgesLines(): void;
  97484. }
  97485. }
  97486. declare module BABYLON {
  97487. /**
  97488. * This represents the object necessary to create a rendering group.
  97489. * This is exclusively used and created by the rendering manager.
  97490. * To modify the behavior, you use the available helpers in your scene or meshes.
  97491. * @hidden
  97492. */
  97493. export class RenderingGroup {
  97494. index: number;
  97495. private static _zeroVector;
  97496. private _scene;
  97497. private _opaqueSubMeshes;
  97498. private _transparentSubMeshes;
  97499. private _alphaTestSubMeshes;
  97500. private _depthOnlySubMeshes;
  97501. private _particleSystems;
  97502. private _spriteManagers;
  97503. private _opaqueSortCompareFn;
  97504. private _alphaTestSortCompareFn;
  97505. private _transparentSortCompareFn;
  97506. private _renderOpaque;
  97507. private _renderAlphaTest;
  97508. private _renderTransparent;
  97509. /** @hidden */
  97510. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97511. onBeforeTransparentRendering: () => void;
  97512. /**
  97513. * Set the opaque sort comparison function.
  97514. * If null the sub meshes will be render in the order they were created
  97515. */
  97516. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97517. /**
  97518. * Set the alpha test sort comparison function.
  97519. * If null the sub meshes will be render in the order they were created
  97520. */
  97521. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97522. /**
  97523. * Set the transparent sort comparison function.
  97524. * If null the sub meshes will be render in the order they were created
  97525. */
  97526. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97527. /**
  97528. * Creates a new rendering group.
  97529. * @param index The rendering group index
  97530. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97531. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97532. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97533. */
  97534. 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>);
  97535. /**
  97536. * Render all the sub meshes contained in the group.
  97537. * @param customRenderFunction Used to override the default render behaviour of the group.
  97538. * @returns true if rendered some submeshes.
  97539. */
  97540. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97541. /**
  97542. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97543. * @param subMeshes The submeshes to render
  97544. */
  97545. private renderOpaqueSorted;
  97546. /**
  97547. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97548. * @param subMeshes The submeshes to render
  97549. */
  97550. private renderAlphaTestSorted;
  97551. /**
  97552. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97553. * @param subMeshes The submeshes to render
  97554. */
  97555. private renderTransparentSorted;
  97556. /**
  97557. * Renders the submeshes in a specified order.
  97558. * @param subMeshes The submeshes to sort before render
  97559. * @param sortCompareFn The comparison function use to sort
  97560. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97561. * @param transparent Specifies to activate blending if true
  97562. */
  97563. private static renderSorted;
  97564. /**
  97565. * Renders the submeshes in the order they were dispatched (no sort applied).
  97566. * @param subMeshes The submeshes to render
  97567. */
  97568. private static renderUnsorted;
  97569. /**
  97570. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97571. * are rendered back to front if in the same alpha index.
  97572. *
  97573. * @param a The first submesh
  97574. * @param b The second submesh
  97575. * @returns The result of the comparison
  97576. */
  97577. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97578. /**
  97579. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97580. * are rendered back to front.
  97581. *
  97582. * @param a The first submesh
  97583. * @param b The second submesh
  97584. * @returns The result of the comparison
  97585. */
  97586. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97587. /**
  97588. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97589. * are rendered front to back (prevent overdraw).
  97590. *
  97591. * @param a The first submesh
  97592. * @param b The second submesh
  97593. * @returns The result of the comparison
  97594. */
  97595. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97596. /**
  97597. * Resets the different lists of submeshes to prepare a new frame.
  97598. */
  97599. prepare(): void;
  97600. dispose(): void;
  97601. /**
  97602. * Inserts the submesh in its correct queue depending on its material.
  97603. * @param subMesh The submesh to dispatch
  97604. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97605. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97606. */
  97607. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97608. dispatchSprites(spriteManager: ISpriteManager): void;
  97609. dispatchParticles(particleSystem: IParticleSystem): void;
  97610. private _renderParticles;
  97611. private _renderSprites;
  97612. }
  97613. }
  97614. declare module BABYLON {
  97615. /**
  97616. * Interface describing the different options available in the rendering manager
  97617. * regarding Auto Clear between groups.
  97618. */
  97619. export interface IRenderingManagerAutoClearSetup {
  97620. /**
  97621. * Defines whether or not autoclear is enable.
  97622. */
  97623. autoClear: boolean;
  97624. /**
  97625. * Defines whether or not to autoclear the depth buffer.
  97626. */
  97627. depth: boolean;
  97628. /**
  97629. * Defines whether or not to autoclear the stencil buffer.
  97630. */
  97631. stencil: boolean;
  97632. }
  97633. /**
  97634. * This class is used by the onRenderingGroupObservable
  97635. */
  97636. export class RenderingGroupInfo {
  97637. /**
  97638. * The Scene that being rendered
  97639. */
  97640. scene: Scene;
  97641. /**
  97642. * The camera currently used for the rendering pass
  97643. */
  97644. camera: Nullable<Camera>;
  97645. /**
  97646. * The ID of the renderingGroup being processed
  97647. */
  97648. renderingGroupId: number;
  97649. }
  97650. /**
  97651. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97652. * It is enable to manage the different groups as well as the different necessary sort functions.
  97653. * This should not be used directly aside of the few static configurations
  97654. */
  97655. export class RenderingManager {
  97656. /**
  97657. * The max id used for rendering groups (not included)
  97658. */
  97659. static MAX_RENDERINGGROUPS: number;
  97660. /**
  97661. * The min id used for rendering groups (included)
  97662. */
  97663. static MIN_RENDERINGGROUPS: number;
  97664. /**
  97665. * Used to globally prevent autoclearing scenes.
  97666. */
  97667. static AUTOCLEAR: boolean;
  97668. /**
  97669. * @hidden
  97670. */
  97671. _useSceneAutoClearSetup: boolean;
  97672. private _scene;
  97673. private _renderingGroups;
  97674. private _depthStencilBufferAlreadyCleaned;
  97675. private _autoClearDepthStencil;
  97676. private _customOpaqueSortCompareFn;
  97677. private _customAlphaTestSortCompareFn;
  97678. private _customTransparentSortCompareFn;
  97679. private _renderingGroupInfo;
  97680. /**
  97681. * Instantiates a new rendering group for a particular scene
  97682. * @param scene Defines the scene the groups belongs to
  97683. */
  97684. constructor(scene: Scene);
  97685. private _clearDepthStencilBuffer;
  97686. /**
  97687. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97688. * @hidden
  97689. */
  97690. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97691. /**
  97692. * Resets the different information of the group to prepare a new frame
  97693. * @hidden
  97694. */
  97695. reset(): void;
  97696. /**
  97697. * Dispose and release the group and its associated resources.
  97698. * @hidden
  97699. */
  97700. dispose(): void;
  97701. /**
  97702. * Clear the info related to rendering groups preventing retention points during dispose.
  97703. */
  97704. freeRenderingGroups(): void;
  97705. private _prepareRenderingGroup;
  97706. /**
  97707. * Add a sprite manager to the rendering manager in order to render it this frame.
  97708. * @param spriteManager Define the sprite manager to render
  97709. */
  97710. dispatchSprites(spriteManager: ISpriteManager): void;
  97711. /**
  97712. * Add a particle system to the rendering manager in order to render it this frame.
  97713. * @param particleSystem Define the particle system to render
  97714. */
  97715. dispatchParticles(particleSystem: IParticleSystem): void;
  97716. /**
  97717. * Add a submesh to the manager in order to render it this frame
  97718. * @param subMesh The submesh to dispatch
  97719. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97720. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97721. */
  97722. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97723. /**
  97724. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97725. * This allowed control for front to back rendering or reversly depending of the special needs.
  97726. *
  97727. * @param renderingGroupId The rendering group id corresponding to its index
  97728. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97729. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97730. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97731. */
  97732. 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;
  97733. /**
  97734. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97735. *
  97736. * @param renderingGroupId The rendering group id corresponding to its index
  97737. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97738. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97739. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97740. */
  97741. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97742. /**
  97743. * Gets the current auto clear configuration for one rendering group of the rendering
  97744. * manager.
  97745. * @param index the rendering group index to get the information for
  97746. * @returns The auto clear setup for the requested rendering group
  97747. */
  97748. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97749. }
  97750. }
  97751. declare module BABYLON {
  97752. /**
  97753. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97754. */
  97755. export interface ICustomShaderOptions {
  97756. /**
  97757. * Gets or sets the custom shader name to use
  97758. */
  97759. shaderName: string;
  97760. /**
  97761. * The list of attribute names used in the shader
  97762. */
  97763. attributes?: string[];
  97764. /**
  97765. * The list of unifrom names used in the shader
  97766. */
  97767. uniforms?: string[];
  97768. /**
  97769. * The list of sampler names used in the shader
  97770. */
  97771. samplers?: string[];
  97772. /**
  97773. * The list of defines used in the shader
  97774. */
  97775. defines?: string[];
  97776. }
  97777. /**
  97778. * Interface to implement to create a shadow generator compatible with BJS.
  97779. */
  97780. export interface IShadowGenerator {
  97781. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97782. id: string;
  97783. /**
  97784. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97785. * @returns The render target texture if present otherwise, null
  97786. */
  97787. getShadowMap(): Nullable<RenderTargetTexture>;
  97788. /**
  97789. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97790. * @param subMesh The submesh we want to render in the shadow map
  97791. * @param useInstances Defines wether will draw in the map using instances
  97792. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97793. * @returns true if ready otherwise, false
  97794. */
  97795. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97796. /**
  97797. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97798. * @param defines Defines of the material we want to update
  97799. * @param lightIndex Index of the light in the enabled light list of the material
  97800. */
  97801. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97802. /**
  97803. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97804. * defined in the generator but impacting the effect).
  97805. * It implies the unifroms available on the materials are the standard BJS ones.
  97806. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97807. * @param effect The effect we are binfing the information for
  97808. */
  97809. bindShadowLight(lightIndex: string, effect: Effect): void;
  97810. /**
  97811. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97812. * (eq to shadow prjection matrix * light transform matrix)
  97813. * @returns The transform matrix used to create the shadow map
  97814. */
  97815. getTransformMatrix(): Matrix;
  97816. /**
  97817. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97818. * Cube and 2D textures for instance.
  97819. */
  97820. recreateShadowMap(): void;
  97821. /**
  97822. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97823. * @param onCompiled Callback triggered at the and of the effects compilation
  97824. * @param options Sets of optional options forcing the compilation with different modes
  97825. */
  97826. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97827. useInstances: boolean;
  97828. }>): void;
  97829. /**
  97830. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97831. * @param options Sets of optional options forcing the compilation with different modes
  97832. * @returns A promise that resolves when the compilation completes
  97833. */
  97834. forceCompilationAsync(options?: Partial<{
  97835. useInstances: boolean;
  97836. }>): Promise<void>;
  97837. /**
  97838. * Serializes the shadow generator setup to a json object.
  97839. * @returns The serialized JSON object
  97840. */
  97841. serialize(): any;
  97842. /**
  97843. * Disposes the Shadow map and related Textures and effects.
  97844. */
  97845. dispose(): void;
  97846. }
  97847. /**
  97848. * Default implementation IShadowGenerator.
  97849. * This is the main object responsible of generating shadows in the framework.
  97850. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97851. */
  97852. export class ShadowGenerator implements IShadowGenerator {
  97853. /**
  97854. * Name of the shadow generator class
  97855. */
  97856. static CLASSNAME: string;
  97857. /**
  97858. * Shadow generator mode None: no filtering applied.
  97859. */
  97860. static readonly FILTER_NONE: number;
  97861. /**
  97862. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97863. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97864. */
  97865. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97866. /**
  97867. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97868. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97869. */
  97870. static readonly FILTER_POISSONSAMPLING: number;
  97871. /**
  97872. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97873. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97874. */
  97875. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97876. /**
  97877. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97878. * edge artifacts on steep falloff.
  97879. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97880. */
  97881. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97882. /**
  97883. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97884. * edge artifacts on steep falloff.
  97885. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97886. */
  97887. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97888. /**
  97889. * Shadow generator mode PCF: Percentage Closer Filtering
  97890. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97891. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97892. */
  97893. static readonly FILTER_PCF: number;
  97894. /**
  97895. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97896. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97897. * Contact Hardening
  97898. */
  97899. static readonly FILTER_PCSS: number;
  97900. /**
  97901. * Reserved for PCF and PCSS
  97902. * Highest Quality.
  97903. *
  97904. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97905. *
  97906. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97907. */
  97908. static readonly QUALITY_HIGH: number;
  97909. /**
  97910. * Reserved for PCF and PCSS
  97911. * Good tradeoff for quality/perf cross devices
  97912. *
  97913. * Execute PCF on a 3*3 kernel.
  97914. *
  97915. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97916. */
  97917. static readonly QUALITY_MEDIUM: number;
  97918. /**
  97919. * Reserved for PCF and PCSS
  97920. * The lowest quality but the fastest.
  97921. *
  97922. * Execute PCF on a 1*1 kernel.
  97923. *
  97924. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97925. */
  97926. static readonly QUALITY_LOW: number;
  97927. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97928. id: string;
  97929. /** Gets or sets the custom shader name to use */
  97930. customShaderOptions: ICustomShaderOptions;
  97931. /**
  97932. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97933. */
  97934. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97935. /**
  97936. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97937. */
  97938. onAfterShadowMapRenderObservable: Observable<Effect>;
  97939. /**
  97940. * Observable triggered before a mesh is rendered in the shadow map.
  97941. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97942. */
  97943. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97944. /**
  97945. * Observable triggered after a mesh is rendered in the shadow map.
  97946. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97947. */
  97948. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97949. protected _bias: number;
  97950. /**
  97951. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97952. */
  97953. get bias(): number;
  97954. /**
  97955. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97956. */
  97957. set bias(bias: number);
  97958. protected _normalBias: number;
  97959. /**
  97960. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97961. */
  97962. get normalBias(): number;
  97963. /**
  97964. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97965. */
  97966. set normalBias(normalBias: number);
  97967. protected _blurBoxOffset: number;
  97968. /**
  97969. * Gets the blur box offset: offset applied during the blur pass.
  97970. * Only useful if useKernelBlur = false
  97971. */
  97972. get blurBoxOffset(): number;
  97973. /**
  97974. * Sets the blur box offset: offset applied during the blur pass.
  97975. * Only useful if useKernelBlur = false
  97976. */
  97977. set blurBoxOffset(value: number);
  97978. protected _blurScale: number;
  97979. /**
  97980. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97981. * 2 means half of the size.
  97982. */
  97983. get blurScale(): number;
  97984. /**
  97985. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97986. * 2 means half of the size.
  97987. */
  97988. set blurScale(value: number);
  97989. protected _blurKernel: number;
  97990. /**
  97991. * Gets the blur kernel: kernel size of the blur pass.
  97992. * Only useful if useKernelBlur = true
  97993. */
  97994. get blurKernel(): number;
  97995. /**
  97996. * Sets the blur kernel: kernel size of the blur pass.
  97997. * Only useful if useKernelBlur = true
  97998. */
  97999. set blurKernel(value: number);
  98000. protected _useKernelBlur: boolean;
  98001. /**
  98002. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98003. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98004. */
  98005. get useKernelBlur(): boolean;
  98006. /**
  98007. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98008. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98009. */
  98010. set useKernelBlur(value: boolean);
  98011. protected _depthScale: number;
  98012. /**
  98013. * Gets the depth scale used in ESM mode.
  98014. */
  98015. get depthScale(): number;
  98016. /**
  98017. * Sets the depth scale used in ESM mode.
  98018. * This can override the scale stored on the light.
  98019. */
  98020. set depthScale(value: number);
  98021. protected _validateFilter(filter: number): number;
  98022. protected _filter: number;
  98023. /**
  98024. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98025. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98026. */
  98027. get filter(): number;
  98028. /**
  98029. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98030. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98031. */
  98032. set filter(value: number);
  98033. /**
  98034. * Gets if the current filter is set to Poisson Sampling.
  98035. */
  98036. get usePoissonSampling(): boolean;
  98037. /**
  98038. * Sets the current filter to Poisson Sampling.
  98039. */
  98040. set usePoissonSampling(value: boolean);
  98041. /**
  98042. * Gets if the current filter is set to ESM.
  98043. */
  98044. get useExponentialShadowMap(): boolean;
  98045. /**
  98046. * Sets the current filter is to ESM.
  98047. */
  98048. set useExponentialShadowMap(value: boolean);
  98049. /**
  98050. * Gets if the current filter is set to filtered ESM.
  98051. */
  98052. get useBlurExponentialShadowMap(): boolean;
  98053. /**
  98054. * Gets if the current filter is set to filtered ESM.
  98055. */
  98056. set useBlurExponentialShadowMap(value: boolean);
  98057. /**
  98058. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98059. * exponential to prevent steep falloff artifacts).
  98060. */
  98061. get useCloseExponentialShadowMap(): boolean;
  98062. /**
  98063. * Sets the current filter to "close ESM" (using the inverse of the
  98064. * exponential to prevent steep falloff artifacts).
  98065. */
  98066. set useCloseExponentialShadowMap(value: boolean);
  98067. /**
  98068. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98069. * exponential to prevent steep falloff artifacts).
  98070. */
  98071. get useBlurCloseExponentialShadowMap(): boolean;
  98072. /**
  98073. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98074. * exponential to prevent steep falloff artifacts).
  98075. */
  98076. set useBlurCloseExponentialShadowMap(value: boolean);
  98077. /**
  98078. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98079. */
  98080. get usePercentageCloserFiltering(): boolean;
  98081. /**
  98082. * Sets the current filter to "PCF" (percentage closer filtering).
  98083. */
  98084. set usePercentageCloserFiltering(value: boolean);
  98085. protected _filteringQuality: number;
  98086. /**
  98087. * Gets the PCF or PCSS Quality.
  98088. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98089. */
  98090. get filteringQuality(): number;
  98091. /**
  98092. * Sets the PCF or PCSS Quality.
  98093. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98094. */
  98095. set filteringQuality(filteringQuality: number);
  98096. /**
  98097. * Gets if the current filter is set to "PCSS" (contact hardening).
  98098. */
  98099. get useContactHardeningShadow(): boolean;
  98100. /**
  98101. * Sets the current filter to "PCSS" (contact hardening).
  98102. */
  98103. set useContactHardeningShadow(value: boolean);
  98104. protected _contactHardeningLightSizeUVRatio: number;
  98105. /**
  98106. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98107. * Using a ratio helps keeping shape stability independently of the map size.
  98108. *
  98109. * It does not account for the light projection as it was having too much
  98110. * instability during the light setup or during light position changes.
  98111. *
  98112. * Only valid if useContactHardeningShadow is true.
  98113. */
  98114. get contactHardeningLightSizeUVRatio(): number;
  98115. /**
  98116. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98117. * Using a ratio helps keeping shape stability independently of the map size.
  98118. *
  98119. * It does not account for the light projection as it was having too much
  98120. * instability during the light setup or during light position changes.
  98121. *
  98122. * Only valid if useContactHardeningShadow is true.
  98123. */
  98124. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98125. protected _darkness: number;
  98126. /** Gets or sets the actual darkness of a shadow */
  98127. get darkness(): number;
  98128. set darkness(value: number);
  98129. /**
  98130. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98131. * 0 means strongest and 1 would means no shadow.
  98132. * @returns the darkness.
  98133. */
  98134. getDarkness(): number;
  98135. /**
  98136. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98137. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98138. * @returns the shadow generator allowing fluent coding.
  98139. */
  98140. setDarkness(darkness: number): ShadowGenerator;
  98141. protected _transparencyShadow: boolean;
  98142. /** Gets or sets the ability to have transparent shadow */
  98143. get transparencyShadow(): boolean;
  98144. set transparencyShadow(value: boolean);
  98145. /**
  98146. * Sets the ability to have transparent shadow (boolean).
  98147. * @param transparent True if transparent else False
  98148. * @returns the shadow generator allowing fluent coding
  98149. */
  98150. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98151. /**
  98152. * Enables or disables shadows with varying strength based on the transparency
  98153. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98154. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98155. * mesh.visibility * alphaTexture.a
  98156. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98157. */
  98158. enableSoftTransparentShadow: boolean;
  98159. protected _shadowMap: Nullable<RenderTargetTexture>;
  98160. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98161. /**
  98162. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98163. * @returns The render target texture if present otherwise, null
  98164. */
  98165. getShadowMap(): Nullable<RenderTargetTexture>;
  98166. /**
  98167. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98168. * @returns The render target texture if the shadow map is present otherwise, null
  98169. */
  98170. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98171. /**
  98172. * Gets the class name of that object
  98173. * @returns "ShadowGenerator"
  98174. */
  98175. getClassName(): string;
  98176. /**
  98177. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98178. * @param mesh Mesh to add
  98179. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98180. * @returns the Shadow Generator itself
  98181. */
  98182. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98183. /**
  98184. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98185. * @param mesh Mesh to remove
  98186. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98187. * @returns the Shadow Generator itself
  98188. */
  98189. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98190. /**
  98191. * Controls the extent to which the shadows fade out at the edge of the frustum
  98192. */
  98193. frustumEdgeFalloff: number;
  98194. protected _light: IShadowLight;
  98195. /**
  98196. * Returns the associated light object.
  98197. * @returns the light generating the shadow
  98198. */
  98199. getLight(): IShadowLight;
  98200. /**
  98201. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98202. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98203. * It might on the other hand introduce peter panning.
  98204. */
  98205. forceBackFacesOnly: boolean;
  98206. protected _scene: Scene;
  98207. protected _lightDirection: Vector3;
  98208. protected _effect: Effect;
  98209. protected _viewMatrix: Matrix;
  98210. protected _projectionMatrix: Matrix;
  98211. protected _transformMatrix: Matrix;
  98212. protected _cachedPosition: Vector3;
  98213. protected _cachedDirection: Vector3;
  98214. protected _cachedDefines: string;
  98215. protected _currentRenderID: number;
  98216. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98217. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98218. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98219. protected _blurPostProcesses: PostProcess[];
  98220. protected _mapSize: number;
  98221. protected _currentFaceIndex: number;
  98222. protected _currentFaceIndexCache: number;
  98223. protected _textureType: number;
  98224. protected _defaultTextureMatrix: Matrix;
  98225. protected _storedUniqueId: Nullable<number>;
  98226. /** @hidden */
  98227. static _SceneComponentInitialization: (scene: Scene) => void;
  98228. /**
  98229. * Creates a ShadowGenerator object.
  98230. * A ShadowGenerator is the required tool to use the shadows.
  98231. * Each light casting shadows needs to use its own ShadowGenerator.
  98232. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98233. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98234. * @param light The light object generating the shadows.
  98235. * @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.
  98236. */
  98237. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98238. protected _initializeGenerator(): void;
  98239. protected _createTargetRenderTexture(): void;
  98240. protected _initializeShadowMap(): void;
  98241. protected _initializeBlurRTTAndPostProcesses(): void;
  98242. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98243. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98244. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98245. protected _applyFilterValues(): void;
  98246. /**
  98247. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98248. * @param onCompiled Callback triggered at the and of the effects compilation
  98249. * @param options Sets of optional options forcing the compilation with different modes
  98250. */
  98251. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98252. useInstances: boolean;
  98253. }>): void;
  98254. /**
  98255. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98256. * @param options Sets of optional options forcing the compilation with different modes
  98257. * @returns A promise that resolves when the compilation completes
  98258. */
  98259. forceCompilationAsync(options?: Partial<{
  98260. useInstances: boolean;
  98261. }>): Promise<void>;
  98262. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98263. private _prepareShadowDefines;
  98264. /**
  98265. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98266. * @param subMesh The submesh we want to render in the shadow map
  98267. * @param useInstances Defines wether will draw in the map using instances
  98268. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98269. * @returns true if ready otherwise, false
  98270. */
  98271. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98272. /**
  98273. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98274. * @param defines Defines of the material we want to update
  98275. * @param lightIndex Index of the light in the enabled light list of the material
  98276. */
  98277. prepareDefines(defines: any, lightIndex: number): void;
  98278. /**
  98279. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98280. * defined in the generator but impacting the effect).
  98281. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98282. * @param effect The effect we are binfing the information for
  98283. */
  98284. bindShadowLight(lightIndex: string, effect: Effect): void;
  98285. /**
  98286. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98287. * (eq to shadow prjection matrix * light transform matrix)
  98288. * @returns The transform matrix used to create the shadow map
  98289. */
  98290. getTransformMatrix(): Matrix;
  98291. /**
  98292. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98293. * Cube and 2D textures for instance.
  98294. */
  98295. recreateShadowMap(): void;
  98296. protected _disposeBlurPostProcesses(): void;
  98297. protected _disposeRTTandPostProcesses(): void;
  98298. /**
  98299. * Disposes the ShadowGenerator.
  98300. * Returns nothing.
  98301. */
  98302. dispose(): void;
  98303. /**
  98304. * Serializes the shadow generator setup to a json object.
  98305. * @returns The serialized JSON object
  98306. */
  98307. serialize(): any;
  98308. /**
  98309. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98310. * @param parsedShadowGenerator The JSON object to parse
  98311. * @param scene The scene to create the shadow map for
  98312. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98313. * @returns The parsed shadow generator
  98314. */
  98315. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98316. }
  98317. }
  98318. declare module BABYLON {
  98319. /**
  98320. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98321. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98322. * 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.
  98323. */
  98324. export abstract class Light extends Node {
  98325. /**
  98326. * Falloff Default: light is falling off following the material specification:
  98327. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98328. */
  98329. static readonly FALLOFF_DEFAULT: number;
  98330. /**
  98331. * Falloff Physical: light is falling off following the inverse squared distance law.
  98332. */
  98333. static readonly FALLOFF_PHYSICAL: number;
  98334. /**
  98335. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98336. * to enhance interoperability with other engines.
  98337. */
  98338. static readonly FALLOFF_GLTF: number;
  98339. /**
  98340. * Falloff Standard: light is falling off like in the standard material
  98341. * to enhance interoperability with other materials.
  98342. */
  98343. static readonly FALLOFF_STANDARD: number;
  98344. /**
  98345. * If every light affecting the material is in this lightmapMode,
  98346. * material.lightmapTexture adds or multiplies
  98347. * (depends on material.useLightmapAsShadowmap)
  98348. * after every other light calculations.
  98349. */
  98350. static readonly LIGHTMAP_DEFAULT: number;
  98351. /**
  98352. * material.lightmapTexture as only diffuse lighting from this light
  98353. * adds only specular lighting from this light
  98354. * adds dynamic shadows
  98355. */
  98356. static readonly LIGHTMAP_SPECULAR: number;
  98357. /**
  98358. * material.lightmapTexture as only lighting
  98359. * no light calculation from this light
  98360. * only adds dynamic shadows from this light
  98361. */
  98362. static readonly LIGHTMAP_SHADOWSONLY: number;
  98363. /**
  98364. * Each light type uses the default quantity according to its type:
  98365. * point/spot lights use luminous intensity
  98366. * directional lights use illuminance
  98367. */
  98368. static readonly INTENSITYMODE_AUTOMATIC: number;
  98369. /**
  98370. * lumen (lm)
  98371. */
  98372. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98373. /**
  98374. * candela (lm/sr)
  98375. */
  98376. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98377. /**
  98378. * lux (lm/m^2)
  98379. */
  98380. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98381. /**
  98382. * nit (cd/m^2)
  98383. */
  98384. static readonly INTENSITYMODE_LUMINANCE: number;
  98385. /**
  98386. * Light type const id of the point light.
  98387. */
  98388. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98389. /**
  98390. * Light type const id of the directional light.
  98391. */
  98392. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98393. /**
  98394. * Light type const id of the spot light.
  98395. */
  98396. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98397. /**
  98398. * Light type const id of the hemispheric light.
  98399. */
  98400. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98401. /**
  98402. * Diffuse gives the basic color to an object.
  98403. */
  98404. diffuse: Color3;
  98405. /**
  98406. * Specular produces a highlight color on an object.
  98407. * Note: This is note affecting PBR materials.
  98408. */
  98409. specular: Color3;
  98410. /**
  98411. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98412. * falling off base on range or angle.
  98413. * This can be set to any values in Light.FALLOFF_x.
  98414. *
  98415. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98416. * other types of materials.
  98417. */
  98418. falloffType: number;
  98419. /**
  98420. * Strength of the light.
  98421. * Note: By default it is define in the framework own unit.
  98422. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98423. */
  98424. intensity: number;
  98425. private _range;
  98426. protected _inverseSquaredRange: number;
  98427. /**
  98428. * Defines how far from the source the light is impacting in scene units.
  98429. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98430. */
  98431. get range(): number;
  98432. /**
  98433. * Defines how far from the source the light is impacting in scene units.
  98434. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98435. */
  98436. set range(value: number);
  98437. /**
  98438. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98439. * of light.
  98440. */
  98441. private _photometricScale;
  98442. private _intensityMode;
  98443. /**
  98444. * Gets the photometric scale used to interpret the intensity.
  98445. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98446. */
  98447. get intensityMode(): number;
  98448. /**
  98449. * Sets the photometric scale used to interpret the intensity.
  98450. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98451. */
  98452. set intensityMode(value: number);
  98453. private _radius;
  98454. /**
  98455. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98456. */
  98457. get radius(): number;
  98458. /**
  98459. * sets the light radius used by PBR Materials to simulate soft area lights.
  98460. */
  98461. set radius(value: number);
  98462. private _renderPriority;
  98463. /**
  98464. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98465. * exceeding the number allowed of the materials.
  98466. */
  98467. renderPriority: number;
  98468. private _shadowEnabled;
  98469. /**
  98470. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98471. * the current shadow generator.
  98472. */
  98473. get shadowEnabled(): boolean;
  98474. /**
  98475. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98476. * the current shadow generator.
  98477. */
  98478. set shadowEnabled(value: boolean);
  98479. private _includedOnlyMeshes;
  98480. /**
  98481. * Gets the only meshes impacted by this light.
  98482. */
  98483. get includedOnlyMeshes(): AbstractMesh[];
  98484. /**
  98485. * Sets the only meshes impacted by this light.
  98486. */
  98487. set includedOnlyMeshes(value: AbstractMesh[]);
  98488. private _excludedMeshes;
  98489. /**
  98490. * Gets the meshes not impacted by this light.
  98491. */
  98492. get excludedMeshes(): AbstractMesh[];
  98493. /**
  98494. * Sets the meshes not impacted by this light.
  98495. */
  98496. set excludedMeshes(value: AbstractMesh[]);
  98497. private _excludeWithLayerMask;
  98498. /**
  98499. * Gets the layer id use to find what meshes are not impacted by the light.
  98500. * Inactive if 0
  98501. */
  98502. get excludeWithLayerMask(): number;
  98503. /**
  98504. * Sets the layer id use to find what meshes are not impacted by the light.
  98505. * Inactive if 0
  98506. */
  98507. set excludeWithLayerMask(value: number);
  98508. private _includeOnlyWithLayerMask;
  98509. /**
  98510. * Gets the layer id use to find what meshes are impacted by the light.
  98511. * Inactive if 0
  98512. */
  98513. get includeOnlyWithLayerMask(): number;
  98514. /**
  98515. * Sets the layer id use to find what meshes are impacted by the light.
  98516. * Inactive if 0
  98517. */
  98518. set includeOnlyWithLayerMask(value: number);
  98519. private _lightmapMode;
  98520. /**
  98521. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98522. */
  98523. get lightmapMode(): number;
  98524. /**
  98525. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98526. */
  98527. set lightmapMode(value: number);
  98528. /**
  98529. * Shadow generator associted to the light.
  98530. * @hidden Internal use only.
  98531. */
  98532. _shadowGenerator: Nullable<IShadowGenerator>;
  98533. /**
  98534. * @hidden Internal use only.
  98535. */
  98536. _excludedMeshesIds: string[];
  98537. /**
  98538. * @hidden Internal use only.
  98539. */
  98540. _includedOnlyMeshesIds: string[];
  98541. /**
  98542. * The current light unifom buffer.
  98543. * @hidden Internal use only.
  98544. */
  98545. _uniformBuffer: UniformBuffer;
  98546. /** @hidden */
  98547. _renderId: number;
  98548. /**
  98549. * Creates a Light object in the scene.
  98550. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98551. * @param name The firendly name of the light
  98552. * @param scene The scene the light belongs too
  98553. */
  98554. constructor(name: string, scene: Scene);
  98555. protected abstract _buildUniformLayout(): void;
  98556. /**
  98557. * Sets the passed Effect "effect" with the Light information.
  98558. * @param effect The effect to update
  98559. * @param lightIndex The index of the light in the effect to update
  98560. * @returns The light
  98561. */
  98562. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98563. /**
  98564. * Sets the passed Effect "effect" with the Light textures.
  98565. * @param effect The effect to update
  98566. * @param lightIndex The index of the light in the effect to update
  98567. * @returns The light
  98568. */
  98569. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98570. /**
  98571. * Binds the lights information from the scene to the effect for the given mesh.
  98572. * @param lightIndex Light index
  98573. * @param scene The scene where the light belongs to
  98574. * @param effect The effect we are binding the data to
  98575. * @param useSpecular Defines if specular is supported
  98576. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98577. */
  98578. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98579. /**
  98580. * Sets the passed Effect "effect" with the Light information.
  98581. * @param effect The effect to update
  98582. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98583. * @returns The light
  98584. */
  98585. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98586. /**
  98587. * Returns the string "Light".
  98588. * @returns the class name
  98589. */
  98590. getClassName(): string;
  98591. /** @hidden */
  98592. readonly _isLight: boolean;
  98593. /**
  98594. * Converts the light information to a readable string for debug purpose.
  98595. * @param fullDetails Supports for multiple levels of logging within scene loading
  98596. * @returns the human readable light info
  98597. */
  98598. toString(fullDetails?: boolean): string;
  98599. /** @hidden */
  98600. protected _syncParentEnabledState(): void;
  98601. /**
  98602. * Set the enabled state of this node.
  98603. * @param value - the new enabled state
  98604. */
  98605. setEnabled(value: boolean): void;
  98606. /**
  98607. * Returns the Light associated shadow generator if any.
  98608. * @return the associated shadow generator.
  98609. */
  98610. getShadowGenerator(): Nullable<IShadowGenerator>;
  98611. /**
  98612. * Returns a Vector3, the absolute light position in the World.
  98613. * @returns the world space position of the light
  98614. */
  98615. getAbsolutePosition(): Vector3;
  98616. /**
  98617. * Specifies if the light will affect the passed mesh.
  98618. * @param mesh The mesh to test against the light
  98619. * @return true the mesh is affected otherwise, false.
  98620. */
  98621. canAffectMesh(mesh: AbstractMesh): boolean;
  98622. /**
  98623. * Sort function to order lights for rendering.
  98624. * @param a First Light object to compare to second.
  98625. * @param b Second Light object to compare first.
  98626. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98627. */
  98628. static CompareLightsPriority(a: Light, b: Light): number;
  98629. /**
  98630. * Releases resources associated with this node.
  98631. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98632. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98633. */
  98634. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98635. /**
  98636. * Returns the light type ID (integer).
  98637. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98638. */
  98639. getTypeID(): number;
  98640. /**
  98641. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98642. * @returns the scaled intensity in intensity mode unit
  98643. */
  98644. getScaledIntensity(): number;
  98645. /**
  98646. * Returns a new Light object, named "name", from the current one.
  98647. * @param name The name of the cloned light
  98648. * @param newParent The parent of this light, if it has one
  98649. * @returns the new created light
  98650. */
  98651. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98652. /**
  98653. * Serializes the current light into a Serialization object.
  98654. * @returns the serialized object.
  98655. */
  98656. serialize(): any;
  98657. /**
  98658. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98659. * This new light is named "name" and added to the passed scene.
  98660. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98661. * @param name The friendly name of the light
  98662. * @param scene The scene the new light will belong to
  98663. * @returns the constructor function
  98664. */
  98665. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98666. /**
  98667. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98668. * @param parsedLight The JSON representation of the light
  98669. * @param scene The scene to create the parsed light in
  98670. * @returns the created light after parsing
  98671. */
  98672. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98673. private _hookArrayForExcluded;
  98674. private _hookArrayForIncludedOnly;
  98675. private _resyncMeshes;
  98676. /**
  98677. * Forces the meshes to update their light related information in their rendering used effects
  98678. * @hidden Internal Use Only
  98679. */
  98680. _markMeshesAsLightDirty(): void;
  98681. /**
  98682. * Recomputes the cached photometric scale if needed.
  98683. */
  98684. private _computePhotometricScale;
  98685. /**
  98686. * Returns the Photometric Scale according to the light type and intensity mode.
  98687. */
  98688. private _getPhotometricScale;
  98689. /**
  98690. * Reorder the light in the scene according to their defined priority.
  98691. * @hidden Internal Use Only
  98692. */
  98693. _reorderLightsInScene(): void;
  98694. /**
  98695. * Prepares the list of defines specific to the light type.
  98696. * @param defines the list of defines
  98697. * @param lightIndex defines the index of the light for the effect
  98698. */
  98699. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98700. }
  98701. }
  98702. declare module BABYLON {
  98703. /**
  98704. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98705. * This is the base of the follow, arc rotate cameras and Free camera
  98706. * @see https://doc.babylonjs.com/features/cameras
  98707. */
  98708. export class TargetCamera extends Camera {
  98709. private static _RigCamTransformMatrix;
  98710. private static _TargetTransformMatrix;
  98711. private static _TargetFocalPoint;
  98712. private _tmpUpVector;
  98713. private _tmpTargetVector;
  98714. /**
  98715. * Define the current direction the camera is moving to
  98716. */
  98717. cameraDirection: Vector3;
  98718. /**
  98719. * Define the current rotation the camera is rotating to
  98720. */
  98721. cameraRotation: Vector2;
  98722. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98723. ignoreParentScaling: boolean;
  98724. /**
  98725. * When set, the up vector of the camera will be updated by the rotation of the camera
  98726. */
  98727. updateUpVectorFromRotation: boolean;
  98728. private _tmpQuaternion;
  98729. /**
  98730. * Define the current rotation of the camera
  98731. */
  98732. rotation: Vector3;
  98733. /**
  98734. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98735. */
  98736. rotationQuaternion: Quaternion;
  98737. /**
  98738. * Define the current speed of the camera
  98739. */
  98740. speed: number;
  98741. /**
  98742. * Add constraint to the camera to prevent it to move freely in all directions and
  98743. * around all axis.
  98744. */
  98745. noRotationConstraint: boolean;
  98746. /**
  98747. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98748. * panning
  98749. */
  98750. invertRotation: boolean;
  98751. /**
  98752. * Speed multiplier for inverse camera panning
  98753. */
  98754. inverseRotationSpeed: number;
  98755. /**
  98756. * Define the current target of the camera as an object or a position.
  98757. */
  98758. lockedTarget: any;
  98759. /** @hidden */
  98760. _currentTarget: Vector3;
  98761. /** @hidden */
  98762. _initialFocalDistance: number;
  98763. /** @hidden */
  98764. _viewMatrix: Matrix;
  98765. /** @hidden */
  98766. _camMatrix: Matrix;
  98767. /** @hidden */
  98768. _cameraTransformMatrix: Matrix;
  98769. /** @hidden */
  98770. _cameraRotationMatrix: Matrix;
  98771. /** @hidden */
  98772. _referencePoint: Vector3;
  98773. /** @hidden */
  98774. _transformedReferencePoint: Vector3;
  98775. /** @hidden */
  98776. _reset: () => void;
  98777. private _defaultUp;
  98778. /**
  98779. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98780. * This is the base of the follow, arc rotate cameras and Free camera
  98781. * @see https://doc.babylonjs.com/features/cameras
  98782. * @param name Defines the name of the camera in the scene
  98783. * @param position Defines the start position of the camera in the scene
  98784. * @param scene Defines the scene the camera belongs to
  98785. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98786. */
  98787. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98788. /**
  98789. * Gets the position in front of the camera at a given distance.
  98790. * @param distance The distance from the camera we want the position to be
  98791. * @returns the position
  98792. */
  98793. getFrontPosition(distance: number): Vector3;
  98794. /** @hidden */
  98795. _getLockedTargetPosition(): Nullable<Vector3>;
  98796. private _storedPosition;
  98797. private _storedRotation;
  98798. private _storedRotationQuaternion;
  98799. /**
  98800. * Store current camera state of the camera (fov, position, rotation, etc..)
  98801. * @returns the camera
  98802. */
  98803. storeState(): Camera;
  98804. /**
  98805. * Restored camera state. You must call storeState() first
  98806. * @returns whether it was successful or not
  98807. * @hidden
  98808. */
  98809. _restoreStateValues(): boolean;
  98810. /** @hidden */
  98811. _initCache(): void;
  98812. /** @hidden */
  98813. _updateCache(ignoreParentClass?: boolean): void;
  98814. /** @hidden */
  98815. _isSynchronizedViewMatrix(): boolean;
  98816. /** @hidden */
  98817. _computeLocalCameraSpeed(): number;
  98818. /**
  98819. * Defines the target the camera should look at.
  98820. * @param target Defines the new target as a Vector or a mesh
  98821. */
  98822. setTarget(target: Vector3): void;
  98823. /**
  98824. * Defines the target point of the camera.
  98825. * The camera looks towards it form the radius distance.
  98826. */
  98827. get target(): Vector3;
  98828. set target(value: Vector3);
  98829. /**
  98830. * Return the current target position of the camera. This value is expressed in local space.
  98831. * @returns the target position
  98832. */
  98833. getTarget(): Vector3;
  98834. /** @hidden */
  98835. _decideIfNeedsToMove(): boolean;
  98836. /** @hidden */
  98837. _updatePosition(): void;
  98838. /** @hidden */
  98839. _checkInputs(): void;
  98840. protected _updateCameraRotationMatrix(): void;
  98841. /**
  98842. * 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)
  98843. * @returns the current camera
  98844. */
  98845. private _rotateUpVectorWithCameraRotationMatrix;
  98846. private _cachedRotationZ;
  98847. private _cachedQuaternionRotationZ;
  98848. /** @hidden */
  98849. _getViewMatrix(): Matrix;
  98850. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98851. /**
  98852. * @hidden
  98853. */
  98854. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98855. /**
  98856. * @hidden
  98857. */
  98858. _updateRigCameras(): void;
  98859. private _getRigCamPositionAndTarget;
  98860. /**
  98861. * Gets the current object class name.
  98862. * @return the class name
  98863. */
  98864. getClassName(): string;
  98865. }
  98866. }
  98867. declare module BABYLON {
  98868. /**
  98869. * Gather the list of keyboard event types as constants.
  98870. */
  98871. export class KeyboardEventTypes {
  98872. /**
  98873. * The keydown event is fired when a key becomes active (pressed).
  98874. */
  98875. static readonly KEYDOWN: number;
  98876. /**
  98877. * The keyup event is fired when a key has been released.
  98878. */
  98879. static readonly KEYUP: number;
  98880. }
  98881. /**
  98882. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98883. */
  98884. export class KeyboardInfo {
  98885. /**
  98886. * Defines the type of event (KeyboardEventTypes)
  98887. */
  98888. type: number;
  98889. /**
  98890. * Defines the related dom event
  98891. */
  98892. event: KeyboardEvent;
  98893. /**
  98894. * Instantiates a new keyboard info.
  98895. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98896. * @param type Defines the type of event (KeyboardEventTypes)
  98897. * @param event Defines the related dom event
  98898. */
  98899. constructor(
  98900. /**
  98901. * Defines the type of event (KeyboardEventTypes)
  98902. */
  98903. type: number,
  98904. /**
  98905. * Defines the related dom event
  98906. */
  98907. event: KeyboardEvent);
  98908. }
  98909. /**
  98910. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98911. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98912. */
  98913. export class KeyboardInfoPre extends KeyboardInfo {
  98914. /**
  98915. * Defines the type of event (KeyboardEventTypes)
  98916. */
  98917. type: number;
  98918. /**
  98919. * Defines the related dom event
  98920. */
  98921. event: KeyboardEvent;
  98922. /**
  98923. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98924. */
  98925. skipOnPointerObservable: boolean;
  98926. /**
  98927. * Instantiates a new keyboard pre info.
  98928. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98929. * @param type Defines the type of event (KeyboardEventTypes)
  98930. * @param event Defines the related dom event
  98931. */
  98932. constructor(
  98933. /**
  98934. * Defines the type of event (KeyboardEventTypes)
  98935. */
  98936. type: number,
  98937. /**
  98938. * Defines the related dom event
  98939. */
  98940. event: KeyboardEvent);
  98941. }
  98942. }
  98943. declare module BABYLON {
  98944. /**
  98945. * Manage the keyboard inputs to control the movement of a free camera.
  98946. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98947. */
  98948. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98949. /**
  98950. * Defines the camera the input is attached to.
  98951. */
  98952. camera: FreeCamera;
  98953. /**
  98954. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98955. */
  98956. keysUp: number[];
  98957. /**
  98958. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98959. */
  98960. keysUpward: number[];
  98961. /**
  98962. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98963. */
  98964. keysDown: number[];
  98965. /**
  98966. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98967. */
  98968. keysDownward: number[];
  98969. /**
  98970. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98971. */
  98972. keysLeft: number[];
  98973. /**
  98974. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98975. */
  98976. keysRight: number[];
  98977. private _keys;
  98978. private _onCanvasBlurObserver;
  98979. private _onKeyboardObserver;
  98980. private _engine;
  98981. private _scene;
  98982. /**
  98983. * Attach the input controls to a specific dom element to get the input from.
  98984. * @param element Defines the element the controls should be listened from
  98985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98986. */
  98987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98988. /**
  98989. * Detach the current controls from the specified dom element.
  98990. * @param element Defines the element to stop listening the inputs from
  98991. */
  98992. detachControl(element: Nullable<HTMLElement>): void;
  98993. /**
  98994. * Update the current camera state depending on the inputs that have been used this frame.
  98995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98996. */
  98997. checkInputs(): void;
  98998. /**
  98999. * Gets the class name of the current intput.
  99000. * @returns the class name
  99001. */
  99002. getClassName(): string;
  99003. /** @hidden */
  99004. _onLostFocus(): void;
  99005. /**
  99006. * Get the friendly name associated with the input class.
  99007. * @returns the input friendly name
  99008. */
  99009. getSimpleName(): string;
  99010. }
  99011. }
  99012. declare module BABYLON {
  99013. /**
  99014. * Gather the list of pointer event types as constants.
  99015. */
  99016. export class PointerEventTypes {
  99017. /**
  99018. * 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.
  99019. */
  99020. static readonly POINTERDOWN: number;
  99021. /**
  99022. * The pointerup event is fired when a pointer is no longer active.
  99023. */
  99024. static readonly POINTERUP: number;
  99025. /**
  99026. * The pointermove event is fired when a pointer changes coordinates.
  99027. */
  99028. static readonly POINTERMOVE: number;
  99029. /**
  99030. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99031. */
  99032. static readonly POINTERWHEEL: number;
  99033. /**
  99034. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99035. */
  99036. static readonly POINTERPICK: number;
  99037. /**
  99038. * The pointertap event is fired when a the object has been touched and released without drag.
  99039. */
  99040. static readonly POINTERTAP: number;
  99041. /**
  99042. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99043. */
  99044. static readonly POINTERDOUBLETAP: number;
  99045. }
  99046. /**
  99047. * Base class of pointer info types.
  99048. */
  99049. export class PointerInfoBase {
  99050. /**
  99051. * Defines the type of event (PointerEventTypes)
  99052. */
  99053. type: number;
  99054. /**
  99055. * Defines the related dom event
  99056. */
  99057. event: PointerEvent | MouseWheelEvent;
  99058. /**
  99059. * Instantiates the base class of pointers info.
  99060. * @param type Defines the type of event (PointerEventTypes)
  99061. * @param event Defines the related dom event
  99062. */
  99063. constructor(
  99064. /**
  99065. * Defines the type of event (PointerEventTypes)
  99066. */
  99067. type: number,
  99068. /**
  99069. * Defines the related dom event
  99070. */
  99071. event: PointerEvent | MouseWheelEvent);
  99072. }
  99073. /**
  99074. * This class is used to store pointer related info for the onPrePointerObservable event.
  99075. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99076. */
  99077. export class PointerInfoPre extends PointerInfoBase {
  99078. /**
  99079. * Ray from a pointer if availible (eg. 6dof controller)
  99080. */
  99081. ray: Nullable<Ray>;
  99082. /**
  99083. * Defines the local position of the pointer on the canvas.
  99084. */
  99085. localPosition: Vector2;
  99086. /**
  99087. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99088. */
  99089. skipOnPointerObservable: boolean;
  99090. /**
  99091. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99092. * @param type Defines the type of event (PointerEventTypes)
  99093. * @param event Defines the related dom event
  99094. * @param localX Defines the local x coordinates of the pointer when the event occured
  99095. * @param localY Defines the local y coordinates of the pointer when the event occured
  99096. */
  99097. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99098. }
  99099. /**
  99100. * This type contains all the data related to a pointer event in Babylon.js.
  99101. * 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.
  99102. */
  99103. export class PointerInfo extends PointerInfoBase {
  99104. /**
  99105. * Defines the picking info associated to the info (if any)\
  99106. */
  99107. pickInfo: Nullable<PickingInfo>;
  99108. /**
  99109. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99110. * @param type Defines the type of event (PointerEventTypes)
  99111. * @param event Defines the related dom event
  99112. * @param pickInfo Defines the picking info associated to the info (if any)\
  99113. */
  99114. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99115. /**
  99116. * Defines the picking info associated to the info (if any)\
  99117. */
  99118. pickInfo: Nullable<PickingInfo>);
  99119. }
  99120. /**
  99121. * Data relating to a touch event on the screen.
  99122. */
  99123. export interface PointerTouch {
  99124. /**
  99125. * X coordinate of touch.
  99126. */
  99127. x: number;
  99128. /**
  99129. * Y coordinate of touch.
  99130. */
  99131. y: number;
  99132. /**
  99133. * Id of touch. Unique for each finger.
  99134. */
  99135. pointerId: number;
  99136. /**
  99137. * Event type passed from DOM.
  99138. */
  99139. type: any;
  99140. }
  99141. }
  99142. declare module BABYLON {
  99143. /**
  99144. * Manage the mouse inputs to control the movement of a free camera.
  99145. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99146. */
  99147. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99148. /**
  99149. * Define if touch is enabled in the mouse input
  99150. */
  99151. touchEnabled: boolean;
  99152. /**
  99153. * Defines the camera the input is attached to.
  99154. */
  99155. camera: FreeCamera;
  99156. /**
  99157. * Defines the buttons associated with the input to handle camera move.
  99158. */
  99159. buttons: number[];
  99160. /**
  99161. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99162. */
  99163. angularSensibility: number;
  99164. private _pointerInput;
  99165. private _onMouseMove;
  99166. private _observer;
  99167. private previousPosition;
  99168. /**
  99169. * Observable for when a pointer move event occurs containing the move offset
  99170. */
  99171. onPointerMovedObservable: Observable<{
  99172. offsetX: number;
  99173. offsetY: number;
  99174. }>;
  99175. /**
  99176. * @hidden
  99177. * If the camera should be rotated automatically based on pointer movement
  99178. */
  99179. _allowCameraRotation: boolean;
  99180. /**
  99181. * Manage the mouse inputs to control the movement of a free camera.
  99182. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99183. * @param touchEnabled Defines if touch is enabled or not
  99184. */
  99185. constructor(
  99186. /**
  99187. * Define if touch is enabled in the mouse input
  99188. */
  99189. touchEnabled?: boolean);
  99190. /**
  99191. * Attach the input controls to a specific dom element to get the input from.
  99192. * @param element Defines the element the controls should be listened from
  99193. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99194. */
  99195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99196. /**
  99197. * Called on JS contextmenu event.
  99198. * Override this method to provide functionality.
  99199. */
  99200. protected onContextMenu(evt: PointerEvent): void;
  99201. /**
  99202. * Detach the current controls from the specified dom element.
  99203. * @param element Defines the element to stop listening the inputs from
  99204. */
  99205. detachControl(element: Nullable<HTMLElement>): void;
  99206. /**
  99207. * Gets the class name of the current intput.
  99208. * @returns the class name
  99209. */
  99210. getClassName(): string;
  99211. /**
  99212. * Get the friendly name associated with the input class.
  99213. * @returns the input friendly name
  99214. */
  99215. getSimpleName(): string;
  99216. }
  99217. }
  99218. declare module BABYLON {
  99219. /**
  99220. * Manage the touch inputs to control the movement of a free camera.
  99221. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99222. */
  99223. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99224. /**
  99225. * Define if mouse events can be treated as touch events
  99226. */
  99227. allowMouse: boolean;
  99228. /**
  99229. * Defines the camera the input is attached to.
  99230. */
  99231. camera: FreeCamera;
  99232. /**
  99233. * Defines the touch sensibility for rotation.
  99234. * The higher the faster.
  99235. */
  99236. touchAngularSensibility: number;
  99237. /**
  99238. * Defines the touch sensibility for move.
  99239. * The higher the faster.
  99240. */
  99241. touchMoveSensibility: number;
  99242. private _offsetX;
  99243. private _offsetY;
  99244. private _pointerPressed;
  99245. private _pointerInput;
  99246. private _observer;
  99247. private _onLostFocus;
  99248. /**
  99249. * Manage the touch inputs to control the movement of a free camera.
  99250. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99251. * @param allowMouse Defines if mouse events can be treated as touch events
  99252. */
  99253. constructor(
  99254. /**
  99255. * Define if mouse events can be treated as touch events
  99256. */
  99257. allowMouse?: boolean);
  99258. /**
  99259. * Attach the input controls to a specific dom element to get the input from.
  99260. * @param element Defines the element the controls should be listened from
  99261. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99262. */
  99263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99264. /**
  99265. * Detach the current controls from the specified dom element.
  99266. * @param element Defines the element to stop listening the inputs from
  99267. */
  99268. detachControl(element: Nullable<HTMLElement>): void;
  99269. /**
  99270. * Update the current camera state depending on the inputs that have been used this frame.
  99271. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99272. */
  99273. checkInputs(): void;
  99274. /**
  99275. * Gets the class name of the current intput.
  99276. * @returns the class name
  99277. */
  99278. getClassName(): string;
  99279. /**
  99280. * Get the friendly name associated with the input class.
  99281. * @returns the input friendly name
  99282. */
  99283. getSimpleName(): string;
  99284. }
  99285. }
  99286. declare module BABYLON {
  99287. /**
  99288. * Default Inputs manager for the FreeCamera.
  99289. * It groups all the default supported inputs for ease of use.
  99290. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99291. */
  99292. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99293. /**
  99294. * @hidden
  99295. */
  99296. _mouseInput: Nullable<FreeCameraMouseInput>;
  99297. /**
  99298. * Instantiates a new FreeCameraInputsManager.
  99299. * @param camera Defines the camera the inputs belong to
  99300. */
  99301. constructor(camera: FreeCamera);
  99302. /**
  99303. * Add keyboard input support to the input manager.
  99304. * @returns the current input manager
  99305. */
  99306. addKeyboard(): FreeCameraInputsManager;
  99307. /**
  99308. * Add mouse input support to the input manager.
  99309. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99310. * @returns the current input manager
  99311. */
  99312. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99313. /**
  99314. * Removes the mouse input support from the manager
  99315. * @returns the current input manager
  99316. */
  99317. removeMouse(): FreeCameraInputsManager;
  99318. /**
  99319. * Add touch input support to the input manager.
  99320. * @returns the current input manager
  99321. */
  99322. addTouch(): FreeCameraInputsManager;
  99323. /**
  99324. * Remove all attached input methods from a camera
  99325. */
  99326. clear(): void;
  99327. }
  99328. }
  99329. declare module BABYLON {
  99330. /**
  99331. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99332. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99333. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99334. */
  99335. export class FreeCamera extends TargetCamera {
  99336. /**
  99337. * Define the collision ellipsoid of the camera.
  99338. * This is helpful to simulate a camera body like the player body around the camera
  99339. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99340. */
  99341. ellipsoid: Vector3;
  99342. /**
  99343. * Define an offset for the position of the ellipsoid around the camera.
  99344. * This can be helpful to determine the center of the body near the gravity center of the body
  99345. * instead of its head.
  99346. */
  99347. ellipsoidOffset: Vector3;
  99348. /**
  99349. * Enable or disable collisions of the camera with the rest of the scene objects.
  99350. */
  99351. checkCollisions: boolean;
  99352. /**
  99353. * Enable or disable gravity on the camera.
  99354. */
  99355. applyGravity: boolean;
  99356. /**
  99357. * Define the input manager associated to the camera.
  99358. */
  99359. inputs: FreeCameraInputsManager;
  99360. /**
  99361. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99362. * Higher values reduce sensitivity.
  99363. */
  99364. get angularSensibility(): number;
  99365. /**
  99366. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99367. * Higher values reduce sensitivity.
  99368. */
  99369. set angularSensibility(value: number);
  99370. /**
  99371. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99372. */
  99373. get keysUp(): number[];
  99374. set keysUp(value: number[]);
  99375. /**
  99376. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99377. */
  99378. get keysUpward(): number[];
  99379. set keysUpward(value: number[]);
  99380. /**
  99381. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99382. */
  99383. get keysDown(): number[];
  99384. set keysDown(value: number[]);
  99385. /**
  99386. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99387. */
  99388. get keysDownward(): number[];
  99389. set keysDownward(value: number[]);
  99390. /**
  99391. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99392. */
  99393. get keysLeft(): number[];
  99394. set keysLeft(value: number[]);
  99395. /**
  99396. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99397. */
  99398. get keysRight(): number[];
  99399. set keysRight(value: number[]);
  99400. /**
  99401. * Event raised when the camera collide with a mesh in the scene.
  99402. */
  99403. onCollide: (collidedMesh: AbstractMesh) => void;
  99404. private _collider;
  99405. private _needMoveForGravity;
  99406. private _oldPosition;
  99407. private _diffPosition;
  99408. private _newPosition;
  99409. /** @hidden */
  99410. _localDirection: Vector3;
  99411. /** @hidden */
  99412. _transformedDirection: Vector3;
  99413. /**
  99414. * Instantiates a Free Camera.
  99415. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99416. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99417. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99418. * @param name Define the name of the camera in the scene
  99419. * @param position Define the start position of the camera in the scene
  99420. * @param scene Define the scene the camera belongs to
  99421. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99422. */
  99423. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99424. /**
  99425. * Attached controls to the current camera.
  99426. * @param element Defines the element the controls should be listened from
  99427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99428. */
  99429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99430. /**
  99431. * Detach the current controls from the camera.
  99432. * The camera will stop reacting to inputs.
  99433. * @param element Defines the element to stop listening the inputs from
  99434. */
  99435. detachControl(element: HTMLElement): void;
  99436. private _collisionMask;
  99437. /**
  99438. * Define a collision mask to limit the list of object the camera can collide with
  99439. */
  99440. get collisionMask(): number;
  99441. set collisionMask(mask: number);
  99442. /** @hidden */
  99443. _collideWithWorld(displacement: Vector3): void;
  99444. private _onCollisionPositionChange;
  99445. /** @hidden */
  99446. _checkInputs(): void;
  99447. /** @hidden */
  99448. _decideIfNeedsToMove(): boolean;
  99449. /** @hidden */
  99450. _updatePosition(): void;
  99451. /**
  99452. * Destroy the camera and release the current resources hold by it.
  99453. */
  99454. dispose(): void;
  99455. /**
  99456. * Gets the current object class name.
  99457. * @return the class name
  99458. */
  99459. getClassName(): string;
  99460. }
  99461. }
  99462. declare module BABYLON {
  99463. /**
  99464. * Represents a gamepad control stick position
  99465. */
  99466. export class StickValues {
  99467. /**
  99468. * The x component of the control stick
  99469. */
  99470. x: number;
  99471. /**
  99472. * The y component of the control stick
  99473. */
  99474. y: number;
  99475. /**
  99476. * Initializes the gamepad x and y control stick values
  99477. * @param x The x component of the gamepad control stick value
  99478. * @param y The y component of the gamepad control stick value
  99479. */
  99480. constructor(
  99481. /**
  99482. * The x component of the control stick
  99483. */
  99484. x: number,
  99485. /**
  99486. * The y component of the control stick
  99487. */
  99488. y: number);
  99489. }
  99490. /**
  99491. * An interface which manages callbacks for gamepad button changes
  99492. */
  99493. export interface GamepadButtonChanges {
  99494. /**
  99495. * Called when a gamepad has been changed
  99496. */
  99497. changed: boolean;
  99498. /**
  99499. * Called when a gamepad press event has been triggered
  99500. */
  99501. pressChanged: boolean;
  99502. /**
  99503. * Called when a touch event has been triggered
  99504. */
  99505. touchChanged: boolean;
  99506. /**
  99507. * Called when a value has changed
  99508. */
  99509. valueChanged: boolean;
  99510. }
  99511. /**
  99512. * Represents a gamepad
  99513. */
  99514. export class Gamepad {
  99515. /**
  99516. * The id of the gamepad
  99517. */
  99518. id: string;
  99519. /**
  99520. * The index of the gamepad
  99521. */
  99522. index: number;
  99523. /**
  99524. * The browser gamepad
  99525. */
  99526. browserGamepad: any;
  99527. /**
  99528. * Specifies what type of gamepad this represents
  99529. */
  99530. type: number;
  99531. private _leftStick;
  99532. private _rightStick;
  99533. /** @hidden */
  99534. _isConnected: boolean;
  99535. private _leftStickAxisX;
  99536. private _leftStickAxisY;
  99537. private _rightStickAxisX;
  99538. private _rightStickAxisY;
  99539. /**
  99540. * Triggered when the left control stick has been changed
  99541. */
  99542. private _onleftstickchanged;
  99543. /**
  99544. * Triggered when the right control stick has been changed
  99545. */
  99546. private _onrightstickchanged;
  99547. /**
  99548. * Represents a gamepad controller
  99549. */
  99550. static GAMEPAD: number;
  99551. /**
  99552. * Represents a generic controller
  99553. */
  99554. static GENERIC: number;
  99555. /**
  99556. * Represents an XBox controller
  99557. */
  99558. static XBOX: number;
  99559. /**
  99560. * Represents a pose-enabled controller
  99561. */
  99562. static POSE_ENABLED: number;
  99563. /**
  99564. * Represents an Dual Shock controller
  99565. */
  99566. static DUALSHOCK: number;
  99567. /**
  99568. * Specifies whether the left control stick should be Y-inverted
  99569. */
  99570. protected _invertLeftStickY: boolean;
  99571. /**
  99572. * Specifies if the gamepad has been connected
  99573. */
  99574. get isConnected(): boolean;
  99575. /**
  99576. * Initializes the gamepad
  99577. * @param id The id of the gamepad
  99578. * @param index The index of the gamepad
  99579. * @param browserGamepad The browser gamepad
  99580. * @param leftStickX The x component of the left joystick
  99581. * @param leftStickY The y component of the left joystick
  99582. * @param rightStickX The x component of the right joystick
  99583. * @param rightStickY The y component of the right joystick
  99584. */
  99585. constructor(
  99586. /**
  99587. * The id of the gamepad
  99588. */
  99589. id: string,
  99590. /**
  99591. * The index of the gamepad
  99592. */
  99593. index: number,
  99594. /**
  99595. * The browser gamepad
  99596. */
  99597. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99598. /**
  99599. * Callback triggered when the left joystick has changed
  99600. * @param callback
  99601. */
  99602. onleftstickchanged(callback: (values: StickValues) => void): void;
  99603. /**
  99604. * Callback triggered when the right joystick has changed
  99605. * @param callback
  99606. */
  99607. onrightstickchanged(callback: (values: StickValues) => void): void;
  99608. /**
  99609. * Gets the left joystick
  99610. */
  99611. get leftStick(): StickValues;
  99612. /**
  99613. * Sets the left joystick values
  99614. */
  99615. set leftStick(newValues: StickValues);
  99616. /**
  99617. * Gets the right joystick
  99618. */
  99619. get rightStick(): StickValues;
  99620. /**
  99621. * Sets the right joystick value
  99622. */
  99623. set rightStick(newValues: StickValues);
  99624. /**
  99625. * Updates the gamepad joystick positions
  99626. */
  99627. update(): void;
  99628. /**
  99629. * Disposes the gamepad
  99630. */
  99631. dispose(): void;
  99632. }
  99633. /**
  99634. * Represents a generic gamepad
  99635. */
  99636. export class GenericPad extends Gamepad {
  99637. private _buttons;
  99638. private _onbuttondown;
  99639. private _onbuttonup;
  99640. /**
  99641. * Observable triggered when a button has been pressed
  99642. */
  99643. onButtonDownObservable: Observable<number>;
  99644. /**
  99645. * Observable triggered when a button has been released
  99646. */
  99647. onButtonUpObservable: Observable<number>;
  99648. /**
  99649. * Callback triggered when a button has been pressed
  99650. * @param callback Called when a button has been pressed
  99651. */
  99652. onbuttondown(callback: (buttonPressed: number) => void): void;
  99653. /**
  99654. * Callback triggered when a button has been released
  99655. * @param callback Called when a button has been released
  99656. */
  99657. onbuttonup(callback: (buttonReleased: number) => void): void;
  99658. /**
  99659. * Initializes the generic gamepad
  99660. * @param id The id of the generic gamepad
  99661. * @param index The index of the generic gamepad
  99662. * @param browserGamepad The browser gamepad
  99663. */
  99664. constructor(id: string, index: number, browserGamepad: any);
  99665. private _setButtonValue;
  99666. /**
  99667. * Updates the generic gamepad
  99668. */
  99669. update(): void;
  99670. /**
  99671. * Disposes the generic gamepad
  99672. */
  99673. dispose(): void;
  99674. }
  99675. }
  99676. declare module BABYLON {
  99677. /**
  99678. * Defines the types of pose enabled controllers that are supported
  99679. */
  99680. export enum PoseEnabledControllerType {
  99681. /**
  99682. * HTC Vive
  99683. */
  99684. VIVE = 0,
  99685. /**
  99686. * Oculus Rift
  99687. */
  99688. OCULUS = 1,
  99689. /**
  99690. * Windows mixed reality
  99691. */
  99692. WINDOWS = 2,
  99693. /**
  99694. * Samsung gear VR
  99695. */
  99696. GEAR_VR = 3,
  99697. /**
  99698. * Google Daydream
  99699. */
  99700. DAYDREAM = 4,
  99701. /**
  99702. * Generic
  99703. */
  99704. GENERIC = 5
  99705. }
  99706. /**
  99707. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99708. */
  99709. export interface MutableGamepadButton {
  99710. /**
  99711. * Value of the button/trigger
  99712. */
  99713. value: number;
  99714. /**
  99715. * If the button/trigger is currently touched
  99716. */
  99717. touched: boolean;
  99718. /**
  99719. * If the button/trigger is currently pressed
  99720. */
  99721. pressed: boolean;
  99722. }
  99723. /**
  99724. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99725. * @hidden
  99726. */
  99727. export interface ExtendedGamepadButton extends GamepadButton {
  99728. /**
  99729. * If the button/trigger is currently pressed
  99730. */
  99731. readonly pressed: boolean;
  99732. /**
  99733. * If the button/trigger is currently touched
  99734. */
  99735. readonly touched: boolean;
  99736. /**
  99737. * Value of the button/trigger
  99738. */
  99739. readonly value: number;
  99740. }
  99741. /** @hidden */
  99742. export interface _GamePadFactory {
  99743. /**
  99744. * Returns whether or not the current gamepad can be created for this type of controller.
  99745. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99746. * @returns true if it can be created, otherwise false
  99747. */
  99748. canCreate(gamepadInfo: any): boolean;
  99749. /**
  99750. * Creates a new instance of the Gamepad.
  99751. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99752. * @returns the new gamepad instance
  99753. */
  99754. create(gamepadInfo: any): Gamepad;
  99755. }
  99756. /**
  99757. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99758. */
  99759. export class PoseEnabledControllerHelper {
  99760. /** @hidden */
  99761. static _ControllerFactories: _GamePadFactory[];
  99762. /** @hidden */
  99763. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99764. /**
  99765. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99766. * @param vrGamepad the gamepad to initialized
  99767. * @returns a vr controller of the type the gamepad identified as
  99768. */
  99769. static InitiateController(vrGamepad: any): Gamepad;
  99770. }
  99771. /**
  99772. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99773. */
  99774. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99775. /**
  99776. * If the controller is used in a webXR session
  99777. */
  99778. isXR: boolean;
  99779. private _deviceRoomPosition;
  99780. private _deviceRoomRotationQuaternion;
  99781. /**
  99782. * The device position in babylon space
  99783. */
  99784. devicePosition: Vector3;
  99785. /**
  99786. * The device rotation in babylon space
  99787. */
  99788. deviceRotationQuaternion: Quaternion;
  99789. /**
  99790. * The scale factor of the device in babylon space
  99791. */
  99792. deviceScaleFactor: number;
  99793. /**
  99794. * (Likely devicePosition should be used instead) The device position in its room space
  99795. */
  99796. position: Vector3;
  99797. /**
  99798. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99799. */
  99800. rotationQuaternion: Quaternion;
  99801. /**
  99802. * The type of controller (Eg. Windows mixed reality)
  99803. */
  99804. controllerType: PoseEnabledControllerType;
  99805. protected _calculatedPosition: Vector3;
  99806. private _calculatedRotation;
  99807. /**
  99808. * The raw pose from the device
  99809. */
  99810. rawPose: DevicePose;
  99811. private _trackPosition;
  99812. private _maxRotationDistFromHeadset;
  99813. private _draggedRoomRotation;
  99814. /**
  99815. * @hidden
  99816. */
  99817. _disableTrackPosition(fixedPosition: Vector3): void;
  99818. /**
  99819. * Internal, the mesh attached to the controller
  99820. * @hidden
  99821. */
  99822. _mesh: Nullable<AbstractMesh>;
  99823. private _poseControlledCamera;
  99824. private _leftHandSystemQuaternion;
  99825. /**
  99826. * Internal, matrix used to convert room space to babylon space
  99827. * @hidden
  99828. */
  99829. _deviceToWorld: Matrix;
  99830. /**
  99831. * Node to be used when casting a ray from the controller
  99832. * @hidden
  99833. */
  99834. _pointingPoseNode: Nullable<TransformNode>;
  99835. /**
  99836. * Name of the child mesh that can be used to cast a ray from the controller
  99837. */
  99838. static readonly POINTING_POSE: string;
  99839. /**
  99840. * Creates a new PoseEnabledController from a gamepad
  99841. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99842. */
  99843. constructor(browserGamepad: any);
  99844. private _workingMatrix;
  99845. /**
  99846. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99847. */
  99848. update(): void;
  99849. /**
  99850. * Updates only the pose device and mesh without doing any button event checking
  99851. */
  99852. protected _updatePoseAndMesh(): void;
  99853. /**
  99854. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99855. * @param poseData raw pose fromthe device
  99856. */
  99857. updateFromDevice(poseData: DevicePose): void;
  99858. /**
  99859. * @hidden
  99860. */
  99861. _meshAttachedObservable: Observable<AbstractMesh>;
  99862. /**
  99863. * Attaches a mesh to the controller
  99864. * @param mesh the mesh to be attached
  99865. */
  99866. attachToMesh(mesh: AbstractMesh): void;
  99867. /**
  99868. * Attaches the controllers mesh to a camera
  99869. * @param camera the camera the mesh should be attached to
  99870. */
  99871. attachToPoseControlledCamera(camera: TargetCamera): void;
  99872. /**
  99873. * Disposes of the controller
  99874. */
  99875. dispose(): void;
  99876. /**
  99877. * The mesh that is attached to the controller
  99878. */
  99879. get mesh(): Nullable<AbstractMesh>;
  99880. /**
  99881. * Gets the ray of the controller in the direction the controller is pointing
  99882. * @param length the length the resulting ray should be
  99883. * @returns a ray in the direction the controller is pointing
  99884. */
  99885. getForwardRay(length?: number): Ray;
  99886. }
  99887. }
  99888. declare module BABYLON {
  99889. /**
  99890. * Defines the WebVRController object that represents controllers tracked in 3D space
  99891. */
  99892. export abstract class WebVRController extends PoseEnabledController {
  99893. /**
  99894. * Internal, the default controller model for the controller
  99895. */
  99896. protected _defaultModel: Nullable<AbstractMesh>;
  99897. /**
  99898. * Fired when the trigger state has changed
  99899. */
  99900. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99901. /**
  99902. * Fired when the main button state has changed
  99903. */
  99904. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99905. /**
  99906. * Fired when the secondary button state has changed
  99907. */
  99908. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99909. /**
  99910. * Fired when the pad state has changed
  99911. */
  99912. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99913. /**
  99914. * Fired when controllers stick values have changed
  99915. */
  99916. onPadValuesChangedObservable: Observable<StickValues>;
  99917. /**
  99918. * Array of button availible on the controller
  99919. */
  99920. protected _buttons: Array<MutableGamepadButton>;
  99921. private _onButtonStateChange;
  99922. /**
  99923. * Fired when a controller button's state has changed
  99924. * @param callback the callback containing the button that was modified
  99925. */
  99926. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99927. /**
  99928. * X and Y axis corresponding to the controllers joystick
  99929. */
  99930. pad: StickValues;
  99931. /**
  99932. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99933. */
  99934. hand: string;
  99935. /**
  99936. * The default controller model for the controller
  99937. */
  99938. get defaultModel(): Nullable<AbstractMesh>;
  99939. /**
  99940. * Creates a new WebVRController from a gamepad
  99941. * @param vrGamepad the gamepad that the WebVRController should be created from
  99942. */
  99943. constructor(vrGamepad: any);
  99944. /**
  99945. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99946. */
  99947. update(): void;
  99948. /**
  99949. * Function to be called when a button is modified
  99950. */
  99951. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99952. /**
  99953. * Loads a mesh and attaches it to the controller
  99954. * @param scene the scene the mesh should be added to
  99955. * @param meshLoaded callback for when the mesh has been loaded
  99956. */
  99957. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99958. private _setButtonValue;
  99959. private _changes;
  99960. private _checkChanges;
  99961. /**
  99962. * Disposes of th webVRCOntroller
  99963. */
  99964. dispose(): void;
  99965. }
  99966. }
  99967. declare module BABYLON {
  99968. /**
  99969. * The HemisphericLight simulates the ambient environment light,
  99970. * so the passed direction is the light reflection direction, not the incoming direction.
  99971. */
  99972. export class HemisphericLight extends Light {
  99973. /**
  99974. * The groundColor is the light in the opposite direction to the one specified during creation.
  99975. * 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.
  99976. */
  99977. groundColor: Color3;
  99978. /**
  99979. * The light reflection direction, not the incoming direction.
  99980. */
  99981. direction: Vector3;
  99982. /**
  99983. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99984. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99985. * The HemisphericLight can't cast shadows.
  99986. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99987. * @param name The friendly name of the light
  99988. * @param direction The direction of the light reflection
  99989. * @param scene The scene the light belongs to
  99990. */
  99991. constructor(name: string, direction: Vector3, scene: Scene);
  99992. protected _buildUniformLayout(): void;
  99993. /**
  99994. * Returns the string "HemisphericLight".
  99995. * @return The class name
  99996. */
  99997. getClassName(): string;
  99998. /**
  99999. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100000. * Returns the updated direction.
  100001. * @param target The target the direction should point to
  100002. * @return The computed direction
  100003. */
  100004. setDirectionToTarget(target: Vector3): Vector3;
  100005. /**
  100006. * Returns the shadow generator associated to the light.
  100007. * @returns Always null for hemispheric lights because it does not support shadows.
  100008. */
  100009. getShadowGenerator(): Nullable<IShadowGenerator>;
  100010. /**
  100011. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100012. * @param effect The effect to update
  100013. * @param lightIndex The index of the light in the effect to update
  100014. * @returns The hemispheric light
  100015. */
  100016. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100017. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100018. /**
  100019. * Computes the world matrix of the node
  100020. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100021. * @param useWasUpdatedFlag defines a reserved property
  100022. * @returns the world matrix
  100023. */
  100024. computeWorldMatrix(): Matrix;
  100025. /**
  100026. * Returns the integer 3.
  100027. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100028. */
  100029. getTypeID(): number;
  100030. /**
  100031. * Prepares the list of defines specific to the light type.
  100032. * @param defines the list of defines
  100033. * @param lightIndex defines the index of the light for the effect
  100034. */
  100035. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100036. }
  100037. }
  100038. declare module BABYLON {
  100039. /** @hidden */
  100040. export var vrMultiviewToSingleviewPixelShader: {
  100041. name: string;
  100042. shader: string;
  100043. };
  100044. }
  100045. declare module BABYLON {
  100046. /**
  100047. * Renders to multiple views with a single draw call
  100048. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100049. */
  100050. export class MultiviewRenderTarget extends RenderTargetTexture {
  100051. /**
  100052. * Creates a multiview render target
  100053. * @param scene scene used with the render target
  100054. * @param size the size of the render target (used for each view)
  100055. */
  100056. constructor(scene: Scene, size?: number | {
  100057. width: number;
  100058. height: number;
  100059. } | {
  100060. ratio: number;
  100061. });
  100062. /**
  100063. * @hidden
  100064. * @param faceIndex the face index, if its a cube texture
  100065. */
  100066. _bindFrameBuffer(faceIndex?: number): void;
  100067. /**
  100068. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100069. * @returns the view count
  100070. */
  100071. getViewCount(): number;
  100072. }
  100073. }
  100074. declare module BABYLON {
  100075. interface Engine {
  100076. /**
  100077. * Creates a new multiview render target
  100078. * @param width defines the width of the texture
  100079. * @param height defines the height of the texture
  100080. * @returns the created multiview texture
  100081. */
  100082. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100083. /**
  100084. * Binds a multiview framebuffer to be drawn to
  100085. * @param multiviewTexture texture to bind
  100086. */
  100087. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100088. }
  100089. interface Camera {
  100090. /**
  100091. * @hidden
  100092. * 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)
  100093. */
  100094. _useMultiviewToSingleView: boolean;
  100095. /**
  100096. * @hidden
  100097. * 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)
  100098. */
  100099. _multiviewTexture: Nullable<RenderTargetTexture>;
  100100. /**
  100101. * @hidden
  100102. * ensures the multiview texture of the camera exists and has the specified width/height
  100103. * @param width height to set on the multiview texture
  100104. * @param height width to set on the multiview texture
  100105. */
  100106. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100107. }
  100108. interface Scene {
  100109. /** @hidden */
  100110. _transformMatrixR: Matrix;
  100111. /** @hidden */
  100112. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100113. /** @hidden */
  100114. _createMultiviewUbo(): void;
  100115. /** @hidden */
  100116. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100117. /** @hidden */
  100118. _renderMultiviewToSingleView(camera: Camera): void;
  100119. }
  100120. }
  100121. declare module BABYLON {
  100122. /**
  100123. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100124. * This will not be used for webXR as it supports displaying texture arrays directly
  100125. */
  100126. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100127. /**
  100128. * Gets a string identifying the name of the class
  100129. * @returns "VRMultiviewToSingleviewPostProcess" string
  100130. */
  100131. getClassName(): string;
  100132. /**
  100133. * Initializes a VRMultiviewToSingleview
  100134. * @param name name of the post process
  100135. * @param camera camera to be applied to
  100136. * @param scaleFactor scaling factor to the size of the output texture
  100137. */
  100138. constructor(name: string, camera: Camera, scaleFactor: number);
  100139. }
  100140. }
  100141. declare module BABYLON {
  100142. /**
  100143. * Interface used to define additional presentation attributes
  100144. */
  100145. export interface IVRPresentationAttributes {
  100146. /**
  100147. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100148. */
  100149. highRefreshRate: boolean;
  100150. /**
  100151. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100152. */
  100153. foveationLevel: number;
  100154. }
  100155. interface Engine {
  100156. /** @hidden */
  100157. _vrDisplay: any;
  100158. /** @hidden */
  100159. _vrSupported: boolean;
  100160. /** @hidden */
  100161. _oldSize: Size;
  100162. /** @hidden */
  100163. _oldHardwareScaleFactor: number;
  100164. /** @hidden */
  100165. _vrExclusivePointerMode: boolean;
  100166. /** @hidden */
  100167. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100168. /** @hidden */
  100169. _onVRDisplayPointerRestricted: () => void;
  100170. /** @hidden */
  100171. _onVRDisplayPointerUnrestricted: () => void;
  100172. /** @hidden */
  100173. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100174. /** @hidden */
  100175. _onVrDisplayDisconnect: Nullable<() => void>;
  100176. /** @hidden */
  100177. _onVrDisplayPresentChange: Nullable<() => void>;
  100178. /**
  100179. * Observable signaled when VR display mode changes
  100180. */
  100181. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100182. /**
  100183. * Observable signaled when VR request present is complete
  100184. */
  100185. onVRRequestPresentComplete: Observable<boolean>;
  100186. /**
  100187. * Observable signaled when VR request present starts
  100188. */
  100189. onVRRequestPresentStart: Observable<Engine>;
  100190. /**
  100191. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100192. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100193. */
  100194. isInVRExclusivePointerMode: boolean;
  100195. /**
  100196. * Gets a boolean indicating if a webVR device was detected
  100197. * @returns true if a webVR device was detected
  100198. */
  100199. isVRDevicePresent(): boolean;
  100200. /**
  100201. * Gets the current webVR device
  100202. * @returns the current webVR device (or null)
  100203. */
  100204. getVRDevice(): any;
  100205. /**
  100206. * Initializes a webVR display and starts listening to display change events
  100207. * The onVRDisplayChangedObservable will be notified upon these changes
  100208. * @returns A promise containing a VRDisplay and if vr is supported
  100209. */
  100210. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100211. /** @hidden */
  100212. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100213. /**
  100214. * Gets or sets the presentation attributes used to configure VR rendering
  100215. */
  100216. vrPresentationAttributes?: IVRPresentationAttributes;
  100217. /**
  100218. * Call this function to switch to webVR mode
  100219. * Will do nothing if webVR is not supported or if there is no webVR device
  100220. * @param options the webvr options provided to the camera. mainly used for multiview
  100221. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100222. */
  100223. enableVR(options: WebVROptions): void;
  100224. /** @hidden */
  100225. _onVRFullScreenTriggered(): void;
  100226. }
  100227. }
  100228. declare module BABYLON {
  100229. /**
  100230. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100231. * IMPORTANT!! The data is right-hand data.
  100232. * @export
  100233. * @interface DevicePose
  100234. */
  100235. export interface DevicePose {
  100236. /**
  100237. * The position of the device, values in array are [x,y,z].
  100238. */
  100239. readonly position: Nullable<Float32Array>;
  100240. /**
  100241. * The linearVelocity of the device, values in array are [x,y,z].
  100242. */
  100243. readonly linearVelocity: Nullable<Float32Array>;
  100244. /**
  100245. * The linearAcceleration of the device, values in array are [x,y,z].
  100246. */
  100247. readonly linearAcceleration: Nullable<Float32Array>;
  100248. /**
  100249. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100250. */
  100251. readonly orientation: Nullable<Float32Array>;
  100252. /**
  100253. * The angularVelocity of the device, values in array are [x,y,z].
  100254. */
  100255. readonly angularVelocity: Nullable<Float32Array>;
  100256. /**
  100257. * The angularAcceleration of the device, values in array are [x,y,z].
  100258. */
  100259. readonly angularAcceleration: Nullable<Float32Array>;
  100260. }
  100261. /**
  100262. * Interface representing a pose controlled object in Babylon.
  100263. * A pose controlled object has both regular pose values as well as pose values
  100264. * from an external device such as a VR head mounted display
  100265. */
  100266. export interface PoseControlled {
  100267. /**
  100268. * The position of the object in babylon space.
  100269. */
  100270. position: Vector3;
  100271. /**
  100272. * The rotation quaternion of the object in babylon space.
  100273. */
  100274. rotationQuaternion: Quaternion;
  100275. /**
  100276. * The position of the device in babylon space.
  100277. */
  100278. devicePosition?: Vector3;
  100279. /**
  100280. * The rotation quaternion of the device in babylon space.
  100281. */
  100282. deviceRotationQuaternion: Quaternion;
  100283. /**
  100284. * The raw pose coming from the device.
  100285. */
  100286. rawPose: Nullable<DevicePose>;
  100287. /**
  100288. * The scale of the device to be used when translating from device space to babylon space.
  100289. */
  100290. deviceScaleFactor: number;
  100291. /**
  100292. * Updates the poseControlled values based on the input device pose.
  100293. * @param poseData the pose data to update the object with
  100294. */
  100295. updateFromDevice(poseData: DevicePose): void;
  100296. }
  100297. /**
  100298. * Set of options to customize the webVRCamera
  100299. */
  100300. export interface WebVROptions {
  100301. /**
  100302. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100303. */
  100304. trackPosition?: boolean;
  100305. /**
  100306. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100307. */
  100308. positionScale?: number;
  100309. /**
  100310. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100311. */
  100312. displayName?: string;
  100313. /**
  100314. * Should the native controller meshes be initialized. (default: true)
  100315. */
  100316. controllerMeshes?: boolean;
  100317. /**
  100318. * Creating a default HemiLight only on controllers. (default: true)
  100319. */
  100320. defaultLightingOnControllers?: boolean;
  100321. /**
  100322. * If you don't want to use the default VR button of the helper. (default: false)
  100323. */
  100324. useCustomVRButton?: boolean;
  100325. /**
  100326. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100327. */
  100328. customVRButton?: HTMLButtonElement;
  100329. /**
  100330. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100331. */
  100332. rayLength?: number;
  100333. /**
  100334. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100335. */
  100336. defaultHeight?: number;
  100337. /**
  100338. * If multiview should be used if availible (default: false)
  100339. */
  100340. useMultiview?: boolean;
  100341. }
  100342. /**
  100343. * This represents a WebVR camera.
  100344. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100345. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100346. */
  100347. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100348. private webVROptions;
  100349. /**
  100350. * @hidden
  100351. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100352. */
  100353. _vrDevice: any;
  100354. /**
  100355. * The rawPose of the vrDevice.
  100356. */
  100357. rawPose: Nullable<DevicePose>;
  100358. private _onVREnabled;
  100359. private _specsVersion;
  100360. private _attached;
  100361. private _frameData;
  100362. protected _descendants: Array<Node>;
  100363. private _deviceRoomPosition;
  100364. /** @hidden */
  100365. _deviceRoomRotationQuaternion: Quaternion;
  100366. private _standingMatrix;
  100367. /**
  100368. * Represents device position in babylon space.
  100369. */
  100370. devicePosition: Vector3;
  100371. /**
  100372. * Represents device rotation in babylon space.
  100373. */
  100374. deviceRotationQuaternion: Quaternion;
  100375. /**
  100376. * The scale of the device to be used when translating from device space to babylon space.
  100377. */
  100378. deviceScaleFactor: number;
  100379. private _deviceToWorld;
  100380. private _worldToDevice;
  100381. /**
  100382. * References to the webVR controllers for the vrDevice.
  100383. */
  100384. controllers: Array<WebVRController>;
  100385. /**
  100386. * Emits an event when a controller is attached.
  100387. */
  100388. onControllersAttachedObservable: Observable<WebVRController[]>;
  100389. /**
  100390. * Emits an event when a controller's mesh has been loaded;
  100391. */
  100392. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100393. /**
  100394. * Emits an event when the HMD's pose has been updated.
  100395. */
  100396. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100397. private _poseSet;
  100398. /**
  100399. * If the rig cameras be used as parent instead of this camera.
  100400. */
  100401. rigParenting: boolean;
  100402. private _lightOnControllers;
  100403. private _defaultHeight?;
  100404. /**
  100405. * Instantiates a WebVRFreeCamera.
  100406. * @param name The name of the WebVRFreeCamera
  100407. * @param position The starting anchor position for the camera
  100408. * @param scene The scene the camera belongs to
  100409. * @param webVROptions a set of customizable options for the webVRCamera
  100410. */
  100411. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100412. /**
  100413. * Gets the device distance from the ground in meters.
  100414. * @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.
  100415. */
  100416. deviceDistanceToRoomGround(): number;
  100417. /**
  100418. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100419. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100420. */
  100421. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100422. /**
  100423. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100424. * @returns A promise with a boolean set to if the standing matrix is supported.
  100425. */
  100426. useStandingMatrixAsync(): Promise<boolean>;
  100427. /**
  100428. * Disposes the camera
  100429. */
  100430. dispose(): void;
  100431. /**
  100432. * Gets a vrController by name.
  100433. * @param name The name of the controller to retreive
  100434. * @returns the controller matching the name specified or null if not found
  100435. */
  100436. getControllerByName(name: string): Nullable<WebVRController>;
  100437. private _leftController;
  100438. /**
  100439. * The controller corresponding to the users left hand.
  100440. */
  100441. get leftController(): Nullable<WebVRController>;
  100442. private _rightController;
  100443. /**
  100444. * The controller corresponding to the users right hand.
  100445. */
  100446. get rightController(): Nullable<WebVRController>;
  100447. /**
  100448. * Casts a ray forward from the vrCamera's gaze.
  100449. * @param length Length of the ray (default: 100)
  100450. * @returns the ray corresponding to the gaze
  100451. */
  100452. getForwardRay(length?: number): Ray;
  100453. /**
  100454. * @hidden
  100455. * Updates the camera based on device's frame data
  100456. */
  100457. _checkInputs(): void;
  100458. /**
  100459. * Updates the poseControlled values based on the input device pose.
  100460. * @param poseData Pose coming from the device
  100461. */
  100462. updateFromDevice(poseData: DevicePose): void;
  100463. private _htmlElementAttached;
  100464. private _detachIfAttached;
  100465. /**
  100466. * WebVR's attach control will start broadcasting frames to the device.
  100467. * Note that in certain browsers (chrome for example) this function must be called
  100468. * within a user-interaction callback. Example:
  100469. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100470. *
  100471. * @param element html element to attach the vrDevice to
  100472. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100473. */
  100474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100475. /**
  100476. * Detaches the camera from the html element and disables VR
  100477. *
  100478. * @param element html element to detach from
  100479. */
  100480. detachControl(element: HTMLElement): void;
  100481. /**
  100482. * @returns the name of this class
  100483. */
  100484. getClassName(): string;
  100485. /**
  100486. * Calls resetPose on the vrDisplay
  100487. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100488. */
  100489. resetToCurrentRotation(): void;
  100490. /**
  100491. * @hidden
  100492. * Updates the rig cameras (left and right eye)
  100493. */
  100494. _updateRigCameras(): void;
  100495. private _workingVector;
  100496. private _oneVector;
  100497. private _workingMatrix;
  100498. private updateCacheCalled;
  100499. private _correctPositionIfNotTrackPosition;
  100500. /**
  100501. * @hidden
  100502. * Updates the cached values of the camera
  100503. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100504. */
  100505. _updateCache(ignoreParentClass?: boolean): void;
  100506. /**
  100507. * @hidden
  100508. * Get current device position in babylon world
  100509. */
  100510. _computeDevicePosition(): void;
  100511. /**
  100512. * Updates the current device position and rotation in the babylon world
  100513. */
  100514. update(): void;
  100515. /**
  100516. * @hidden
  100517. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100518. * @returns an identity matrix
  100519. */
  100520. _getViewMatrix(): Matrix;
  100521. private _tmpMatrix;
  100522. /**
  100523. * This function is called by the two RIG cameras.
  100524. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100525. * @hidden
  100526. */
  100527. _getWebVRViewMatrix(): Matrix;
  100528. /** @hidden */
  100529. _getWebVRProjectionMatrix(): Matrix;
  100530. private _onGamepadConnectedObserver;
  100531. private _onGamepadDisconnectedObserver;
  100532. private _updateCacheWhenTrackingDisabledObserver;
  100533. /**
  100534. * Initializes the controllers and their meshes
  100535. */
  100536. initControllers(): void;
  100537. }
  100538. }
  100539. declare module BABYLON {
  100540. /**
  100541. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100542. *
  100543. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100544. *
  100545. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100546. */
  100547. export class MaterialHelper {
  100548. /**
  100549. * Bind the current view position to an effect.
  100550. * @param effect The effect to be bound
  100551. * @param scene The scene the eyes position is used from
  100552. * @param variableName name of the shader variable that will hold the eye position
  100553. */
  100554. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100555. /**
  100556. * Helps preparing the defines values about the UVs in used in the effect.
  100557. * UVs are shared as much as we can accross channels in the shaders.
  100558. * @param texture The texture we are preparing the UVs for
  100559. * @param defines The defines to update
  100560. * @param key The channel key "diffuse", "specular"... used in the shader
  100561. */
  100562. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100563. /**
  100564. * Binds a texture matrix value to its corrsponding uniform
  100565. * @param texture The texture to bind the matrix for
  100566. * @param uniformBuffer The uniform buffer receivin the data
  100567. * @param key The channel key "diffuse", "specular"... used in the shader
  100568. */
  100569. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100570. /**
  100571. * Gets the current status of the fog (should it be enabled?)
  100572. * @param mesh defines the mesh to evaluate for fog support
  100573. * @param scene defines the hosting scene
  100574. * @returns true if fog must be enabled
  100575. */
  100576. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100577. /**
  100578. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100579. * @param mesh defines the current mesh
  100580. * @param scene defines the current scene
  100581. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100582. * @param pointsCloud defines if point cloud rendering has to be turned on
  100583. * @param fogEnabled defines if fog has to be turned on
  100584. * @param alphaTest defines if alpha testing has to be turned on
  100585. * @param defines defines the current list of defines
  100586. */
  100587. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100588. /**
  100589. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100590. * @param scene defines the current scene
  100591. * @param engine defines the current engine
  100592. * @param defines specifies the list of active defines
  100593. * @param useInstances defines if instances have to be turned on
  100594. * @param useClipPlane defines if clip plane have to be turned on
  100595. * @param useInstances defines if instances have to be turned on
  100596. * @param useThinInstances defines if thin instances have to be turned on
  100597. */
  100598. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100599. /**
  100600. * Prepares the defines for bones
  100601. * @param mesh The mesh containing the geometry data we will draw
  100602. * @param defines The defines to update
  100603. */
  100604. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100605. /**
  100606. * Prepares the defines for morph targets
  100607. * @param mesh The mesh containing the geometry data we will draw
  100608. * @param defines The defines to update
  100609. */
  100610. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100611. /**
  100612. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100613. * @param mesh The mesh containing the geometry data we will draw
  100614. * @param defines The defines to update
  100615. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100616. * @param useBones Precise whether bones should be used or not (override mesh info)
  100617. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100618. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100619. * @returns false if defines are considered not dirty and have not been checked
  100620. */
  100621. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100622. /**
  100623. * Prepares the defines related to multiview
  100624. * @param scene The scene we are intending to draw
  100625. * @param defines The defines to update
  100626. */
  100627. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100628. /**
  100629. * Prepares the defines related to the prepass
  100630. * @param scene The scene we are intending to draw
  100631. * @param defines The defines to update
  100632. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100633. */
  100634. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100635. /**
  100636. * Prepares the defines related to the light information passed in parameter
  100637. * @param scene The scene we are intending to draw
  100638. * @param mesh The mesh the effect is compiling for
  100639. * @param light The light the effect is compiling for
  100640. * @param lightIndex The index of the light
  100641. * @param defines The defines to update
  100642. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100643. * @param state Defines the current state regarding what is needed (normals, etc...)
  100644. */
  100645. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100646. needNormals: boolean;
  100647. needRebuild: boolean;
  100648. shadowEnabled: boolean;
  100649. specularEnabled: boolean;
  100650. lightmapMode: boolean;
  100651. }): void;
  100652. /**
  100653. * Prepares the defines related to the light information passed in parameter
  100654. * @param scene The scene we are intending to draw
  100655. * @param mesh The mesh the effect is compiling for
  100656. * @param defines The defines to update
  100657. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100658. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100659. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100660. * @returns true if normals will be required for the rest of the effect
  100661. */
  100662. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100663. /**
  100664. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100665. * @param lightIndex defines the light index
  100666. * @param uniformsList The uniform list
  100667. * @param samplersList The sampler list
  100668. * @param projectedLightTexture defines if projected texture must be used
  100669. * @param uniformBuffersList defines an optional list of uniform buffers
  100670. */
  100671. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100672. /**
  100673. * Prepares the uniforms and samplers list to be used in the effect
  100674. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100675. * @param samplersList The sampler list
  100676. * @param defines The defines helping in the list generation
  100677. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100678. */
  100679. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100680. /**
  100681. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100682. * @param defines The defines to update while falling back
  100683. * @param fallbacks The authorized effect fallbacks
  100684. * @param maxSimultaneousLights The maximum number of lights allowed
  100685. * @param rank the current rank of the Effect
  100686. * @returns The newly affected rank
  100687. */
  100688. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100689. private static _TmpMorphInfluencers;
  100690. /**
  100691. * Prepares the list of attributes required for morph targets according to the effect defines.
  100692. * @param attribs The current list of supported attribs
  100693. * @param mesh The mesh to prepare the morph targets attributes for
  100694. * @param influencers The number of influencers
  100695. */
  100696. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100697. /**
  100698. * Prepares the list of attributes required for morph targets according to the effect defines.
  100699. * @param attribs The current list of supported attribs
  100700. * @param mesh The mesh to prepare the morph targets attributes for
  100701. * @param defines The current Defines of the effect
  100702. */
  100703. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100704. /**
  100705. * Prepares the list of attributes required for bones according to the effect defines.
  100706. * @param attribs The current list of supported attribs
  100707. * @param mesh The mesh to prepare the bones attributes for
  100708. * @param defines The current Defines of the effect
  100709. * @param fallbacks The current efffect fallback strategy
  100710. */
  100711. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100712. /**
  100713. * Check and prepare the list of attributes required for instances according to the effect defines.
  100714. * @param attribs The current list of supported attribs
  100715. * @param defines The current MaterialDefines of the effect
  100716. */
  100717. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100718. /**
  100719. * Add the list of attributes required for instances to the attribs array.
  100720. * @param attribs The current list of supported attribs
  100721. */
  100722. static PushAttributesForInstances(attribs: string[]): void;
  100723. /**
  100724. * Binds the light information to the effect.
  100725. * @param light The light containing the generator
  100726. * @param effect The effect we are binding the data to
  100727. * @param lightIndex The light index in the effect used to render
  100728. */
  100729. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100730. /**
  100731. * Binds the lights information from the scene to the effect for the given mesh.
  100732. * @param light Light to bind
  100733. * @param lightIndex Light index
  100734. * @param scene The scene where the light belongs to
  100735. * @param effect The effect we are binding the data to
  100736. * @param useSpecular Defines if specular is supported
  100737. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100738. */
  100739. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100740. /**
  100741. * Binds the lights information from the scene to the effect for the given mesh.
  100742. * @param scene The scene the lights belongs to
  100743. * @param mesh The mesh we are binding the information to render
  100744. * @param effect The effect we are binding the data to
  100745. * @param defines The generated defines for the effect
  100746. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100747. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100748. */
  100749. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100750. private static _tempFogColor;
  100751. /**
  100752. * Binds the fog information from the scene to the effect for the given mesh.
  100753. * @param scene The scene the lights belongs to
  100754. * @param mesh The mesh we are binding the information to render
  100755. * @param effect The effect we are binding the data to
  100756. * @param linearSpace Defines if the fog effect is applied in linear space
  100757. */
  100758. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100759. /**
  100760. * Binds the bones information from the mesh to the effect.
  100761. * @param mesh The mesh we are binding the information to render
  100762. * @param effect The effect we are binding the data to
  100763. */
  100764. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100765. /**
  100766. * Binds the morph targets information from the mesh to the effect.
  100767. * @param abstractMesh The mesh we are binding the information to render
  100768. * @param effect The effect we are binding the data to
  100769. */
  100770. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100771. /**
  100772. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100773. * @param defines The generated defines used in the effect
  100774. * @param effect The effect we are binding the data to
  100775. * @param scene The scene we are willing to render with logarithmic scale for
  100776. */
  100777. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100778. /**
  100779. * Binds the clip plane information from the scene to the effect.
  100780. * @param scene The scene the clip plane information are extracted from
  100781. * @param effect The effect we are binding the data to
  100782. */
  100783. static BindClipPlane(effect: Effect, scene: Scene): void;
  100784. }
  100785. }
  100786. declare module BABYLON {
  100787. /**
  100788. * Block used to expose an input value
  100789. */
  100790. export class InputBlock extends NodeMaterialBlock {
  100791. private _mode;
  100792. private _associatedVariableName;
  100793. private _storedValue;
  100794. private _valueCallback;
  100795. private _type;
  100796. private _animationType;
  100797. /** Gets or set a value used to limit the range of float values */
  100798. min: number;
  100799. /** Gets or set a value used to limit the range of float values */
  100800. max: number;
  100801. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100802. isBoolean: boolean;
  100803. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100804. matrixMode: number;
  100805. /** @hidden */
  100806. _systemValue: Nullable<NodeMaterialSystemValues>;
  100807. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100808. isConstant: boolean;
  100809. /** Gets or sets the group to use to display this block in the Inspector */
  100810. groupInInspector: string;
  100811. /** Gets an observable raised when the value is changed */
  100812. onValueChangedObservable: Observable<InputBlock>;
  100813. /**
  100814. * Gets or sets the connection point type (default is float)
  100815. */
  100816. get type(): NodeMaterialBlockConnectionPointTypes;
  100817. /**
  100818. * Creates a new InputBlock
  100819. * @param name defines the block name
  100820. * @param target defines the target of that block (Vertex by default)
  100821. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100822. */
  100823. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100824. /**
  100825. * Validates if a name is a reserve word.
  100826. * @param newName the new name to be given to the node.
  100827. * @returns false if the name is a reserve word, else true.
  100828. */
  100829. validateBlockName(newName: string): boolean;
  100830. /**
  100831. * Gets the output component
  100832. */
  100833. get output(): NodeMaterialConnectionPoint;
  100834. /**
  100835. * Set the source of this connection point to a vertex attribute
  100836. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100837. * @returns the current connection point
  100838. */
  100839. setAsAttribute(attributeName?: string): InputBlock;
  100840. /**
  100841. * Set the source of this connection point to a system value
  100842. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100843. * @returns the current connection point
  100844. */
  100845. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100846. /**
  100847. * Gets or sets the value of that point.
  100848. * Please note that this value will be ignored if valueCallback is defined
  100849. */
  100850. get value(): any;
  100851. set value(value: any);
  100852. /**
  100853. * Gets or sets a callback used to get the value of that point.
  100854. * Please note that setting this value will force the connection point to ignore the value property
  100855. */
  100856. get valueCallback(): () => any;
  100857. set valueCallback(value: () => any);
  100858. /**
  100859. * Gets or sets the associated variable name in the shader
  100860. */
  100861. get associatedVariableName(): string;
  100862. set associatedVariableName(value: string);
  100863. /** Gets or sets the type of animation applied to the input */
  100864. get animationType(): AnimatedInputBlockTypes;
  100865. set animationType(value: AnimatedInputBlockTypes);
  100866. /**
  100867. * Gets a boolean indicating that this connection point not defined yet
  100868. */
  100869. get isUndefined(): boolean;
  100870. /**
  100871. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100872. * In this case the connection point name must be the name of the uniform to use.
  100873. * Can only be set on inputs
  100874. */
  100875. get isUniform(): boolean;
  100876. set isUniform(value: boolean);
  100877. /**
  100878. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100879. * In this case the connection point name must be the name of the attribute to use
  100880. * Can only be set on inputs
  100881. */
  100882. get isAttribute(): boolean;
  100883. set isAttribute(value: boolean);
  100884. /**
  100885. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100886. * Can only be set on exit points
  100887. */
  100888. get isVarying(): boolean;
  100889. set isVarying(value: boolean);
  100890. /**
  100891. * Gets a boolean indicating that the current connection point is a system value
  100892. */
  100893. get isSystemValue(): boolean;
  100894. /**
  100895. * Gets or sets the current well known value or null if not defined as a system value
  100896. */
  100897. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100898. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100899. /**
  100900. * Gets the current class name
  100901. * @returns the class name
  100902. */
  100903. getClassName(): string;
  100904. /**
  100905. * Animate the input if animationType !== None
  100906. * @param scene defines the rendering scene
  100907. */
  100908. animate(scene: Scene): void;
  100909. private _emitDefine;
  100910. initialize(state: NodeMaterialBuildState): void;
  100911. /**
  100912. * Set the input block to its default value (based on its type)
  100913. */
  100914. setDefaultValue(): void;
  100915. private _emitConstant;
  100916. /** @hidden */
  100917. get _noContextSwitch(): boolean;
  100918. private _emit;
  100919. /** @hidden */
  100920. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100921. /** @hidden */
  100922. _transmit(effect: Effect, scene: Scene): void;
  100923. protected _buildBlock(state: NodeMaterialBuildState): void;
  100924. protected _dumpPropertiesCode(): string;
  100925. dispose(): void;
  100926. serialize(): any;
  100927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100928. }
  100929. }
  100930. declare module BABYLON {
  100931. /**
  100932. * Enum used to define the compatibility state between two connection points
  100933. */
  100934. export enum NodeMaterialConnectionPointCompatibilityStates {
  100935. /** Points are compatibles */
  100936. Compatible = 0,
  100937. /** Points are incompatible because of their types */
  100938. TypeIncompatible = 1,
  100939. /** Points are incompatible because of their targets (vertex vs fragment) */
  100940. TargetIncompatible = 2
  100941. }
  100942. /**
  100943. * Defines the direction of a connection point
  100944. */
  100945. export enum NodeMaterialConnectionPointDirection {
  100946. /** Input */
  100947. Input = 0,
  100948. /** Output */
  100949. Output = 1
  100950. }
  100951. /**
  100952. * Defines a connection point for a block
  100953. */
  100954. export class NodeMaterialConnectionPoint {
  100955. /** @hidden */
  100956. _ownerBlock: NodeMaterialBlock;
  100957. /** @hidden */
  100958. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100959. private _endpoints;
  100960. private _associatedVariableName;
  100961. private _direction;
  100962. /** @hidden */
  100963. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100964. /** @hidden */
  100965. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100966. private _type;
  100967. /** @hidden */
  100968. _enforceAssociatedVariableName: boolean;
  100969. /** Gets the direction of the point */
  100970. get direction(): NodeMaterialConnectionPointDirection;
  100971. /** Indicates that this connection point needs dual validation before being connected to another point */
  100972. needDualDirectionValidation: boolean;
  100973. /**
  100974. * Gets or sets the additional types supported by this connection point
  100975. */
  100976. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100977. /**
  100978. * Gets or sets the additional types excluded by this connection point
  100979. */
  100980. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100981. /**
  100982. * Observable triggered when this point is connected
  100983. */
  100984. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100985. /**
  100986. * Gets or sets the associated variable name in the shader
  100987. */
  100988. get associatedVariableName(): string;
  100989. set associatedVariableName(value: string);
  100990. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100991. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100992. /**
  100993. * Gets or sets the connection point type (default is float)
  100994. */
  100995. get type(): NodeMaterialBlockConnectionPointTypes;
  100996. set type(value: NodeMaterialBlockConnectionPointTypes);
  100997. /**
  100998. * Gets or sets the connection point name
  100999. */
  101000. name: string;
  101001. /**
  101002. * Gets or sets the connection point name
  101003. */
  101004. displayName: string;
  101005. /**
  101006. * Gets or sets a boolean indicating that this connection point can be omitted
  101007. */
  101008. isOptional: boolean;
  101009. /**
  101010. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101011. */
  101012. isExposedOnFrame: boolean;
  101013. /**
  101014. * Gets or sets number indicating the position that the port is exposed to on a frame
  101015. */
  101016. exposedPortPosition: number;
  101017. /**
  101018. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101019. */
  101020. define: string;
  101021. /** @hidden */
  101022. _prioritizeVertex: boolean;
  101023. private _target;
  101024. /** Gets or sets the target of that connection point */
  101025. get target(): NodeMaterialBlockTargets;
  101026. set target(value: NodeMaterialBlockTargets);
  101027. /**
  101028. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101029. */
  101030. get isConnected(): boolean;
  101031. /**
  101032. * Gets a boolean indicating that the current point is connected to an input block
  101033. */
  101034. get isConnectedToInputBlock(): boolean;
  101035. /**
  101036. * Gets a the connected input block (if any)
  101037. */
  101038. get connectInputBlock(): Nullable<InputBlock>;
  101039. /** Get the other side of the connection (if any) */
  101040. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101041. /** Get the block that owns this connection point */
  101042. get ownerBlock(): NodeMaterialBlock;
  101043. /** Get the block connected on the other side of this connection (if any) */
  101044. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101045. /** Get the block connected on the endpoints of this connection (if any) */
  101046. get connectedBlocks(): Array<NodeMaterialBlock>;
  101047. /** Gets the list of connected endpoints */
  101048. get endpoints(): NodeMaterialConnectionPoint[];
  101049. /** Gets a boolean indicating if that output point is connected to at least one input */
  101050. get hasEndpoints(): boolean;
  101051. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101052. get isConnectedInVertexShader(): boolean;
  101053. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101054. get isConnectedInFragmentShader(): boolean;
  101055. /**
  101056. * Creates a block suitable to be used as an input for this input point.
  101057. * If null is returned, a block based on the point type will be created.
  101058. * @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
  101059. */
  101060. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101061. /**
  101062. * Creates a new connection point
  101063. * @param name defines the connection point name
  101064. * @param ownerBlock defines the block hosting this connection point
  101065. * @param direction defines the direction of the connection point
  101066. */
  101067. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101068. /**
  101069. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101070. * @returns the class name
  101071. */
  101072. getClassName(): string;
  101073. /**
  101074. * Gets a boolean indicating if the current point can be connected to another point
  101075. * @param connectionPoint defines the other connection point
  101076. * @returns a boolean
  101077. */
  101078. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101079. /**
  101080. * Gets a number indicating if the current point can be connected to another point
  101081. * @param connectionPoint defines the other connection point
  101082. * @returns a number defining the compatibility state
  101083. */
  101084. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101085. /**
  101086. * Connect this point to another connection point
  101087. * @param connectionPoint defines the other connection point
  101088. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101089. * @returns the current connection point
  101090. */
  101091. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101092. /**
  101093. * Disconnect this point from one of his endpoint
  101094. * @param endpoint defines the other connection point
  101095. * @returns the current connection point
  101096. */
  101097. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101098. /**
  101099. * Serializes this point in a JSON representation
  101100. * @param isInput defines if the connection point is an input (default is true)
  101101. * @returns the serialized point object
  101102. */
  101103. serialize(isInput?: boolean): any;
  101104. /**
  101105. * Release resources
  101106. */
  101107. dispose(): void;
  101108. }
  101109. }
  101110. declare module BABYLON {
  101111. /**
  101112. * Enum used to define the material modes
  101113. */
  101114. export enum NodeMaterialModes {
  101115. /** Regular material */
  101116. Material = 0,
  101117. /** For post process */
  101118. PostProcess = 1,
  101119. /** For particle system */
  101120. Particle = 2,
  101121. /** For procedural texture */
  101122. ProceduralTexture = 3
  101123. }
  101124. }
  101125. declare module BABYLON {
  101126. /**
  101127. * Block used to read a texture from a sampler
  101128. */
  101129. export class TextureBlock extends NodeMaterialBlock {
  101130. private _defineName;
  101131. private _linearDefineName;
  101132. private _gammaDefineName;
  101133. private _tempTextureRead;
  101134. private _samplerName;
  101135. private _transformedUVName;
  101136. private _textureTransformName;
  101137. private _textureInfoName;
  101138. private _mainUVName;
  101139. private _mainUVDefineName;
  101140. private _fragmentOnly;
  101141. /**
  101142. * Gets or sets the texture associated with the node
  101143. */
  101144. texture: Nullable<Texture>;
  101145. /**
  101146. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101147. */
  101148. convertToGammaSpace: boolean;
  101149. /**
  101150. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101151. */
  101152. convertToLinearSpace: boolean;
  101153. /**
  101154. * Create a new TextureBlock
  101155. * @param name defines the block name
  101156. */
  101157. constructor(name: string, fragmentOnly?: boolean);
  101158. /**
  101159. * Gets the current class name
  101160. * @returns the class name
  101161. */
  101162. getClassName(): string;
  101163. /**
  101164. * Gets the uv input component
  101165. */
  101166. get uv(): NodeMaterialConnectionPoint;
  101167. /**
  101168. * Gets the rgba output component
  101169. */
  101170. get rgba(): NodeMaterialConnectionPoint;
  101171. /**
  101172. * Gets the rgb output component
  101173. */
  101174. get rgb(): NodeMaterialConnectionPoint;
  101175. /**
  101176. * Gets the r output component
  101177. */
  101178. get r(): NodeMaterialConnectionPoint;
  101179. /**
  101180. * Gets the g output component
  101181. */
  101182. get g(): NodeMaterialConnectionPoint;
  101183. /**
  101184. * Gets the b output component
  101185. */
  101186. get b(): NodeMaterialConnectionPoint;
  101187. /**
  101188. * Gets the a output component
  101189. */
  101190. get a(): NodeMaterialConnectionPoint;
  101191. get target(): NodeMaterialBlockTargets;
  101192. autoConfigure(material: NodeMaterial): void;
  101193. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101195. isReady(): boolean;
  101196. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101197. private get _isMixed();
  101198. private _injectVertexCode;
  101199. private _writeTextureRead;
  101200. private _writeOutput;
  101201. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101202. protected _dumpPropertiesCode(): string;
  101203. serialize(): any;
  101204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101205. }
  101206. }
  101207. declare module BABYLON {
  101208. /** @hidden */
  101209. export var reflectionFunction: {
  101210. name: string;
  101211. shader: string;
  101212. };
  101213. }
  101214. declare module BABYLON {
  101215. /**
  101216. * Base block used to read a reflection texture from a sampler
  101217. */
  101218. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101219. /** @hidden */
  101220. _define3DName: string;
  101221. /** @hidden */
  101222. _defineCubicName: string;
  101223. /** @hidden */
  101224. _defineExplicitName: string;
  101225. /** @hidden */
  101226. _defineProjectionName: string;
  101227. /** @hidden */
  101228. _defineLocalCubicName: string;
  101229. /** @hidden */
  101230. _defineSphericalName: string;
  101231. /** @hidden */
  101232. _definePlanarName: string;
  101233. /** @hidden */
  101234. _defineEquirectangularName: string;
  101235. /** @hidden */
  101236. _defineMirroredEquirectangularFixedName: string;
  101237. /** @hidden */
  101238. _defineEquirectangularFixedName: string;
  101239. /** @hidden */
  101240. _defineSkyboxName: string;
  101241. /** @hidden */
  101242. _defineOppositeZ: string;
  101243. /** @hidden */
  101244. _cubeSamplerName: string;
  101245. /** @hidden */
  101246. _2DSamplerName: string;
  101247. protected _positionUVWName: string;
  101248. protected _directionWName: string;
  101249. protected _reflectionVectorName: string;
  101250. /** @hidden */
  101251. _reflectionCoordsName: string;
  101252. /** @hidden */
  101253. _reflectionMatrixName: string;
  101254. protected _reflectionColorName: string;
  101255. /**
  101256. * Gets or sets the texture associated with the node
  101257. */
  101258. texture: Nullable<BaseTexture>;
  101259. /**
  101260. * Create a new ReflectionTextureBaseBlock
  101261. * @param name defines the block name
  101262. */
  101263. constructor(name: string);
  101264. /**
  101265. * Gets the current class name
  101266. * @returns the class name
  101267. */
  101268. getClassName(): string;
  101269. /**
  101270. * Gets the world position input component
  101271. */
  101272. abstract get position(): NodeMaterialConnectionPoint;
  101273. /**
  101274. * Gets the world position input component
  101275. */
  101276. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101277. /**
  101278. * Gets the world normal input component
  101279. */
  101280. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101281. /**
  101282. * Gets the world input component
  101283. */
  101284. abstract get world(): NodeMaterialConnectionPoint;
  101285. /**
  101286. * Gets the camera (or eye) position component
  101287. */
  101288. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101289. /**
  101290. * Gets the view input component
  101291. */
  101292. abstract get view(): NodeMaterialConnectionPoint;
  101293. protected _getTexture(): Nullable<BaseTexture>;
  101294. autoConfigure(material: NodeMaterial): void;
  101295. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101296. isReady(): boolean;
  101297. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101298. /**
  101299. * Gets the code to inject in the vertex shader
  101300. * @param state current state of the node material building
  101301. * @returns the shader code
  101302. */
  101303. handleVertexSide(state: NodeMaterialBuildState): string;
  101304. /**
  101305. * Handles the inits for the fragment code path
  101306. * @param state node material build state
  101307. */
  101308. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101309. /**
  101310. * Generates the reflection coords code for the fragment code path
  101311. * @param worldNormalVarName name of the world normal variable
  101312. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101313. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101314. * @returns the shader code
  101315. */
  101316. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101317. /**
  101318. * Generates the reflection color code for the fragment code path
  101319. * @param lodVarName name of the lod variable
  101320. * @param swizzleLookupTexture swizzle to use for the final color variable
  101321. * @returns the shader code
  101322. */
  101323. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101324. /**
  101325. * Generates the code corresponding to the connected output points
  101326. * @param state node material build state
  101327. * @param varName name of the variable to output
  101328. * @returns the shader code
  101329. */
  101330. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101331. protected _buildBlock(state: NodeMaterialBuildState): this;
  101332. protected _dumpPropertiesCode(): string;
  101333. serialize(): any;
  101334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101335. }
  101336. }
  101337. declare module BABYLON {
  101338. /**
  101339. * Defines a connection point to be used for points with a custom object type
  101340. */
  101341. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101342. private _blockType;
  101343. private _blockName;
  101344. private _nameForCheking?;
  101345. /**
  101346. * Creates a new connection point
  101347. * @param name defines the connection point name
  101348. * @param ownerBlock defines the block hosting this connection point
  101349. * @param direction defines the direction of the connection point
  101350. */
  101351. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101352. /**
  101353. * Gets a number indicating if the current point can be connected to another point
  101354. * @param connectionPoint defines the other connection point
  101355. * @returns a number defining the compatibility state
  101356. */
  101357. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101358. /**
  101359. * Creates a block suitable to be used as an input for this input point.
  101360. * If null is returned, a block based on the point type will be created.
  101361. * @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
  101362. */
  101363. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101364. }
  101365. }
  101366. declare module BABYLON {
  101367. /**
  101368. * Enum defining the type of properties that can be edited in the property pages in the NME
  101369. */
  101370. export enum PropertyTypeForEdition {
  101371. /** property is a boolean */
  101372. Boolean = 0,
  101373. /** property is a float */
  101374. Float = 1,
  101375. /** property is a Vector2 */
  101376. Vector2 = 2,
  101377. /** property is a list of values */
  101378. List = 3
  101379. }
  101380. /**
  101381. * Interface that defines an option in a variable of type list
  101382. */
  101383. export interface IEditablePropertyListOption {
  101384. /** label of the option */
  101385. "label": string;
  101386. /** value of the option */
  101387. "value": number;
  101388. }
  101389. /**
  101390. * Interface that defines the options available for an editable property
  101391. */
  101392. export interface IEditablePropertyOption {
  101393. /** min value */
  101394. "min"?: number;
  101395. /** max value */
  101396. "max"?: number;
  101397. /** notifiers: indicates which actions to take when the property is changed */
  101398. "notifiers"?: {
  101399. /** the material should be rebuilt */
  101400. "rebuild"?: boolean;
  101401. /** the preview should be updated */
  101402. "update"?: boolean;
  101403. };
  101404. /** list of the options for a variable of type list */
  101405. "options"?: IEditablePropertyListOption[];
  101406. }
  101407. /**
  101408. * Interface that describes an editable property
  101409. */
  101410. export interface IPropertyDescriptionForEdition {
  101411. /** name of the property */
  101412. "propertyName": string;
  101413. /** display name of the property */
  101414. "displayName": string;
  101415. /** type of the property */
  101416. "type": PropertyTypeForEdition;
  101417. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101418. "groupName": string;
  101419. /** options for the property */
  101420. "options": IEditablePropertyOption;
  101421. }
  101422. /**
  101423. * Decorator that flags a property in a node material block as being editable
  101424. */
  101425. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101426. }
  101427. declare module BABYLON {
  101428. /**
  101429. * Block used to implement the refraction part of the sub surface module of the PBR material
  101430. */
  101431. export class RefractionBlock extends NodeMaterialBlock {
  101432. /** @hidden */
  101433. _define3DName: string;
  101434. /** @hidden */
  101435. _refractionMatrixName: string;
  101436. /** @hidden */
  101437. _defineLODRefractionAlpha: string;
  101438. /** @hidden */
  101439. _defineLinearSpecularRefraction: string;
  101440. /** @hidden */
  101441. _defineOppositeZ: string;
  101442. /** @hidden */
  101443. _cubeSamplerName: string;
  101444. /** @hidden */
  101445. _2DSamplerName: string;
  101446. /** @hidden */
  101447. _vRefractionMicrosurfaceInfosName: string;
  101448. /** @hidden */
  101449. _vRefractionInfosName: string;
  101450. private _scene;
  101451. /**
  101452. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101453. * Materials half opaque for instance using refraction could benefit from this control.
  101454. */
  101455. linkRefractionWithTransparency: boolean;
  101456. /**
  101457. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101458. */
  101459. invertRefractionY: boolean;
  101460. /**
  101461. * Gets or sets the texture associated with the node
  101462. */
  101463. texture: Nullable<BaseTexture>;
  101464. /**
  101465. * Create a new RefractionBlock
  101466. * @param name defines the block name
  101467. */
  101468. constructor(name: string);
  101469. /**
  101470. * Gets the current class name
  101471. * @returns the class name
  101472. */
  101473. getClassName(): string;
  101474. /**
  101475. * Gets the intensity input component
  101476. */
  101477. get intensity(): NodeMaterialConnectionPoint;
  101478. /**
  101479. * Gets the index of refraction input component
  101480. */
  101481. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101482. /**
  101483. * Gets the tint at distance input component
  101484. */
  101485. get tintAtDistance(): NodeMaterialConnectionPoint;
  101486. /**
  101487. * Gets the view input component
  101488. */
  101489. get view(): NodeMaterialConnectionPoint;
  101490. /**
  101491. * Gets the refraction object output component
  101492. */
  101493. get refraction(): NodeMaterialConnectionPoint;
  101494. /**
  101495. * Returns true if the block has a texture
  101496. */
  101497. get hasTexture(): boolean;
  101498. protected _getTexture(): Nullable<BaseTexture>;
  101499. autoConfigure(material: NodeMaterial): void;
  101500. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101501. isReady(): boolean;
  101502. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101503. /**
  101504. * Gets the main code of the block (fragment side)
  101505. * @param state current state of the node material building
  101506. * @returns the shader code
  101507. */
  101508. getCode(state: NodeMaterialBuildState): string;
  101509. protected _buildBlock(state: NodeMaterialBuildState): this;
  101510. protected _dumpPropertiesCode(): string;
  101511. serialize(): any;
  101512. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101513. }
  101514. }
  101515. declare module BABYLON {
  101516. /**
  101517. * Base block used as input for post process
  101518. */
  101519. export class CurrentScreenBlock extends NodeMaterialBlock {
  101520. private _samplerName;
  101521. private _linearDefineName;
  101522. private _gammaDefineName;
  101523. private _mainUVName;
  101524. private _tempTextureRead;
  101525. /**
  101526. * Gets or sets the texture associated with the node
  101527. */
  101528. texture: Nullable<BaseTexture>;
  101529. /**
  101530. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101531. */
  101532. convertToGammaSpace: boolean;
  101533. /**
  101534. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101535. */
  101536. convertToLinearSpace: boolean;
  101537. /**
  101538. * Create a new CurrentScreenBlock
  101539. * @param name defines the block name
  101540. */
  101541. constructor(name: string);
  101542. /**
  101543. * Gets the current class name
  101544. * @returns the class name
  101545. */
  101546. getClassName(): string;
  101547. /**
  101548. * Gets the uv input component
  101549. */
  101550. get uv(): NodeMaterialConnectionPoint;
  101551. /**
  101552. * Gets the rgba output component
  101553. */
  101554. get rgba(): NodeMaterialConnectionPoint;
  101555. /**
  101556. * Gets the rgb output component
  101557. */
  101558. get rgb(): NodeMaterialConnectionPoint;
  101559. /**
  101560. * Gets the r output component
  101561. */
  101562. get r(): NodeMaterialConnectionPoint;
  101563. /**
  101564. * Gets the g output component
  101565. */
  101566. get g(): NodeMaterialConnectionPoint;
  101567. /**
  101568. * Gets the b output component
  101569. */
  101570. get b(): NodeMaterialConnectionPoint;
  101571. /**
  101572. * Gets the a output component
  101573. */
  101574. get a(): NodeMaterialConnectionPoint;
  101575. /**
  101576. * Initialize the block and prepare the context for build
  101577. * @param state defines the state that will be used for the build
  101578. */
  101579. initialize(state: NodeMaterialBuildState): void;
  101580. get target(): NodeMaterialBlockTargets;
  101581. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101582. isReady(): boolean;
  101583. private _injectVertexCode;
  101584. private _writeTextureRead;
  101585. private _writeOutput;
  101586. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101587. serialize(): any;
  101588. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101589. }
  101590. }
  101591. declare module BABYLON {
  101592. /**
  101593. * Base block used for the particle texture
  101594. */
  101595. export class ParticleTextureBlock extends NodeMaterialBlock {
  101596. private _samplerName;
  101597. private _linearDefineName;
  101598. private _gammaDefineName;
  101599. private _tempTextureRead;
  101600. /**
  101601. * Gets or sets the texture associated with the node
  101602. */
  101603. texture: Nullable<BaseTexture>;
  101604. /**
  101605. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101606. */
  101607. convertToGammaSpace: boolean;
  101608. /**
  101609. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101610. */
  101611. convertToLinearSpace: boolean;
  101612. /**
  101613. * Create a new ParticleTextureBlock
  101614. * @param name defines the block name
  101615. */
  101616. constructor(name: string);
  101617. /**
  101618. * Gets the current class name
  101619. * @returns the class name
  101620. */
  101621. getClassName(): string;
  101622. /**
  101623. * Gets the uv input component
  101624. */
  101625. get uv(): NodeMaterialConnectionPoint;
  101626. /**
  101627. * Gets the rgba output component
  101628. */
  101629. get rgba(): NodeMaterialConnectionPoint;
  101630. /**
  101631. * Gets the rgb output component
  101632. */
  101633. get rgb(): NodeMaterialConnectionPoint;
  101634. /**
  101635. * Gets the r output component
  101636. */
  101637. get r(): NodeMaterialConnectionPoint;
  101638. /**
  101639. * Gets the g output component
  101640. */
  101641. get g(): NodeMaterialConnectionPoint;
  101642. /**
  101643. * Gets the b output component
  101644. */
  101645. get b(): NodeMaterialConnectionPoint;
  101646. /**
  101647. * Gets the a output component
  101648. */
  101649. get a(): NodeMaterialConnectionPoint;
  101650. /**
  101651. * Initialize the block and prepare the context for build
  101652. * @param state defines the state that will be used for the build
  101653. */
  101654. initialize(state: NodeMaterialBuildState): void;
  101655. autoConfigure(material: NodeMaterial): void;
  101656. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101657. isReady(): boolean;
  101658. private _writeOutput;
  101659. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101660. serialize(): any;
  101661. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101662. }
  101663. }
  101664. declare module BABYLON {
  101665. /**
  101666. * Class used to store shared data between 2 NodeMaterialBuildState
  101667. */
  101668. export class NodeMaterialBuildStateSharedData {
  101669. /**
  101670. * Gets the list of emitted varyings
  101671. */
  101672. temps: string[];
  101673. /**
  101674. * Gets the list of emitted varyings
  101675. */
  101676. varyings: string[];
  101677. /**
  101678. * Gets the varying declaration string
  101679. */
  101680. varyingDeclaration: string;
  101681. /**
  101682. * Input blocks
  101683. */
  101684. inputBlocks: InputBlock[];
  101685. /**
  101686. * Input blocks
  101687. */
  101688. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101689. /**
  101690. * Bindable blocks (Blocks that need to set data to the effect)
  101691. */
  101692. bindableBlocks: NodeMaterialBlock[];
  101693. /**
  101694. * List of blocks that can provide a compilation fallback
  101695. */
  101696. blocksWithFallbacks: NodeMaterialBlock[];
  101697. /**
  101698. * List of blocks that can provide a define update
  101699. */
  101700. blocksWithDefines: NodeMaterialBlock[];
  101701. /**
  101702. * List of blocks that can provide a repeatable content
  101703. */
  101704. repeatableContentBlocks: NodeMaterialBlock[];
  101705. /**
  101706. * List of blocks that can provide a dynamic list of uniforms
  101707. */
  101708. dynamicUniformBlocks: NodeMaterialBlock[];
  101709. /**
  101710. * List of blocks that can block the isReady function for the material
  101711. */
  101712. blockingBlocks: NodeMaterialBlock[];
  101713. /**
  101714. * Gets the list of animated inputs
  101715. */
  101716. animatedInputs: InputBlock[];
  101717. /**
  101718. * Build Id used to avoid multiple recompilations
  101719. */
  101720. buildId: number;
  101721. /** List of emitted variables */
  101722. variableNames: {
  101723. [key: string]: number;
  101724. };
  101725. /** List of emitted defines */
  101726. defineNames: {
  101727. [key: string]: number;
  101728. };
  101729. /** Should emit comments? */
  101730. emitComments: boolean;
  101731. /** Emit build activity */
  101732. verbose: boolean;
  101733. /** Gets or sets the hosting scene */
  101734. scene: Scene;
  101735. /**
  101736. * Gets the compilation hints emitted at compilation time
  101737. */
  101738. hints: {
  101739. needWorldViewMatrix: boolean;
  101740. needWorldViewProjectionMatrix: boolean;
  101741. needAlphaBlending: boolean;
  101742. needAlphaTesting: boolean;
  101743. };
  101744. /**
  101745. * List of compilation checks
  101746. */
  101747. checks: {
  101748. emitVertex: boolean;
  101749. emitFragment: boolean;
  101750. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101751. };
  101752. /**
  101753. * Is vertex program allowed to be empty?
  101754. */
  101755. allowEmptyVertexProgram: boolean;
  101756. /** Creates a new shared data */
  101757. constructor();
  101758. /**
  101759. * Emits console errors and exceptions if there is a failing check
  101760. */
  101761. emitErrors(): void;
  101762. }
  101763. }
  101764. declare module BABYLON {
  101765. /**
  101766. * Class used to store node based material build state
  101767. */
  101768. export class NodeMaterialBuildState {
  101769. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101770. supportUniformBuffers: boolean;
  101771. /**
  101772. * Gets the list of emitted attributes
  101773. */
  101774. attributes: string[];
  101775. /**
  101776. * Gets the list of emitted uniforms
  101777. */
  101778. uniforms: string[];
  101779. /**
  101780. * Gets the list of emitted constants
  101781. */
  101782. constants: string[];
  101783. /**
  101784. * Gets the list of emitted samplers
  101785. */
  101786. samplers: string[];
  101787. /**
  101788. * Gets the list of emitted functions
  101789. */
  101790. functions: {
  101791. [key: string]: string;
  101792. };
  101793. /**
  101794. * Gets the list of emitted extensions
  101795. */
  101796. extensions: {
  101797. [key: string]: string;
  101798. };
  101799. /**
  101800. * Gets the target of the compilation state
  101801. */
  101802. target: NodeMaterialBlockTargets;
  101803. /**
  101804. * Gets the list of emitted counters
  101805. */
  101806. counters: {
  101807. [key: string]: number;
  101808. };
  101809. /**
  101810. * Shared data between multiple NodeMaterialBuildState instances
  101811. */
  101812. sharedData: NodeMaterialBuildStateSharedData;
  101813. /** @hidden */
  101814. _vertexState: NodeMaterialBuildState;
  101815. /** @hidden */
  101816. _attributeDeclaration: string;
  101817. /** @hidden */
  101818. _uniformDeclaration: string;
  101819. /** @hidden */
  101820. _constantDeclaration: string;
  101821. /** @hidden */
  101822. _samplerDeclaration: string;
  101823. /** @hidden */
  101824. _varyingTransfer: string;
  101825. /** @hidden */
  101826. _injectAtEnd: string;
  101827. private _repeatableContentAnchorIndex;
  101828. /** @hidden */
  101829. _builtCompilationString: string;
  101830. /**
  101831. * Gets the emitted compilation strings
  101832. */
  101833. compilationString: string;
  101834. /**
  101835. * Finalize the compilation strings
  101836. * @param state defines the current compilation state
  101837. */
  101838. finalize(state: NodeMaterialBuildState): void;
  101839. /** @hidden */
  101840. get _repeatableContentAnchor(): string;
  101841. /** @hidden */
  101842. _getFreeVariableName(prefix: string): string;
  101843. /** @hidden */
  101844. _getFreeDefineName(prefix: string): string;
  101845. /** @hidden */
  101846. _excludeVariableName(name: string): void;
  101847. /** @hidden */
  101848. _emit2DSampler(name: string): void;
  101849. /** @hidden */
  101850. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101851. /** @hidden */
  101852. _emitExtension(name: string, extension: string, define?: string): void;
  101853. /** @hidden */
  101854. _emitFunction(name: string, code: string, comments: string): void;
  101855. /** @hidden */
  101856. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101857. replaceStrings?: {
  101858. search: RegExp;
  101859. replace: string;
  101860. }[];
  101861. repeatKey?: string;
  101862. }): string;
  101863. /** @hidden */
  101864. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101865. repeatKey?: string;
  101866. removeAttributes?: boolean;
  101867. removeUniforms?: boolean;
  101868. removeVaryings?: boolean;
  101869. removeIfDef?: boolean;
  101870. replaceStrings?: {
  101871. search: RegExp;
  101872. replace: string;
  101873. }[];
  101874. }, storeKey?: string): void;
  101875. /** @hidden */
  101876. _registerTempVariable(name: string): boolean;
  101877. /** @hidden */
  101878. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101879. /** @hidden */
  101880. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101881. /** @hidden */
  101882. _emitFloat(value: number): string;
  101883. }
  101884. }
  101885. declare module BABYLON {
  101886. /**
  101887. * Helper class used to generate session unique ID
  101888. */
  101889. export class UniqueIdGenerator {
  101890. private static _UniqueIdCounter;
  101891. /**
  101892. * Gets an unique (relatively to the current scene) Id
  101893. */
  101894. static get UniqueId(): number;
  101895. }
  101896. }
  101897. declare module BABYLON {
  101898. /**
  101899. * Defines a block that can be used inside a node based material
  101900. */
  101901. export class NodeMaterialBlock {
  101902. private _buildId;
  101903. private _buildTarget;
  101904. private _target;
  101905. private _isFinalMerger;
  101906. private _isInput;
  101907. private _name;
  101908. protected _isUnique: boolean;
  101909. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101910. inputsAreExclusive: boolean;
  101911. /** @hidden */
  101912. _codeVariableName: string;
  101913. /** @hidden */
  101914. _inputs: NodeMaterialConnectionPoint[];
  101915. /** @hidden */
  101916. _outputs: NodeMaterialConnectionPoint[];
  101917. /** @hidden */
  101918. _preparationId: number;
  101919. /**
  101920. * Gets the name of the block
  101921. */
  101922. get name(): string;
  101923. /**
  101924. * Sets the name of the block. Will check if the name is valid.
  101925. */
  101926. set name(newName: string);
  101927. /**
  101928. * Gets or sets the unique id of the node
  101929. */
  101930. uniqueId: number;
  101931. /**
  101932. * Gets or sets the comments associated with this block
  101933. */
  101934. comments: string;
  101935. /**
  101936. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101937. */
  101938. get isUnique(): boolean;
  101939. /**
  101940. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101941. */
  101942. get isFinalMerger(): boolean;
  101943. /**
  101944. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101945. */
  101946. get isInput(): boolean;
  101947. /**
  101948. * Gets or sets the build Id
  101949. */
  101950. get buildId(): number;
  101951. set buildId(value: number);
  101952. /**
  101953. * Gets or sets the target of the block
  101954. */
  101955. get target(): NodeMaterialBlockTargets;
  101956. set target(value: NodeMaterialBlockTargets);
  101957. /**
  101958. * Gets the list of input points
  101959. */
  101960. get inputs(): NodeMaterialConnectionPoint[];
  101961. /** Gets the list of output points */
  101962. get outputs(): NodeMaterialConnectionPoint[];
  101963. /**
  101964. * Find an input by its name
  101965. * @param name defines the name of the input to look for
  101966. * @returns the input or null if not found
  101967. */
  101968. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101969. /**
  101970. * Find an output by its name
  101971. * @param name defines the name of the outputto look for
  101972. * @returns the output or null if not found
  101973. */
  101974. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101975. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  101976. visibleInInspector: boolean;
  101977. /**
  101978. * Creates a new NodeMaterialBlock
  101979. * @param name defines the block name
  101980. * @param target defines the target of that block (Vertex by default)
  101981. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101982. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101983. */
  101984. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101985. /**
  101986. * Initialize the block and prepare the context for build
  101987. * @param state defines the state that will be used for the build
  101988. */
  101989. initialize(state: NodeMaterialBuildState): void;
  101990. /**
  101991. * Bind data to effect. Will only be called for blocks with isBindable === true
  101992. * @param effect defines the effect to bind data to
  101993. * @param nodeMaterial defines the hosting NodeMaterial
  101994. * @param mesh defines the mesh that will be rendered
  101995. * @param subMesh defines the submesh that will be rendered
  101996. */
  101997. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101998. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101999. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102000. protected _writeFloat(value: number): string;
  102001. /**
  102002. * Gets the current class name e.g. "NodeMaterialBlock"
  102003. * @returns the class name
  102004. */
  102005. getClassName(): string;
  102006. /**
  102007. * Register a new input. Must be called inside a block constructor
  102008. * @param name defines the connection point name
  102009. * @param type defines the connection point type
  102010. * @param isOptional defines a boolean indicating that this input can be omitted
  102011. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102012. * @param point an already created connection point. If not provided, create a new one
  102013. * @returns the current block
  102014. */
  102015. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102016. /**
  102017. * Register a new output. Must be called inside a block constructor
  102018. * @param name defines the connection point name
  102019. * @param type defines the connection point type
  102020. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102021. * @param point an already created connection point. If not provided, create a new one
  102022. * @returns the current block
  102023. */
  102024. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102025. /**
  102026. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102027. * @param forOutput defines an optional connection point to check compatibility with
  102028. * @returns the first available input or null
  102029. */
  102030. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102031. /**
  102032. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102033. * @param forBlock defines an optional block to check compatibility with
  102034. * @returns the first available input or null
  102035. */
  102036. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102037. /**
  102038. * Gets the sibling of the given output
  102039. * @param current defines the current output
  102040. * @returns the next output in the list or null
  102041. */
  102042. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102043. /**
  102044. * Connect current block with another block
  102045. * @param other defines the block to connect with
  102046. * @param options define the various options to help pick the right connections
  102047. * @returns the current block
  102048. */
  102049. connectTo(other: NodeMaterialBlock, options?: {
  102050. input?: string;
  102051. output?: string;
  102052. outputSwizzle?: string;
  102053. }): this | undefined;
  102054. protected _buildBlock(state: NodeMaterialBuildState): void;
  102055. /**
  102056. * Add uniforms, samplers and uniform buffers at compilation time
  102057. * @param state defines the state to update
  102058. * @param nodeMaterial defines the node material requesting the update
  102059. * @param defines defines the material defines to update
  102060. * @param uniformBuffers defines the list of uniform buffer names
  102061. */
  102062. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102063. /**
  102064. * Add potential fallbacks if shader compilation fails
  102065. * @param mesh defines the mesh to be rendered
  102066. * @param fallbacks defines the current prioritized list of fallbacks
  102067. */
  102068. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102069. /**
  102070. * Initialize defines for shader compilation
  102071. * @param mesh defines the mesh to be rendered
  102072. * @param nodeMaterial defines the node material requesting the update
  102073. * @param defines defines the material defines to update
  102074. * @param useInstances specifies that instances should be used
  102075. */
  102076. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102077. /**
  102078. * Update defines for shader compilation
  102079. * @param mesh defines the mesh to be rendered
  102080. * @param nodeMaterial defines the node material requesting the update
  102081. * @param defines defines the material defines to update
  102082. * @param useInstances specifies that instances should be used
  102083. * @param subMesh defines which submesh to render
  102084. */
  102085. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102086. /**
  102087. * Lets the block try to connect some inputs automatically
  102088. * @param material defines the hosting NodeMaterial
  102089. */
  102090. autoConfigure(material: NodeMaterial): void;
  102091. /**
  102092. * Function called when a block is declared as repeatable content generator
  102093. * @param vertexShaderState defines the current compilation state for the vertex shader
  102094. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102095. * @param mesh defines the mesh to be rendered
  102096. * @param defines defines the material defines to update
  102097. */
  102098. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102099. /**
  102100. * Checks if the block is ready
  102101. * @param mesh defines the mesh to be rendered
  102102. * @param nodeMaterial defines the node material requesting the update
  102103. * @param defines defines the material defines to update
  102104. * @param useInstances specifies that instances should be used
  102105. * @returns true if the block is ready
  102106. */
  102107. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102108. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102109. private _processBuild;
  102110. /**
  102111. * Validates the new name for the block node.
  102112. * @param newName the new name to be given to the node.
  102113. * @returns false if the name is a reserve word, else true.
  102114. */
  102115. validateBlockName(newName: string): boolean;
  102116. /**
  102117. * Compile the current node and generate the shader code
  102118. * @param state defines the current compilation state (uniforms, samplers, current string)
  102119. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102120. * @returns true if already built
  102121. */
  102122. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102123. protected _inputRename(name: string): string;
  102124. protected _outputRename(name: string): string;
  102125. protected _dumpPropertiesCode(): string;
  102126. /** @hidden */
  102127. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102128. /** @hidden */
  102129. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102130. /**
  102131. * Clone the current block to a new identical block
  102132. * @param scene defines the hosting scene
  102133. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102134. * @returns a copy of the current block
  102135. */
  102136. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102137. /**
  102138. * Serializes this block in a JSON representation
  102139. * @returns the serialized block object
  102140. */
  102141. serialize(): any;
  102142. /** @hidden */
  102143. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102144. private _deserializePortDisplayNamesAndExposedOnFrame;
  102145. /**
  102146. * Release resources
  102147. */
  102148. dispose(): void;
  102149. }
  102150. }
  102151. declare module BABYLON {
  102152. /**
  102153. * Base class of materials working in push mode in babylon JS
  102154. * @hidden
  102155. */
  102156. export class PushMaterial extends Material {
  102157. protected _activeEffect: Effect;
  102158. protected _normalMatrix: Matrix;
  102159. constructor(name: string, scene: Scene);
  102160. getEffect(): Effect;
  102161. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102162. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102163. /**
  102164. * Binds the given world matrix to the active effect
  102165. *
  102166. * @param world the matrix to bind
  102167. */
  102168. bindOnlyWorldMatrix(world: Matrix): void;
  102169. /**
  102170. * Binds the given normal matrix to the active effect
  102171. *
  102172. * @param normalMatrix the matrix to bind
  102173. */
  102174. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102175. bind(world: Matrix, mesh?: Mesh): void;
  102176. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102177. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102178. }
  102179. }
  102180. declare module BABYLON {
  102181. /**
  102182. * Root class for all node material optimizers
  102183. */
  102184. export class NodeMaterialOptimizer {
  102185. /**
  102186. * Function used to optimize a NodeMaterial graph
  102187. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102188. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102189. */
  102190. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102191. }
  102192. }
  102193. declare module BABYLON {
  102194. /**
  102195. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102196. */
  102197. export class TransformBlock extends NodeMaterialBlock {
  102198. /**
  102199. * Defines the value to use to complement W value to transform it to a Vector4
  102200. */
  102201. complementW: number;
  102202. /**
  102203. * Defines the value to use to complement z value to transform it to a Vector4
  102204. */
  102205. complementZ: number;
  102206. /**
  102207. * Creates a new TransformBlock
  102208. * @param name defines the block name
  102209. */
  102210. constructor(name: string);
  102211. /**
  102212. * Gets the current class name
  102213. * @returns the class name
  102214. */
  102215. getClassName(): string;
  102216. /**
  102217. * Gets the vector input
  102218. */
  102219. get vector(): NodeMaterialConnectionPoint;
  102220. /**
  102221. * Gets the output component
  102222. */
  102223. get output(): NodeMaterialConnectionPoint;
  102224. /**
  102225. * Gets the xyz output component
  102226. */
  102227. get xyz(): NodeMaterialConnectionPoint;
  102228. /**
  102229. * Gets the matrix transform input
  102230. */
  102231. get transform(): NodeMaterialConnectionPoint;
  102232. protected _buildBlock(state: NodeMaterialBuildState): this;
  102233. /**
  102234. * Update defines for shader compilation
  102235. * @param mesh defines the mesh to be rendered
  102236. * @param nodeMaterial defines the node material requesting the update
  102237. * @param defines defines the material defines to update
  102238. * @param useInstances specifies that instances should be used
  102239. * @param subMesh defines which submesh to render
  102240. */
  102241. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102242. serialize(): any;
  102243. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102244. protected _dumpPropertiesCode(): string;
  102245. }
  102246. }
  102247. declare module BABYLON {
  102248. /**
  102249. * Block used to output the vertex position
  102250. */
  102251. export class VertexOutputBlock extends NodeMaterialBlock {
  102252. /**
  102253. * Creates a new VertexOutputBlock
  102254. * @param name defines the block name
  102255. */
  102256. constructor(name: string);
  102257. /**
  102258. * Gets the current class name
  102259. * @returns the class name
  102260. */
  102261. getClassName(): string;
  102262. /**
  102263. * Gets the vector input component
  102264. */
  102265. get vector(): NodeMaterialConnectionPoint;
  102266. protected _buildBlock(state: NodeMaterialBuildState): this;
  102267. }
  102268. }
  102269. declare module BABYLON {
  102270. /**
  102271. * Block used to output the final color
  102272. */
  102273. export class FragmentOutputBlock extends NodeMaterialBlock {
  102274. /**
  102275. * Create a new FragmentOutputBlock
  102276. * @param name defines the block name
  102277. */
  102278. constructor(name: string);
  102279. /**
  102280. * Gets the current class name
  102281. * @returns the class name
  102282. */
  102283. getClassName(): string;
  102284. /**
  102285. * Gets the rgba input component
  102286. */
  102287. get rgba(): NodeMaterialConnectionPoint;
  102288. /**
  102289. * Gets the rgb input component
  102290. */
  102291. get rgb(): NodeMaterialConnectionPoint;
  102292. /**
  102293. * Gets the a input component
  102294. */
  102295. get a(): NodeMaterialConnectionPoint;
  102296. protected _buildBlock(state: NodeMaterialBuildState): this;
  102297. }
  102298. }
  102299. declare module BABYLON {
  102300. /**
  102301. * Block used for the particle ramp gradient section
  102302. */
  102303. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102304. /**
  102305. * Create a new ParticleRampGradientBlock
  102306. * @param name defines the block name
  102307. */
  102308. constructor(name: string);
  102309. /**
  102310. * Gets the current class name
  102311. * @returns the class name
  102312. */
  102313. getClassName(): string;
  102314. /**
  102315. * Gets the color input component
  102316. */
  102317. get color(): NodeMaterialConnectionPoint;
  102318. /**
  102319. * Gets the rampColor output component
  102320. */
  102321. get rampColor(): NodeMaterialConnectionPoint;
  102322. /**
  102323. * Initialize the block and prepare the context for build
  102324. * @param state defines the state that will be used for the build
  102325. */
  102326. initialize(state: NodeMaterialBuildState): void;
  102327. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102328. }
  102329. }
  102330. declare module BABYLON {
  102331. /**
  102332. * Block used for the particle blend multiply section
  102333. */
  102334. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102335. /**
  102336. * Create a new ParticleBlendMultiplyBlock
  102337. * @param name defines the block name
  102338. */
  102339. constructor(name: string);
  102340. /**
  102341. * Gets the current class name
  102342. * @returns the class name
  102343. */
  102344. getClassName(): string;
  102345. /**
  102346. * Gets the color input component
  102347. */
  102348. get color(): NodeMaterialConnectionPoint;
  102349. /**
  102350. * Gets the alphaTexture input component
  102351. */
  102352. get alphaTexture(): NodeMaterialConnectionPoint;
  102353. /**
  102354. * Gets the alphaColor input component
  102355. */
  102356. get alphaColor(): NodeMaterialConnectionPoint;
  102357. /**
  102358. * Gets the blendColor output component
  102359. */
  102360. get blendColor(): NodeMaterialConnectionPoint;
  102361. /**
  102362. * Initialize the block and prepare the context for build
  102363. * @param state defines the state that will be used for the build
  102364. */
  102365. initialize(state: NodeMaterialBuildState): void;
  102366. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102367. }
  102368. }
  102369. declare module BABYLON {
  102370. /**
  102371. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102372. */
  102373. export class VectorMergerBlock extends NodeMaterialBlock {
  102374. /**
  102375. * Create a new VectorMergerBlock
  102376. * @param name defines the block name
  102377. */
  102378. constructor(name: string);
  102379. /**
  102380. * Gets the current class name
  102381. * @returns the class name
  102382. */
  102383. getClassName(): string;
  102384. /**
  102385. * Gets the xyz component (input)
  102386. */
  102387. get xyzIn(): NodeMaterialConnectionPoint;
  102388. /**
  102389. * Gets the xy component (input)
  102390. */
  102391. get xyIn(): NodeMaterialConnectionPoint;
  102392. /**
  102393. * Gets the x component (input)
  102394. */
  102395. get x(): NodeMaterialConnectionPoint;
  102396. /**
  102397. * Gets the y component (input)
  102398. */
  102399. get y(): NodeMaterialConnectionPoint;
  102400. /**
  102401. * Gets the z component (input)
  102402. */
  102403. get z(): NodeMaterialConnectionPoint;
  102404. /**
  102405. * Gets the w component (input)
  102406. */
  102407. get w(): NodeMaterialConnectionPoint;
  102408. /**
  102409. * Gets the xyzw component (output)
  102410. */
  102411. get xyzw(): NodeMaterialConnectionPoint;
  102412. /**
  102413. * Gets the xyz component (output)
  102414. */
  102415. get xyzOut(): NodeMaterialConnectionPoint;
  102416. /**
  102417. * Gets the xy component (output)
  102418. */
  102419. get xyOut(): NodeMaterialConnectionPoint;
  102420. /**
  102421. * Gets the xy component (output)
  102422. * @deprecated Please use xyOut instead.
  102423. */
  102424. get xy(): NodeMaterialConnectionPoint;
  102425. /**
  102426. * Gets the xyz component (output)
  102427. * @deprecated Please use xyzOut instead.
  102428. */
  102429. get xyz(): NodeMaterialConnectionPoint;
  102430. protected _buildBlock(state: NodeMaterialBuildState): this;
  102431. }
  102432. }
  102433. declare module BABYLON {
  102434. /**
  102435. * Block used to remap a float from a range to a new one
  102436. */
  102437. export class RemapBlock extends NodeMaterialBlock {
  102438. /**
  102439. * Gets or sets the source range
  102440. */
  102441. sourceRange: Vector2;
  102442. /**
  102443. * Gets or sets the target range
  102444. */
  102445. targetRange: Vector2;
  102446. /**
  102447. * Creates a new RemapBlock
  102448. * @param name defines the block name
  102449. */
  102450. constructor(name: string);
  102451. /**
  102452. * Gets the current class name
  102453. * @returns the class name
  102454. */
  102455. getClassName(): string;
  102456. /**
  102457. * Gets the input component
  102458. */
  102459. get input(): NodeMaterialConnectionPoint;
  102460. /**
  102461. * Gets the source min input component
  102462. */
  102463. get sourceMin(): NodeMaterialConnectionPoint;
  102464. /**
  102465. * Gets the source max input component
  102466. */
  102467. get sourceMax(): NodeMaterialConnectionPoint;
  102468. /**
  102469. * Gets the target min input component
  102470. */
  102471. get targetMin(): NodeMaterialConnectionPoint;
  102472. /**
  102473. * Gets the target max input component
  102474. */
  102475. get targetMax(): NodeMaterialConnectionPoint;
  102476. /**
  102477. * Gets the output component
  102478. */
  102479. get output(): NodeMaterialConnectionPoint;
  102480. protected _buildBlock(state: NodeMaterialBuildState): this;
  102481. protected _dumpPropertiesCode(): string;
  102482. serialize(): any;
  102483. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102484. }
  102485. }
  102486. declare module BABYLON {
  102487. /**
  102488. * Block used to multiply 2 values
  102489. */
  102490. export class MultiplyBlock extends NodeMaterialBlock {
  102491. /**
  102492. * Creates a new MultiplyBlock
  102493. * @param name defines the block name
  102494. */
  102495. constructor(name: string);
  102496. /**
  102497. * Gets the current class name
  102498. * @returns the class name
  102499. */
  102500. getClassName(): string;
  102501. /**
  102502. * Gets the left operand input component
  102503. */
  102504. get left(): NodeMaterialConnectionPoint;
  102505. /**
  102506. * Gets the right operand input component
  102507. */
  102508. get right(): NodeMaterialConnectionPoint;
  102509. /**
  102510. * Gets the output component
  102511. */
  102512. get output(): NodeMaterialConnectionPoint;
  102513. protected _buildBlock(state: NodeMaterialBuildState): this;
  102514. }
  102515. }
  102516. declare module BABYLON {
  102517. /**
  102518. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102519. */
  102520. export class ColorSplitterBlock extends NodeMaterialBlock {
  102521. /**
  102522. * Create a new ColorSplitterBlock
  102523. * @param name defines the block name
  102524. */
  102525. constructor(name: string);
  102526. /**
  102527. * Gets the current class name
  102528. * @returns the class name
  102529. */
  102530. getClassName(): string;
  102531. /**
  102532. * Gets the rgba component (input)
  102533. */
  102534. get rgba(): NodeMaterialConnectionPoint;
  102535. /**
  102536. * Gets the rgb component (input)
  102537. */
  102538. get rgbIn(): NodeMaterialConnectionPoint;
  102539. /**
  102540. * Gets the rgb component (output)
  102541. */
  102542. get rgbOut(): NodeMaterialConnectionPoint;
  102543. /**
  102544. * Gets the r component (output)
  102545. */
  102546. get r(): NodeMaterialConnectionPoint;
  102547. /**
  102548. * Gets the g component (output)
  102549. */
  102550. get g(): NodeMaterialConnectionPoint;
  102551. /**
  102552. * Gets the b component (output)
  102553. */
  102554. get b(): NodeMaterialConnectionPoint;
  102555. /**
  102556. * Gets the a component (output)
  102557. */
  102558. get a(): NodeMaterialConnectionPoint;
  102559. protected _inputRename(name: string): string;
  102560. protected _outputRename(name: string): string;
  102561. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102562. }
  102563. }
  102564. declare module BABYLON {
  102565. /**
  102566. * Operations supported by the Trigonometry block
  102567. */
  102568. export enum TrigonometryBlockOperations {
  102569. /** Cos */
  102570. Cos = 0,
  102571. /** Sin */
  102572. Sin = 1,
  102573. /** Abs */
  102574. Abs = 2,
  102575. /** Exp */
  102576. Exp = 3,
  102577. /** Exp2 */
  102578. Exp2 = 4,
  102579. /** Round */
  102580. Round = 5,
  102581. /** Floor */
  102582. Floor = 6,
  102583. /** Ceiling */
  102584. Ceiling = 7,
  102585. /** Square root */
  102586. Sqrt = 8,
  102587. /** Log */
  102588. Log = 9,
  102589. /** Tangent */
  102590. Tan = 10,
  102591. /** Arc tangent */
  102592. ArcTan = 11,
  102593. /** Arc cosinus */
  102594. ArcCos = 12,
  102595. /** Arc sinus */
  102596. ArcSin = 13,
  102597. /** Fraction */
  102598. Fract = 14,
  102599. /** Sign */
  102600. Sign = 15,
  102601. /** To radians (from degrees) */
  102602. Radians = 16,
  102603. /** To degrees (from radians) */
  102604. Degrees = 17
  102605. }
  102606. /**
  102607. * Block used to apply trigonometry operation to floats
  102608. */
  102609. export class TrigonometryBlock extends NodeMaterialBlock {
  102610. /**
  102611. * Gets or sets the operation applied by the block
  102612. */
  102613. operation: TrigonometryBlockOperations;
  102614. /**
  102615. * Creates a new TrigonometryBlock
  102616. * @param name defines the block name
  102617. */
  102618. constructor(name: string);
  102619. /**
  102620. * Gets the current class name
  102621. * @returns the class name
  102622. */
  102623. getClassName(): string;
  102624. /**
  102625. * Gets the input component
  102626. */
  102627. get input(): NodeMaterialConnectionPoint;
  102628. /**
  102629. * Gets the output component
  102630. */
  102631. get output(): NodeMaterialConnectionPoint;
  102632. protected _buildBlock(state: NodeMaterialBuildState): this;
  102633. serialize(): any;
  102634. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102635. protected _dumpPropertiesCode(): string;
  102636. }
  102637. }
  102638. declare module BABYLON {
  102639. /**
  102640. * Interface used to configure the node material editor
  102641. */
  102642. export interface INodeMaterialEditorOptions {
  102643. /** Define the URl to load node editor script */
  102644. editorURL?: string;
  102645. }
  102646. /** @hidden */
  102647. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102648. NORMAL: boolean;
  102649. TANGENT: boolean;
  102650. UV1: boolean;
  102651. /** BONES */
  102652. NUM_BONE_INFLUENCERS: number;
  102653. BonesPerMesh: number;
  102654. BONETEXTURE: boolean;
  102655. /** MORPH TARGETS */
  102656. MORPHTARGETS: boolean;
  102657. MORPHTARGETS_NORMAL: boolean;
  102658. MORPHTARGETS_TANGENT: boolean;
  102659. MORPHTARGETS_UV: boolean;
  102660. NUM_MORPH_INFLUENCERS: number;
  102661. /** IMAGE PROCESSING */
  102662. IMAGEPROCESSING: boolean;
  102663. VIGNETTE: boolean;
  102664. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102665. VIGNETTEBLENDMODEOPAQUE: boolean;
  102666. TONEMAPPING: boolean;
  102667. TONEMAPPING_ACES: boolean;
  102668. CONTRAST: boolean;
  102669. EXPOSURE: boolean;
  102670. COLORCURVES: boolean;
  102671. COLORGRADING: boolean;
  102672. COLORGRADING3D: boolean;
  102673. SAMPLER3DGREENDEPTH: boolean;
  102674. SAMPLER3DBGRMAP: boolean;
  102675. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102676. /** MISC. */
  102677. BUMPDIRECTUV: number;
  102678. constructor();
  102679. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102680. }
  102681. /**
  102682. * Class used to configure NodeMaterial
  102683. */
  102684. export interface INodeMaterialOptions {
  102685. /**
  102686. * Defines if blocks should emit comments
  102687. */
  102688. emitComments: boolean;
  102689. }
  102690. /**
  102691. * Class used to create a node based material built by assembling shader blocks
  102692. */
  102693. export class NodeMaterial extends PushMaterial {
  102694. private static _BuildIdGenerator;
  102695. private _options;
  102696. private _vertexCompilationState;
  102697. private _fragmentCompilationState;
  102698. private _sharedData;
  102699. private _buildId;
  102700. private _buildWasSuccessful;
  102701. private _cachedWorldViewMatrix;
  102702. private _cachedWorldViewProjectionMatrix;
  102703. private _optimizers;
  102704. private _animationFrame;
  102705. /** Define the Url to load node editor script */
  102706. static EditorURL: string;
  102707. /** Define the Url to load snippets */
  102708. static SnippetUrl: string;
  102709. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102710. static IgnoreTexturesAtLoadTime: boolean;
  102711. private BJSNODEMATERIALEDITOR;
  102712. /** Get the inspector from bundle or global */
  102713. private _getGlobalNodeMaterialEditor;
  102714. /**
  102715. * Snippet ID if the material was created from the snippet server
  102716. */
  102717. snippetId: string;
  102718. /**
  102719. * Gets or sets data used by visual editor
  102720. * @see https://nme.babylonjs.com
  102721. */
  102722. editorData: any;
  102723. /**
  102724. * 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)
  102725. */
  102726. ignoreAlpha: boolean;
  102727. /**
  102728. * Defines the maximum number of lights that can be used in the material
  102729. */
  102730. maxSimultaneousLights: number;
  102731. /**
  102732. * Observable raised when the material is built
  102733. */
  102734. onBuildObservable: Observable<NodeMaterial>;
  102735. /**
  102736. * Gets or sets the root nodes of the material vertex shader
  102737. */
  102738. _vertexOutputNodes: NodeMaterialBlock[];
  102739. /**
  102740. * Gets or sets the root nodes of the material fragment (pixel) shader
  102741. */
  102742. _fragmentOutputNodes: NodeMaterialBlock[];
  102743. /** Gets or sets options to control the node material overall behavior */
  102744. get options(): INodeMaterialOptions;
  102745. set options(options: INodeMaterialOptions);
  102746. /**
  102747. * Default configuration related to image processing available in the standard Material.
  102748. */
  102749. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102750. /**
  102751. * Gets the image processing configuration used either in this material.
  102752. */
  102753. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102754. /**
  102755. * Sets the Default image processing configuration used either in the this material.
  102756. *
  102757. * If sets to null, the scene one is in use.
  102758. */
  102759. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102760. /**
  102761. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102762. */
  102763. attachedBlocks: NodeMaterialBlock[];
  102764. /**
  102765. * Specifies the mode of the node material
  102766. * @hidden
  102767. */
  102768. _mode: NodeMaterialModes;
  102769. /**
  102770. * Gets the mode property
  102771. */
  102772. get mode(): NodeMaterialModes;
  102773. /**
  102774. * Create a new node based material
  102775. * @param name defines the material name
  102776. * @param scene defines the hosting scene
  102777. * @param options defines creation option
  102778. */
  102779. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102780. /**
  102781. * Gets the current class name of the material e.g. "NodeMaterial"
  102782. * @returns the class name
  102783. */
  102784. getClassName(): string;
  102785. /**
  102786. * Keep track of the image processing observer to allow dispose and replace.
  102787. */
  102788. private _imageProcessingObserver;
  102789. /**
  102790. * Attaches a new image processing configuration to the Standard Material.
  102791. * @param configuration
  102792. */
  102793. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102794. /**
  102795. * Get a block by its name
  102796. * @param name defines the name of the block to retrieve
  102797. * @returns the required block or null if not found
  102798. */
  102799. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102800. /**
  102801. * Get a block by its name
  102802. * @param predicate defines the predicate used to find the good candidate
  102803. * @returns the required block or null if not found
  102804. */
  102805. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102806. /**
  102807. * Get an input block by its name
  102808. * @param predicate defines the predicate used to find the good candidate
  102809. * @returns the required input block or null if not found
  102810. */
  102811. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102812. /**
  102813. * Gets the list of input blocks attached to this material
  102814. * @returns an array of InputBlocks
  102815. */
  102816. getInputBlocks(): InputBlock[];
  102817. /**
  102818. * Adds a new optimizer to the list of optimizers
  102819. * @param optimizer defines the optimizers to add
  102820. * @returns the current material
  102821. */
  102822. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102823. /**
  102824. * Remove an optimizer from the list of optimizers
  102825. * @param optimizer defines the optimizers to remove
  102826. * @returns the current material
  102827. */
  102828. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102829. /**
  102830. * Add a new block to the list of output nodes
  102831. * @param node defines the node to add
  102832. * @returns the current material
  102833. */
  102834. addOutputNode(node: NodeMaterialBlock): this;
  102835. /**
  102836. * Remove a block from the list of root nodes
  102837. * @param node defines the node to remove
  102838. * @returns the current material
  102839. */
  102840. removeOutputNode(node: NodeMaterialBlock): this;
  102841. private _addVertexOutputNode;
  102842. private _removeVertexOutputNode;
  102843. private _addFragmentOutputNode;
  102844. private _removeFragmentOutputNode;
  102845. /**
  102846. * Specifies if the material will require alpha blending
  102847. * @returns a boolean specifying if alpha blending is needed
  102848. */
  102849. needAlphaBlending(): boolean;
  102850. /**
  102851. * Specifies if this material should be rendered in alpha test mode
  102852. * @returns a boolean specifying if an alpha test is needed.
  102853. */
  102854. needAlphaTesting(): boolean;
  102855. private _initializeBlock;
  102856. private _resetDualBlocks;
  102857. /**
  102858. * Remove a block from the current node material
  102859. * @param block defines the block to remove
  102860. */
  102861. removeBlock(block: NodeMaterialBlock): void;
  102862. /**
  102863. * Build the material and generates the inner effect
  102864. * @param verbose defines if the build should log activity
  102865. */
  102866. build(verbose?: boolean): void;
  102867. /**
  102868. * Runs an otpimization phase to try to improve the shader code
  102869. */
  102870. optimize(): void;
  102871. private _prepareDefinesForAttributes;
  102872. /**
  102873. * Create a post process from the material
  102874. * @param camera The camera to apply the render pass to.
  102875. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102877. * @param engine The engine which the post process will be applied. (default: current engine)
  102878. * @param reusable If the post process can be reused on the same frame. (default: false)
  102879. * @param textureType Type of textures used when performing the post process. (default: 0)
  102880. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102881. * @returns the post process created
  102882. */
  102883. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  102884. /**
  102885. * Create the post process effect from the material
  102886. * @param postProcess The post process to create the effect for
  102887. */
  102888. createEffectForPostProcess(postProcess: PostProcess): void;
  102889. private _createEffectForPostProcess;
  102890. /**
  102891. * Create a new procedural texture based on this node material
  102892. * @param size defines the size of the texture
  102893. * @param scene defines the hosting scene
  102894. * @returns the new procedural texture attached to this node material
  102895. */
  102896. createProceduralTexture(size: number | {
  102897. width: number;
  102898. height: number;
  102899. layers?: number;
  102900. }, scene: Scene): Nullable<ProceduralTexture>;
  102901. private _createEffectForParticles;
  102902. private _checkInternals;
  102903. /**
  102904. * Create the effect to be used as the custom effect for a particle system
  102905. * @param particleSystem Particle system to create the effect for
  102906. * @param onCompiled defines a function to call when the effect creation is successful
  102907. * @param onError defines a function to call when the effect creation has failed
  102908. */
  102909. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102910. private _processDefines;
  102911. /**
  102912. * Get if the submesh is ready to be used and all its information available.
  102913. * Child classes can use it to update shaders
  102914. * @param mesh defines the mesh to check
  102915. * @param subMesh defines which submesh to check
  102916. * @param useInstances specifies that instances should be used
  102917. * @returns a boolean indicating that the submesh is ready or not
  102918. */
  102919. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102920. /**
  102921. * Get a string representing the shaders built by the current node graph
  102922. */
  102923. get compiledShaders(): string;
  102924. /**
  102925. * Binds the world matrix to the material
  102926. * @param world defines the world transformation matrix
  102927. */
  102928. bindOnlyWorldMatrix(world: Matrix): void;
  102929. /**
  102930. * Binds the submesh to this material by preparing the effect and shader to draw
  102931. * @param world defines the world transformation matrix
  102932. * @param mesh defines the mesh containing the submesh
  102933. * @param subMesh defines the submesh to bind the material to
  102934. */
  102935. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102936. /**
  102937. * Gets the active textures from the material
  102938. * @returns an array of textures
  102939. */
  102940. getActiveTextures(): BaseTexture[];
  102941. /**
  102942. * Gets the list of texture blocks
  102943. * @returns an array of texture blocks
  102944. */
  102945. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102946. /**
  102947. * Specifies if the material uses a texture
  102948. * @param texture defines the texture to check against the material
  102949. * @returns a boolean specifying if the material uses the texture
  102950. */
  102951. hasTexture(texture: BaseTexture): boolean;
  102952. /**
  102953. * Disposes the material
  102954. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102955. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102956. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102957. */
  102958. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102959. /** Creates the node editor window. */
  102960. private _createNodeEditor;
  102961. /**
  102962. * Launch the node material editor
  102963. * @param config Define the configuration of the editor
  102964. * @return a promise fulfilled when the node editor is visible
  102965. */
  102966. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102967. /**
  102968. * Clear the current material
  102969. */
  102970. clear(): void;
  102971. /**
  102972. * Clear the current material and set it to a default state
  102973. */
  102974. setToDefault(): void;
  102975. /**
  102976. * Clear the current material and set it to a default state for post process
  102977. */
  102978. setToDefaultPostProcess(): void;
  102979. /**
  102980. * Clear the current material and set it to a default state for procedural texture
  102981. */
  102982. setToDefaultProceduralTexture(): void;
  102983. /**
  102984. * Clear the current material and set it to a default state for particle
  102985. */
  102986. setToDefaultParticle(): void;
  102987. /**
  102988. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102989. * @param url defines the url to load from
  102990. * @returns a promise that will fullfil when the material is fully loaded
  102991. */
  102992. loadAsync(url: string): Promise<void>;
  102993. private _gatherBlocks;
  102994. /**
  102995. * Generate a string containing the code declaration required to create an equivalent of this material
  102996. * @returns a string
  102997. */
  102998. generateCode(): string;
  102999. /**
  103000. * Serializes this material in a JSON representation
  103001. * @returns the serialized material object
  103002. */
  103003. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103004. private _restoreConnections;
  103005. /**
  103006. * Clear the current graph and load a new one from a serialization object
  103007. * @param source defines the JSON representation of the material
  103008. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103009. * @param merge defines whether or not the source must be merged or replace the current content
  103010. */
  103011. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103012. /**
  103013. * Makes a duplicate of the current material.
  103014. * @param name - name to use for the new material.
  103015. */
  103016. clone(name: string): NodeMaterial;
  103017. /**
  103018. * Creates a node material from parsed material data
  103019. * @param source defines the JSON representation of the material
  103020. * @param scene defines the hosting scene
  103021. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103022. * @returns a new node material
  103023. */
  103024. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103025. /**
  103026. * Creates a node material from a snippet saved in a remote file
  103027. * @param name defines the name of the material to create
  103028. * @param url defines the url to load from
  103029. * @param scene defines the hosting scene
  103030. * @returns a promise that will resolve to the new node material
  103031. */
  103032. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103033. /**
  103034. * Creates a node material from a snippet saved by the node material editor
  103035. * @param snippetId defines the snippet to load
  103036. * @param scene defines the hosting scene
  103037. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103038. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103039. * @returns a promise that will resolve to the new node material
  103040. */
  103041. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103042. /**
  103043. * Creates a new node material set to default basic configuration
  103044. * @param name defines the name of the material
  103045. * @param scene defines the hosting scene
  103046. * @returns a new NodeMaterial
  103047. */
  103048. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103049. }
  103050. }
  103051. declare module BABYLON {
  103052. /**
  103053. * Size options for a post process
  103054. */
  103055. export type PostProcessOptions = {
  103056. width: number;
  103057. height: number;
  103058. };
  103059. /**
  103060. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103061. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103062. */
  103063. export class PostProcess {
  103064. /**
  103065. * Gets or sets the unique id of the post process
  103066. */
  103067. uniqueId: number;
  103068. /** Name of the PostProcess. */
  103069. name: string;
  103070. /**
  103071. * Width of the texture to apply the post process on
  103072. */
  103073. width: number;
  103074. /**
  103075. * Height of the texture to apply the post process on
  103076. */
  103077. height: number;
  103078. /**
  103079. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103080. */
  103081. nodeMaterialSource: Nullable<NodeMaterial>;
  103082. /**
  103083. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103084. * @hidden
  103085. */
  103086. _outputTexture: Nullable<InternalTexture>;
  103087. /**
  103088. * Sampling mode used by the shader
  103089. * See https://doc.babylonjs.com/classes/3.1/texture
  103090. */
  103091. renderTargetSamplingMode: number;
  103092. /**
  103093. * Clear color to use when screen clearing
  103094. */
  103095. clearColor: Color4;
  103096. /**
  103097. * If the buffer needs to be cleared before applying the post process. (default: true)
  103098. * Should be set to false if shader will overwrite all previous pixels.
  103099. */
  103100. autoClear: boolean;
  103101. /**
  103102. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103103. */
  103104. alphaMode: number;
  103105. /**
  103106. * Sets the setAlphaBlendConstants of the babylon engine
  103107. */
  103108. alphaConstants: Color4;
  103109. /**
  103110. * Animations to be used for the post processing
  103111. */
  103112. animations: Animation[];
  103113. /**
  103114. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103115. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103116. */
  103117. enablePixelPerfectMode: boolean;
  103118. /**
  103119. * Force the postprocess to be applied without taking in account viewport
  103120. */
  103121. forceFullscreenViewport: boolean;
  103122. /**
  103123. * List of inspectable custom properties (used by the Inspector)
  103124. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103125. */
  103126. inspectableCustomProperties: IInspectable[];
  103127. /**
  103128. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103129. *
  103130. * | Value | Type | Description |
  103131. * | ----- | ----------------------------------- | ----------- |
  103132. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103133. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103134. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103135. *
  103136. */
  103137. scaleMode: number;
  103138. /**
  103139. * Force textures to be a power of two (default: false)
  103140. */
  103141. alwaysForcePOT: boolean;
  103142. private _samples;
  103143. /**
  103144. * Number of sample textures (default: 1)
  103145. */
  103146. get samples(): number;
  103147. set samples(n: number);
  103148. /**
  103149. * Modify the scale of the post process to be the same as the viewport (default: false)
  103150. */
  103151. adaptScaleToCurrentViewport: boolean;
  103152. private _camera;
  103153. protected _scene: Scene;
  103154. private _engine;
  103155. private _options;
  103156. private _reusable;
  103157. private _textureType;
  103158. private _textureFormat;
  103159. /**
  103160. * Smart array of input and output textures for the post process.
  103161. * @hidden
  103162. */
  103163. _textures: SmartArray<InternalTexture>;
  103164. /**
  103165. * The index in _textures that corresponds to the output texture.
  103166. * @hidden
  103167. */
  103168. _currentRenderTextureInd: number;
  103169. private _effect;
  103170. private _samplers;
  103171. private _fragmentUrl;
  103172. private _vertexUrl;
  103173. private _parameters;
  103174. private _scaleRatio;
  103175. protected _indexParameters: any;
  103176. private _shareOutputWithPostProcess;
  103177. private _texelSize;
  103178. private _forcedOutputTexture;
  103179. /**
  103180. * Returns the fragment url or shader name used in the post process.
  103181. * @returns the fragment url or name in the shader store.
  103182. */
  103183. getEffectName(): string;
  103184. /**
  103185. * An event triggered when the postprocess is activated.
  103186. */
  103187. onActivateObservable: Observable<Camera>;
  103188. private _onActivateObserver;
  103189. /**
  103190. * A function that is added to the onActivateObservable
  103191. */
  103192. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103193. /**
  103194. * An event triggered when the postprocess changes its size.
  103195. */
  103196. onSizeChangedObservable: Observable<PostProcess>;
  103197. private _onSizeChangedObserver;
  103198. /**
  103199. * A function that is added to the onSizeChangedObservable
  103200. */
  103201. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103202. /**
  103203. * An event triggered when the postprocess applies its effect.
  103204. */
  103205. onApplyObservable: Observable<Effect>;
  103206. private _onApplyObserver;
  103207. /**
  103208. * A function that is added to the onApplyObservable
  103209. */
  103210. set onApply(callback: (effect: Effect) => void);
  103211. /**
  103212. * An event triggered before rendering the postprocess
  103213. */
  103214. onBeforeRenderObservable: Observable<Effect>;
  103215. private _onBeforeRenderObserver;
  103216. /**
  103217. * A function that is added to the onBeforeRenderObservable
  103218. */
  103219. set onBeforeRender(callback: (effect: Effect) => void);
  103220. /**
  103221. * An event triggered after rendering the postprocess
  103222. */
  103223. onAfterRenderObservable: Observable<Effect>;
  103224. private _onAfterRenderObserver;
  103225. /**
  103226. * A function that is added to the onAfterRenderObservable
  103227. */
  103228. set onAfterRender(callback: (efect: Effect) => void);
  103229. /**
  103230. * 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
  103231. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  103232. */
  103233. get inputTexture(): InternalTexture;
  103234. set inputTexture(value: InternalTexture);
  103235. /**
  103236. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  103237. * the only way to unset it is to use this function to restore its internal state
  103238. */
  103239. restoreDefaultInputTexture(): void;
  103240. /**
  103241. * Gets the camera which post process is applied to.
  103242. * @returns The camera the post process is applied to.
  103243. */
  103244. getCamera(): Camera;
  103245. /**
  103246. * Gets the texel size of the postprocess.
  103247. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  103248. */
  103249. get texelSize(): Vector2;
  103250. /**
  103251. * Creates a new instance PostProcess
  103252. * @param name The name of the PostProcess.
  103253. * @param fragmentUrl The url of the fragment shader to be used.
  103254. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  103255. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  103256. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103257. * @param camera The camera to apply the render pass to.
  103258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103259. * @param engine The engine which the post process will be applied. (default: current engine)
  103260. * @param reusable If the post process can be reused on the same frame. (default: false)
  103261. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  103262. * @param textureType Type of textures used when performing the post process. (default: 0)
  103263. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  103264. * @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
  103265. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  103266. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103267. */
  103268. 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);
  103269. /**
  103270. * Gets a string identifying the name of the class
  103271. * @returns "PostProcess" string
  103272. */
  103273. getClassName(): string;
  103274. /**
  103275. * Gets the engine which this post process belongs to.
  103276. * @returns The engine the post process was enabled with.
  103277. */
  103278. getEngine(): Engine;
  103279. /**
  103280. * The effect that is created when initializing the post process.
  103281. * @returns The created effect corresponding the the postprocess.
  103282. */
  103283. getEffect(): Effect;
  103284. /**
  103285. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  103286. * @param postProcess The post process to share the output with.
  103287. * @returns This post process.
  103288. */
  103289. shareOutputWith(postProcess: PostProcess): PostProcess;
  103290. /**
  103291. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  103292. * This should be called if the post process that shares output with this post process is disabled/disposed.
  103293. */
  103294. useOwnOutput(): void;
  103295. /**
  103296. * Updates the effect with the current post process compile time values and recompiles the shader.
  103297. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103298. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103299. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103300. * @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
  103301. * @param onCompiled Called when the shader has been compiled.
  103302. * @param onError Called if there is an error when compiling a shader.
  103303. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  103304. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  103305. */
  103306. 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;
  103307. /**
  103308. * The post process is reusable if it can be used multiple times within one frame.
  103309. * @returns If the post process is reusable
  103310. */
  103311. isReusable(): boolean;
  103312. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  103313. markTextureDirty(): void;
  103314. /**
  103315. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  103316. * 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.
  103317. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  103318. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  103319. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  103320. * @returns The target texture that was bound to be written to.
  103321. */
  103322. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  103323. /**
  103324. * If the post process is supported.
  103325. */
  103326. get isSupported(): boolean;
  103327. /**
  103328. * The aspect ratio of the output texture.
  103329. */
  103330. get aspectRatio(): number;
  103331. /**
  103332. * Get a value indicating if the post-process is ready to be used
  103333. * @returns true if the post-process is ready (shader is compiled)
  103334. */
  103335. isReady(): boolean;
  103336. /**
  103337. * Binds all textures and uniforms to the shader, this will be run on every pass.
  103338. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  103339. */
  103340. apply(): Nullable<Effect>;
  103341. private _disposeTextures;
  103342. /**
  103343. * Disposes the post process.
  103344. * @param camera The camera to dispose the post process on.
  103345. */
  103346. dispose(camera?: Camera): void;
  103347. /**
  103348. * Serializes the particle system to a JSON object
  103349. * @returns the JSON object
  103350. */
  103351. serialize(): any;
  103352. /**
  103353. * Creates a material from parsed material data
  103354. * @param parsedPostProcess defines parsed post process data
  103355. * @param scene defines the hosting scene
  103356. * @param rootUrl defines the root URL to use to load textures
  103357. * @returns a new post process
  103358. */
  103359. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  103360. }
  103361. }
  103362. declare module BABYLON {
  103363. /** @hidden */
  103364. export var kernelBlurVaryingDeclaration: {
  103365. name: string;
  103366. shader: string;
  103367. };
  103368. }
  103369. declare module BABYLON {
  103370. /** @hidden */
  103371. export var kernelBlurFragment: {
  103372. name: string;
  103373. shader: string;
  103374. };
  103375. }
  103376. declare module BABYLON {
  103377. /** @hidden */
  103378. export var kernelBlurFragment2: {
  103379. name: string;
  103380. shader: string;
  103381. };
  103382. }
  103383. declare module BABYLON {
  103384. /** @hidden */
  103385. export var kernelBlurPixelShader: {
  103386. name: string;
  103387. shader: string;
  103388. };
  103389. }
  103390. declare module BABYLON {
  103391. /** @hidden */
  103392. export var kernelBlurVertex: {
  103393. name: string;
  103394. shader: string;
  103395. };
  103396. }
  103397. declare module BABYLON {
  103398. /** @hidden */
  103399. export var kernelBlurVertexShader: {
  103400. name: string;
  103401. shader: string;
  103402. };
  103403. }
  103404. declare module BABYLON {
  103405. /**
  103406. * The Blur Post Process which blurs an image based on a kernel and direction.
  103407. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  103408. */
  103409. export class BlurPostProcess extends PostProcess {
  103410. private blockCompilation;
  103411. protected _kernel: number;
  103412. protected _idealKernel: number;
  103413. protected _packedFloat: boolean;
  103414. private _staticDefines;
  103415. /** The direction in which to blur the image. */
  103416. direction: Vector2;
  103417. /**
  103418. * Sets the length in pixels of the blur sample region
  103419. */
  103420. set kernel(v: number);
  103421. /**
  103422. * Gets the length in pixels of the blur sample region
  103423. */
  103424. get kernel(): number;
  103425. /**
  103426. * Sets wether or not the blur needs to unpack/repack floats
  103427. */
  103428. set packedFloat(v: boolean);
  103429. /**
  103430. * Gets wether or not the blur is unpacking/repacking floats
  103431. */
  103432. get packedFloat(): boolean;
  103433. /**
  103434. * Gets a string identifying the name of the class
  103435. * @returns "BlurPostProcess" string
  103436. */
  103437. getClassName(): string;
  103438. /**
  103439. * Creates a new instance BlurPostProcess
  103440. * @param name The name of the effect.
  103441. * @param direction The direction in which to blur the image.
  103442. * @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.
  103443. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103444. * @param camera The camera to apply the render pass to.
  103445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103446. * @param engine The engine which the post process will be applied. (default: current engine)
  103447. * @param reusable If the post process can be reused on the same frame. (default: false)
  103448. * @param textureType Type of textures used when performing the post process. (default: 0)
  103449. * @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)
  103450. */
  103451. 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);
  103452. /**
  103453. * Updates the effect with the current post process compile time values and recompiles the shader.
  103454. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103455. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103456. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103457. * @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
  103458. * @param onCompiled Called when the shader has been compiled.
  103459. * @param onError Called if there is an error when compiling a shader.
  103460. */
  103461. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103462. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103463. /**
  103464. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  103465. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  103466. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  103467. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  103468. * The gaps between physical kernels are compensated for in the weighting of the samples
  103469. * @param idealKernel Ideal blur kernel.
  103470. * @return Nearest best kernel.
  103471. */
  103472. protected _nearestBestKernel(idealKernel: number): number;
  103473. /**
  103474. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  103475. * @param x The point on the Gaussian distribution to sample.
  103476. * @return the value of the Gaussian function at x.
  103477. */
  103478. protected _gaussianWeight(x: number): number;
  103479. /**
  103480. * Generates a string that can be used as a floating point number in GLSL.
  103481. * @param x Value to print.
  103482. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  103483. * @return GLSL float string.
  103484. */
  103485. protected _glslFloat(x: number, decimalFigures?: number): string;
  103486. /** @hidden */
  103487. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  103488. }
  103489. }
  103490. declare module BABYLON {
  103491. /**
  103492. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103493. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103494. * You can then easily use it as a reflectionTexture on a flat surface.
  103495. * In case the surface is not a plane, please consider relying on reflection probes.
  103496. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103497. */
  103498. export class MirrorTexture extends RenderTargetTexture {
  103499. private scene;
  103500. /**
  103501. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  103502. * 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.
  103503. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103504. */
  103505. mirrorPlane: Plane;
  103506. /**
  103507. * Define the blur ratio used to blur the reflection if needed.
  103508. */
  103509. set blurRatio(value: number);
  103510. get blurRatio(): number;
  103511. /**
  103512. * Define the adaptive blur kernel used to blur the reflection if needed.
  103513. * This will autocompute the closest best match for the `blurKernel`
  103514. */
  103515. set adaptiveBlurKernel(value: number);
  103516. /**
  103517. * Define the blur kernel used to blur the reflection if needed.
  103518. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103519. */
  103520. set blurKernel(value: number);
  103521. /**
  103522. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  103523. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103524. */
  103525. set blurKernelX(value: number);
  103526. get blurKernelX(): number;
  103527. /**
  103528. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  103529. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103530. */
  103531. set blurKernelY(value: number);
  103532. get blurKernelY(): number;
  103533. private _autoComputeBlurKernel;
  103534. protected _onRatioRescale(): void;
  103535. private _updateGammaSpace;
  103536. private _imageProcessingConfigChangeObserver;
  103537. private _transformMatrix;
  103538. private _mirrorMatrix;
  103539. private _savedViewMatrix;
  103540. private _blurX;
  103541. private _blurY;
  103542. private _adaptiveBlurKernel;
  103543. private _blurKernelX;
  103544. private _blurKernelY;
  103545. private _blurRatio;
  103546. /**
  103547. * Instantiates a Mirror Texture.
  103548. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103549. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103550. * You can then easily use it as a reflectionTexture on a flat surface.
  103551. * In case the surface is not a plane, please consider relying on reflection probes.
  103552. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103553. * @param name
  103554. * @param size
  103555. * @param scene
  103556. * @param generateMipMaps
  103557. * @param type
  103558. * @param samplingMode
  103559. * @param generateDepthBuffer
  103560. */
  103561. constructor(name: string, size: number | {
  103562. width: number;
  103563. height: number;
  103564. } | {
  103565. ratio: number;
  103566. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  103567. private _preparePostProcesses;
  103568. /**
  103569. * Clone the mirror texture.
  103570. * @returns the cloned texture
  103571. */
  103572. clone(): MirrorTexture;
  103573. /**
  103574. * Serialize the texture to a JSON representation you could use in Parse later on
  103575. * @returns the serialized JSON representation
  103576. */
  103577. serialize(): any;
  103578. /**
  103579. * Dispose the texture and release its associated resources.
  103580. */
  103581. dispose(): void;
  103582. }
  103583. }
  103584. declare module BABYLON {
  103585. /**
  103586. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103587. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103588. */
  103589. export class Texture extends BaseTexture {
  103590. /**
  103591. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  103592. */
  103593. static SerializeBuffers: boolean;
  103594. /** @hidden */
  103595. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  103596. /** @hidden */
  103597. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  103598. /** @hidden */
  103599. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  103600. /** nearest is mag = nearest and min = nearest and mip = linear */
  103601. static readonly NEAREST_SAMPLINGMODE: number;
  103602. /** nearest is mag = nearest and min = nearest and mip = linear */
  103603. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  103604. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103605. static readonly BILINEAR_SAMPLINGMODE: number;
  103606. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103607. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  103608. /** Trilinear is mag = linear and min = linear and mip = linear */
  103609. static readonly TRILINEAR_SAMPLINGMODE: number;
  103610. /** Trilinear is mag = linear and min = linear and mip = linear */
  103611. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  103612. /** mag = nearest and min = nearest and mip = nearest */
  103613. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  103614. /** mag = nearest and min = linear and mip = nearest */
  103615. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  103616. /** mag = nearest and min = linear and mip = linear */
  103617. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  103618. /** mag = nearest and min = linear and mip = none */
  103619. static readonly NEAREST_LINEAR: number;
  103620. /** mag = nearest and min = nearest and mip = none */
  103621. static readonly NEAREST_NEAREST: number;
  103622. /** mag = linear and min = nearest and mip = nearest */
  103623. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  103624. /** mag = linear and min = nearest and mip = linear */
  103625. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  103626. /** mag = linear and min = linear and mip = none */
  103627. static readonly LINEAR_LINEAR: number;
  103628. /** mag = linear and min = nearest and mip = none */
  103629. static readonly LINEAR_NEAREST: number;
  103630. /** Explicit coordinates mode */
  103631. static readonly EXPLICIT_MODE: number;
  103632. /** Spherical coordinates mode */
  103633. static readonly SPHERICAL_MODE: number;
  103634. /** Planar coordinates mode */
  103635. static readonly PLANAR_MODE: number;
  103636. /** Cubic coordinates mode */
  103637. static readonly CUBIC_MODE: number;
  103638. /** Projection coordinates mode */
  103639. static readonly PROJECTION_MODE: number;
  103640. /** Inverse Cubic coordinates mode */
  103641. static readonly SKYBOX_MODE: number;
  103642. /** Inverse Cubic coordinates mode */
  103643. static readonly INVCUBIC_MODE: number;
  103644. /** Equirectangular coordinates mode */
  103645. static readonly EQUIRECTANGULAR_MODE: number;
  103646. /** Equirectangular Fixed coordinates mode */
  103647. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  103648. /** Equirectangular Fixed Mirrored coordinates mode */
  103649. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103650. /** Texture is not repeating outside of 0..1 UVs */
  103651. static readonly CLAMP_ADDRESSMODE: number;
  103652. /** Texture is repeating outside of 0..1 UVs */
  103653. static readonly WRAP_ADDRESSMODE: number;
  103654. /** Texture is repeating and mirrored */
  103655. static readonly MIRROR_ADDRESSMODE: number;
  103656. /**
  103657. * 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
  103658. */
  103659. static UseSerializedUrlIfAny: boolean;
  103660. /**
  103661. * Define the url of the texture.
  103662. */
  103663. url: Nullable<string>;
  103664. /**
  103665. * Define an offset on the texture to offset the u coordinates of the UVs
  103666. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103667. */
  103668. uOffset: number;
  103669. /**
  103670. * Define an offset on the texture to offset the v coordinates of the UVs
  103671. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103672. */
  103673. vOffset: number;
  103674. /**
  103675. * Define an offset on the texture to scale the u coordinates of the UVs
  103676. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103677. */
  103678. uScale: number;
  103679. /**
  103680. * Define an offset on the texture to scale the v coordinates of the UVs
  103681. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103682. */
  103683. vScale: number;
  103684. /**
  103685. * Define an offset on the texture to rotate around the u coordinates of the UVs
  103686. * @see https://doc.babylonjs.com/how_to/more_materials
  103687. */
  103688. uAng: number;
  103689. /**
  103690. * Define an offset on the texture to rotate around the v coordinates of the UVs
  103691. * @see https://doc.babylonjs.com/how_to/more_materials
  103692. */
  103693. vAng: number;
  103694. /**
  103695. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  103696. * @see https://doc.babylonjs.com/how_to/more_materials
  103697. */
  103698. wAng: number;
  103699. /**
  103700. * Defines the center of rotation (U)
  103701. */
  103702. uRotationCenter: number;
  103703. /**
  103704. * Defines the center of rotation (V)
  103705. */
  103706. vRotationCenter: number;
  103707. /**
  103708. * Defines the center of rotation (W)
  103709. */
  103710. wRotationCenter: number;
  103711. /**
  103712. * Are mip maps generated for this texture or not.
  103713. */
  103714. get noMipmap(): boolean;
  103715. /**
  103716. * List of inspectable custom properties (used by the Inspector)
  103717. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103718. */
  103719. inspectableCustomProperties: Nullable<IInspectable[]>;
  103720. private _noMipmap;
  103721. /** @hidden */
  103722. _invertY: boolean;
  103723. private _rowGenerationMatrix;
  103724. private _cachedTextureMatrix;
  103725. private _projectionModeMatrix;
  103726. private _t0;
  103727. private _t1;
  103728. private _t2;
  103729. private _cachedUOffset;
  103730. private _cachedVOffset;
  103731. private _cachedUScale;
  103732. private _cachedVScale;
  103733. private _cachedUAng;
  103734. private _cachedVAng;
  103735. private _cachedWAng;
  103736. private _cachedProjectionMatrixId;
  103737. private _cachedCoordinatesMode;
  103738. /** @hidden */
  103739. protected _initialSamplingMode: number;
  103740. /** @hidden */
  103741. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103742. private _deleteBuffer;
  103743. protected _format: Nullable<number>;
  103744. private _delayedOnLoad;
  103745. private _delayedOnError;
  103746. private _mimeType?;
  103747. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  103748. get mimeType(): string | undefined;
  103749. /**
  103750. * Observable triggered once the texture has been loaded.
  103751. */
  103752. onLoadObservable: Observable<Texture>;
  103753. protected _isBlocking: boolean;
  103754. /**
  103755. * Is the texture preventing material to render while loading.
  103756. * If false, a default texture will be used instead of the loading one during the preparation step.
  103757. */
  103758. set isBlocking(value: boolean);
  103759. get isBlocking(): boolean;
  103760. /**
  103761. * Get the current sampling mode associated with the texture.
  103762. */
  103763. get samplingMode(): number;
  103764. /**
  103765. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  103766. */
  103767. get invertY(): boolean;
  103768. /**
  103769. * Instantiates a new texture.
  103770. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103771. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103772. * @param url defines the url of the picture to load as a texture
  103773. * @param sceneOrEngine defines the scene or engine the texture will belong to
  103774. * @param noMipmap defines if the texture will require mip maps or not
  103775. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  103776. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103777. * @param onLoad defines a callback triggered when the texture has been loaded
  103778. * @param onError defines a callback triggered when an error occurred during the loading session
  103779. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103780. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103781. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103782. * @param mimeType defines an optional mime type information
  103783. */
  103784. 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);
  103785. /**
  103786. * Update the url (and optional buffer) of this texture if url was null during construction.
  103787. * @param url the url of the texture
  103788. * @param buffer the buffer of the texture (defaults to null)
  103789. * @param onLoad callback called when the texture is loaded (defaults to null)
  103790. */
  103791. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103792. /**
  103793. * Finish the loading sequence of a texture flagged as delayed load.
  103794. * @hidden
  103795. */
  103796. delayLoad(): void;
  103797. private _prepareRowForTextureGeneration;
  103798. /**
  103799. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103800. * @returns the transform matrix of the texture.
  103801. */
  103802. getTextureMatrix(uBase?: number): Matrix;
  103803. /**
  103804. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103805. * @returns The reflection texture transform
  103806. */
  103807. getReflectionTextureMatrix(): Matrix;
  103808. /**
  103809. * Clones the texture.
  103810. * @returns the cloned texture
  103811. */
  103812. clone(): Texture;
  103813. /**
  103814. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103815. * @returns The JSON representation of the texture
  103816. */
  103817. serialize(): any;
  103818. /**
  103819. * Get the current class name of the texture useful for serialization or dynamic coding.
  103820. * @returns "Texture"
  103821. */
  103822. getClassName(): string;
  103823. /**
  103824. * Dispose the texture and release its associated resources.
  103825. */
  103826. dispose(): void;
  103827. /**
  103828. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103829. * @param parsedTexture Define the JSON representation of the texture
  103830. * @param scene Define the scene the parsed texture should be instantiated in
  103831. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103832. * @returns The parsed texture if successful
  103833. */
  103834. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103835. /**
  103836. * Creates a texture from its base 64 representation.
  103837. * @param data Define the base64 payload without the data: prefix
  103838. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103839. * @param scene Define the scene the texture should belong to
  103840. * @param noMipmap Forces the texture to not create mip map information if true
  103841. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103842. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103843. * @param onLoad define a callback triggered when the texture has been loaded
  103844. * @param onError define a callback triggered when an error occurred during the loading session
  103845. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103846. * @returns the created texture
  103847. */
  103848. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103849. /**
  103850. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103851. * @param data Define the base64 payload without the data: prefix
  103852. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103853. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103854. * @param scene Define the scene the texture should belong to
  103855. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103856. * @param noMipmap Forces the texture to not create mip map information if true
  103857. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103858. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103859. * @param onLoad define a callback triggered when the texture has been loaded
  103860. * @param onError define a callback triggered when an error occurred during the loading session
  103861. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103862. * @returns the created texture
  103863. */
  103864. 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;
  103865. }
  103866. }
  103867. declare module BABYLON {
  103868. /**
  103869. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103870. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103871. */
  103872. export class PostProcessManager {
  103873. private _scene;
  103874. private _indexBuffer;
  103875. private _vertexBuffers;
  103876. /**
  103877. * Creates a new instance PostProcess
  103878. * @param scene The scene that the post process is associated with.
  103879. */
  103880. constructor(scene: Scene);
  103881. private _prepareBuffers;
  103882. private _buildIndexBuffer;
  103883. /**
  103884. * Rebuilds the vertex buffers of the manager.
  103885. * @hidden
  103886. */
  103887. _rebuild(): void;
  103888. /**
  103889. * Prepares a frame to be run through a post process.
  103890. * @param sourceTexture The input texture to the post procesess. (default: null)
  103891. * @param postProcesses An array of post processes to be run. (default: null)
  103892. * @returns True if the post processes were able to be run.
  103893. * @hidden
  103894. */
  103895. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103896. /**
  103897. * Manually render a set of post processes to a texture.
  103898. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103899. * @param postProcesses An array of post processes to be run.
  103900. * @param targetTexture The target texture to render to.
  103901. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103902. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103903. * @param lodLevel defines which lod of the texture to render to
  103904. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103905. */
  103906. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103907. /**
  103908. * Finalize the result of the output of the postprocesses.
  103909. * @param doNotPresent If true the result will not be displayed to the screen.
  103910. * @param targetTexture The target texture to render to.
  103911. * @param faceIndex The index of the face to bind the target texture to.
  103912. * @param postProcesses The array of post processes to render.
  103913. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103914. * @hidden
  103915. */
  103916. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103917. /**
  103918. * Disposes of the post process manager.
  103919. */
  103920. dispose(): void;
  103921. }
  103922. }
  103923. declare module BABYLON {
  103924. /**
  103925. * This Helps creating a texture that will be created from a camera in your scene.
  103926. * It is basically a dynamic texture that could be used to create special effects for instance.
  103927. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103928. */
  103929. export class RenderTargetTexture extends Texture {
  103930. /**
  103931. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103932. */
  103933. static readonly REFRESHRATE_RENDER_ONCE: number;
  103934. /**
  103935. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103936. */
  103937. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103938. /**
  103939. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103940. * the central point of your effect and can save a lot of performances.
  103941. */
  103942. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103943. /**
  103944. * Use this predicate to dynamically define the list of mesh you want to render.
  103945. * If set, the renderList property will be overwritten.
  103946. */
  103947. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103948. private _renderList;
  103949. /**
  103950. * Use this list to define the list of mesh you want to render.
  103951. */
  103952. get renderList(): Nullable<Array<AbstractMesh>>;
  103953. set renderList(value: Nullable<Array<AbstractMesh>>);
  103954. /**
  103955. * Use this function to overload the renderList array at rendering time.
  103956. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103957. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103958. * the cube (if the RTT is a cube, else layerOrFace=0).
  103959. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103960. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103961. * hold dummy elements!
  103962. */
  103963. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103964. private _hookArray;
  103965. /**
  103966. * Define if particles should be rendered in your texture.
  103967. */
  103968. renderParticles: boolean;
  103969. /**
  103970. * Define if sprites should be rendered in your texture.
  103971. */
  103972. renderSprites: boolean;
  103973. /**
  103974. * Define the camera used to render the texture.
  103975. */
  103976. activeCamera: Nullable<Camera>;
  103977. /**
  103978. * Override the mesh isReady function with your own one.
  103979. */
  103980. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103981. /**
  103982. * Override the render function of the texture with your own one.
  103983. */
  103984. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103985. /**
  103986. * Define if camera post processes should be use while rendering the texture.
  103987. */
  103988. useCameraPostProcesses: boolean;
  103989. /**
  103990. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103991. */
  103992. ignoreCameraViewport: boolean;
  103993. private _postProcessManager;
  103994. private _postProcesses;
  103995. private _resizeObserver;
  103996. /**
  103997. * An event triggered when the texture is unbind.
  103998. */
  103999. onBeforeBindObservable: Observable<RenderTargetTexture>;
  104000. /**
  104001. * An event triggered when the texture is unbind.
  104002. */
  104003. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  104004. private _onAfterUnbindObserver;
  104005. /**
  104006. * Set a after unbind callback in the texture.
  104007. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  104008. */
  104009. set onAfterUnbind(callback: () => void);
  104010. /**
  104011. * An event triggered before rendering the texture
  104012. */
  104013. onBeforeRenderObservable: Observable<number>;
  104014. private _onBeforeRenderObserver;
  104015. /**
  104016. * Set a before render callback in the texture.
  104017. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  104018. */
  104019. set onBeforeRender(callback: (faceIndex: number) => void);
  104020. /**
  104021. * An event triggered after rendering the texture
  104022. */
  104023. onAfterRenderObservable: Observable<number>;
  104024. private _onAfterRenderObserver;
  104025. /**
  104026. * Set a after render callback in the texture.
  104027. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  104028. */
  104029. set onAfterRender(callback: (faceIndex: number) => void);
  104030. /**
  104031. * An event triggered after the texture clear
  104032. */
  104033. onClearObservable: Observable<Engine>;
  104034. private _onClearObserver;
  104035. /**
  104036. * Set a clear callback in the texture.
  104037. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  104038. */
  104039. set onClear(callback: (Engine: Engine) => void);
  104040. /**
  104041. * An event triggered when the texture is resized.
  104042. */
  104043. onResizeObservable: Observable<RenderTargetTexture>;
  104044. /**
  104045. * Define the clear color of the Render Target if it should be different from the scene.
  104046. */
  104047. clearColor: Color4;
  104048. protected _size: number | {
  104049. width: number;
  104050. height: number;
  104051. layers?: number;
  104052. };
  104053. protected _initialSizeParameter: number | {
  104054. width: number;
  104055. height: number;
  104056. } | {
  104057. ratio: number;
  104058. };
  104059. protected _sizeRatio: Nullable<number>;
  104060. /** @hidden */
  104061. _generateMipMaps: boolean;
  104062. protected _renderingManager: RenderingManager;
  104063. /** @hidden */
  104064. _waitingRenderList?: string[];
  104065. protected _doNotChangeAspectRatio: boolean;
  104066. protected _currentRefreshId: number;
  104067. protected _refreshRate: number;
  104068. protected _textureMatrix: Matrix;
  104069. protected _samples: number;
  104070. protected _renderTargetOptions: RenderTargetCreationOptions;
  104071. /**
  104072. * Gets render target creation options that were used.
  104073. */
  104074. get renderTargetOptions(): RenderTargetCreationOptions;
  104075. protected _onRatioRescale(): void;
  104076. /**
  104077. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  104078. * It must define where the camera used to render the texture is set
  104079. */
  104080. boundingBoxPosition: Vector3;
  104081. private _boundingBoxSize;
  104082. /**
  104083. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  104084. * When defined, the cubemap will switch to local mode
  104085. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104086. * @example https://www.babylonjs-playground.com/#RNASML
  104087. */
  104088. set boundingBoxSize(value: Vector3);
  104089. get boundingBoxSize(): Vector3;
  104090. /**
  104091. * In case the RTT has been created with a depth texture, get the associated
  104092. * depth texture.
  104093. * Otherwise, return null.
  104094. */
  104095. get depthStencilTexture(): Nullable<InternalTexture>;
  104096. /**
  104097. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  104098. * or used a shadow, depth texture...
  104099. * @param name The friendly name of the texture
  104100. * @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)
  104101. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  104102. * @param generateMipMaps True if mip maps need to be generated after render.
  104103. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  104104. * @param type The type of the buffer in the RTT (int, half float, float...)
  104105. * @param isCube True if a cube texture needs to be created
  104106. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  104107. * @param generateDepthBuffer True to generate a depth buffer
  104108. * @param generateStencilBuffer True to generate a stencil buffer
  104109. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  104110. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  104111. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104112. */
  104113. constructor(name: string, size: number | {
  104114. width: number;
  104115. height: number;
  104116. layers?: number;
  104117. } | {
  104118. ratio: number;
  104119. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  104120. /**
  104121. * Creates a depth stencil texture.
  104122. * This is only available in WebGL 2 or with the depth texture extension available.
  104123. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  104124. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  104125. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  104126. */
  104127. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  104128. private _processSizeParameter;
  104129. /**
  104130. * Define the number of samples to use in case of MSAA.
  104131. * It defaults to one meaning no MSAA has been enabled.
  104132. */
  104133. get samples(): number;
  104134. set samples(value: number);
  104135. /**
  104136. * Resets the refresh counter of the texture and start bak from scratch.
  104137. * Could be useful to regenerate the texture if it is setup to render only once.
  104138. */
  104139. resetRefreshCounter(): void;
  104140. /**
  104141. * Define the refresh rate of the texture or the rendering frequency.
  104142. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  104143. */
  104144. get refreshRate(): number;
  104145. set refreshRate(value: number);
  104146. /**
  104147. * Adds a post process to the render target rendering passes.
  104148. * @param postProcess define the post process to add
  104149. */
  104150. addPostProcess(postProcess: PostProcess): void;
  104151. /**
  104152. * Clear all the post processes attached to the render target
  104153. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  104154. */
  104155. clearPostProcesses(dispose?: boolean): void;
  104156. /**
  104157. * Remove one of the post process from the list of attached post processes to the texture
  104158. * @param postProcess define the post process to remove from the list
  104159. */
  104160. removePostProcess(postProcess: PostProcess): void;
  104161. /** @hidden */
  104162. _shouldRender(): boolean;
  104163. /**
  104164. * Gets the actual render size of the texture.
  104165. * @returns the width of the render size
  104166. */
  104167. getRenderSize(): number;
  104168. /**
  104169. * Gets the actual render width of the texture.
  104170. * @returns the width of the render size
  104171. */
  104172. getRenderWidth(): number;
  104173. /**
  104174. * Gets the actual render height of the texture.
  104175. * @returns the height of the render size
  104176. */
  104177. getRenderHeight(): number;
  104178. /**
  104179. * Gets the actual number of layers of the texture.
  104180. * @returns the number of layers
  104181. */
  104182. getRenderLayers(): number;
  104183. /**
  104184. * Get if the texture can be rescaled or not.
  104185. */
  104186. get canRescale(): boolean;
  104187. /**
  104188. * Resize the texture using a ratio.
  104189. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  104190. */
  104191. scale(ratio: number): void;
  104192. /**
  104193. * Get the texture reflection matrix used to rotate/transform the reflection.
  104194. * @returns the reflection matrix
  104195. */
  104196. getReflectionTextureMatrix(): Matrix;
  104197. /**
  104198. * Resize the texture to a new desired size.
  104199. * Be carrefull as it will recreate all the data in the new texture.
  104200. * @param size Define the new size. It can be:
  104201. * - a number for squared texture,
  104202. * - an object containing { width: number, height: number }
  104203. * - or an object containing a ratio { ratio: number }
  104204. */
  104205. resize(size: number | {
  104206. width: number;
  104207. height: number;
  104208. } | {
  104209. ratio: number;
  104210. }): void;
  104211. private _defaultRenderListPrepared;
  104212. /**
  104213. * Renders all the objects from the render list into the texture.
  104214. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  104215. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  104216. */
  104217. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  104218. private _bestReflectionRenderTargetDimension;
  104219. private _prepareRenderingManager;
  104220. /**
  104221. * @hidden
  104222. * @param faceIndex face index to bind to if this is a cubetexture
  104223. * @param layer defines the index of the texture to bind in the array
  104224. */
  104225. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  104226. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104227. private renderToTarget;
  104228. /**
  104229. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  104230. * This allowed control for front to back rendering or reversly depending of the special needs.
  104231. *
  104232. * @param renderingGroupId The rendering group id corresponding to its index
  104233. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  104234. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  104235. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  104236. */
  104237. 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;
  104238. /**
  104239. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  104240. *
  104241. * @param renderingGroupId The rendering group id corresponding to its index
  104242. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104243. */
  104244. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104245. /**
  104246. * Clones the texture.
  104247. * @returns the cloned texture
  104248. */
  104249. clone(): RenderTargetTexture;
  104250. /**
  104251. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104252. * @returns The JSON representation of the texture
  104253. */
  104254. serialize(): any;
  104255. /**
  104256. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  104257. */
  104258. disposeFramebufferObjects(): void;
  104259. /**
  104260. * Dispose the texture and release its associated resources.
  104261. */
  104262. dispose(): void;
  104263. /** @hidden */
  104264. _rebuild(): void;
  104265. /**
  104266. * Clear the info related to rendering groups preventing retention point in material dispose.
  104267. */
  104268. freeRenderingGroups(): void;
  104269. /**
  104270. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  104271. * @returns the view count
  104272. */
  104273. getViewCount(): number;
  104274. }
  104275. }
  104276. declare module BABYLON {
  104277. /**
  104278. * Class used to manipulate GUIDs
  104279. */
  104280. export class GUID {
  104281. /**
  104282. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104283. * Be aware Math.random() could cause collisions, but:
  104284. * "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"
  104285. * @returns a pseudo random id
  104286. */
  104287. static RandomId(): string;
  104288. }
  104289. }
  104290. declare module BABYLON {
  104291. /**
  104292. * Options to be used when creating a shadow depth material
  104293. */
  104294. export interface IIOptionShadowDepthMaterial {
  104295. /** Variables in the vertex shader code that need to have their names remapped.
  104296. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  104297. * "var_name" should be either: worldPos or vNormalW
  104298. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  104299. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  104300. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  104301. */
  104302. remappedVariables?: string[];
  104303. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  104304. standalone?: boolean;
  104305. }
  104306. /**
  104307. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  104308. */
  104309. export class ShadowDepthWrapper {
  104310. private _scene;
  104311. private _options?;
  104312. private _baseMaterial;
  104313. private _onEffectCreatedObserver;
  104314. private _subMeshToEffect;
  104315. private _subMeshToDepthEffect;
  104316. private _meshes;
  104317. /** @hidden */
  104318. _matriceNames: any;
  104319. /** Gets the standalone status of the wrapper */
  104320. get standalone(): boolean;
  104321. /** Gets the base material the wrapper is built upon */
  104322. get baseMaterial(): Material;
  104323. /**
  104324. * Instantiate a new shadow depth wrapper.
  104325. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  104326. * generate the shadow depth map. For more information, please refer to the documentation:
  104327. * https://doc.babylonjs.com/babylon101/shadows
  104328. * @param baseMaterial Material to wrap
  104329. * @param scene Define the scene the material belongs to
  104330. * @param options Options used to create the wrapper
  104331. */
  104332. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  104333. /**
  104334. * Gets the effect to use to generate the depth map
  104335. * @param subMesh subMesh to get the effect for
  104336. * @param shadowGenerator shadow generator to get the effect for
  104337. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  104338. */
  104339. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  104340. /**
  104341. * Specifies that the submesh is ready to be used for depth rendering
  104342. * @param subMesh submesh to check
  104343. * @param defines the list of defines to take into account when checking the effect
  104344. * @param shadowGenerator combined with subMesh, it defines the effect to check
  104345. * @param useInstances specifies that instances should be used
  104346. * @returns a boolean indicating that the submesh is ready or not
  104347. */
  104348. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  104349. /**
  104350. * Disposes the resources
  104351. */
  104352. dispose(): void;
  104353. private _makeEffect;
  104354. }
  104355. }
  104356. declare module BABYLON {
  104357. interface ThinEngine {
  104358. /**
  104359. * Unbind a list of render target textures from the webGL context
  104360. * This is used only when drawBuffer extension or webGL2 are active
  104361. * @param textures defines the render target textures to unbind
  104362. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104363. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104364. */
  104365. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104366. /**
  104367. * Create a multi render target texture
  104368. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  104369. * @param size defines the size of the texture
  104370. * @param options defines the creation options
  104371. * @returns the cube texture as an InternalTexture
  104372. */
  104373. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104374. /**
  104375. * Update the sample count for a given multiple render target texture
  104376. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104377. * @param textures defines the textures to update
  104378. * @param samples defines the sample count to set
  104379. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104380. */
  104381. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104382. /**
  104383. * Select a subsets of attachments to draw to.
  104384. * @param attachments gl attachments
  104385. */
  104386. bindAttachments(attachments: number[]): void;
  104387. }
  104388. }
  104389. declare module BABYLON {
  104390. /**
  104391. * Creation options of the multi render target texture.
  104392. */
  104393. export interface IMultiRenderTargetOptions {
  104394. /**
  104395. * Define if the texture needs to create mip maps after render.
  104396. */
  104397. generateMipMaps?: boolean;
  104398. /**
  104399. * Define the types of all the draw buffers we want to create
  104400. */
  104401. types?: number[];
  104402. /**
  104403. * Define the sampling modes of all the draw buffers we want to create
  104404. */
  104405. samplingModes?: number[];
  104406. /**
  104407. * Define if a depth buffer is required
  104408. */
  104409. generateDepthBuffer?: boolean;
  104410. /**
  104411. * Define if a stencil buffer is required
  104412. */
  104413. generateStencilBuffer?: boolean;
  104414. /**
  104415. * Define if a depth texture is required instead of a depth buffer
  104416. */
  104417. generateDepthTexture?: boolean;
  104418. /**
  104419. * Define the number of desired draw buffers
  104420. */
  104421. textureCount?: number;
  104422. /**
  104423. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104424. */
  104425. doNotChangeAspectRatio?: boolean;
  104426. /**
  104427. * Define the default type of the buffers we are creating
  104428. */
  104429. defaultType?: number;
  104430. }
  104431. /**
  104432. * A multi render target, like a render target provides the ability to render to a texture.
  104433. * Unlike the render target, it can render to several draw buffers in one draw.
  104434. * This is specially interesting in deferred rendering or for any effects requiring more than
  104435. * just one color from a single pass.
  104436. */
  104437. export class MultiRenderTarget extends RenderTargetTexture {
  104438. private _internalTextures;
  104439. private _textures;
  104440. private _multiRenderTargetOptions;
  104441. private _count;
  104442. /**
  104443. * Get if draw buffers are currently supported by the used hardware and browser.
  104444. */
  104445. get isSupported(): boolean;
  104446. /**
  104447. * Get the list of textures generated by the multi render target.
  104448. */
  104449. get textures(): Texture[];
  104450. /**
  104451. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104452. */
  104453. get count(): number;
  104454. /**
  104455. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104456. */
  104457. get depthTexture(): Texture;
  104458. /**
  104459. * Set the wrapping mode on U of all the textures we are rendering to.
  104460. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104461. */
  104462. set wrapU(wrap: number);
  104463. /**
  104464. * Set the wrapping mode on V of all the textures we are rendering to.
  104465. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104466. */
  104467. set wrapV(wrap: number);
  104468. /**
  104469. * Instantiate a new multi render target texture.
  104470. * A multi render target, like a render target provides the ability to render to a texture.
  104471. * Unlike the render target, it can render to several draw buffers in one draw.
  104472. * This is specially interesting in deferred rendering or for any effects requiring more than
  104473. * just one color from a single pass.
  104474. * @param name Define the name of the texture
  104475. * @param size Define the size of the buffers to render to
  104476. * @param count Define the number of target we are rendering into
  104477. * @param scene Define the scene the texture belongs to
  104478. * @param options Define the options used to create the multi render target
  104479. */
  104480. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104481. private _initTypes;
  104482. /** @hidden */
  104483. _rebuild(forceFullRebuild?: boolean): void;
  104484. private _createInternalTextures;
  104485. private _createTextures;
  104486. /**
  104487. * Define the number of samples used if MSAA is enabled.
  104488. */
  104489. get samples(): number;
  104490. set samples(value: number);
  104491. /**
  104492. * Resize all the textures in the multi render target.
  104493. * Be careful as it will recreate all the data in the new texture.
  104494. * @param size Define the new size
  104495. */
  104496. resize(size: any): void;
  104497. /**
  104498. * Changes the number of render targets in this MRT
  104499. * Be careful as it will recreate all the data in the new texture.
  104500. * @param count new texture count
  104501. * @param options Specifies texture types and sampling modes for new textures
  104502. */
  104503. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  104504. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104505. /**
  104506. * Dispose the render targets and their associated resources
  104507. */
  104508. dispose(): void;
  104509. /**
  104510. * Release all the underlying texture used as draw buffers.
  104511. */
  104512. releaseInternalTextures(): void;
  104513. }
  104514. }
  104515. declare module BABYLON {
  104516. /** @hidden */
  104517. export var imageProcessingPixelShader: {
  104518. name: string;
  104519. shader: string;
  104520. };
  104521. }
  104522. declare module BABYLON {
  104523. /**
  104524. * ImageProcessingPostProcess
  104525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104526. */
  104527. export class ImageProcessingPostProcess extends PostProcess {
  104528. /**
  104529. * Default configuration related to image processing available in the PBR Material.
  104530. */
  104531. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104532. /**
  104533. * Gets the image processing configuration used either in this material.
  104534. */
  104535. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104536. /**
  104537. * Sets the Default image processing configuration used either in the this material.
  104538. *
  104539. * If sets to null, the scene one is in use.
  104540. */
  104541. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104542. /**
  104543. * Keep track of the image processing observer to allow dispose and replace.
  104544. */
  104545. private _imageProcessingObserver;
  104546. /**
  104547. * Attaches a new image processing configuration to the PBR Material.
  104548. * @param configuration
  104549. */
  104550. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104551. /**
  104552. * If the post process is supported.
  104553. */
  104554. get isSupported(): boolean;
  104555. /**
  104556. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104557. */
  104558. get colorCurves(): Nullable<ColorCurves>;
  104559. /**
  104560. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104561. */
  104562. set colorCurves(value: Nullable<ColorCurves>);
  104563. /**
  104564. * Gets wether the color curves effect is enabled.
  104565. */
  104566. get colorCurvesEnabled(): boolean;
  104567. /**
  104568. * Sets wether the color curves effect is enabled.
  104569. */
  104570. set colorCurvesEnabled(value: boolean);
  104571. /**
  104572. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104573. */
  104574. get colorGradingTexture(): Nullable<BaseTexture>;
  104575. /**
  104576. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104577. */
  104578. set colorGradingTexture(value: Nullable<BaseTexture>);
  104579. /**
  104580. * Gets wether the color grading effect is enabled.
  104581. */
  104582. get colorGradingEnabled(): boolean;
  104583. /**
  104584. * Gets wether the color grading effect is enabled.
  104585. */
  104586. set colorGradingEnabled(value: boolean);
  104587. /**
  104588. * Gets exposure used in the effect.
  104589. */
  104590. get exposure(): number;
  104591. /**
  104592. * Sets exposure used in the effect.
  104593. */
  104594. set exposure(value: number);
  104595. /**
  104596. * Gets wether tonemapping is enabled or not.
  104597. */
  104598. get toneMappingEnabled(): boolean;
  104599. /**
  104600. * Sets wether tonemapping is enabled or not
  104601. */
  104602. set toneMappingEnabled(value: boolean);
  104603. /**
  104604. * Gets the type of tone mapping effect.
  104605. */
  104606. get toneMappingType(): number;
  104607. /**
  104608. * Sets the type of tone mapping effect.
  104609. */
  104610. set toneMappingType(value: number);
  104611. /**
  104612. * Gets contrast used in the effect.
  104613. */
  104614. get contrast(): number;
  104615. /**
  104616. * Sets contrast used in the effect.
  104617. */
  104618. set contrast(value: number);
  104619. /**
  104620. * Gets Vignette stretch size.
  104621. */
  104622. get vignetteStretch(): number;
  104623. /**
  104624. * Sets Vignette stretch size.
  104625. */
  104626. set vignetteStretch(value: number);
  104627. /**
  104628. * Gets Vignette centre X Offset.
  104629. */
  104630. get vignetteCentreX(): number;
  104631. /**
  104632. * Sets Vignette centre X Offset.
  104633. */
  104634. set vignetteCentreX(value: number);
  104635. /**
  104636. * Gets Vignette centre Y Offset.
  104637. */
  104638. get vignetteCentreY(): number;
  104639. /**
  104640. * Sets Vignette centre Y Offset.
  104641. */
  104642. set vignetteCentreY(value: number);
  104643. /**
  104644. * Gets Vignette weight or intensity of the vignette effect.
  104645. */
  104646. get vignetteWeight(): number;
  104647. /**
  104648. * Sets Vignette weight or intensity of the vignette effect.
  104649. */
  104650. set vignetteWeight(value: number);
  104651. /**
  104652. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104653. * if vignetteEnabled is set to true.
  104654. */
  104655. get vignetteColor(): Color4;
  104656. /**
  104657. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104658. * if vignetteEnabled is set to true.
  104659. */
  104660. set vignetteColor(value: Color4);
  104661. /**
  104662. * Gets Camera field of view used by the Vignette effect.
  104663. */
  104664. get vignetteCameraFov(): number;
  104665. /**
  104666. * Sets Camera field of view used by the Vignette effect.
  104667. */
  104668. set vignetteCameraFov(value: number);
  104669. /**
  104670. * Gets the vignette blend mode allowing different kind of effect.
  104671. */
  104672. get vignetteBlendMode(): number;
  104673. /**
  104674. * Sets the vignette blend mode allowing different kind of effect.
  104675. */
  104676. set vignetteBlendMode(value: number);
  104677. /**
  104678. * Gets wether the vignette effect is enabled.
  104679. */
  104680. get vignetteEnabled(): boolean;
  104681. /**
  104682. * Sets wether the vignette effect is enabled.
  104683. */
  104684. set vignetteEnabled(value: boolean);
  104685. private _fromLinearSpace;
  104686. /**
  104687. * Gets wether the input of the processing is in Gamma or Linear Space.
  104688. */
  104689. get fromLinearSpace(): boolean;
  104690. /**
  104691. * Sets wether the input of the processing is in Gamma or Linear Space.
  104692. */
  104693. set fromLinearSpace(value: boolean);
  104694. /**
  104695. * Defines cache preventing GC.
  104696. */
  104697. private _defines;
  104698. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104699. /**
  104700. * "ImageProcessingPostProcess"
  104701. * @returns "ImageProcessingPostProcess"
  104702. */
  104703. getClassName(): string;
  104704. /**
  104705. * @hidden
  104706. */
  104707. _updateParameters(): void;
  104708. dispose(camera?: Camera): void;
  104709. }
  104710. }
  104711. declare module BABYLON {
  104712. /**
  104713. * Interface for defining prepass effects in the prepass post-process pipeline
  104714. */
  104715. export interface PrePassEffectConfiguration {
  104716. /**
  104717. * Name of the effect
  104718. */
  104719. name: string;
  104720. /**
  104721. * Post process to attach for this effect
  104722. */
  104723. postProcess?: PostProcess;
  104724. /**
  104725. * Textures required in the MRT
  104726. */
  104727. texturesRequired: number[];
  104728. /**
  104729. * Is the effect enabled
  104730. */
  104731. enabled: boolean;
  104732. /**
  104733. * Disposes the effect configuration
  104734. */
  104735. dispose(): void;
  104736. /**
  104737. * Creates the associated post process
  104738. */
  104739. createPostProcess?: () => PostProcess;
  104740. }
  104741. }
  104742. declare module BABYLON {
  104743. /**
  104744. * Renders a pre pass of the scene
  104745. * This means every mesh in the scene will be rendered to a render target texture
  104746. * And then this texture will be composited to the rendering canvas with post processes
  104747. * It is necessary for effects like subsurface scattering or deferred shading
  104748. */
  104749. export class PrePassRenderer {
  104750. /** @hidden */
  104751. static _SceneComponentInitialization: (scene: Scene) => void;
  104752. private _textureFormats;
  104753. private _textureIndices;
  104754. private _scene;
  104755. private _engine;
  104756. private _isDirty;
  104757. /**
  104758. * Number of textures in the multi render target texture where the scene is directly rendered
  104759. */
  104760. mrtCount: number;
  104761. /**
  104762. * The render target where the scene is directly rendered
  104763. */
  104764. prePassRT: MultiRenderTarget;
  104765. private _multiRenderAttachments;
  104766. private _defaultAttachments;
  104767. private _clearAttachments;
  104768. private _postProcesses;
  104769. private readonly _clearColor;
  104770. /**
  104771. * Image processing post process for composition
  104772. */
  104773. imageProcessingPostProcess: ImageProcessingPostProcess;
  104774. /**
  104775. * Configuration for prepass effects
  104776. */
  104777. private _effectConfigurations;
  104778. /**
  104779. * Should materials render their geometry on the MRT
  104780. */
  104781. materialsShouldRenderGeometry: boolean;
  104782. /**
  104783. * Should materials render the irradiance information on the MRT
  104784. */
  104785. materialsShouldRenderIrradiance: boolean;
  104786. private _mrtFormats;
  104787. private _mrtLayout;
  104788. private _enabled;
  104789. /**
  104790. * Indicates if the prepass is enabled
  104791. */
  104792. get enabled(): boolean;
  104793. /**
  104794. * How many samples are used for MSAA of the scene render target
  104795. */
  104796. get samples(): number;
  104797. set samples(n: number);
  104798. /**
  104799. * Instanciates a prepass renderer
  104800. * @param scene The scene
  104801. */
  104802. constructor(scene: Scene);
  104803. private _initializeAttachments;
  104804. private _createCompositionEffect;
  104805. /**
  104806. * Indicates if rendering a prepass is supported
  104807. */
  104808. get isSupported(): boolean;
  104809. /**
  104810. * Sets the proper output textures to draw in the engine.
  104811. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104812. */
  104813. bindAttachmentsForEffect(effect: Effect): void;
  104814. /**
  104815. * @hidden
  104816. */
  104817. _beforeCameraDraw(): void;
  104818. /**
  104819. * @hidden
  104820. */
  104821. _afterCameraDraw(): void;
  104822. private _checkRTSize;
  104823. private _bindFrameBuffer;
  104824. /**
  104825. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104826. */
  104827. clear(): void;
  104828. private _setState;
  104829. private _checkTextureType;
  104830. /**
  104831. * Adds an effect configuration to the prepass.
  104832. * If an effect has already been added, it won't add it twice and will return the configuration
  104833. * already present.
  104834. * @param cfg the effect configuration
  104835. * @return the effect configuration now used by the prepass
  104836. */
  104837. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  104838. /**
  104839. * Returns the index of a texture in the multi render target texture array.
  104840. * @param type Texture type
  104841. * @return The index
  104842. */
  104843. getIndex(type: number): number;
  104844. private _enable;
  104845. private _disable;
  104846. private _resetLayout;
  104847. private _resetPostProcessChain;
  104848. private _bindPostProcessChain;
  104849. /**
  104850. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104851. */
  104852. markAsDirty(): void;
  104853. /**
  104854. * Enables a texture on the MultiRenderTarget for prepass
  104855. */
  104856. private _enableTextures;
  104857. private _update;
  104858. /**
  104859. * Disposes the prepass renderer.
  104860. */
  104861. dispose(): void;
  104862. }
  104863. }
  104864. declare module BABYLON {
  104865. /**
  104866. * Options for compiling materials.
  104867. */
  104868. export interface IMaterialCompilationOptions {
  104869. /**
  104870. * Defines whether clip planes are enabled.
  104871. */
  104872. clipPlane: boolean;
  104873. /**
  104874. * Defines whether instances are enabled.
  104875. */
  104876. useInstances: boolean;
  104877. }
  104878. /**
  104879. * Options passed when calling customShaderNameResolve
  104880. */
  104881. export interface ICustomShaderNameResolveOptions {
  104882. /**
  104883. * 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
  104884. */
  104885. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104886. }
  104887. /**
  104888. * Base class for the main features of a material in Babylon.js
  104889. */
  104890. export class Material implements IAnimatable {
  104891. /**
  104892. * Returns the triangle fill mode
  104893. */
  104894. static readonly TriangleFillMode: number;
  104895. /**
  104896. * Returns the wireframe mode
  104897. */
  104898. static readonly WireFrameFillMode: number;
  104899. /**
  104900. * Returns the point fill mode
  104901. */
  104902. static readonly PointFillMode: number;
  104903. /**
  104904. * Returns the point list draw mode
  104905. */
  104906. static readonly PointListDrawMode: number;
  104907. /**
  104908. * Returns the line list draw mode
  104909. */
  104910. static readonly LineListDrawMode: number;
  104911. /**
  104912. * Returns the line loop draw mode
  104913. */
  104914. static readonly LineLoopDrawMode: number;
  104915. /**
  104916. * Returns the line strip draw mode
  104917. */
  104918. static readonly LineStripDrawMode: number;
  104919. /**
  104920. * Returns the triangle strip draw mode
  104921. */
  104922. static readonly TriangleStripDrawMode: number;
  104923. /**
  104924. * Returns the triangle fan draw mode
  104925. */
  104926. static readonly TriangleFanDrawMode: number;
  104927. /**
  104928. * Stores the clock-wise side orientation
  104929. */
  104930. static readonly ClockWiseSideOrientation: number;
  104931. /**
  104932. * Stores the counter clock-wise side orientation
  104933. */
  104934. static readonly CounterClockWiseSideOrientation: number;
  104935. /**
  104936. * The dirty texture flag value
  104937. */
  104938. static readonly TextureDirtyFlag: number;
  104939. /**
  104940. * The dirty light flag value
  104941. */
  104942. static readonly LightDirtyFlag: number;
  104943. /**
  104944. * The dirty fresnel flag value
  104945. */
  104946. static readonly FresnelDirtyFlag: number;
  104947. /**
  104948. * The dirty attribute flag value
  104949. */
  104950. static readonly AttributesDirtyFlag: number;
  104951. /**
  104952. * The dirty misc flag value
  104953. */
  104954. static readonly MiscDirtyFlag: number;
  104955. /**
  104956. * The all dirty flag value
  104957. */
  104958. static readonly AllDirtyFlag: number;
  104959. /**
  104960. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104961. */
  104962. static readonly MATERIAL_OPAQUE: number;
  104963. /**
  104964. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104965. */
  104966. static readonly MATERIAL_ALPHATEST: number;
  104967. /**
  104968. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104969. */
  104970. static readonly MATERIAL_ALPHABLEND: number;
  104971. /**
  104972. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104973. * They are also discarded below the alpha cutoff threshold to improve performances.
  104974. */
  104975. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104976. /**
  104977. * The Whiteout method is used to blend normals.
  104978. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104979. */
  104980. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104981. /**
  104982. * The Reoriented Normal Mapping method is used to blend normals.
  104983. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104984. */
  104985. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104986. /**
  104987. * Custom callback helping to override the default shader used in the material.
  104988. */
  104989. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104990. /**
  104991. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104992. */
  104993. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104994. /**
  104995. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104996. * This means that the material can keep using a previous shader while a new one is being compiled.
  104997. * This is mostly used when shader parallel compilation is supported (true by default)
  104998. */
  104999. allowShaderHotSwapping: boolean;
  105000. /**
  105001. * The ID of the material
  105002. */
  105003. id: string;
  105004. /**
  105005. * Gets or sets the unique id of the material
  105006. */
  105007. uniqueId: number;
  105008. /**
  105009. * The name of the material
  105010. */
  105011. name: string;
  105012. /**
  105013. * Gets or sets user defined metadata
  105014. */
  105015. metadata: any;
  105016. /**
  105017. * For internal use only. Please do not use.
  105018. */
  105019. reservedDataStore: any;
  105020. /**
  105021. * Specifies if the ready state should be checked on each call
  105022. */
  105023. checkReadyOnEveryCall: boolean;
  105024. /**
  105025. * Specifies if the ready state should be checked once
  105026. */
  105027. checkReadyOnlyOnce: boolean;
  105028. /**
  105029. * The state of the material
  105030. */
  105031. state: string;
  105032. /**
  105033. * If the material can be rendered to several textures with MRT extension
  105034. */
  105035. get canRenderToMRT(): boolean;
  105036. /**
  105037. * The alpha value of the material
  105038. */
  105039. protected _alpha: number;
  105040. /**
  105041. * List of inspectable custom properties (used by the Inspector)
  105042. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105043. */
  105044. inspectableCustomProperties: IInspectable[];
  105045. /**
  105046. * Sets the alpha value of the material
  105047. */
  105048. set alpha(value: number);
  105049. /**
  105050. * Gets the alpha value of the material
  105051. */
  105052. get alpha(): number;
  105053. /**
  105054. * Specifies if back face culling is enabled
  105055. */
  105056. protected _backFaceCulling: boolean;
  105057. /**
  105058. * Sets the back-face culling state
  105059. */
  105060. set backFaceCulling(value: boolean);
  105061. /**
  105062. * Gets the back-face culling state
  105063. */
  105064. get backFaceCulling(): boolean;
  105065. /**
  105066. * Stores the value for side orientation
  105067. */
  105068. sideOrientation: number;
  105069. /**
  105070. * Callback triggered when the material is compiled
  105071. */
  105072. onCompiled: Nullable<(effect: Effect) => void>;
  105073. /**
  105074. * Callback triggered when an error occurs
  105075. */
  105076. onError: Nullable<(effect: Effect, errors: string) => void>;
  105077. /**
  105078. * Callback triggered to get the render target textures
  105079. */
  105080. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  105081. /**
  105082. * Gets a boolean indicating that current material needs to register RTT
  105083. */
  105084. get hasRenderTargetTextures(): boolean;
  105085. /**
  105086. * Specifies if the material should be serialized
  105087. */
  105088. doNotSerialize: boolean;
  105089. /**
  105090. * @hidden
  105091. */
  105092. _storeEffectOnSubMeshes: boolean;
  105093. /**
  105094. * Stores the animations for the material
  105095. */
  105096. animations: Nullable<Array<Animation>>;
  105097. /**
  105098. * An event triggered when the material is disposed
  105099. */
  105100. onDisposeObservable: Observable<Material>;
  105101. /**
  105102. * An observer which watches for dispose events
  105103. */
  105104. private _onDisposeObserver;
  105105. private _onUnBindObservable;
  105106. /**
  105107. * Called during a dispose event
  105108. */
  105109. set onDispose(callback: () => void);
  105110. private _onBindObservable;
  105111. /**
  105112. * An event triggered when the material is bound
  105113. */
  105114. get onBindObservable(): Observable<AbstractMesh>;
  105115. /**
  105116. * An observer which watches for bind events
  105117. */
  105118. private _onBindObserver;
  105119. /**
  105120. * Called during a bind event
  105121. */
  105122. set onBind(callback: (Mesh: AbstractMesh) => void);
  105123. /**
  105124. * An event triggered when the material is unbound
  105125. */
  105126. get onUnBindObservable(): Observable<Material>;
  105127. protected _onEffectCreatedObservable: Nullable<Observable<{
  105128. effect: Effect;
  105129. subMesh: Nullable<SubMesh>;
  105130. }>>;
  105131. /**
  105132. * An event triggered when the effect is (re)created
  105133. */
  105134. get onEffectCreatedObservable(): Observable<{
  105135. effect: Effect;
  105136. subMesh: Nullable<SubMesh>;
  105137. }>;
  105138. /**
  105139. * Stores the value of the alpha mode
  105140. */
  105141. private _alphaMode;
  105142. /**
  105143. * Sets the value of the alpha mode.
  105144. *
  105145. * | Value | Type | Description |
  105146. * | --- | --- | --- |
  105147. * | 0 | ALPHA_DISABLE | |
  105148. * | 1 | ALPHA_ADD | |
  105149. * | 2 | ALPHA_COMBINE | |
  105150. * | 3 | ALPHA_SUBTRACT | |
  105151. * | 4 | ALPHA_MULTIPLY | |
  105152. * | 5 | ALPHA_MAXIMIZED | |
  105153. * | 6 | ALPHA_ONEONE | |
  105154. * | 7 | ALPHA_PREMULTIPLIED | |
  105155. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  105156. * | 9 | ALPHA_INTERPOLATE | |
  105157. * | 10 | ALPHA_SCREENMODE | |
  105158. *
  105159. */
  105160. set alphaMode(value: number);
  105161. /**
  105162. * Gets the value of the alpha mode
  105163. */
  105164. get alphaMode(): number;
  105165. /**
  105166. * Stores the state of the need depth pre-pass value
  105167. */
  105168. private _needDepthPrePass;
  105169. /**
  105170. * Sets the need depth pre-pass value
  105171. */
  105172. set needDepthPrePass(value: boolean);
  105173. /**
  105174. * Gets the depth pre-pass value
  105175. */
  105176. get needDepthPrePass(): boolean;
  105177. /**
  105178. * Specifies if depth writing should be disabled
  105179. */
  105180. disableDepthWrite: boolean;
  105181. /**
  105182. * Specifies if color writing should be disabled
  105183. */
  105184. disableColorWrite: boolean;
  105185. /**
  105186. * Specifies if depth writing should be forced
  105187. */
  105188. forceDepthWrite: boolean;
  105189. /**
  105190. * Specifies the depth function that should be used. 0 means the default engine function
  105191. */
  105192. depthFunction: number;
  105193. /**
  105194. * Specifies if there should be a separate pass for culling
  105195. */
  105196. separateCullingPass: boolean;
  105197. /**
  105198. * Stores the state specifing if fog should be enabled
  105199. */
  105200. private _fogEnabled;
  105201. /**
  105202. * Sets the state for enabling fog
  105203. */
  105204. set fogEnabled(value: boolean);
  105205. /**
  105206. * Gets the value of the fog enabled state
  105207. */
  105208. get fogEnabled(): boolean;
  105209. /**
  105210. * Stores the size of points
  105211. */
  105212. pointSize: number;
  105213. /**
  105214. * Stores the z offset value
  105215. */
  105216. zOffset: number;
  105217. get wireframe(): boolean;
  105218. /**
  105219. * Sets the state of wireframe mode
  105220. */
  105221. set wireframe(value: boolean);
  105222. /**
  105223. * Gets the value specifying if point clouds are enabled
  105224. */
  105225. get pointsCloud(): boolean;
  105226. /**
  105227. * Sets the state of point cloud mode
  105228. */
  105229. set pointsCloud(value: boolean);
  105230. /**
  105231. * Gets the material fill mode
  105232. */
  105233. get fillMode(): number;
  105234. /**
  105235. * Sets the material fill mode
  105236. */
  105237. set fillMode(value: number);
  105238. /**
  105239. * @hidden
  105240. * Stores the effects for the material
  105241. */
  105242. _effect: Nullable<Effect>;
  105243. /**
  105244. * Specifies if uniform buffers should be used
  105245. */
  105246. private _useUBO;
  105247. /**
  105248. * Stores a reference to the scene
  105249. */
  105250. private _scene;
  105251. /**
  105252. * Stores the fill mode state
  105253. */
  105254. private _fillMode;
  105255. /**
  105256. * Specifies if the depth write state should be cached
  105257. */
  105258. private _cachedDepthWriteState;
  105259. /**
  105260. * Specifies if the color write state should be cached
  105261. */
  105262. private _cachedColorWriteState;
  105263. /**
  105264. * Specifies if the depth function state should be cached
  105265. */
  105266. private _cachedDepthFunctionState;
  105267. /**
  105268. * Stores the uniform buffer
  105269. */
  105270. protected _uniformBuffer: UniformBuffer;
  105271. /** @hidden */
  105272. _indexInSceneMaterialArray: number;
  105273. /** @hidden */
  105274. meshMap: Nullable<{
  105275. [id: string]: AbstractMesh | undefined;
  105276. }>;
  105277. /**
  105278. * Creates a material instance
  105279. * @param name defines the name of the material
  105280. * @param scene defines the scene to reference
  105281. * @param doNotAdd specifies if the material should be added to the scene
  105282. */
  105283. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  105284. /**
  105285. * Returns a string representation of the current material
  105286. * @param fullDetails defines a boolean indicating which levels of logging is desired
  105287. * @returns a string with material information
  105288. */
  105289. toString(fullDetails?: boolean): string;
  105290. /**
  105291. * Gets the class name of the material
  105292. * @returns a string with the class name of the material
  105293. */
  105294. getClassName(): string;
  105295. /**
  105296. * Specifies if updates for the material been locked
  105297. */
  105298. get isFrozen(): boolean;
  105299. /**
  105300. * Locks updates for the material
  105301. */
  105302. freeze(): void;
  105303. /**
  105304. * Unlocks updates for the material
  105305. */
  105306. unfreeze(): void;
  105307. /**
  105308. * Specifies if the material is ready to be used
  105309. * @param mesh defines the mesh to check
  105310. * @param useInstances specifies if instances should be used
  105311. * @returns a boolean indicating if the material is ready to be used
  105312. */
  105313. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105314. /**
  105315. * Specifies that the submesh is ready to be used
  105316. * @param mesh defines the mesh to check
  105317. * @param subMesh defines which submesh to check
  105318. * @param useInstances specifies that instances should be used
  105319. * @returns a boolean indicating that the submesh is ready or not
  105320. */
  105321. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105322. /**
  105323. * Returns the material effect
  105324. * @returns the effect associated with the material
  105325. */
  105326. getEffect(): Nullable<Effect>;
  105327. /**
  105328. * Returns the current scene
  105329. * @returns a Scene
  105330. */
  105331. getScene(): Scene;
  105332. /**
  105333. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105334. */
  105335. protected _forceAlphaTest: boolean;
  105336. /**
  105337. * The transparency mode of the material.
  105338. */
  105339. protected _transparencyMode: Nullable<number>;
  105340. /**
  105341. * Gets the current transparency mode.
  105342. */
  105343. get transparencyMode(): Nullable<number>;
  105344. /**
  105345. * Sets the transparency mode of the material.
  105346. *
  105347. * | Value | Type | Description |
  105348. * | ----- | ----------------------------------- | ----------- |
  105349. * | 0 | OPAQUE | |
  105350. * | 1 | ALPHATEST | |
  105351. * | 2 | ALPHABLEND | |
  105352. * | 3 | ALPHATESTANDBLEND | |
  105353. *
  105354. */
  105355. set transparencyMode(value: Nullable<number>);
  105356. /**
  105357. * Returns true if alpha blending should be disabled.
  105358. */
  105359. protected get _disableAlphaBlending(): boolean;
  105360. /**
  105361. * Specifies whether or not this material should be rendered in alpha blend mode.
  105362. * @returns a boolean specifying if alpha blending is needed
  105363. */
  105364. needAlphaBlending(): boolean;
  105365. /**
  105366. * Specifies if the mesh will require alpha blending
  105367. * @param mesh defines the mesh to check
  105368. * @returns a boolean specifying if alpha blending is needed for the mesh
  105369. */
  105370. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105371. /**
  105372. * Specifies whether or not this material should be rendered in alpha test mode.
  105373. * @returns a boolean specifying if an alpha test is needed.
  105374. */
  105375. needAlphaTesting(): boolean;
  105376. /**
  105377. * Specifies if material alpha testing should be turned on for the mesh
  105378. * @param mesh defines the mesh to check
  105379. */
  105380. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  105381. /**
  105382. * Gets the texture used for the alpha test
  105383. * @returns the texture to use for alpha testing
  105384. */
  105385. getAlphaTestTexture(): Nullable<BaseTexture>;
  105386. /**
  105387. * Marks the material to indicate that it needs to be re-calculated
  105388. */
  105389. markDirty(): void;
  105390. /** @hidden */
  105391. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  105392. /**
  105393. * Binds the material to the mesh
  105394. * @param world defines the world transformation matrix
  105395. * @param mesh defines the mesh to bind the material to
  105396. */
  105397. bind(world: Matrix, mesh?: Mesh): void;
  105398. /**
  105399. * Binds the submesh to the material
  105400. * @param world defines the world transformation matrix
  105401. * @param mesh defines the mesh containing the submesh
  105402. * @param subMesh defines the submesh to bind the material to
  105403. */
  105404. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105405. /**
  105406. * Binds the world matrix to the material
  105407. * @param world defines the world transformation matrix
  105408. */
  105409. bindOnlyWorldMatrix(world: Matrix): void;
  105410. /**
  105411. * Binds the scene's uniform buffer to the effect.
  105412. * @param effect defines the effect to bind to the scene uniform buffer
  105413. * @param sceneUbo defines the uniform buffer storing scene data
  105414. */
  105415. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  105416. /**
  105417. * Binds the view matrix to the effect
  105418. * @param effect defines the effect to bind the view matrix to
  105419. */
  105420. bindView(effect: Effect): void;
  105421. /**
  105422. * Binds the view projection matrix to the effect
  105423. * @param effect defines the effect to bind the view projection matrix to
  105424. */
  105425. bindViewProjection(effect: Effect): void;
  105426. /**
  105427. * Processes to execute after binding the material to a mesh
  105428. * @param mesh defines the rendered mesh
  105429. */
  105430. protected _afterBind(mesh?: Mesh): void;
  105431. /**
  105432. * Unbinds the material from the mesh
  105433. */
  105434. unbind(): void;
  105435. /**
  105436. * Gets the active textures from the material
  105437. * @returns an array of textures
  105438. */
  105439. getActiveTextures(): BaseTexture[];
  105440. /**
  105441. * Specifies if the material uses a texture
  105442. * @param texture defines the texture to check against the material
  105443. * @returns a boolean specifying if the material uses the texture
  105444. */
  105445. hasTexture(texture: BaseTexture): boolean;
  105446. /**
  105447. * Makes a duplicate of the material, and gives it a new name
  105448. * @param name defines the new name for the duplicated material
  105449. * @returns the cloned material
  105450. */
  105451. clone(name: string): Nullable<Material>;
  105452. /**
  105453. * Gets the meshes bound to the material
  105454. * @returns an array of meshes bound to the material
  105455. */
  105456. getBindedMeshes(): AbstractMesh[];
  105457. /**
  105458. * Force shader compilation
  105459. * @param mesh defines the mesh associated with this material
  105460. * @param onCompiled defines a function to execute once the material is compiled
  105461. * @param options defines the options to configure the compilation
  105462. * @param onError defines a function to execute if the material fails compiling
  105463. */
  105464. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105465. /**
  105466. * Force shader compilation
  105467. * @param mesh defines the mesh that will use this material
  105468. * @param options defines additional options for compiling the shaders
  105469. * @returns a promise that resolves when the compilation completes
  105470. */
  105471. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105472. private static readonly _AllDirtyCallBack;
  105473. private static readonly _ImageProcessingDirtyCallBack;
  105474. private static readonly _TextureDirtyCallBack;
  105475. private static readonly _FresnelDirtyCallBack;
  105476. private static readonly _MiscDirtyCallBack;
  105477. private static readonly _LightsDirtyCallBack;
  105478. private static readonly _AttributeDirtyCallBack;
  105479. private static _FresnelAndMiscDirtyCallBack;
  105480. private static _TextureAndMiscDirtyCallBack;
  105481. private static readonly _DirtyCallbackArray;
  105482. private static readonly _RunDirtyCallBacks;
  105483. /**
  105484. * Marks a define in the material to indicate that it needs to be re-computed
  105485. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105486. */
  105487. markAsDirty(flag: number): void;
  105488. /**
  105489. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105490. * @param func defines a function which checks material defines against the submeshes
  105491. */
  105492. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105493. /**
  105494. * Indicates that the scene should check if the rendering now needs a prepass
  105495. */
  105496. protected _markScenePrePassDirty(): void;
  105497. /**
  105498. * Indicates that we need to re-calculated for all submeshes
  105499. */
  105500. protected _markAllSubMeshesAsAllDirty(): void;
  105501. /**
  105502. * Indicates that image processing needs to be re-calculated for all submeshes
  105503. */
  105504. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105505. /**
  105506. * Indicates that textures need to be re-calculated for all submeshes
  105507. */
  105508. protected _markAllSubMeshesAsTexturesDirty(): void;
  105509. /**
  105510. * Indicates that fresnel needs to be re-calculated for all submeshes
  105511. */
  105512. protected _markAllSubMeshesAsFresnelDirty(): void;
  105513. /**
  105514. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105515. */
  105516. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105517. /**
  105518. * Indicates that lights need to be re-calculated for all submeshes
  105519. */
  105520. protected _markAllSubMeshesAsLightsDirty(): void;
  105521. /**
  105522. * Indicates that attributes need to be re-calculated for all submeshes
  105523. */
  105524. protected _markAllSubMeshesAsAttributesDirty(): void;
  105525. /**
  105526. * Indicates that misc needs to be re-calculated for all submeshes
  105527. */
  105528. protected _markAllSubMeshesAsMiscDirty(): void;
  105529. /**
  105530. * Indicates that textures and misc need to be re-calculated for all submeshes
  105531. */
  105532. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105533. /**
  105534. * Sets the required values to the prepass renderer.
  105535. * @param prePassRenderer defines the prepass renderer to setup.
  105536. * @returns true if the pre pass is needed.
  105537. */
  105538. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105539. /**
  105540. * Disposes the material
  105541. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105542. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105543. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105544. */
  105545. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105546. /** @hidden */
  105547. private releaseVertexArrayObject;
  105548. /**
  105549. * Serializes this material
  105550. * @returns the serialized material object
  105551. */
  105552. serialize(): any;
  105553. /**
  105554. * Creates a material from parsed material data
  105555. * @param parsedMaterial defines parsed material data
  105556. * @param scene defines the hosting scene
  105557. * @param rootUrl defines the root URL to use to load textures
  105558. * @returns a new material
  105559. */
  105560. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105561. }
  105562. }
  105563. declare module BABYLON {
  105564. /**
  105565. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105566. * separate meshes. This can be use to improve performances.
  105567. * @see https://doc.babylonjs.com/how_to/multi_materials
  105568. */
  105569. export class MultiMaterial extends Material {
  105570. private _subMaterials;
  105571. /**
  105572. * Gets or Sets the list of Materials used within the multi material.
  105573. * They need to be ordered according to the submeshes order in the associated mesh
  105574. */
  105575. get subMaterials(): Nullable<Material>[];
  105576. set subMaterials(value: Nullable<Material>[]);
  105577. /**
  105578. * Function used to align with Node.getChildren()
  105579. * @returns the list of Materials used within the multi material
  105580. */
  105581. getChildren(): Nullable<Material>[];
  105582. /**
  105583. * Instantiates a new Multi Material
  105584. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105585. * separate meshes. This can be use to improve performances.
  105586. * @see https://doc.babylonjs.com/how_to/multi_materials
  105587. * @param name Define the name in the scene
  105588. * @param scene Define the scene the material belongs to
  105589. */
  105590. constructor(name: string, scene: Scene);
  105591. private _hookArray;
  105592. /**
  105593. * Get one of the submaterial by its index in the submaterials array
  105594. * @param index The index to look the sub material at
  105595. * @returns The Material if the index has been defined
  105596. */
  105597. getSubMaterial(index: number): Nullable<Material>;
  105598. /**
  105599. * Get the list of active textures for the whole sub materials list.
  105600. * @returns All the textures that will be used during the rendering
  105601. */
  105602. getActiveTextures(): BaseTexture[];
  105603. /**
  105604. * Gets the current class name of the material e.g. "MultiMaterial"
  105605. * Mainly use in serialization.
  105606. * @returns the class name
  105607. */
  105608. getClassName(): string;
  105609. /**
  105610. * Checks if the material is ready to render the requested sub mesh
  105611. * @param mesh Define the mesh the submesh belongs to
  105612. * @param subMesh Define the sub mesh to look readyness for
  105613. * @param useInstances Define whether or not the material is used with instances
  105614. * @returns true if ready, otherwise false
  105615. */
  105616. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105617. /**
  105618. * Clones the current material and its related sub materials
  105619. * @param name Define the name of the newly cloned material
  105620. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105621. * @returns the cloned material
  105622. */
  105623. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105624. /**
  105625. * Serializes the materials into a JSON representation.
  105626. * @returns the JSON representation
  105627. */
  105628. serialize(): any;
  105629. /**
  105630. * Dispose the material and release its associated resources
  105631. * @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)
  105632. * @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)
  105633. * @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)
  105634. */
  105635. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105636. /**
  105637. * Creates a MultiMaterial from parsed MultiMaterial data.
  105638. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105639. * @param scene defines the hosting scene
  105640. * @returns a new MultiMaterial
  105641. */
  105642. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105643. }
  105644. }
  105645. declare module BABYLON {
  105646. /**
  105647. * Defines a subdivision inside a mesh
  105648. */
  105649. export class SubMesh implements ICullable {
  105650. /** the material index to use */
  105651. materialIndex: number;
  105652. /** vertex index start */
  105653. verticesStart: number;
  105654. /** vertices count */
  105655. verticesCount: number;
  105656. /** index start */
  105657. indexStart: number;
  105658. /** indices count */
  105659. indexCount: number;
  105660. /** @hidden */
  105661. _materialDefines: Nullable<MaterialDefines>;
  105662. /** @hidden */
  105663. _materialEffect: Nullable<Effect>;
  105664. /** @hidden */
  105665. _effectOverride: Nullable<Effect>;
  105666. /**
  105667. * Gets material defines used by the effect associated to the sub mesh
  105668. */
  105669. get materialDefines(): Nullable<MaterialDefines>;
  105670. /**
  105671. * Sets material defines used by the effect associated to the sub mesh
  105672. */
  105673. set materialDefines(defines: Nullable<MaterialDefines>);
  105674. /**
  105675. * Gets associated effect
  105676. */
  105677. get effect(): Nullable<Effect>;
  105678. /**
  105679. * Sets associated effect (effect used to render this submesh)
  105680. * @param effect defines the effect to associate with
  105681. * @param defines defines the set of defines used to compile this effect
  105682. */
  105683. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105684. /** @hidden */
  105685. _linesIndexCount: number;
  105686. private _mesh;
  105687. private _renderingMesh;
  105688. private _boundingInfo;
  105689. private _linesIndexBuffer;
  105690. /** @hidden */
  105691. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105692. /** @hidden */
  105693. _trianglePlanes: Plane[];
  105694. /** @hidden */
  105695. _lastColliderTransformMatrix: Nullable<Matrix>;
  105696. /** @hidden */
  105697. _renderId: number;
  105698. /** @hidden */
  105699. _alphaIndex: number;
  105700. /** @hidden */
  105701. _distanceToCamera: number;
  105702. /** @hidden */
  105703. _id: number;
  105704. private _currentMaterial;
  105705. /**
  105706. * Add a new submesh to a mesh
  105707. * @param materialIndex defines the material index to use
  105708. * @param verticesStart defines vertex index start
  105709. * @param verticesCount defines vertices count
  105710. * @param indexStart defines index start
  105711. * @param indexCount defines indices count
  105712. * @param mesh defines the parent mesh
  105713. * @param renderingMesh defines an optional rendering mesh
  105714. * @param createBoundingBox defines if bounding box should be created for this submesh
  105715. * @returns the new submesh
  105716. */
  105717. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105718. /**
  105719. * Creates a new submesh
  105720. * @param materialIndex defines the material index to use
  105721. * @param verticesStart defines vertex index start
  105722. * @param verticesCount defines vertices count
  105723. * @param indexStart defines index start
  105724. * @param indexCount defines indices count
  105725. * @param mesh defines the parent mesh
  105726. * @param renderingMesh defines an optional rendering mesh
  105727. * @param createBoundingBox defines if bounding box should be created for this submesh
  105728. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105729. */
  105730. constructor(
  105731. /** the material index to use */
  105732. materialIndex: number,
  105733. /** vertex index start */
  105734. verticesStart: number,
  105735. /** vertices count */
  105736. verticesCount: number,
  105737. /** index start */
  105738. indexStart: number,
  105739. /** indices count */
  105740. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105741. /**
  105742. * Returns true if this submesh covers the entire parent mesh
  105743. * @ignorenaming
  105744. */
  105745. get IsGlobal(): boolean;
  105746. /**
  105747. * Returns the submesh BoudingInfo object
  105748. * @returns current bounding info (or mesh's one if the submesh is global)
  105749. */
  105750. getBoundingInfo(): BoundingInfo;
  105751. /**
  105752. * Sets the submesh BoundingInfo
  105753. * @param boundingInfo defines the new bounding info to use
  105754. * @returns the SubMesh
  105755. */
  105756. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105757. /**
  105758. * Returns the mesh of the current submesh
  105759. * @return the parent mesh
  105760. */
  105761. getMesh(): AbstractMesh;
  105762. /**
  105763. * Returns the rendering mesh of the submesh
  105764. * @returns the rendering mesh (could be different from parent mesh)
  105765. */
  105766. getRenderingMesh(): Mesh;
  105767. /**
  105768. * Returns the replacement mesh of the submesh
  105769. * @returns the replacement mesh (could be different from parent mesh)
  105770. */
  105771. getReplacementMesh(): Nullable<AbstractMesh>;
  105772. /**
  105773. * Returns the effective mesh of the submesh
  105774. * @returns the effective mesh (could be different from parent mesh)
  105775. */
  105776. getEffectiveMesh(): AbstractMesh;
  105777. /**
  105778. * Returns the submesh material
  105779. * @returns null or the current material
  105780. */
  105781. getMaterial(): Nullable<Material>;
  105782. private _IsMultiMaterial;
  105783. /**
  105784. * Sets a new updated BoundingInfo object to the submesh
  105785. * @param data defines an optional position array to use to determine the bounding info
  105786. * @returns the SubMesh
  105787. */
  105788. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105789. /** @hidden */
  105790. _checkCollision(collider: Collider): boolean;
  105791. /**
  105792. * Updates the submesh BoundingInfo
  105793. * @param world defines the world matrix to use to update the bounding info
  105794. * @returns the submesh
  105795. */
  105796. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105797. /**
  105798. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105799. * @param frustumPlanes defines the frustum planes
  105800. * @returns true if the submesh is intersecting with the frustum
  105801. */
  105802. isInFrustum(frustumPlanes: Plane[]): boolean;
  105803. /**
  105804. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105805. * @param frustumPlanes defines the frustum planes
  105806. * @returns true if the submesh is inside the frustum
  105807. */
  105808. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105809. /**
  105810. * Renders the submesh
  105811. * @param enableAlphaMode defines if alpha needs to be used
  105812. * @returns the submesh
  105813. */
  105814. render(enableAlphaMode: boolean): SubMesh;
  105815. /**
  105816. * @hidden
  105817. */
  105818. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105819. /**
  105820. * Checks if the submesh intersects with a ray
  105821. * @param ray defines the ray to test
  105822. * @returns true is the passed ray intersects the submesh bounding box
  105823. */
  105824. canIntersects(ray: Ray): boolean;
  105825. /**
  105826. * Intersects current submesh with a ray
  105827. * @param ray defines the ray to test
  105828. * @param positions defines mesh's positions array
  105829. * @param indices defines mesh's indices array
  105830. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105831. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105832. * @returns intersection info or null if no intersection
  105833. */
  105834. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105835. /** @hidden */
  105836. private _intersectLines;
  105837. /** @hidden */
  105838. private _intersectUnIndexedLines;
  105839. /** @hidden */
  105840. private _intersectTriangles;
  105841. /** @hidden */
  105842. private _intersectUnIndexedTriangles;
  105843. /** @hidden */
  105844. _rebuild(): void;
  105845. /**
  105846. * Creates a new submesh from the passed mesh
  105847. * @param newMesh defines the new hosting mesh
  105848. * @param newRenderingMesh defines an optional rendering mesh
  105849. * @returns the new submesh
  105850. */
  105851. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105852. /**
  105853. * Release associated resources
  105854. */
  105855. dispose(): void;
  105856. /**
  105857. * Gets the class name
  105858. * @returns the string "SubMesh".
  105859. */
  105860. getClassName(): string;
  105861. /**
  105862. * Creates a new submesh from indices data
  105863. * @param materialIndex the index of the main mesh material
  105864. * @param startIndex the index where to start the copy in the mesh indices array
  105865. * @param indexCount the number of indices to copy then from the startIndex
  105866. * @param mesh the main mesh to create the submesh from
  105867. * @param renderingMesh the optional rendering mesh
  105868. * @returns a new submesh
  105869. */
  105870. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105871. }
  105872. }
  105873. declare module BABYLON {
  105874. /**
  105875. * Class used to represent data loading progression
  105876. */
  105877. export class SceneLoaderFlags {
  105878. private static _ForceFullSceneLoadingForIncremental;
  105879. private static _ShowLoadingScreen;
  105880. private static _CleanBoneMatrixWeights;
  105881. private static _loggingLevel;
  105882. /**
  105883. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105884. */
  105885. static get ForceFullSceneLoadingForIncremental(): boolean;
  105886. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105887. /**
  105888. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105889. */
  105890. static get ShowLoadingScreen(): boolean;
  105891. static set ShowLoadingScreen(value: boolean);
  105892. /**
  105893. * Defines the current logging level (while loading the scene)
  105894. * @ignorenaming
  105895. */
  105896. static get loggingLevel(): number;
  105897. static set loggingLevel(value: number);
  105898. /**
  105899. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105900. */
  105901. static get CleanBoneMatrixWeights(): boolean;
  105902. static set CleanBoneMatrixWeights(value: boolean);
  105903. }
  105904. }
  105905. declare module BABYLON {
  105906. /**
  105907. * Class used to store geometry data (vertex buffers + index buffer)
  105908. */
  105909. export class Geometry implements IGetSetVerticesData {
  105910. /**
  105911. * Gets or sets the ID of the geometry
  105912. */
  105913. id: string;
  105914. /**
  105915. * Gets or sets the unique ID of the geometry
  105916. */
  105917. uniqueId: number;
  105918. /**
  105919. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105920. */
  105921. delayLoadState: number;
  105922. /**
  105923. * Gets the file containing the data to load when running in delay load state
  105924. */
  105925. delayLoadingFile: Nullable<string>;
  105926. /**
  105927. * Callback called when the geometry is updated
  105928. */
  105929. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105930. private _scene;
  105931. private _engine;
  105932. private _meshes;
  105933. private _totalVertices;
  105934. /** @hidden */
  105935. _indices: IndicesArray;
  105936. /** @hidden */
  105937. _vertexBuffers: {
  105938. [key: string]: VertexBuffer;
  105939. };
  105940. private _isDisposed;
  105941. private _extend;
  105942. private _boundingBias;
  105943. /** @hidden */
  105944. _delayInfo: Array<string>;
  105945. private _indexBuffer;
  105946. private _indexBufferIsUpdatable;
  105947. /** @hidden */
  105948. _boundingInfo: Nullable<BoundingInfo>;
  105949. /** @hidden */
  105950. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105951. /** @hidden */
  105952. _softwareSkinningFrameId: number;
  105953. private _vertexArrayObjects;
  105954. private _updatable;
  105955. /** @hidden */
  105956. _positions: Nullable<Vector3[]>;
  105957. /**
  105958. * 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
  105959. */
  105960. get boundingBias(): Vector2;
  105961. /**
  105962. * 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
  105963. */
  105964. set boundingBias(value: Vector2);
  105965. /**
  105966. * Static function used to attach a new empty geometry to a mesh
  105967. * @param mesh defines the mesh to attach the geometry to
  105968. * @returns the new Geometry
  105969. */
  105970. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105971. /** Get the list of meshes using this geometry */
  105972. get meshes(): Mesh[];
  105973. /**
  105974. * 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
  105975. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105976. */
  105977. useBoundingInfoFromGeometry: boolean;
  105978. /**
  105979. * Creates a new geometry
  105980. * @param id defines the unique ID
  105981. * @param scene defines the hosting scene
  105982. * @param vertexData defines the VertexData used to get geometry data
  105983. * @param updatable defines if geometry must be updatable (false by default)
  105984. * @param mesh defines the mesh that will be associated with the geometry
  105985. */
  105986. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105987. /**
  105988. * Gets the current extend of the geometry
  105989. */
  105990. get extend(): {
  105991. minimum: Vector3;
  105992. maximum: Vector3;
  105993. };
  105994. /**
  105995. * Gets the hosting scene
  105996. * @returns the hosting Scene
  105997. */
  105998. getScene(): Scene;
  105999. /**
  106000. * Gets the hosting engine
  106001. * @returns the hosting Engine
  106002. */
  106003. getEngine(): Engine;
  106004. /**
  106005. * Defines if the geometry is ready to use
  106006. * @returns true if the geometry is ready to be used
  106007. */
  106008. isReady(): boolean;
  106009. /**
  106010. * Gets a value indicating that the geometry should not be serialized
  106011. */
  106012. get doNotSerialize(): boolean;
  106013. /** @hidden */
  106014. _rebuild(): void;
  106015. /**
  106016. * Affects all geometry data in one call
  106017. * @param vertexData defines the geometry data
  106018. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  106019. */
  106020. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  106021. /**
  106022. * Set specific vertex data
  106023. * @param kind defines the data kind (Position, normal, etc...)
  106024. * @param data defines the vertex data to use
  106025. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106026. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106027. */
  106028. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  106029. /**
  106030. * Removes a specific vertex data
  106031. * @param kind defines the data kind (Position, normal, etc...)
  106032. */
  106033. removeVerticesData(kind: string): void;
  106034. /**
  106035. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  106036. * @param buffer defines the vertex buffer to use
  106037. * @param totalVertices defines the total number of vertices for position kind (could be null)
  106038. */
  106039. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  106040. /**
  106041. * Update a specific vertex buffer
  106042. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  106043. * It will do nothing if the buffer is not updatable
  106044. * @param kind defines the data kind (Position, normal, etc...)
  106045. * @param data defines the data to use
  106046. * @param offset defines the offset in the target buffer where to store the data
  106047. * @param useBytes set to true if the offset is in bytes
  106048. */
  106049. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  106050. /**
  106051. * Update a specific vertex buffer
  106052. * This function will create a new buffer if the current one is not updatable
  106053. * @param kind defines the data kind (Position, normal, etc...)
  106054. * @param data defines the data to use
  106055. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  106056. */
  106057. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  106058. private _updateBoundingInfo;
  106059. /** @hidden */
  106060. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  106061. /**
  106062. * Gets total number of vertices
  106063. * @returns the total number of vertices
  106064. */
  106065. getTotalVertices(): number;
  106066. /**
  106067. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106068. * @param kind defines the data kind (Position, normal, etc...)
  106069. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106070. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106071. * @returns a float array containing vertex data
  106072. */
  106073. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106074. /**
  106075. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  106076. * @param kind defines the data kind (Position, normal, etc...)
  106077. * @returns true if the vertex buffer with the specified kind is updatable
  106078. */
  106079. isVertexBufferUpdatable(kind: string): boolean;
  106080. /**
  106081. * Gets a specific vertex buffer
  106082. * @param kind defines the data kind (Position, normal, etc...)
  106083. * @returns a VertexBuffer
  106084. */
  106085. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106086. /**
  106087. * Returns all vertex buffers
  106088. * @return an object holding all vertex buffers indexed by kind
  106089. */
  106090. getVertexBuffers(): Nullable<{
  106091. [key: string]: VertexBuffer;
  106092. }>;
  106093. /**
  106094. * Gets a boolean indicating if specific vertex buffer is present
  106095. * @param kind defines the data kind (Position, normal, etc...)
  106096. * @returns true if data is present
  106097. */
  106098. isVerticesDataPresent(kind: string): boolean;
  106099. /**
  106100. * Gets a list of all attached data kinds (Position, normal, etc...)
  106101. * @returns a list of string containing all kinds
  106102. */
  106103. getVerticesDataKinds(): string[];
  106104. /**
  106105. * Update index buffer
  106106. * @param indices defines the indices to store in the index buffer
  106107. * @param offset defines the offset in the target buffer where to store the data
  106108. * @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)
  106109. */
  106110. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  106111. /**
  106112. * Creates a new index buffer
  106113. * @param indices defines the indices to store in the index buffer
  106114. * @param totalVertices defines the total number of vertices (could be null)
  106115. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106116. */
  106117. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  106118. /**
  106119. * Return the total number of indices
  106120. * @returns the total number of indices
  106121. */
  106122. getTotalIndices(): number;
  106123. /**
  106124. * Gets the index buffer array
  106125. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106126. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106127. * @returns the index buffer array
  106128. */
  106129. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106130. /**
  106131. * Gets the index buffer
  106132. * @return the index buffer
  106133. */
  106134. getIndexBuffer(): Nullable<DataBuffer>;
  106135. /** @hidden */
  106136. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  106137. /**
  106138. * Release the associated resources for a specific mesh
  106139. * @param mesh defines the source mesh
  106140. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  106141. */
  106142. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  106143. /**
  106144. * Apply current geometry to a given mesh
  106145. * @param mesh defines the mesh to apply geometry to
  106146. */
  106147. applyToMesh(mesh: Mesh): void;
  106148. private _updateExtend;
  106149. private _applyToMesh;
  106150. private notifyUpdate;
  106151. /**
  106152. * Load the geometry if it was flagged as delay loaded
  106153. * @param scene defines the hosting scene
  106154. * @param onLoaded defines a callback called when the geometry is loaded
  106155. */
  106156. load(scene: Scene, onLoaded?: () => void): void;
  106157. private _queueLoad;
  106158. /**
  106159. * Invert the geometry to move from a right handed system to a left handed one.
  106160. */
  106161. toLeftHanded(): void;
  106162. /** @hidden */
  106163. _resetPointsArrayCache(): void;
  106164. /** @hidden */
  106165. _generatePointsArray(): boolean;
  106166. /**
  106167. * Gets a value indicating if the geometry is disposed
  106168. * @returns true if the geometry was disposed
  106169. */
  106170. isDisposed(): boolean;
  106171. private _disposeVertexArrayObjects;
  106172. /**
  106173. * Free all associated resources
  106174. */
  106175. dispose(): void;
  106176. /**
  106177. * Clone the current geometry into a new geometry
  106178. * @param id defines the unique ID of the new geometry
  106179. * @returns a new geometry object
  106180. */
  106181. copy(id: string): Geometry;
  106182. /**
  106183. * Serialize the current geometry info (and not the vertices data) into a JSON object
  106184. * @return a JSON representation of the current geometry data (without the vertices data)
  106185. */
  106186. serialize(): any;
  106187. private toNumberArray;
  106188. /**
  106189. * Serialize all vertices data into a JSON oject
  106190. * @returns a JSON representation of the current geometry data
  106191. */
  106192. serializeVerticeData(): any;
  106193. /**
  106194. * Extracts a clone of a mesh geometry
  106195. * @param mesh defines the source mesh
  106196. * @param id defines the unique ID of the new geometry object
  106197. * @returns the new geometry object
  106198. */
  106199. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  106200. /**
  106201. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  106202. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106203. * Be aware Math.random() could cause collisions, but:
  106204. * "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"
  106205. * @returns a string containing a new GUID
  106206. */
  106207. static RandomId(): string;
  106208. /** @hidden */
  106209. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  106210. private static _CleanMatricesWeights;
  106211. /**
  106212. * Create a new geometry from persisted data (Using .babylon file format)
  106213. * @param parsedVertexData defines the persisted data
  106214. * @param scene defines the hosting scene
  106215. * @param rootUrl defines the root url to use to load assets (like delayed data)
  106216. * @returns the new geometry object
  106217. */
  106218. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  106219. }
  106220. }
  106221. declare module BABYLON {
  106222. /**
  106223. * Define an interface for all classes that will get and set the data on vertices
  106224. */
  106225. export interface IGetSetVerticesData {
  106226. /**
  106227. * Gets a boolean indicating if specific vertex data is present
  106228. * @param kind defines the vertex data kind to use
  106229. * @returns true is data kind is present
  106230. */
  106231. isVerticesDataPresent(kind: string): boolean;
  106232. /**
  106233. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106234. * @param kind defines the data kind (Position, normal, etc...)
  106235. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106236. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106237. * @returns a float array containing vertex data
  106238. */
  106239. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106240. /**
  106241. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106242. * @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.
  106243. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106244. * @returns the indices array or an empty array if the mesh has no geometry
  106245. */
  106246. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106247. /**
  106248. * Set specific vertex data
  106249. * @param kind defines the data kind (Position, normal, etc...)
  106250. * @param data defines the vertex data to use
  106251. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106252. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106253. */
  106254. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  106255. /**
  106256. * Update a specific associated vertex buffer
  106257. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106258. * - VertexBuffer.PositionKind
  106259. * - VertexBuffer.UVKind
  106260. * - VertexBuffer.UV2Kind
  106261. * - VertexBuffer.UV3Kind
  106262. * - VertexBuffer.UV4Kind
  106263. * - VertexBuffer.UV5Kind
  106264. * - VertexBuffer.UV6Kind
  106265. * - VertexBuffer.ColorKind
  106266. * - VertexBuffer.MatricesIndicesKind
  106267. * - VertexBuffer.MatricesIndicesExtraKind
  106268. * - VertexBuffer.MatricesWeightsKind
  106269. * - VertexBuffer.MatricesWeightsExtraKind
  106270. * @param data defines the data source
  106271. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106272. * @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)
  106273. */
  106274. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  106275. /**
  106276. * Creates a new index buffer
  106277. * @param indices defines the indices to store in the index buffer
  106278. * @param totalVertices defines the total number of vertices (could be null)
  106279. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106280. */
  106281. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  106282. }
  106283. /**
  106284. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  106285. */
  106286. export class VertexData {
  106287. /**
  106288. * Mesh side orientation : usually the external or front surface
  106289. */
  106290. static readonly FRONTSIDE: number;
  106291. /**
  106292. * Mesh side orientation : usually the internal or back surface
  106293. */
  106294. static readonly BACKSIDE: number;
  106295. /**
  106296. * Mesh side orientation : both internal and external or front and back surfaces
  106297. */
  106298. static readonly DOUBLESIDE: number;
  106299. /**
  106300. * Mesh side orientation : by default, `FRONTSIDE`
  106301. */
  106302. static readonly DEFAULTSIDE: number;
  106303. /**
  106304. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  106305. */
  106306. positions: Nullable<FloatArray>;
  106307. /**
  106308. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  106309. */
  106310. normals: Nullable<FloatArray>;
  106311. /**
  106312. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  106313. */
  106314. tangents: Nullable<FloatArray>;
  106315. /**
  106316. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106317. */
  106318. uvs: Nullable<FloatArray>;
  106319. /**
  106320. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106321. */
  106322. uvs2: Nullable<FloatArray>;
  106323. /**
  106324. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106325. */
  106326. uvs3: Nullable<FloatArray>;
  106327. /**
  106328. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106329. */
  106330. uvs4: Nullable<FloatArray>;
  106331. /**
  106332. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106333. */
  106334. uvs5: Nullable<FloatArray>;
  106335. /**
  106336. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106337. */
  106338. uvs6: Nullable<FloatArray>;
  106339. /**
  106340. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  106341. */
  106342. colors: Nullable<FloatArray>;
  106343. /**
  106344. * 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).
  106345. */
  106346. matricesIndices: Nullable<FloatArray>;
  106347. /**
  106348. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  106349. */
  106350. matricesWeights: Nullable<FloatArray>;
  106351. /**
  106352. * An array extending the number of possible indices
  106353. */
  106354. matricesIndicesExtra: Nullable<FloatArray>;
  106355. /**
  106356. * An array extending the number of possible weights when the number of indices is extended
  106357. */
  106358. matricesWeightsExtra: Nullable<FloatArray>;
  106359. /**
  106360. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  106361. */
  106362. indices: Nullable<IndicesArray>;
  106363. /**
  106364. * Uses the passed data array to set the set the values for the specified kind of data
  106365. * @param data a linear array of floating numbers
  106366. * @param kind the type of data that is being set, eg positions, colors etc
  106367. */
  106368. set(data: FloatArray, kind: string): void;
  106369. /**
  106370. * Associates the vertexData to the passed Mesh.
  106371. * Sets it as updatable or not (default `false`)
  106372. * @param mesh the mesh the vertexData is applied to
  106373. * @param updatable when used and having the value true allows new data to update the vertexData
  106374. * @returns the VertexData
  106375. */
  106376. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  106377. /**
  106378. * Associates the vertexData to the passed Geometry.
  106379. * Sets it as updatable or not (default `false`)
  106380. * @param geometry the geometry the vertexData is applied to
  106381. * @param updatable when used and having the value true allows new data to update the vertexData
  106382. * @returns VertexData
  106383. */
  106384. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  106385. /**
  106386. * Updates the associated mesh
  106387. * @param mesh the mesh to be updated
  106388. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106389. * @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
  106390. * @returns VertexData
  106391. */
  106392. updateMesh(mesh: Mesh): VertexData;
  106393. /**
  106394. * Updates the associated geometry
  106395. * @param geometry the geometry to be updated
  106396. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106397. * @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
  106398. * @returns VertexData.
  106399. */
  106400. updateGeometry(geometry: Geometry): VertexData;
  106401. private _applyTo;
  106402. private _update;
  106403. /**
  106404. * Transforms each position and each normal of the vertexData according to the passed Matrix
  106405. * @param matrix the transforming matrix
  106406. * @returns the VertexData
  106407. */
  106408. transform(matrix: Matrix): VertexData;
  106409. /**
  106410. * Merges the passed VertexData into the current one
  106411. * @param other the VertexData to be merged into the current one
  106412. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  106413. * @returns the modified VertexData
  106414. */
  106415. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  106416. private _mergeElement;
  106417. private _validate;
  106418. /**
  106419. * Serializes the VertexData
  106420. * @returns a serialized object
  106421. */
  106422. serialize(): any;
  106423. /**
  106424. * Extracts the vertexData from a mesh
  106425. * @param mesh the mesh from which to extract the VertexData
  106426. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  106427. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106428. * @returns the object VertexData associated to the passed mesh
  106429. */
  106430. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106431. /**
  106432. * Extracts the vertexData from the geometry
  106433. * @param geometry the geometry from which to extract the VertexData
  106434. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  106435. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106436. * @returns the object VertexData associated to the passed mesh
  106437. */
  106438. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106439. private static _ExtractFrom;
  106440. /**
  106441. * Creates the VertexData for a Ribbon
  106442. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  106443. * * pathArray array of paths, each of which an array of successive Vector3
  106444. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  106445. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  106446. * * 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
  106447. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106448. * * 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)
  106449. * * 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)
  106450. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  106451. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  106452. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  106453. * @returns the VertexData of the ribbon
  106454. */
  106455. static CreateRibbon(options: {
  106456. pathArray: Vector3[][];
  106457. closeArray?: boolean;
  106458. closePath?: boolean;
  106459. offset?: number;
  106460. sideOrientation?: number;
  106461. frontUVs?: Vector4;
  106462. backUVs?: Vector4;
  106463. invertUV?: boolean;
  106464. uvs?: Vector2[];
  106465. colors?: Color4[];
  106466. }): VertexData;
  106467. /**
  106468. * Creates the VertexData for a box
  106469. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106470. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106471. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106472. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106473. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106474. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106475. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106476. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106477. * * 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)
  106478. * * 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)
  106479. * @returns the VertexData of the box
  106480. */
  106481. static CreateBox(options: {
  106482. size?: number;
  106483. width?: number;
  106484. height?: number;
  106485. depth?: number;
  106486. faceUV?: Vector4[];
  106487. faceColors?: Color4[];
  106488. sideOrientation?: number;
  106489. frontUVs?: Vector4;
  106490. backUVs?: Vector4;
  106491. }): VertexData;
  106492. /**
  106493. * Creates the VertexData for a tiled box
  106494. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106495. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106496. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106497. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106499. * @returns the VertexData of the box
  106500. */
  106501. static CreateTiledBox(options: {
  106502. pattern?: number;
  106503. width?: number;
  106504. height?: number;
  106505. depth?: number;
  106506. tileSize?: number;
  106507. tileWidth?: number;
  106508. tileHeight?: number;
  106509. alignHorizontal?: number;
  106510. alignVertical?: number;
  106511. faceUV?: Vector4[];
  106512. faceColors?: Color4[];
  106513. sideOrientation?: number;
  106514. }): VertexData;
  106515. /**
  106516. * Creates the VertexData for a tiled plane
  106517. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106518. * * pattern a limited pattern arrangement depending on the number
  106519. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106520. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106521. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106522. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106523. * * 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)
  106524. * * 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)
  106525. * @returns the VertexData of the tiled plane
  106526. */
  106527. static CreateTiledPlane(options: {
  106528. pattern?: number;
  106529. tileSize?: number;
  106530. tileWidth?: number;
  106531. tileHeight?: number;
  106532. size?: number;
  106533. width?: number;
  106534. height?: number;
  106535. alignHorizontal?: number;
  106536. alignVertical?: number;
  106537. sideOrientation?: number;
  106538. frontUVs?: Vector4;
  106539. backUVs?: Vector4;
  106540. }): VertexData;
  106541. /**
  106542. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106543. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106544. * * segments sets the number of horizontal strips optional, default 32
  106545. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106546. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106547. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106548. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106549. * * 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
  106550. * * 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
  106551. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106552. * * 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)
  106553. * * 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)
  106554. * @returns the VertexData of the ellipsoid
  106555. */
  106556. static CreateSphere(options: {
  106557. segments?: number;
  106558. diameter?: number;
  106559. diameterX?: number;
  106560. diameterY?: number;
  106561. diameterZ?: number;
  106562. arc?: number;
  106563. slice?: number;
  106564. sideOrientation?: number;
  106565. frontUVs?: Vector4;
  106566. backUVs?: Vector4;
  106567. }): VertexData;
  106568. /**
  106569. * Creates the VertexData for a cylinder, cone or prism
  106570. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106571. * * height sets the height (y direction) of the cylinder, optional, default 2
  106572. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106573. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106574. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106575. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106576. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106577. * * 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
  106578. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106579. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106580. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106581. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106582. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106583. * * 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)
  106584. * * 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)
  106585. * @returns the VertexData of the cylinder, cone or prism
  106586. */
  106587. static CreateCylinder(options: {
  106588. height?: number;
  106589. diameterTop?: number;
  106590. diameterBottom?: number;
  106591. diameter?: number;
  106592. tessellation?: number;
  106593. subdivisions?: number;
  106594. arc?: number;
  106595. faceColors?: Color4[];
  106596. faceUV?: Vector4[];
  106597. hasRings?: boolean;
  106598. enclose?: boolean;
  106599. sideOrientation?: number;
  106600. frontUVs?: Vector4;
  106601. backUVs?: Vector4;
  106602. }): VertexData;
  106603. /**
  106604. * Creates the VertexData for a torus
  106605. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106606. * * diameter the diameter of the torus, optional default 1
  106607. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106608. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106609. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106610. * * 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)
  106611. * * 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)
  106612. * @returns the VertexData of the torus
  106613. */
  106614. static CreateTorus(options: {
  106615. diameter?: number;
  106616. thickness?: number;
  106617. tessellation?: number;
  106618. sideOrientation?: number;
  106619. frontUVs?: Vector4;
  106620. backUVs?: Vector4;
  106621. }): VertexData;
  106622. /**
  106623. * Creates the VertexData of the LineSystem
  106624. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106625. * - lines an array of lines, each line being an array of successive Vector3
  106626. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106627. * @returns the VertexData of the LineSystem
  106628. */
  106629. static CreateLineSystem(options: {
  106630. lines: Vector3[][];
  106631. colors?: Nullable<Color4[][]>;
  106632. }): VertexData;
  106633. /**
  106634. * Create the VertexData for a DashedLines
  106635. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106636. * - points an array successive Vector3
  106637. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106638. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106639. * - dashNb the intended total number of dashes, optional, default 200
  106640. * @returns the VertexData for the DashedLines
  106641. */
  106642. static CreateDashedLines(options: {
  106643. points: Vector3[];
  106644. dashSize?: number;
  106645. gapSize?: number;
  106646. dashNb?: number;
  106647. }): VertexData;
  106648. /**
  106649. * Creates the VertexData for a Ground
  106650. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106651. * - width the width (x direction) of the ground, optional, default 1
  106652. * - height the height (z direction) of the ground, optional, default 1
  106653. * - subdivisions the number of subdivisions per side, optional, default 1
  106654. * @returns the VertexData of the Ground
  106655. */
  106656. static CreateGround(options: {
  106657. width?: number;
  106658. height?: number;
  106659. subdivisions?: number;
  106660. subdivisionsX?: number;
  106661. subdivisionsY?: number;
  106662. }): VertexData;
  106663. /**
  106664. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106665. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106666. * * xmin the ground minimum X coordinate, optional, default -1
  106667. * * zmin the ground minimum Z coordinate, optional, default -1
  106668. * * xmax the ground maximum X coordinate, optional, default 1
  106669. * * zmax the ground maximum Z coordinate, optional, default 1
  106670. * * 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}
  106671. * * 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}
  106672. * @returns the VertexData of the TiledGround
  106673. */
  106674. static CreateTiledGround(options: {
  106675. xmin: number;
  106676. zmin: number;
  106677. xmax: number;
  106678. zmax: number;
  106679. subdivisions?: {
  106680. w: number;
  106681. h: number;
  106682. };
  106683. precision?: {
  106684. w: number;
  106685. h: number;
  106686. };
  106687. }): VertexData;
  106688. /**
  106689. * Creates the VertexData of the Ground designed from a heightmap
  106690. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106691. * * width the width (x direction) of the ground
  106692. * * height the height (z direction) of the ground
  106693. * * subdivisions the number of subdivisions per side
  106694. * * minHeight the minimum altitude on the ground, optional, default 0
  106695. * * maxHeight the maximum altitude on the ground, optional default 1
  106696. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106697. * * buffer the array holding the image color data
  106698. * * bufferWidth the width of image
  106699. * * bufferHeight the height of image
  106700. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106701. * @returns the VertexData of the Ground designed from a heightmap
  106702. */
  106703. static CreateGroundFromHeightMap(options: {
  106704. width: number;
  106705. height: number;
  106706. subdivisions: number;
  106707. minHeight: number;
  106708. maxHeight: number;
  106709. colorFilter: Color3;
  106710. buffer: Uint8Array;
  106711. bufferWidth: number;
  106712. bufferHeight: number;
  106713. alphaFilter: number;
  106714. }): VertexData;
  106715. /**
  106716. * Creates the VertexData for a Plane
  106717. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106718. * * size sets the width and height of the plane to the value of size, optional default 1
  106719. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106720. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106721. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106722. * * 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)
  106723. * * 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)
  106724. * @returns the VertexData of the box
  106725. */
  106726. static CreatePlane(options: {
  106727. size?: number;
  106728. width?: number;
  106729. height?: number;
  106730. sideOrientation?: number;
  106731. frontUVs?: Vector4;
  106732. backUVs?: Vector4;
  106733. }): VertexData;
  106734. /**
  106735. * Creates the VertexData of the Disc or regular Polygon
  106736. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106737. * * radius the radius of the disc, optional default 0.5
  106738. * * tessellation the number of polygon sides, optional, default 64
  106739. * * 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
  106740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106741. * * 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)
  106742. * * 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)
  106743. * @returns the VertexData of the box
  106744. */
  106745. static CreateDisc(options: {
  106746. radius?: number;
  106747. tessellation?: number;
  106748. arc?: number;
  106749. sideOrientation?: number;
  106750. frontUVs?: Vector4;
  106751. backUVs?: Vector4;
  106752. }): VertexData;
  106753. /**
  106754. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106755. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106756. * @param polygon a mesh built from polygonTriangulation.build()
  106757. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106758. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106759. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106760. * @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)
  106761. * @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)
  106762. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106763. * @returns the VertexData of the Polygon
  106764. */
  106765. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106766. /**
  106767. * Creates the VertexData of the IcoSphere
  106768. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106769. * * radius the radius of the IcoSphere, optional default 1
  106770. * * radiusX allows stretching in the x direction, optional, default radius
  106771. * * radiusY allows stretching in the y direction, optional, default radius
  106772. * * radiusZ allows stretching in the z direction, optional, default radius
  106773. * * flat when true creates a flat shaded mesh, optional, default true
  106774. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106775. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106776. * * 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)
  106777. * * 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)
  106778. * @returns the VertexData of the IcoSphere
  106779. */
  106780. static CreateIcoSphere(options: {
  106781. radius?: number;
  106782. radiusX?: number;
  106783. radiusY?: number;
  106784. radiusZ?: number;
  106785. flat?: boolean;
  106786. subdivisions?: number;
  106787. sideOrientation?: number;
  106788. frontUVs?: Vector4;
  106789. backUVs?: Vector4;
  106790. }): VertexData;
  106791. /**
  106792. * Creates the VertexData for a Polyhedron
  106793. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106794. * * type provided types are:
  106795. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106796. * * 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)
  106797. * * size the size of the IcoSphere, optional default 1
  106798. * * sizeX allows stretching in the x direction, optional, default size
  106799. * * sizeY allows stretching in the y direction, optional, default size
  106800. * * sizeZ allows stretching in the z direction, optional, default size
  106801. * * 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
  106802. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106803. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106804. * * flat when true creates a flat shaded mesh, optional, default true
  106805. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106806. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106807. * * 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)
  106808. * * 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)
  106809. * @returns the VertexData of the Polyhedron
  106810. */
  106811. static CreatePolyhedron(options: {
  106812. type?: number;
  106813. size?: number;
  106814. sizeX?: number;
  106815. sizeY?: number;
  106816. sizeZ?: number;
  106817. custom?: any;
  106818. faceUV?: Vector4[];
  106819. faceColors?: Color4[];
  106820. flat?: boolean;
  106821. sideOrientation?: number;
  106822. frontUVs?: Vector4;
  106823. backUVs?: Vector4;
  106824. }): VertexData;
  106825. /**
  106826. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  106827. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  106828. * @returns the VertexData of the Capsule
  106829. */
  106830. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  106831. /**
  106832. * Creates the VertexData for a TorusKnot
  106833. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106834. * * radius the radius of the torus knot, optional, default 2
  106835. * * tube the thickness of the tube, optional, default 0.5
  106836. * * radialSegments the number of sides on each tube segments, optional, default 32
  106837. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106838. * * p the number of windings around the z axis, optional, default 2
  106839. * * q the number of windings around the x axis, optional, default 3
  106840. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106841. * * 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)
  106842. * * 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)
  106843. * @returns the VertexData of the Torus Knot
  106844. */
  106845. static CreateTorusKnot(options: {
  106846. radius?: number;
  106847. tube?: number;
  106848. radialSegments?: number;
  106849. tubularSegments?: number;
  106850. p?: number;
  106851. q?: number;
  106852. sideOrientation?: number;
  106853. frontUVs?: Vector4;
  106854. backUVs?: Vector4;
  106855. }): VertexData;
  106856. /**
  106857. * Compute normals for given positions and indices
  106858. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106859. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106860. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106861. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106862. * * facetNormals : optional array of facet normals (vector3)
  106863. * * facetPositions : optional array of facet positions (vector3)
  106864. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106865. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106866. * * bInfo : optional bounding info, required for facetPartitioning computation
  106867. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106868. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106869. * * useRightHandedSystem: optional boolean to for right handed system computation
  106870. * * depthSort : optional boolean to enable the facet depth sort computation
  106871. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106872. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106873. */
  106874. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106875. facetNormals?: any;
  106876. facetPositions?: any;
  106877. facetPartitioning?: any;
  106878. ratio?: number;
  106879. bInfo?: any;
  106880. bbSize?: Vector3;
  106881. subDiv?: any;
  106882. useRightHandedSystem?: boolean;
  106883. depthSort?: boolean;
  106884. distanceTo?: Vector3;
  106885. depthSortedFacets?: any;
  106886. }): void;
  106887. /** @hidden */
  106888. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106889. /**
  106890. * Applies VertexData created from the imported parameters to the geometry
  106891. * @param parsedVertexData the parsed data from an imported file
  106892. * @param geometry the geometry to apply the VertexData to
  106893. */
  106894. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106895. }
  106896. }
  106897. declare module BABYLON {
  106898. /**
  106899. * Defines a target to use with MorphTargetManager
  106900. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106901. */
  106902. export class MorphTarget implements IAnimatable {
  106903. /** defines the name of the target */
  106904. name: string;
  106905. /**
  106906. * Gets or sets the list of animations
  106907. */
  106908. animations: Animation[];
  106909. private _scene;
  106910. private _positions;
  106911. private _normals;
  106912. private _tangents;
  106913. private _uvs;
  106914. private _influence;
  106915. private _uniqueId;
  106916. /**
  106917. * Observable raised when the influence changes
  106918. */
  106919. onInfluenceChanged: Observable<boolean>;
  106920. /** @hidden */
  106921. _onDataLayoutChanged: Observable<void>;
  106922. /**
  106923. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106924. */
  106925. get influence(): number;
  106926. set influence(influence: number);
  106927. /**
  106928. * Gets or sets the id of the morph Target
  106929. */
  106930. id: string;
  106931. private _animationPropertiesOverride;
  106932. /**
  106933. * Gets or sets the animation properties override
  106934. */
  106935. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106936. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106937. /**
  106938. * Creates a new MorphTarget
  106939. * @param name defines the name of the target
  106940. * @param influence defines the influence to use
  106941. * @param scene defines the scene the morphtarget belongs to
  106942. */
  106943. constructor(
  106944. /** defines the name of the target */
  106945. name: string, influence?: number, scene?: Nullable<Scene>);
  106946. /**
  106947. * Gets the unique ID of this manager
  106948. */
  106949. get uniqueId(): number;
  106950. /**
  106951. * Gets a boolean defining if the target contains position data
  106952. */
  106953. get hasPositions(): boolean;
  106954. /**
  106955. * Gets a boolean defining if the target contains normal data
  106956. */
  106957. get hasNormals(): boolean;
  106958. /**
  106959. * Gets a boolean defining if the target contains tangent data
  106960. */
  106961. get hasTangents(): boolean;
  106962. /**
  106963. * Gets a boolean defining if the target contains texture coordinates data
  106964. */
  106965. get hasUVs(): boolean;
  106966. /**
  106967. * Affects position data to this target
  106968. * @param data defines the position data to use
  106969. */
  106970. setPositions(data: Nullable<FloatArray>): void;
  106971. /**
  106972. * Gets the position data stored in this target
  106973. * @returns a FloatArray containing the position data (or null if not present)
  106974. */
  106975. getPositions(): Nullable<FloatArray>;
  106976. /**
  106977. * Affects normal data to this target
  106978. * @param data defines the normal data to use
  106979. */
  106980. setNormals(data: Nullable<FloatArray>): void;
  106981. /**
  106982. * Gets the normal data stored in this target
  106983. * @returns a FloatArray containing the normal data (or null if not present)
  106984. */
  106985. getNormals(): Nullable<FloatArray>;
  106986. /**
  106987. * Affects tangent data to this target
  106988. * @param data defines the tangent data to use
  106989. */
  106990. setTangents(data: Nullable<FloatArray>): void;
  106991. /**
  106992. * Gets the tangent data stored in this target
  106993. * @returns a FloatArray containing the tangent data (or null if not present)
  106994. */
  106995. getTangents(): Nullable<FloatArray>;
  106996. /**
  106997. * Affects texture coordinates data to this target
  106998. * @param data defines the texture coordinates data to use
  106999. */
  107000. setUVs(data: Nullable<FloatArray>): void;
  107001. /**
  107002. * Gets the texture coordinates data stored in this target
  107003. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  107004. */
  107005. getUVs(): Nullable<FloatArray>;
  107006. /**
  107007. * Clone the current target
  107008. * @returns a new MorphTarget
  107009. */
  107010. clone(): MorphTarget;
  107011. /**
  107012. * Serializes the current target into a Serialization object
  107013. * @returns the serialized object
  107014. */
  107015. serialize(): any;
  107016. /**
  107017. * Returns the string "MorphTarget"
  107018. * @returns "MorphTarget"
  107019. */
  107020. getClassName(): string;
  107021. /**
  107022. * Creates a new target from serialized data
  107023. * @param serializationObject defines the serialized data to use
  107024. * @returns a new MorphTarget
  107025. */
  107026. static Parse(serializationObject: any): MorphTarget;
  107027. /**
  107028. * Creates a MorphTarget from mesh data
  107029. * @param mesh defines the source mesh
  107030. * @param name defines the name to use for the new target
  107031. * @param influence defines the influence to attach to the target
  107032. * @returns a new MorphTarget
  107033. */
  107034. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  107035. }
  107036. }
  107037. declare module BABYLON {
  107038. /**
  107039. * This class is used to deform meshes using morphing between different targets
  107040. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107041. */
  107042. export class MorphTargetManager {
  107043. private _targets;
  107044. private _targetInfluenceChangedObservers;
  107045. private _targetDataLayoutChangedObservers;
  107046. private _activeTargets;
  107047. private _scene;
  107048. private _influences;
  107049. private _supportsNormals;
  107050. private _supportsTangents;
  107051. private _supportsUVs;
  107052. private _vertexCount;
  107053. private _uniqueId;
  107054. private _tempInfluences;
  107055. /**
  107056. * Gets or sets a boolean indicating if normals must be morphed
  107057. */
  107058. enableNormalMorphing: boolean;
  107059. /**
  107060. * Gets or sets a boolean indicating if tangents must be morphed
  107061. */
  107062. enableTangentMorphing: boolean;
  107063. /**
  107064. * Gets or sets a boolean indicating if UV must be morphed
  107065. */
  107066. enableUVMorphing: boolean;
  107067. /**
  107068. * Creates a new MorphTargetManager
  107069. * @param scene defines the current scene
  107070. */
  107071. constructor(scene?: Nullable<Scene>);
  107072. /**
  107073. * Gets the unique ID of this manager
  107074. */
  107075. get uniqueId(): number;
  107076. /**
  107077. * Gets the number of vertices handled by this manager
  107078. */
  107079. get vertexCount(): number;
  107080. /**
  107081. * Gets a boolean indicating if this manager supports morphing of normals
  107082. */
  107083. get supportsNormals(): boolean;
  107084. /**
  107085. * Gets a boolean indicating if this manager supports morphing of tangents
  107086. */
  107087. get supportsTangents(): boolean;
  107088. /**
  107089. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  107090. */
  107091. get supportsUVs(): boolean;
  107092. /**
  107093. * Gets the number of targets stored in this manager
  107094. */
  107095. get numTargets(): number;
  107096. /**
  107097. * Gets the number of influencers (ie. the number of targets with influences > 0)
  107098. */
  107099. get numInfluencers(): number;
  107100. /**
  107101. * Gets the list of influences (one per target)
  107102. */
  107103. get influences(): Float32Array;
  107104. /**
  107105. * Gets the active target at specified index. An active target is a target with an influence > 0
  107106. * @param index defines the index to check
  107107. * @returns the requested target
  107108. */
  107109. getActiveTarget(index: number): MorphTarget;
  107110. /**
  107111. * Gets the target at specified index
  107112. * @param index defines the index to check
  107113. * @returns the requested target
  107114. */
  107115. getTarget(index: number): MorphTarget;
  107116. /**
  107117. * Add a new target to this manager
  107118. * @param target defines the target to add
  107119. */
  107120. addTarget(target: MorphTarget): void;
  107121. /**
  107122. * Removes a target from the manager
  107123. * @param target defines the target to remove
  107124. */
  107125. removeTarget(target: MorphTarget): void;
  107126. /**
  107127. * Clone the current manager
  107128. * @returns a new MorphTargetManager
  107129. */
  107130. clone(): MorphTargetManager;
  107131. /**
  107132. * Serializes the current manager into a Serialization object
  107133. * @returns the serialized object
  107134. */
  107135. serialize(): any;
  107136. private _syncActiveTargets;
  107137. /**
  107138. * Syncrhonize the targets with all the meshes using this morph target manager
  107139. */
  107140. synchronize(): void;
  107141. /**
  107142. * Creates a new MorphTargetManager from serialized data
  107143. * @param serializationObject defines the serialized data
  107144. * @param scene defines the hosting scene
  107145. * @returns the new MorphTargetManager
  107146. */
  107147. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  107148. }
  107149. }
  107150. declare module BABYLON {
  107151. /**
  107152. * Class used to represent a specific level of detail of a mesh
  107153. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107154. */
  107155. export class MeshLODLevel {
  107156. /** Defines the distance where this level should start being displayed */
  107157. distance: number;
  107158. /** Defines the mesh to use to render this level */
  107159. mesh: Nullable<Mesh>;
  107160. /**
  107161. * Creates a new LOD level
  107162. * @param distance defines the distance where this level should star being displayed
  107163. * @param mesh defines the mesh to use to render this level
  107164. */
  107165. constructor(
  107166. /** Defines the distance where this level should start being displayed */
  107167. distance: number,
  107168. /** Defines the mesh to use to render this level */
  107169. mesh: Nullable<Mesh>);
  107170. }
  107171. }
  107172. declare module BABYLON {
  107173. /**
  107174. * Helper class used to generate a canvas to manipulate images
  107175. */
  107176. export class CanvasGenerator {
  107177. /**
  107178. * Create a new canvas (or offscreen canvas depending on the context)
  107179. * @param width defines the expected width
  107180. * @param height defines the expected height
  107181. * @return a new canvas or offscreen canvas
  107182. */
  107183. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  107184. }
  107185. }
  107186. declare module BABYLON {
  107187. /**
  107188. * Mesh representing the gorund
  107189. */
  107190. export class GroundMesh extends Mesh {
  107191. /** If octree should be generated */
  107192. generateOctree: boolean;
  107193. private _heightQuads;
  107194. /** @hidden */
  107195. _subdivisionsX: number;
  107196. /** @hidden */
  107197. _subdivisionsY: number;
  107198. /** @hidden */
  107199. _width: number;
  107200. /** @hidden */
  107201. _height: number;
  107202. /** @hidden */
  107203. _minX: number;
  107204. /** @hidden */
  107205. _maxX: number;
  107206. /** @hidden */
  107207. _minZ: number;
  107208. /** @hidden */
  107209. _maxZ: number;
  107210. constructor(name: string, scene: Scene);
  107211. /**
  107212. * "GroundMesh"
  107213. * @returns "GroundMesh"
  107214. */
  107215. getClassName(): string;
  107216. /**
  107217. * The minimum of x and y subdivisions
  107218. */
  107219. get subdivisions(): number;
  107220. /**
  107221. * X subdivisions
  107222. */
  107223. get subdivisionsX(): number;
  107224. /**
  107225. * Y subdivisions
  107226. */
  107227. get subdivisionsY(): number;
  107228. /**
  107229. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  107230. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107231. * @param chunksCount the number of subdivisions for x and y
  107232. * @param octreeBlocksSize (Default: 32)
  107233. */
  107234. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  107235. /**
  107236. * Returns a height (y) value in the Worl system :
  107237. * the ground altitude at the coordinates (x, z) expressed in the World system.
  107238. * @param x x coordinate
  107239. * @param z z coordinate
  107240. * @returns the ground y position if (x, z) are outside the ground surface.
  107241. */
  107242. getHeightAtCoordinates(x: number, z: number): number;
  107243. /**
  107244. * Returns a normalized vector (Vector3) orthogonal to the ground
  107245. * at the ground coordinates (x, z) expressed in the World system.
  107246. * @param x x coordinate
  107247. * @param z z coordinate
  107248. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  107249. */
  107250. getNormalAtCoordinates(x: number, z: number): Vector3;
  107251. /**
  107252. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  107253. * at the ground coordinates (x, z) expressed in the World system.
  107254. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  107255. * @param x x coordinate
  107256. * @param z z coordinate
  107257. * @param ref vector to store the result
  107258. * @returns the GroundMesh.
  107259. */
  107260. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  107261. /**
  107262. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  107263. * if the ground has been updated.
  107264. * This can be used in the render loop.
  107265. * @returns the GroundMesh.
  107266. */
  107267. updateCoordinateHeights(): GroundMesh;
  107268. private _getFacetAt;
  107269. private _initHeightQuads;
  107270. private _computeHeightQuads;
  107271. /**
  107272. * Serializes this ground mesh
  107273. * @param serializationObject object to write serialization to
  107274. */
  107275. serialize(serializationObject: any): void;
  107276. /**
  107277. * Parses a serialized ground mesh
  107278. * @param parsedMesh the serialized mesh
  107279. * @param scene the scene to create the ground mesh in
  107280. * @returns the created ground mesh
  107281. */
  107282. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  107283. }
  107284. }
  107285. declare module BABYLON {
  107286. /**
  107287. * Interface for Physics-Joint data
  107288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107289. */
  107290. export interface PhysicsJointData {
  107291. /**
  107292. * The main pivot of the joint
  107293. */
  107294. mainPivot?: Vector3;
  107295. /**
  107296. * The connected pivot of the joint
  107297. */
  107298. connectedPivot?: Vector3;
  107299. /**
  107300. * The main axis of the joint
  107301. */
  107302. mainAxis?: Vector3;
  107303. /**
  107304. * The connected axis of the joint
  107305. */
  107306. connectedAxis?: Vector3;
  107307. /**
  107308. * The collision of the joint
  107309. */
  107310. collision?: boolean;
  107311. /**
  107312. * Native Oimo/Cannon/Energy data
  107313. */
  107314. nativeParams?: any;
  107315. }
  107316. /**
  107317. * This is a holder class for the physics joint created by the physics plugin
  107318. * It holds a set of functions to control the underlying joint
  107319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107320. */
  107321. export class PhysicsJoint {
  107322. /**
  107323. * The type of the physics joint
  107324. */
  107325. type: number;
  107326. /**
  107327. * The data for the physics joint
  107328. */
  107329. jointData: PhysicsJointData;
  107330. private _physicsJoint;
  107331. protected _physicsPlugin: IPhysicsEnginePlugin;
  107332. /**
  107333. * Initializes the physics joint
  107334. * @param type The type of the physics joint
  107335. * @param jointData The data for the physics joint
  107336. */
  107337. constructor(
  107338. /**
  107339. * The type of the physics joint
  107340. */
  107341. type: number,
  107342. /**
  107343. * The data for the physics joint
  107344. */
  107345. jointData: PhysicsJointData);
  107346. /**
  107347. * Gets the physics joint
  107348. */
  107349. get physicsJoint(): any;
  107350. /**
  107351. * Sets the physics joint
  107352. */
  107353. set physicsJoint(newJoint: any);
  107354. /**
  107355. * Sets the physics plugin
  107356. */
  107357. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  107358. /**
  107359. * Execute a function that is physics-plugin specific.
  107360. * @param {Function} func the function that will be executed.
  107361. * It accepts two parameters: the physics world and the physics joint
  107362. */
  107363. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  107364. /**
  107365. * Distance-Joint type
  107366. */
  107367. static DistanceJoint: number;
  107368. /**
  107369. * Hinge-Joint type
  107370. */
  107371. static HingeJoint: number;
  107372. /**
  107373. * Ball-and-Socket joint type
  107374. */
  107375. static BallAndSocketJoint: number;
  107376. /**
  107377. * Wheel-Joint type
  107378. */
  107379. static WheelJoint: number;
  107380. /**
  107381. * Slider-Joint type
  107382. */
  107383. static SliderJoint: number;
  107384. /**
  107385. * Prismatic-Joint type
  107386. */
  107387. static PrismaticJoint: number;
  107388. /**
  107389. * Universal-Joint type
  107390. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  107391. */
  107392. static UniversalJoint: number;
  107393. /**
  107394. * Hinge-Joint 2 type
  107395. */
  107396. static Hinge2Joint: number;
  107397. /**
  107398. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  107399. */
  107400. static PointToPointJoint: number;
  107401. /**
  107402. * Spring-Joint type
  107403. */
  107404. static SpringJoint: number;
  107405. /**
  107406. * Lock-Joint type
  107407. */
  107408. static LockJoint: number;
  107409. }
  107410. /**
  107411. * A class representing a physics distance joint
  107412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107413. */
  107414. export class DistanceJoint extends PhysicsJoint {
  107415. /**
  107416. *
  107417. * @param jointData The data for the Distance-Joint
  107418. */
  107419. constructor(jointData: DistanceJointData);
  107420. /**
  107421. * Update the predefined distance.
  107422. * @param maxDistance The maximum preferred distance
  107423. * @param minDistance The minimum preferred distance
  107424. */
  107425. updateDistance(maxDistance: number, minDistance?: number): void;
  107426. }
  107427. /**
  107428. * Represents a Motor-Enabled Joint
  107429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107430. */
  107431. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  107432. /**
  107433. * Initializes the Motor-Enabled Joint
  107434. * @param type The type of the joint
  107435. * @param jointData The physica joint data for the joint
  107436. */
  107437. constructor(type: number, jointData: PhysicsJointData);
  107438. /**
  107439. * Set the motor values.
  107440. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107441. * @param force the force to apply
  107442. * @param maxForce max force for this motor.
  107443. */
  107444. setMotor(force?: number, maxForce?: number): void;
  107445. /**
  107446. * Set the motor's limits.
  107447. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107448. * @param upperLimit The upper limit of the motor
  107449. * @param lowerLimit The lower limit of the motor
  107450. */
  107451. setLimit(upperLimit: number, lowerLimit?: number): void;
  107452. }
  107453. /**
  107454. * This class represents a single physics Hinge-Joint
  107455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107456. */
  107457. export class HingeJoint extends MotorEnabledJoint {
  107458. /**
  107459. * Initializes the Hinge-Joint
  107460. * @param jointData The joint data for the Hinge-Joint
  107461. */
  107462. constructor(jointData: PhysicsJointData);
  107463. /**
  107464. * Set the motor values.
  107465. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107466. * @param {number} force the force to apply
  107467. * @param {number} maxForce max force for this motor.
  107468. */
  107469. setMotor(force?: number, maxForce?: number): void;
  107470. /**
  107471. * Set the motor's limits.
  107472. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107473. * @param upperLimit The upper limit of the motor
  107474. * @param lowerLimit The lower limit of the motor
  107475. */
  107476. setLimit(upperLimit: number, lowerLimit?: number): void;
  107477. }
  107478. /**
  107479. * This class represents a dual hinge physics joint (same as wheel joint)
  107480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107481. */
  107482. export class Hinge2Joint extends MotorEnabledJoint {
  107483. /**
  107484. * Initializes the Hinge2-Joint
  107485. * @param jointData The joint data for the Hinge2-Joint
  107486. */
  107487. constructor(jointData: PhysicsJointData);
  107488. /**
  107489. * Set the motor values.
  107490. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107491. * @param {number} targetSpeed the speed the motor is to reach
  107492. * @param {number} maxForce max force for this motor.
  107493. * @param {motorIndex} the motor's index, 0 or 1.
  107494. */
  107495. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107496. /**
  107497. * Set the motor limits.
  107498. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107499. * @param {number} upperLimit the upper limit
  107500. * @param {number} lowerLimit lower limit
  107501. * @param {motorIndex} the motor's index, 0 or 1.
  107502. */
  107503. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107504. }
  107505. /**
  107506. * Interface for a motor enabled joint
  107507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107508. */
  107509. export interface IMotorEnabledJoint {
  107510. /**
  107511. * Physics joint
  107512. */
  107513. physicsJoint: any;
  107514. /**
  107515. * Sets the motor of the motor-enabled joint
  107516. * @param force The force of the motor
  107517. * @param maxForce The maximum force of the motor
  107518. * @param motorIndex The index of the motor
  107519. */
  107520. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107521. /**
  107522. * Sets the limit of the motor
  107523. * @param upperLimit The upper limit of the motor
  107524. * @param lowerLimit The lower limit of the motor
  107525. * @param motorIndex The index of the motor
  107526. */
  107527. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107528. }
  107529. /**
  107530. * Joint data for a Distance-Joint
  107531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107532. */
  107533. export interface DistanceJointData extends PhysicsJointData {
  107534. /**
  107535. * Max distance the 2 joint objects can be apart
  107536. */
  107537. maxDistance: number;
  107538. }
  107539. /**
  107540. * Joint data from a spring joint
  107541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107542. */
  107543. export interface SpringJointData extends PhysicsJointData {
  107544. /**
  107545. * Length of the spring
  107546. */
  107547. length: number;
  107548. /**
  107549. * Stiffness of the spring
  107550. */
  107551. stiffness: number;
  107552. /**
  107553. * Damping of the spring
  107554. */
  107555. damping: number;
  107556. /** this callback will be called when applying the force to the impostors. */
  107557. forceApplicationCallback: () => void;
  107558. }
  107559. }
  107560. declare module BABYLON {
  107561. /**
  107562. * Holds the data for the raycast result
  107563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107564. */
  107565. export class PhysicsRaycastResult {
  107566. private _hasHit;
  107567. private _hitDistance;
  107568. private _hitNormalWorld;
  107569. private _hitPointWorld;
  107570. private _rayFromWorld;
  107571. private _rayToWorld;
  107572. /**
  107573. * Gets if there was a hit
  107574. */
  107575. get hasHit(): boolean;
  107576. /**
  107577. * Gets the distance from the hit
  107578. */
  107579. get hitDistance(): number;
  107580. /**
  107581. * Gets the hit normal/direction in the world
  107582. */
  107583. get hitNormalWorld(): Vector3;
  107584. /**
  107585. * Gets the hit point in the world
  107586. */
  107587. get hitPointWorld(): Vector3;
  107588. /**
  107589. * Gets the ray "start point" of the ray in the world
  107590. */
  107591. get rayFromWorld(): Vector3;
  107592. /**
  107593. * Gets the ray "end point" of the ray in the world
  107594. */
  107595. get rayToWorld(): Vector3;
  107596. /**
  107597. * Sets the hit data (normal & point in world space)
  107598. * @param hitNormalWorld defines the normal in world space
  107599. * @param hitPointWorld defines the point in world space
  107600. */
  107601. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107602. /**
  107603. * Sets the distance from the start point to the hit point
  107604. * @param distance
  107605. */
  107606. setHitDistance(distance: number): void;
  107607. /**
  107608. * Calculates the distance manually
  107609. */
  107610. calculateHitDistance(): void;
  107611. /**
  107612. * Resets all the values to default
  107613. * @param from The from point on world space
  107614. * @param to The to point on world space
  107615. */
  107616. reset(from?: Vector3, to?: Vector3): void;
  107617. }
  107618. /**
  107619. * Interface for the size containing width and height
  107620. */
  107621. interface IXYZ {
  107622. /**
  107623. * X
  107624. */
  107625. x: number;
  107626. /**
  107627. * Y
  107628. */
  107629. y: number;
  107630. /**
  107631. * Z
  107632. */
  107633. z: number;
  107634. }
  107635. }
  107636. declare module BABYLON {
  107637. /**
  107638. * Interface used to describe a physics joint
  107639. */
  107640. export interface PhysicsImpostorJoint {
  107641. /** Defines the main impostor to which the joint is linked */
  107642. mainImpostor: PhysicsImpostor;
  107643. /** Defines the impostor that is connected to the main impostor using this joint */
  107644. connectedImpostor: PhysicsImpostor;
  107645. /** Defines the joint itself */
  107646. joint: PhysicsJoint;
  107647. }
  107648. /** @hidden */
  107649. export interface IPhysicsEnginePlugin {
  107650. world: any;
  107651. name: string;
  107652. setGravity(gravity: Vector3): void;
  107653. setTimeStep(timeStep: number): void;
  107654. getTimeStep(): number;
  107655. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107656. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107657. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107658. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107659. removePhysicsBody(impostor: PhysicsImpostor): void;
  107660. generateJoint(joint: PhysicsImpostorJoint): void;
  107661. removeJoint(joint: PhysicsImpostorJoint): void;
  107662. isSupported(): boolean;
  107663. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107664. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107665. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107666. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107667. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107668. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107669. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107670. getBodyMass(impostor: PhysicsImpostor): number;
  107671. getBodyFriction(impostor: PhysicsImpostor): number;
  107672. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107673. getBodyRestitution(impostor: PhysicsImpostor): number;
  107674. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107675. getBodyPressure?(impostor: PhysicsImpostor): number;
  107676. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107677. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107678. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107679. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107680. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107681. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107682. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107683. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107684. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107685. sleepBody(impostor: PhysicsImpostor): void;
  107686. wakeUpBody(impostor: PhysicsImpostor): void;
  107687. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107688. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107689. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107690. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107691. getRadius(impostor: PhysicsImpostor): number;
  107692. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107693. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107694. dispose(): void;
  107695. }
  107696. /**
  107697. * Interface used to define a physics engine
  107698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107699. */
  107700. export interface IPhysicsEngine {
  107701. /**
  107702. * Gets the gravity vector used by the simulation
  107703. */
  107704. gravity: Vector3;
  107705. /**
  107706. * Sets the gravity vector used by the simulation
  107707. * @param gravity defines the gravity vector to use
  107708. */
  107709. setGravity(gravity: Vector3): void;
  107710. /**
  107711. * Set the time step of the physics engine.
  107712. * Default is 1/60.
  107713. * To slow it down, enter 1/600 for example.
  107714. * To speed it up, 1/30
  107715. * @param newTimeStep the new timestep to apply to this world.
  107716. */
  107717. setTimeStep(newTimeStep: number): void;
  107718. /**
  107719. * Get the time step of the physics engine.
  107720. * @returns the current time step
  107721. */
  107722. getTimeStep(): number;
  107723. /**
  107724. * Set the sub time step of the physics engine.
  107725. * Default is 0 meaning there is no sub steps
  107726. * To increase physics resolution precision, set a small value (like 1 ms)
  107727. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107728. */
  107729. setSubTimeStep(subTimeStep: number): void;
  107730. /**
  107731. * Get the sub time step of the physics engine.
  107732. * @returns the current sub time step
  107733. */
  107734. getSubTimeStep(): number;
  107735. /**
  107736. * Release all resources
  107737. */
  107738. dispose(): void;
  107739. /**
  107740. * Gets the name of the current physics plugin
  107741. * @returns the name of the plugin
  107742. */
  107743. getPhysicsPluginName(): string;
  107744. /**
  107745. * Adding a new impostor for the impostor tracking.
  107746. * This will be done by the impostor itself.
  107747. * @param impostor the impostor to add
  107748. */
  107749. addImpostor(impostor: PhysicsImpostor): void;
  107750. /**
  107751. * Remove an impostor from the engine.
  107752. * This impostor and its mesh will not longer be updated by the physics engine.
  107753. * @param impostor the impostor to remove
  107754. */
  107755. removeImpostor(impostor: PhysicsImpostor): void;
  107756. /**
  107757. * Add a joint to the physics engine
  107758. * @param mainImpostor defines the main impostor to which the joint is added.
  107759. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107760. * @param joint defines the joint that will connect both impostors.
  107761. */
  107762. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107763. /**
  107764. * Removes a joint from the simulation
  107765. * @param mainImpostor defines the impostor used with the joint
  107766. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107767. * @param joint defines the joint to remove
  107768. */
  107769. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107770. /**
  107771. * Gets the current plugin used to run the simulation
  107772. * @returns current plugin
  107773. */
  107774. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107775. /**
  107776. * Gets the list of physic impostors
  107777. * @returns an array of PhysicsImpostor
  107778. */
  107779. getImpostors(): Array<PhysicsImpostor>;
  107780. /**
  107781. * Gets the impostor for a physics enabled object
  107782. * @param object defines the object impersonated by the impostor
  107783. * @returns the PhysicsImpostor or null if not found
  107784. */
  107785. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107786. /**
  107787. * Gets the impostor for a physics body object
  107788. * @param body defines physics body used by the impostor
  107789. * @returns the PhysicsImpostor or null if not found
  107790. */
  107791. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107792. /**
  107793. * Does a raycast in the physics world
  107794. * @param from when should the ray start?
  107795. * @param to when should the ray end?
  107796. * @returns PhysicsRaycastResult
  107797. */
  107798. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107799. /**
  107800. * Called by the scene. No need to call it.
  107801. * @param delta defines the timespam between frames
  107802. */
  107803. _step(delta: number): void;
  107804. }
  107805. }
  107806. declare module BABYLON {
  107807. /**
  107808. * The interface for the physics imposter parameters
  107809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107810. */
  107811. export interface PhysicsImpostorParameters {
  107812. /**
  107813. * The mass of the physics imposter
  107814. */
  107815. mass: number;
  107816. /**
  107817. * The friction of the physics imposter
  107818. */
  107819. friction?: number;
  107820. /**
  107821. * The coefficient of restitution of the physics imposter
  107822. */
  107823. restitution?: number;
  107824. /**
  107825. * The native options of the physics imposter
  107826. */
  107827. nativeOptions?: any;
  107828. /**
  107829. * Specifies if the parent should be ignored
  107830. */
  107831. ignoreParent?: boolean;
  107832. /**
  107833. * Specifies if bi-directional transformations should be disabled
  107834. */
  107835. disableBidirectionalTransformation?: boolean;
  107836. /**
  107837. * The pressure inside the physics imposter, soft object only
  107838. */
  107839. pressure?: number;
  107840. /**
  107841. * The stiffness the physics imposter, soft object only
  107842. */
  107843. stiffness?: number;
  107844. /**
  107845. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107846. */
  107847. velocityIterations?: number;
  107848. /**
  107849. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107850. */
  107851. positionIterations?: number;
  107852. /**
  107853. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107854. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107855. * Add to fix multiple points
  107856. */
  107857. fixedPoints?: number;
  107858. /**
  107859. * The collision margin around a soft object
  107860. */
  107861. margin?: number;
  107862. /**
  107863. * The collision margin around a soft object
  107864. */
  107865. damping?: number;
  107866. /**
  107867. * The path for a rope based on an extrusion
  107868. */
  107869. path?: any;
  107870. /**
  107871. * The shape of an extrusion used for a rope based on an extrusion
  107872. */
  107873. shape?: any;
  107874. }
  107875. /**
  107876. * Interface for a physics-enabled object
  107877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107878. */
  107879. export interface IPhysicsEnabledObject {
  107880. /**
  107881. * The position of the physics-enabled object
  107882. */
  107883. position: Vector3;
  107884. /**
  107885. * The rotation of the physics-enabled object
  107886. */
  107887. rotationQuaternion: Nullable<Quaternion>;
  107888. /**
  107889. * The scale of the physics-enabled object
  107890. */
  107891. scaling: Vector3;
  107892. /**
  107893. * The rotation of the physics-enabled object
  107894. */
  107895. rotation?: Vector3;
  107896. /**
  107897. * The parent of the physics-enabled object
  107898. */
  107899. parent?: any;
  107900. /**
  107901. * The bounding info of the physics-enabled object
  107902. * @returns The bounding info of the physics-enabled object
  107903. */
  107904. getBoundingInfo(): BoundingInfo;
  107905. /**
  107906. * Computes the world matrix
  107907. * @param force Specifies if the world matrix should be computed by force
  107908. * @returns A world matrix
  107909. */
  107910. computeWorldMatrix(force: boolean): Matrix;
  107911. /**
  107912. * Gets the world matrix
  107913. * @returns A world matrix
  107914. */
  107915. getWorldMatrix?(): Matrix;
  107916. /**
  107917. * Gets the child meshes
  107918. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107919. * @returns An array of abstract meshes
  107920. */
  107921. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107922. /**
  107923. * Gets the vertex data
  107924. * @param kind The type of vertex data
  107925. * @returns A nullable array of numbers, or a float32 array
  107926. */
  107927. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107928. /**
  107929. * Gets the indices from the mesh
  107930. * @returns A nullable array of index arrays
  107931. */
  107932. getIndices?(): Nullable<IndicesArray>;
  107933. /**
  107934. * Gets the scene from the mesh
  107935. * @returns the indices array or null
  107936. */
  107937. getScene?(): Scene;
  107938. /**
  107939. * Gets the absolute position from the mesh
  107940. * @returns the absolute position
  107941. */
  107942. getAbsolutePosition(): Vector3;
  107943. /**
  107944. * Gets the absolute pivot point from the mesh
  107945. * @returns the absolute pivot point
  107946. */
  107947. getAbsolutePivotPoint(): Vector3;
  107948. /**
  107949. * Rotates the mesh
  107950. * @param axis The axis of rotation
  107951. * @param amount The amount of rotation
  107952. * @param space The space of the rotation
  107953. * @returns The rotation transform node
  107954. */
  107955. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107956. /**
  107957. * Translates the mesh
  107958. * @param axis The axis of translation
  107959. * @param distance The distance of translation
  107960. * @param space The space of the translation
  107961. * @returns The transform node
  107962. */
  107963. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107964. /**
  107965. * Sets the absolute position of the mesh
  107966. * @param absolutePosition The absolute position of the mesh
  107967. * @returns The transform node
  107968. */
  107969. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107970. /**
  107971. * Gets the class name of the mesh
  107972. * @returns The class name
  107973. */
  107974. getClassName(): string;
  107975. }
  107976. /**
  107977. * Represents a physics imposter
  107978. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107979. */
  107980. export class PhysicsImpostor {
  107981. /**
  107982. * The physics-enabled object used as the physics imposter
  107983. */
  107984. object: IPhysicsEnabledObject;
  107985. /**
  107986. * The type of the physics imposter
  107987. */
  107988. type: number;
  107989. private _options;
  107990. private _scene?;
  107991. /**
  107992. * The default object size of the imposter
  107993. */
  107994. static DEFAULT_OBJECT_SIZE: Vector3;
  107995. /**
  107996. * The identity quaternion of the imposter
  107997. */
  107998. static IDENTITY_QUATERNION: Quaternion;
  107999. /** @hidden */
  108000. _pluginData: any;
  108001. private _physicsEngine;
  108002. private _physicsBody;
  108003. private _bodyUpdateRequired;
  108004. private _onBeforePhysicsStepCallbacks;
  108005. private _onAfterPhysicsStepCallbacks;
  108006. /** @hidden */
  108007. _onPhysicsCollideCallbacks: Array<{
  108008. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  108009. otherImpostors: Array<PhysicsImpostor>;
  108010. }>;
  108011. private _deltaPosition;
  108012. private _deltaRotation;
  108013. private _deltaRotationConjugated;
  108014. /** @hidden */
  108015. _isFromLine: boolean;
  108016. private _parent;
  108017. private _isDisposed;
  108018. private static _tmpVecs;
  108019. private static _tmpQuat;
  108020. /**
  108021. * Specifies if the physics imposter is disposed
  108022. */
  108023. get isDisposed(): boolean;
  108024. /**
  108025. * Gets the mass of the physics imposter
  108026. */
  108027. get mass(): number;
  108028. set mass(value: number);
  108029. /**
  108030. * Gets the coefficient of friction
  108031. */
  108032. get friction(): number;
  108033. /**
  108034. * Sets the coefficient of friction
  108035. */
  108036. set friction(value: number);
  108037. /**
  108038. * Gets the coefficient of restitution
  108039. */
  108040. get restitution(): number;
  108041. /**
  108042. * Sets the coefficient of restitution
  108043. */
  108044. set restitution(value: number);
  108045. /**
  108046. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  108047. */
  108048. get pressure(): number;
  108049. /**
  108050. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  108051. */
  108052. set pressure(value: number);
  108053. /**
  108054. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108055. */
  108056. get stiffness(): number;
  108057. /**
  108058. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108059. */
  108060. set stiffness(value: number);
  108061. /**
  108062. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108063. */
  108064. get velocityIterations(): number;
  108065. /**
  108066. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108067. */
  108068. set velocityIterations(value: number);
  108069. /**
  108070. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108071. */
  108072. get positionIterations(): number;
  108073. /**
  108074. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108075. */
  108076. set positionIterations(value: number);
  108077. /**
  108078. * The unique id of the physics imposter
  108079. * set by the physics engine when adding this impostor to the array
  108080. */
  108081. uniqueId: number;
  108082. /**
  108083. * @hidden
  108084. */
  108085. soft: boolean;
  108086. /**
  108087. * @hidden
  108088. */
  108089. segments: number;
  108090. private _joints;
  108091. /**
  108092. * Initializes the physics imposter
  108093. * @param object The physics-enabled object used as the physics imposter
  108094. * @param type The type of the physics imposter
  108095. * @param _options The options for the physics imposter
  108096. * @param _scene The Babylon scene
  108097. */
  108098. constructor(
  108099. /**
  108100. * The physics-enabled object used as the physics imposter
  108101. */
  108102. object: IPhysicsEnabledObject,
  108103. /**
  108104. * The type of the physics imposter
  108105. */
  108106. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  108107. /**
  108108. * This function will completly initialize this impostor.
  108109. * It will create a new body - but only if this mesh has no parent.
  108110. * If it has, this impostor will not be used other than to define the impostor
  108111. * of the child mesh.
  108112. * @hidden
  108113. */
  108114. _init(): void;
  108115. private _getPhysicsParent;
  108116. /**
  108117. * Should a new body be generated.
  108118. * @returns boolean specifying if body initialization is required
  108119. */
  108120. isBodyInitRequired(): boolean;
  108121. /**
  108122. * Sets the updated scaling
  108123. * @param updated Specifies if the scaling is updated
  108124. */
  108125. setScalingUpdated(): void;
  108126. /**
  108127. * Force a regeneration of this or the parent's impostor's body.
  108128. * Use under cautious - This will remove all joints already implemented.
  108129. */
  108130. forceUpdate(): void;
  108131. /**
  108132. * Gets the body that holds this impostor. Either its own, or its parent.
  108133. */
  108134. get physicsBody(): any;
  108135. /**
  108136. * Get the parent of the physics imposter
  108137. * @returns Physics imposter or null
  108138. */
  108139. get parent(): Nullable<PhysicsImpostor>;
  108140. /**
  108141. * Sets the parent of the physics imposter
  108142. */
  108143. set parent(value: Nullable<PhysicsImpostor>);
  108144. /**
  108145. * Set the physics body. Used mainly by the physics engine/plugin
  108146. */
  108147. set physicsBody(physicsBody: any);
  108148. /**
  108149. * Resets the update flags
  108150. */
  108151. resetUpdateFlags(): void;
  108152. /**
  108153. * Gets the object extend size
  108154. * @returns the object extend size
  108155. */
  108156. getObjectExtendSize(): Vector3;
  108157. /**
  108158. * Gets the object center
  108159. * @returns The object center
  108160. */
  108161. getObjectCenter(): Vector3;
  108162. /**
  108163. * Get a specific parameter from the options parameters
  108164. * @param paramName The object parameter name
  108165. * @returns The object parameter
  108166. */
  108167. getParam(paramName: string): any;
  108168. /**
  108169. * Sets a specific parameter in the options given to the physics plugin
  108170. * @param paramName The parameter name
  108171. * @param value The value of the parameter
  108172. */
  108173. setParam(paramName: string, value: number): void;
  108174. /**
  108175. * Specifically change the body's mass option. Won't recreate the physics body object
  108176. * @param mass The mass of the physics imposter
  108177. */
  108178. setMass(mass: number): void;
  108179. /**
  108180. * Gets the linear velocity
  108181. * @returns linear velocity or null
  108182. */
  108183. getLinearVelocity(): Nullable<Vector3>;
  108184. /**
  108185. * Sets the linear velocity
  108186. * @param velocity linear velocity or null
  108187. */
  108188. setLinearVelocity(velocity: Nullable<Vector3>): void;
  108189. /**
  108190. * Gets the angular velocity
  108191. * @returns angular velocity or null
  108192. */
  108193. getAngularVelocity(): Nullable<Vector3>;
  108194. /**
  108195. * Sets the angular velocity
  108196. * @param velocity The velocity or null
  108197. */
  108198. setAngularVelocity(velocity: Nullable<Vector3>): void;
  108199. /**
  108200. * Execute a function with the physics plugin native code
  108201. * Provide a function the will have two variables - the world object and the physics body object
  108202. * @param func The function to execute with the physics plugin native code
  108203. */
  108204. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  108205. /**
  108206. * Register a function that will be executed before the physics world is stepping forward
  108207. * @param func The function to execute before the physics world is stepped forward
  108208. */
  108209. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108210. /**
  108211. * Unregister a function that will be executed before the physics world is stepping forward
  108212. * @param func The function to execute before the physics world is stepped forward
  108213. */
  108214. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108215. /**
  108216. * Register a function that will be executed after the physics step
  108217. * @param func The function to execute after physics step
  108218. */
  108219. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108220. /**
  108221. * Unregisters a function that will be executed after the physics step
  108222. * @param func The function to execute after physics step
  108223. */
  108224. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108225. /**
  108226. * register a function that will be executed when this impostor collides against a different body
  108227. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  108228. * @param func Callback that is executed on collision
  108229. */
  108230. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  108231. /**
  108232. * Unregisters the physics imposter on contact
  108233. * @param collideAgainst The physics object to collide against
  108234. * @param func Callback to execute on collision
  108235. */
  108236. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  108237. private _tmpQuat;
  108238. private _tmpQuat2;
  108239. /**
  108240. * Get the parent rotation
  108241. * @returns The parent rotation
  108242. */
  108243. getParentsRotation(): Quaternion;
  108244. /**
  108245. * this function is executed by the physics engine.
  108246. */
  108247. beforeStep: () => void;
  108248. /**
  108249. * this function is executed by the physics engine
  108250. */
  108251. afterStep: () => void;
  108252. /**
  108253. * Legacy collision detection event support
  108254. */
  108255. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  108256. /**
  108257. * event and body object due to cannon's event-based architecture.
  108258. */
  108259. onCollide: (e: {
  108260. body: any;
  108261. }) => void;
  108262. /**
  108263. * Apply a force
  108264. * @param force The force to apply
  108265. * @param contactPoint The contact point for the force
  108266. * @returns The physics imposter
  108267. */
  108268. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108269. /**
  108270. * Apply an impulse
  108271. * @param force The impulse force
  108272. * @param contactPoint The contact point for the impulse force
  108273. * @returns The physics imposter
  108274. */
  108275. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108276. /**
  108277. * A help function to create a joint
  108278. * @param otherImpostor A physics imposter used to create a joint
  108279. * @param jointType The type of joint
  108280. * @param jointData The data for the joint
  108281. * @returns The physics imposter
  108282. */
  108283. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  108284. /**
  108285. * Add a joint to this impostor with a different impostor
  108286. * @param otherImpostor A physics imposter used to add a joint
  108287. * @param joint The joint to add
  108288. * @returns The physics imposter
  108289. */
  108290. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  108291. /**
  108292. * Add an anchor to a cloth impostor
  108293. * @param otherImpostor rigid impostor to anchor to
  108294. * @param width ratio across width from 0 to 1
  108295. * @param height ratio up height from 0 to 1
  108296. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108297. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  108298. * @returns impostor the soft imposter
  108299. */
  108300. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108301. /**
  108302. * Add a hook to a rope impostor
  108303. * @param otherImpostor rigid impostor to anchor to
  108304. * @param length ratio across rope from 0 to 1
  108305. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  108306. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108307. * @returns impostor the rope imposter
  108308. */
  108309. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108310. /**
  108311. * Will keep this body still, in a sleep mode.
  108312. * @returns the physics imposter
  108313. */
  108314. sleep(): PhysicsImpostor;
  108315. /**
  108316. * Wake the body up.
  108317. * @returns The physics imposter
  108318. */
  108319. wakeUp(): PhysicsImpostor;
  108320. /**
  108321. * Clones the physics imposter
  108322. * @param newObject The physics imposter clones to this physics-enabled object
  108323. * @returns A nullable physics imposter
  108324. */
  108325. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108326. /**
  108327. * Disposes the physics imposter
  108328. */
  108329. dispose(): void;
  108330. /**
  108331. * Sets the delta position
  108332. * @param position The delta position amount
  108333. */
  108334. setDeltaPosition(position: Vector3): void;
  108335. /**
  108336. * Sets the delta rotation
  108337. * @param rotation The delta rotation amount
  108338. */
  108339. setDeltaRotation(rotation: Quaternion): void;
  108340. /**
  108341. * Gets the box size of the physics imposter and stores the result in the input parameter
  108342. * @param result Stores the box size
  108343. * @returns The physics imposter
  108344. */
  108345. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  108346. /**
  108347. * Gets the radius of the physics imposter
  108348. * @returns Radius of the physics imposter
  108349. */
  108350. getRadius(): number;
  108351. /**
  108352. * Sync a bone with this impostor
  108353. * @param bone The bone to sync to the impostor.
  108354. * @param boneMesh The mesh that the bone is influencing.
  108355. * @param jointPivot The pivot of the joint / bone in local space.
  108356. * @param distToJoint Optional distance from the impostor to the joint.
  108357. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108358. */
  108359. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  108360. /**
  108361. * Sync impostor to a bone
  108362. * @param bone The bone that the impostor will be synced to.
  108363. * @param boneMesh The mesh that the bone is influencing.
  108364. * @param jointPivot The pivot of the joint / bone in local space.
  108365. * @param distToJoint Optional distance from the impostor to the joint.
  108366. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108367. * @param boneAxis Optional vector3 axis the bone is aligned with
  108368. */
  108369. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  108370. /**
  108371. * No-Imposter type
  108372. */
  108373. static NoImpostor: number;
  108374. /**
  108375. * Sphere-Imposter type
  108376. */
  108377. static SphereImpostor: number;
  108378. /**
  108379. * Box-Imposter type
  108380. */
  108381. static BoxImpostor: number;
  108382. /**
  108383. * Plane-Imposter type
  108384. */
  108385. static PlaneImpostor: number;
  108386. /**
  108387. * Mesh-imposter type
  108388. */
  108389. static MeshImpostor: number;
  108390. /**
  108391. * Capsule-Impostor type (Ammo.js plugin only)
  108392. */
  108393. static CapsuleImpostor: number;
  108394. /**
  108395. * Cylinder-Imposter type
  108396. */
  108397. static CylinderImpostor: number;
  108398. /**
  108399. * Particle-Imposter type
  108400. */
  108401. static ParticleImpostor: number;
  108402. /**
  108403. * Heightmap-Imposter type
  108404. */
  108405. static HeightmapImpostor: number;
  108406. /**
  108407. * ConvexHull-Impostor type (Ammo.js plugin only)
  108408. */
  108409. static ConvexHullImpostor: number;
  108410. /**
  108411. * Custom-Imposter type (Ammo.js plugin only)
  108412. */
  108413. static CustomImpostor: number;
  108414. /**
  108415. * Rope-Imposter type
  108416. */
  108417. static RopeImpostor: number;
  108418. /**
  108419. * Cloth-Imposter type
  108420. */
  108421. static ClothImpostor: number;
  108422. /**
  108423. * Softbody-Imposter type
  108424. */
  108425. static SoftbodyImpostor: number;
  108426. }
  108427. }
  108428. declare module BABYLON {
  108429. /**
  108430. * @hidden
  108431. **/
  108432. export class _CreationDataStorage {
  108433. closePath?: boolean;
  108434. closeArray?: boolean;
  108435. idx: number[];
  108436. dashSize: number;
  108437. gapSize: number;
  108438. path3D: Path3D;
  108439. pathArray: Vector3[][];
  108440. arc: number;
  108441. radius: number;
  108442. cap: number;
  108443. tessellation: number;
  108444. }
  108445. /**
  108446. * @hidden
  108447. **/
  108448. class _InstanceDataStorage {
  108449. visibleInstances: any;
  108450. batchCache: _InstancesBatch;
  108451. instancesBufferSize: number;
  108452. instancesBuffer: Nullable<Buffer>;
  108453. instancesData: Float32Array;
  108454. overridenInstanceCount: number;
  108455. isFrozen: boolean;
  108456. previousBatch: Nullable<_InstancesBatch>;
  108457. hardwareInstancedRendering: boolean;
  108458. sideOrientation: number;
  108459. manualUpdate: boolean;
  108460. previousRenderId: number;
  108461. }
  108462. /**
  108463. * @hidden
  108464. **/
  108465. export class _InstancesBatch {
  108466. mustReturn: boolean;
  108467. visibleInstances: Nullable<InstancedMesh[]>[];
  108468. renderSelf: boolean[];
  108469. hardwareInstancedRendering: boolean[];
  108470. }
  108471. /**
  108472. * @hidden
  108473. **/
  108474. class _ThinInstanceDataStorage {
  108475. instancesCount: number;
  108476. matrixBuffer: Nullable<Buffer>;
  108477. matrixBufferSize: number;
  108478. matrixData: Nullable<Float32Array>;
  108479. boundingVectors: Array<Vector3>;
  108480. worldMatrices: Nullable<Matrix[]>;
  108481. }
  108482. /**
  108483. * Class used to represent renderable models
  108484. */
  108485. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108486. /**
  108487. * Mesh side orientation : usually the external or front surface
  108488. */
  108489. static readonly FRONTSIDE: number;
  108490. /**
  108491. * Mesh side orientation : usually the internal or back surface
  108492. */
  108493. static readonly BACKSIDE: number;
  108494. /**
  108495. * Mesh side orientation : both internal and external or front and back surfaces
  108496. */
  108497. static readonly DOUBLESIDE: number;
  108498. /**
  108499. * Mesh side orientation : by default, `FRONTSIDE`
  108500. */
  108501. static readonly DEFAULTSIDE: number;
  108502. /**
  108503. * Mesh cap setting : no cap
  108504. */
  108505. static readonly NO_CAP: number;
  108506. /**
  108507. * Mesh cap setting : one cap at the beginning of the mesh
  108508. */
  108509. static readonly CAP_START: number;
  108510. /**
  108511. * Mesh cap setting : one cap at the end of the mesh
  108512. */
  108513. static readonly CAP_END: number;
  108514. /**
  108515. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108516. */
  108517. static readonly CAP_ALL: number;
  108518. /**
  108519. * Mesh pattern setting : no flip or rotate
  108520. */
  108521. static readonly NO_FLIP: number;
  108522. /**
  108523. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108524. */
  108525. static readonly FLIP_TILE: number;
  108526. /**
  108527. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108528. */
  108529. static readonly ROTATE_TILE: number;
  108530. /**
  108531. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108532. */
  108533. static readonly FLIP_ROW: number;
  108534. /**
  108535. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108536. */
  108537. static readonly ROTATE_ROW: number;
  108538. /**
  108539. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108540. */
  108541. static readonly FLIP_N_ROTATE_TILE: number;
  108542. /**
  108543. * Mesh pattern setting : rotate pattern and rotate
  108544. */
  108545. static readonly FLIP_N_ROTATE_ROW: number;
  108546. /**
  108547. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108548. */
  108549. static readonly CENTER: number;
  108550. /**
  108551. * Mesh tile positioning : part tiles on left
  108552. */
  108553. static readonly LEFT: number;
  108554. /**
  108555. * Mesh tile positioning : part tiles on right
  108556. */
  108557. static readonly RIGHT: number;
  108558. /**
  108559. * Mesh tile positioning : part tiles on top
  108560. */
  108561. static readonly TOP: number;
  108562. /**
  108563. * Mesh tile positioning : part tiles on bottom
  108564. */
  108565. static readonly BOTTOM: number;
  108566. /**
  108567. * Gets the default side orientation.
  108568. * @param orientation the orientation to value to attempt to get
  108569. * @returns the default orientation
  108570. * @hidden
  108571. */
  108572. static _GetDefaultSideOrientation(orientation?: number): number;
  108573. private _internalMeshDataInfo;
  108574. get computeBonesUsingShaders(): boolean;
  108575. set computeBonesUsingShaders(value: boolean);
  108576. /**
  108577. * An event triggered before rendering the mesh
  108578. */
  108579. get onBeforeRenderObservable(): Observable<Mesh>;
  108580. /**
  108581. * An event triggered before binding the mesh
  108582. */
  108583. get onBeforeBindObservable(): Observable<Mesh>;
  108584. /**
  108585. * An event triggered after rendering the mesh
  108586. */
  108587. get onAfterRenderObservable(): Observable<Mesh>;
  108588. /**
  108589. * An event triggered before drawing the mesh
  108590. */
  108591. get onBeforeDrawObservable(): Observable<Mesh>;
  108592. private _onBeforeDrawObserver;
  108593. /**
  108594. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108595. */
  108596. set onBeforeDraw(callback: () => void);
  108597. get hasInstances(): boolean;
  108598. get hasThinInstances(): boolean;
  108599. /**
  108600. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108601. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108602. */
  108603. delayLoadState: number;
  108604. /**
  108605. * Gets the list of instances created from this mesh
  108606. * it is not supposed to be modified manually.
  108607. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108608. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108609. */
  108610. instances: InstancedMesh[];
  108611. /**
  108612. * Gets the file containing delay loading data for this mesh
  108613. */
  108614. delayLoadingFile: string;
  108615. /** @hidden */
  108616. _binaryInfo: any;
  108617. /**
  108618. * User defined function used to change how LOD level selection is done
  108619. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108620. */
  108621. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108622. /**
  108623. * Gets or sets the morph target manager
  108624. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108625. */
  108626. get morphTargetManager(): Nullable<MorphTargetManager>;
  108627. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108628. /** @hidden */
  108629. _creationDataStorage: Nullable<_CreationDataStorage>;
  108630. /** @hidden */
  108631. _geometry: Nullable<Geometry>;
  108632. /** @hidden */
  108633. _delayInfo: Array<string>;
  108634. /** @hidden */
  108635. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108636. /** @hidden */
  108637. _instanceDataStorage: _InstanceDataStorage;
  108638. /** @hidden */
  108639. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108640. private _effectiveMaterial;
  108641. /** @hidden */
  108642. _shouldGenerateFlatShading: boolean;
  108643. /** @hidden */
  108644. _originalBuilderSideOrientation: number;
  108645. /**
  108646. * Use this property to change the original side orientation defined at construction time
  108647. */
  108648. overrideMaterialSideOrientation: Nullable<number>;
  108649. /**
  108650. * Gets the source mesh (the one used to clone this one from)
  108651. */
  108652. get source(): Nullable<Mesh>;
  108653. /**
  108654. * Gets the list of clones of this mesh
  108655. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108656. * Note that useClonedMeshMap=true is the default setting
  108657. */
  108658. get cloneMeshMap(): Nullable<{
  108659. [id: string]: Mesh | undefined;
  108660. }>;
  108661. /**
  108662. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108663. */
  108664. get isUnIndexed(): boolean;
  108665. set isUnIndexed(value: boolean);
  108666. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108667. get worldMatrixInstancedBuffer(): Float32Array;
  108668. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108669. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108670. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108671. /**
  108672. * @constructor
  108673. * @param name The value used by scene.getMeshByName() to do a lookup.
  108674. * @param scene The scene to add this mesh to.
  108675. * @param parent The parent of this mesh, if it has one
  108676. * @param source An optional Mesh from which geometry is shared, cloned.
  108677. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108678. * When false, achieved by calling a clone(), also passing False.
  108679. * This will make creation of children, recursive.
  108680. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108681. */
  108682. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108683. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108684. doNotInstantiate: boolean;
  108685. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108686. /**
  108687. * Gets the class name
  108688. * @returns the string "Mesh".
  108689. */
  108690. getClassName(): string;
  108691. /** @hidden */
  108692. get _isMesh(): boolean;
  108693. /**
  108694. * Returns a description of this mesh
  108695. * @param fullDetails define if full details about this mesh must be used
  108696. * @returns a descriptive string representing this mesh
  108697. */
  108698. toString(fullDetails?: boolean): string;
  108699. /** @hidden */
  108700. _unBindEffect(): void;
  108701. /**
  108702. * Gets a boolean indicating if this mesh has LOD
  108703. */
  108704. get hasLODLevels(): boolean;
  108705. /**
  108706. * Gets the list of MeshLODLevel associated with the current mesh
  108707. * @returns an array of MeshLODLevel
  108708. */
  108709. getLODLevels(): MeshLODLevel[];
  108710. private _sortLODLevels;
  108711. /**
  108712. * Add a mesh as LOD level triggered at the given distance.
  108713. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108714. * @param distance The distance from the center of the object to show this level
  108715. * @param mesh The mesh to be added as LOD level (can be null)
  108716. * @return This mesh (for chaining)
  108717. */
  108718. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108719. /**
  108720. * Returns the LOD level mesh at the passed distance or null if not found.
  108721. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108722. * @param distance The distance from the center of the object to show this level
  108723. * @returns a Mesh or `null`
  108724. */
  108725. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108726. /**
  108727. * Remove a mesh from the LOD array
  108728. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108729. * @param mesh defines the mesh to be removed
  108730. * @return This mesh (for chaining)
  108731. */
  108732. removeLODLevel(mesh: Mesh): Mesh;
  108733. /**
  108734. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108735. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108736. * @param camera defines the camera to use to compute distance
  108737. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108738. * @return This mesh (for chaining)
  108739. */
  108740. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108741. /**
  108742. * Gets the mesh internal Geometry object
  108743. */
  108744. get geometry(): Nullable<Geometry>;
  108745. /**
  108746. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108747. * @returns the total number of vertices
  108748. */
  108749. getTotalVertices(): number;
  108750. /**
  108751. * Returns the content of an associated vertex buffer
  108752. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108753. * - VertexBuffer.PositionKind
  108754. * - VertexBuffer.UVKind
  108755. * - VertexBuffer.UV2Kind
  108756. * - VertexBuffer.UV3Kind
  108757. * - VertexBuffer.UV4Kind
  108758. * - VertexBuffer.UV5Kind
  108759. * - VertexBuffer.UV6Kind
  108760. * - VertexBuffer.ColorKind
  108761. * - VertexBuffer.MatricesIndicesKind
  108762. * - VertexBuffer.MatricesIndicesExtraKind
  108763. * - VertexBuffer.MatricesWeightsKind
  108764. * - VertexBuffer.MatricesWeightsExtraKind
  108765. * @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
  108766. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108767. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108768. */
  108769. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108770. /**
  108771. * Returns the mesh VertexBuffer object from the requested `kind`
  108772. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108773. * - VertexBuffer.PositionKind
  108774. * - VertexBuffer.NormalKind
  108775. * - VertexBuffer.UVKind
  108776. * - VertexBuffer.UV2Kind
  108777. * - VertexBuffer.UV3Kind
  108778. * - VertexBuffer.UV4Kind
  108779. * - VertexBuffer.UV5Kind
  108780. * - VertexBuffer.UV6Kind
  108781. * - VertexBuffer.ColorKind
  108782. * - VertexBuffer.MatricesIndicesKind
  108783. * - VertexBuffer.MatricesIndicesExtraKind
  108784. * - VertexBuffer.MatricesWeightsKind
  108785. * - VertexBuffer.MatricesWeightsExtraKind
  108786. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108787. */
  108788. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108789. /**
  108790. * Tests if a specific vertex buffer is associated with this mesh
  108791. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108792. * - VertexBuffer.PositionKind
  108793. * - VertexBuffer.NormalKind
  108794. * - VertexBuffer.UVKind
  108795. * - VertexBuffer.UV2Kind
  108796. * - VertexBuffer.UV3Kind
  108797. * - VertexBuffer.UV4Kind
  108798. * - VertexBuffer.UV5Kind
  108799. * - VertexBuffer.UV6Kind
  108800. * - VertexBuffer.ColorKind
  108801. * - VertexBuffer.MatricesIndicesKind
  108802. * - VertexBuffer.MatricesIndicesExtraKind
  108803. * - VertexBuffer.MatricesWeightsKind
  108804. * - VertexBuffer.MatricesWeightsExtraKind
  108805. * @returns a boolean
  108806. */
  108807. isVerticesDataPresent(kind: string): boolean;
  108808. /**
  108809. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108810. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108811. * - VertexBuffer.PositionKind
  108812. * - VertexBuffer.UVKind
  108813. * - VertexBuffer.UV2Kind
  108814. * - VertexBuffer.UV3Kind
  108815. * - VertexBuffer.UV4Kind
  108816. * - VertexBuffer.UV5Kind
  108817. * - VertexBuffer.UV6Kind
  108818. * - VertexBuffer.ColorKind
  108819. * - VertexBuffer.MatricesIndicesKind
  108820. * - VertexBuffer.MatricesIndicesExtraKind
  108821. * - VertexBuffer.MatricesWeightsKind
  108822. * - VertexBuffer.MatricesWeightsExtraKind
  108823. * @returns a boolean
  108824. */
  108825. isVertexBufferUpdatable(kind: string): boolean;
  108826. /**
  108827. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108828. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108829. * - VertexBuffer.PositionKind
  108830. * - VertexBuffer.NormalKind
  108831. * - VertexBuffer.UVKind
  108832. * - VertexBuffer.UV2Kind
  108833. * - VertexBuffer.UV3Kind
  108834. * - VertexBuffer.UV4Kind
  108835. * - VertexBuffer.UV5Kind
  108836. * - VertexBuffer.UV6Kind
  108837. * - VertexBuffer.ColorKind
  108838. * - VertexBuffer.MatricesIndicesKind
  108839. * - VertexBuffer.MatricesIndicesExtraKind
  108840. * - VertexBuffer.MatricesWeightsKind
  108841. * - VertexBuffer.MatricesWeightsExtraKind
  108842. * @returns an array of strings
  108843. */
  108844. getVerticesDataKinds(): string[];
  108845. /**
  108846. * Returns a positive integer : the total number of indices in this mesh geometry.
  108847. * @returns the numner of indices or zero if the mesh has no geometry.
  108848. */
  108849. getTotalIndices(): number;
  108850. /**
  108851. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108852. * @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.
  108853. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108854. * @returns the indices array or an empty array if the mesh has no geometry
  108855. */
  108856. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108857. get isBlocked(): boolean;
  108858. /**
  108859. * Determine if the current mesh is ready to be rendered
  108860. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108861. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108862. * @returns true if all associated assets are ready (material, textures, shaders)
  108863. */
  108864. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108865. /**
  108866. * 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.
  108867. */
  108868. get areNormalsFrozen(): boolean;
  108869. /**
  108870. * 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.
  108871. * @returns the current mesh
  108872. */
  108873. freezeNormals(): Mesh;
  108874. /**
  108875. * 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
  108876. * @returns the current mesh
  108877. */
  108878. unfreezeNormals(): Mesh;
  108879. /**
  108880. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108881. */
  108882. set overridenInstanceCount(count: number);
  108883. /** @hidden */
  108884. _preActivate(): Mesh;
  108885. /** @hidden */
  108886. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108887. /** @hidden */
  108888. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108889. protected _afterComputeWorldMatrix(): void;
  108890. /** @hidden */
  108891. _postActivate(): void;
  108892. /**
  108893. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108894. * This means the mesh underlying bounding box and sphere are recomputed.
  108895. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108896. * @returns the current mesh
  108897. */
  108898. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108899. /** @hidden */
  108900. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108901. /**
  108902. * This function will subdivide the mesh into multiple submeshes
  108903. * @param count defines the expected number of submeshes
  108904. */
  108905. subdivide(count: number): void;
  108906. /**
  108907. * Copy a FloatArray into a specific associated vertex buffer
  108908. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108909. * - VertexBuffer.PositionKind
  108910. * - VertexBuffer.UVKind
  108911. * - VertexBuffer.UV2Kind
  108912. * - VertexBuffer.UV3Kind
  108913. * - VertexBuffer.UV4Kind
  108914. * - VertexBuffer.UV5Kind
  108915. * - VertexBuffer.UV6Kind
  108916. * - VertexBuffer.ColorKind
  108917. * - VertexBuffer.MatricesIndicesKind
  108918. * - VertexBuffer.MatricesIndicesExtraKind
  108919. * - VertexBuffer.MatricesWeightsKind
  108920. * - VertexBuffer.MatricesWeightsExtraKind
  108921. * @param data defines the data source
  108922. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108923. * @param stride defines the data stride size (can be null)
  108924. * @returns the current mesh
  108925. */
  108926. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108927. /**
  108928. * Delete a vertex buffer associated with this mesh
  108929. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108930. * - VertexBuffer.PositionKind
  108931. * - VertexBuffer.UVKind
  108932. * - VertexBuffer.UV2Kind
  108933. * - VertexBuffer.UV3Kind
  108934. * - VertexBuffer.UV4Kind
  108935. * - VertexBuffer.UV5Kind
  108936. * - VertexBuffer.UV6Kind
  108937. * - VertexBuffer.ColorKind
  108938. * - VertexBuffer.MatricesIndicesKind
  108939. * - VertexBuffer.MatricesIndicesExtraKind
  108940. * - VertexBuffer.MatricesWeightsKind
  108941. * - VertexBuffer.MatricesWeightsExtraKind
  108942. */
  108943. removeVerticesData(kind: string): void;
  108944. /**
  108945. * Flags an associated vertex buffer as updatable
  108946. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108947. * - VertexBuffer.PositionKind
  108948. * - VertexBuffer.UVKind
  108949. * - VertexBuffer.UV2Kind
  108950. * - VertexBuffer.UV3Kind
  108951. * - VertexBuffer.UV4Kind
  108952. * - VertexBuffer.UV5Kind
  108953. * - VertexBuffer.UV6Kind
  108954. * - VertexBuffer.ColorKind
  108955. * - VertexBuffer.MatricesIndicesKind
  108956. * - VertexBuffer.MatricesIndicesExtraKind
  108957. * - VertexBuffer.MatricesWeightsKind
  108958. * - VertexBuffer.MatricesWeightsExtraKind
  108959. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108960. */
  108961. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108962. /**
  108963. * Sets the mesh global Vertex Buffer
  108964. * @param buffer defines the buffer to use
  108965. * @returns the current mesh
  108966. */
  108967. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108968. /**
  108969. * Update a specific associated vertex buffer
  108970. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108971. * - VertexBuffer.PositionKind
  108972. * - VertexBuffer.UVKind
  108973. * - VertexBuffer.UV2Kind
  108974. * - VertexBuffer.UV3Kind
  108975. * - VertexBuffer.UV4Kind
  108976. * - VertexBuffer.UV5Kind
  108977. * - VertexBuffer.UV6Kind
  108978. * - VertexBuffer.ColorKind
  108979. * - VertexBuffer.MatricesIndicesKind
  108980. * - VertexBuffer.MatricesIndicesExtraKind
  108981. * - VertexBuffer.MatricesWeightsKind
  108982. * - VertexBuffer.MatricesWeightsExtraKind
  108983. * @param data defines the data source
  108984. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108985. * @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)
  108986. * @returns the current mesh
  108987. */
  108988. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108989. /**
  108990. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108991. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108992. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108993. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108994. * @returns the current mesh
  108995. */
  108996. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108997. /**
  108998. * Creates a un-shared specific occurence of the geometry for the mesh.
  108999. * @returns the current mesh
  109000. */
  109001. makeGeometryUnique(): Mesh;
  109002. /**
  109003. * Set the index buffer of this mesh
  109004. * @param indices defines the source data
  109005. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  109006. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  109007. * @returns the current mesh
  109008. */
  109009. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  109010. /**
  109011. * Update the current index buffer
  109012. * @param indices defines the source data
  109013. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109014. * @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)
  109015. * @returns the current mesh
  109016. */
  109017. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109018. /**
  109019. * Invert the geometry to move from a right handed system to a left handed one.
  109020. * @returns the current mesh
  109021. */
  109022. toLeftHanded(): Mesh;
  109023. /** @hidden */
  109024. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109025. /** @hidden */
  109026. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109027. /**
  109028. * Registers for this mesh a javascript function called just before the rendering process
  109029. * @param func defines the function to call before rendering this mesh
  109030. * @returns the current mesh
  109031. */
  109032. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109033. /**
  109034. * Disposes a previously registered javascript function called before the rendering
  109035. * @param func defines the function to remove
  109036. * @returns the current mesh
  109037. */
  109038. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109039. /**
  109040. * Registers for this mesh a javascript function called just after the rendering is complete
  109041. * @param func defines the function to call after rendering this mesh
  109042. * @returns the current mesh
  109043. */
  109044. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109045. /**
  109046. * Disposes a previously registered javascript function called after the rendering.
  109047. * @param func defines the function to remove
  109048. * @returns the current mesh
  109049. */
  109050. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109051. /** @hidden */
  109052. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  109053. /** @hidden */
  109054. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  109055. /** @hidden */
  109056. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  109057. /** @hidden */
  109058. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  109059. /** @hidden */
  109060. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  109061. /** @hidden */
  109062. _rebuild(): void;
  109063. /** @hidden */
  109064. _freeze(): void;
  109065. /** @hidden */
  109066. _unFreeze(): void;
  109067. /**
  109068. * 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
  109069. * @param subMesh defines the subMesh to render
  109070. * @param enableAlphaMode defines if alpha mode can be changed
  109071. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  109072. * @returns the current mesh
  109073. */
  109074. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  109075. private _onBeforeDraw;
  109076. /**
  109077. * Renormalize the mesh and patch it up if there are no weights
  109078. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  109079. * However in the case of zero weights then we set just a single influence to 1.
  109080. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  109081. */
  109082. cleanMatrixWeights(): void;
  109083. private normalizeSkinFourWeights;
  109084. private normalizeSkinWeightsAndExtra;
  109085. /**
  109086. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  109087. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  109088. * the user know there was an issue with importing the mesh
  109089. * @returns a validation object with skinned, valid and report string
  109090. */
  109091. validateSkinning(): {
  109092. skinned: boolean;
  109093. valid: boolean;
  109094. report: string;
  109095. };
  109096. /** @hidden */
  109097. _checkDelayState(): Mesh;
  109098. private _queueLoad;
  109099. /**
  109100. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109101. * A mesh is in the frustum if its bounding box intersects the frustum
  109102. * @param frustumPlanes defines the frustum to test
  109103. * @returns true if the mesh is in the frustum planes
  109104. */
  109105. isInFrustum(frustumPlanes: Plane[]): boolean;
  109106. /**
  109107. * Sets the mesh material by the material or multiMaterial `id` property
  109108. * @param id is a string identifying the material or the multiMaterial
  109109. * @returns the current mesh
  109110. */
  109111. setMaterialByID(id: string): Mesh;
  109112. /**
  109113. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  109114. * @returns an array of IAnimatable
  109115. */
  109116. getAnimatables(): IAnimatable[];
  109117. /**
  109118. * Modifies the mesh geometry according to the passed transformation matrix.
  109119. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  109120. * The mesh normals are modified using the same transformation.
  109121. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109122. * @param transform defines the transform matrix to use
  109123. * @see https://doc.babylonjs.com/resources/baking_transformations
  109124. * @returns the current mesh
  109125. */
  109126. bakeTransformIntoVertices(transform: Matrix): Mesh;
  109127. /**
  109128. * Modifies the mesh geometry according to its own current World Matrix.
  109129. * The mesh World Matrix is then reset.
  109130. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  109131. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109132. * @see https://doc.babylonjs.com/resources/baking_transformations
  109133. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  109134. * @returns the current mesh
  109135. */
  109136. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  109137. /** @hidden */
  109138. get _positions(): Nullable<Vector3[]>;
  109139. /** @hidden */
  109140. _resetPointsArrayCache(): Mesh;
  109141. /** @hidden */
  109142. _generatePointsArray(): boolean;
  109143. /**
  109144. * Returns a new Mesh object generated from the current mesh properties.
  109145. * This method must not get confused with createInstance()
  109146. * @param name is a string, the name given to the new mesh
  109147. * @param newParent can be any Node object (default `null`)
  109148. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  109149. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  109150. * @returns a new mesh
  109151. */
  109152. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  109153. /**
  109154. * Releases resources associated with this mesh.
  109155. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109156. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109157. */
  109158. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109159. /** @hidden */
  109160. _disposeInstanceSpecificData(): void;
  109161. /** @hidden */
  109162. _disposeThinInstanceSpecificData(): void;
  109163. /**
  109164. * Modifies the mesh geometry according to a displacement map.
  109165. * 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.
  109166. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109167. * @param url is a string, the URL from the image file is to be downloaded.
  109168. * @param minHeight is the lower limit of the displacement.
  109169. * @param maxHeight is the upper limit of the displacement.
  109170. * @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.
  109171. * @param uvOffset is an optional vector2 used to offset UV.
  109172. * @param uvScale is an optional vector2 used to scale UV.
  109173. * @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.
  109174. * @returns the Mesh.
  109175. */
  109176. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109177. /**
  109178. * Modifies the mesh geometry according to a displacementMap buffer.
  109179. * 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.
  109180. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109181. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  109182. * @param heightMapWidth is the width of the buffer image.
  109183. * @param heightMapHeight is the height of the buffer image.
  109184. * @param minHeight is the lower limit of the displacement.
  109185. * @param maxHeight is the upper limit of the displacement.
  109186. * @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.
  109187. * @param uvOffset is an optional vector2 used to offset UV.
  109188. * @param uvScale is an optional vector2 used to scale UV.
  109189. * @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.
  109190. * @returns the Mesh.
  109191. */
  109192. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109193. /**
  109194. * Modify the mesh to get a flat shading rendering.
  109195. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  109196. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  109197. * @returns current mesh
  109198. */
  109199. convertToFlatShadedMesh(): Mesh;
  109200. /**
  109201. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  109202. * In other words, more vertices, no more indices and a single bigger VBO.
  109203. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  109204. * @returns current mesh
  109205. */
  109206. convertToUnIndexedMesh(): Mesh;
  109207. /**
  109208. * Inverses facet orientations.
  109209. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109210. * @param flipNormals will also inverts the normals
  109211. * @returns current mesh
  109212. */
  109213. flipFaces(flipNormals?: boolean): Mesh;
  109214. /**
  109215. * Increase the number of facets and hence vertices in a mesh
  109216. * Vertex normals are interpolated from existing vertex normals
  109217. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109218. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  109219. */
  109220. increaseVertices(numberPerEdge: number): void;
  109221. /**
  109222. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  109223. * This will undo any application of covertToFlatShadedMesh
  109224. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109225. */
  109226. forceSharedVertices(): void;
  109227. /** @hidden */
  109228. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  109229. /** @hidden */
  109230. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  109231. /**
  109232. * Creates a new InstancedMesh object from the mesh model.
  109233. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109234. * @param name defines the name of the new instance
  109235. * @returns a new InstancedMesh
  109236. */
  109237. createInstance(name: string): InstancedMesh;
  109238. /**
  109239. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  109240. * After this call, all the mesh instances have the same submeshes than the current mesh.
  109241. * @returns the current mesh
  109242. */
  109243. synchronizeInstances(): Mesh;
  109244. /**
  109245. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  109246. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  109247. * This should be used together with the simplification to avoid disappearing triangles.
  109248. * @param successCallback an optional success callback to be called after the optimization finished.
  109249. * @returns the current mesh
  109250. */
  109251. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  109252. /**
  109253. * Serialize current mesh
  109254. * @param serializationObject defines the object which will receive the serialization data
  109255. */
  109256. serialize(serializationObject: any): void;
  109257. /** @hidden */
  109258. _syncGeometryWithMorphTargetManager(): void;
  109259. /** @hidden */
  109260. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  109261. /**
  109262. * Returns a new Mesh object parsed from the source provided.
  109263. * @param parsedMesh is the source
  109264. * @param scene defines the hosting scene
  109265. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  109266. * @returns a new Mesh
  109267. */
  109268. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  109269. /**
  109270. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  109271. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109272. * @param name defines the name of the mesh to create
  109273. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  109274. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  109275. * @param closePath creates a seam between the first and the last points of each path of the path array
  109276. * @param offset is taken in account only if the `pathArray` is containing a single path
  109277. * @param scene defines the hosting scene
  109278. * @param updatable defines if the mesh must be flagged as updatable
  109279. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109280. * @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)
  109281. * @returns a new Mesh
  109282. */
  109283. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109284. /**
  109285. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  109286. * @param name defines the name of the mesh to create
  109287. * @param radius sets the radius size (float) of the polygon (default 0.5)
  109288. * @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
  109289. * @param scene defines the hosting scene
  109290. * @param updatable defines if the mesh must be flagged as updatable
  109291. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109292. * @returns a new Mesh
  109293. */
  109294. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109295. /**
  109296. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  109297. * @param name defines the name of the mesh to create
  109298. * @param size sets the size (float) of each box side (default 1)
  109299. * @param scene defines the hosting scene
  109300. * @param updatable defines if the mesh must be flagged as updatable
  109301. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109302. * @returns a new Mesh
  109303. */
  109304. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109305. /**
  109306. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  109307. * @param name defines the name of the mesh to create
  109308. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109309. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109310. * @param scene defines the hosting scene
  109311. * @param updatable defines if the mesh must be flagged as updatable
  109312. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109313. * @returns a new Mesh
  109314. */
  109315. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109316. /**
  109317. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  109318. * @param name defines the name of the mesh to create
  109319. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109320. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109321. * @param scene defines the hosting scene
  109322. * @returns a new Mesh
  109323. */
  109324. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  109325. /**
  109326. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  109327. * @param name defines the name of the mesh to create
  109328. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  109329. * @param diameterTop set the top cap diameter (floats, default 1)
  109330. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  109331. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  109332. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  109333. * @param scene defines the hosting scene
  109334. * @param updatable defines if the mesh must be flagged as updatable
  109335. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109336. * @returns a new Mesh
  109337. */
  109338. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  109339. /**
  109340. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  109341. * @param name defines the name of the mesh to create
  109342. * @param diameter sets the diameter size (float) of the torus (default 1)
  109343. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  109344. * @param tessellation sets the number of torus sides (postive integer, default 16)
  109345. * @param scene defines the hosting scene
  109346. * @param updatable defines if the mesh must be flagged as updatable
  109347. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109348. * @returns a new Mesh
  109349. */
  109350. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109351. /**
  109352. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  109353. * @param name defines the name of the mesh to create
  109354. * @param radius sets the global radius size (float) of the torus knot (default 2)
  109355. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  109356. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  109357. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  109358. * @param p the number of windings on X axis (positive integers, default 2)
  109359. * @param q the number of windings on Y axis (positive integers, default 3)
  109360. * @param scene defines the hosting scene
  109361. * @param updatable defines if the mesh must be flagged as updatable
  109362. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109363. * @returns a new Mesh
  109364. */
  109365. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109366. /**
  109367. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  109368. * @param name defines the name of the mesh to create
  109369. * @param points is an array successive Vector3
  109370. * @param scene defines the hosting scene
  109371. * @param updatable defines if the mesh must be flagged as updatable
  109372. * @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).
  109373. * @returns a new Mesh
  109374. */
  109375. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  109376. /**
  109377. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  109378. * @param name defines the name of the mesh to create
  109379. * @param points is an array successive Vector3
  109380. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  109381. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109382. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  109383. * @param scene defines the hosting scene
  109384. * @param updatable defines if the mesh must be flagged as updatable
  109385. * @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)
  109386. * @returns a new Mesh
  109387. */
  109388. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  109389. /**
  109390. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  109391. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  109392. * 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.
  109393. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109394. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109395. * Remember you can only change the shape positions, not their number when updating a polygon.
  109396. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109397. * @param name defines the name of the mesh to create
  109398. * @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
  109399. * @param scene defines the hosting scene
  109400. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109401. * @param updatable defines if the mesh must be flagged as updatable
  109402. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109403. * @param earcutInjection can be used to inject your own earcut reference
  109404. * @returns a new Mesh
  109405. */
  109406. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109407. /**
  109408. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  109409. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  109410. * @param name defines the name of the mesh to create
  109411. * @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
  109412. * @param depth defines the height of extrusion
  109413. * @param scene defines the hosting scene
  109414. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109415. * @param updatable defines if the mesh must be flagged as updatable
  109416. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109417. * @param earcutInjection can be used to inject your own earcut reference
  109418. * @returns a new Mesh
  109419. */
  109420. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109421. /**
  109422. * Creates an extruded shape mesh.
  109423. * 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
  109424. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109426. * @param name defines the name of the mesh to create
  109427. * @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
  109428. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109429. * @param scale is the value to scale the shape
  109430. * @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
  109431. * @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
  109432. * @param scene defines the hosting scene
  109433. * @param updatable defines if the mesh must be flagged as updatable
  109434. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109435. * @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)
  109436. * @returns a new Mesh
  109437. */
  109438. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109439. /**
  109440. * Creates an custom extruded shape mesh.
  109441. * The custom extrusion is a parametric shape.
  109442. * It has no predefined shape. Its final shape will depend on the input parameters.
  109443. * Please consider using the same method from the MeshBuilder class instead
  109444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109445. * @param name defines the name of the mesh to create
  109446. * @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
  109447. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109448. * @param scaleFunction is a custom Javascript function called on each path point
  109449. * @param rotationFunction is a custom Javascript function called on each path point
  109450. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109451. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  109452. * @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
  109453. * @param scene defines the hosting scene
  109454. * @param updatable defines if the mesh must be flagged as updatable
  109455. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109456. * @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)
  109457. * @returns a new Mesh
  109458. */
  109459. 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;
  109460. /**
  109461. * Creates lathe mesh.
  109462. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109463. * Please consider using the same method from the MeshBuilder class instead
  109464. * @param name defines the name of the mesh to create
  109465. * @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
  109466. * @param radius is the radius value of the lathe
  109467. * @param tessellation is the side number of the lathe.
  109468. * @param scene defines the hosting scene
  109469. * @param updatable defines if the mesh must be flagged as updatable
  109470. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109471. * @returns a new Mesh
  109472. */
  109473. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109474. /**
  109475. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109476. * @param name defines the name of the mesh to create
  109477. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109478. * @param scene defines the hosting scene
  109479. * @param updatable defines if the mesh must be flagged as updatable
  109480. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109481. * @returns a new Mesh
  109482. */
  109483. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109484. /**
  109485. * Creates a ground mesh.
  109486. * Please consider using the same method from the MeshBuilder class instead
  109487. * @param name defines the name of the mesh to create
  109488. * @param width set the width of the ground
  109489. * @param height set the height of the ground
  109490. * @param subdivisions sets the number of subdivisions per side
  109491. * @param scene defines the hosting scene
  109492. * @param updatable defines if the mesh must be flagged as updatable
  109493. * @returns a new Mesh
  109494. */
  109495. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109496. /**
  109497. * Creates a tiled ground mesh.
  109498. * Please consider using the same method from the MeshBuilder class instead
  109499. * @param name defines the name of the mesh to create
  109500. * @param xmin set the ground minimum X coordinate
  109501. * @param zmin set the ground minimum Y coordinate
  109502. * @param xmax set the ground maximum X coordinate
  109503. * @param zmax set the ground maximum Z coordinate
  109504. * @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
  109505. * @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
  109506. * @param scene defines the hosting scene
  109507. * @param updatable defines if the mesh must be flagged as updatable
  109508. * @returns a new Mesh
  109509. */
  109510. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109511. w: number;
  109512. h: number;
  109513. }, precision: {
  109514. w: number;
  109515. h: number;
  109516. }, scene: Scene, updatable?: boolean): Mesh;
  109517. /**
  109518. * Creates a ground mesh from a height map.
  109519. * Please consider using the same method from the MeshBuilder class instead
  109520. * @see https://doc.babylonjs.com/babylon101/height_map
  109521. * @param name defines the name of the mesh to create
  109522. * @param url sets the URL of the height map image resource
  109523. * @param width set the ground width size
  109524. * @param height set the ground height size
  109525. * @param subdivisions sets the number of subdivision per side
  109526. * @param minHeight is the minimum altitude on the ground
  109527. * @param maxHeight is the maximum altitude on the ground
  109528. * @param scene defines the hosting scene
  109529. * @param updatable defines if the mesh must be flagged as updatable
  109530. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109531. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109532. * @returns a new Mesh
  109533. */
  109534. 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;
  109535. /**
  109536. * Creates a tube mesh.
  109537. * The tube is a parametric shape.
  109538. * It has no predefined shape. Its final shape will depend on the input parameters.
  109539. * Please consider using the same method from the MeshBuilder class instead
  109540. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109541. * @param name defines the name of the mesh to create
  109542. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109543. * @param radius sets the tube radius size
  109544. * @param tessellation is the number of sides on the tubular surface
  109545. * @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
  109546. * @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
  109547. * @param scene defines the hosting scene
  109548. * @param updatable defines if the mesh must be flagged as updatable
  109549. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109550. * @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)
  109551. * @returns a new Mesh
  109552. */
  109553. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109554. (i: number, distance: number): number;
  109555. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109556. /**
  109557. * Creates a polyhedron mesh.
  109558. * Please consider using the same method from the MeshBuilder class instead.
  109559. * * 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
  109560. * * The parameter `size` (positive float, default 1) sets the polygon size
  109561. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109562. * * 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`
  109563. * * 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
  109564. * * 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)`)
  109565. * * 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
  109566. * * 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
  109567. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109570. * @param name defines the name of the mesh to create
  109571. * @param options defines the options used to create the mesh
  109572. * @param scene defines the hosting scene
  109573. * @returns a new Mesh
  109574. */
  109575. static CreatePolyhedron(name: string, options: {
  109576. type?: number;
  109577. size?: number;
  109578. sizeX?: number;
  109579. sizeY?: number;
  109580. sizeZ?: number;
  109581. custom?: any;
  109582. faceUV?: Vector4[];
  109583. faceColors?: Color4[];
  109584. updatable?: boolean;
  109585. sideOrientation?: number;
  109586. }, scene: Scene): Mesh;
  109587. /**
  109588. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109589. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109590. * * 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`)
  109591. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109592. * * 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
  109593. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109596. * @param name defines the name of the mesh
  109597. * @param options defines the options used to create the mesh
  109598. * @param scene defines the hosting scene
  109599. * @returns a new Mesh
  109600. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109601. */
  109602. static CreateIcoSphere(name: string, options: {
  109603. radius?: number;
  109604. flat?: boolean;
  109605. subdivisions?: number;
  109606. sideOrientation?: number;
  109607. updatable?: boolean;
  109608. }, scene: Scene): Mesh;
  109609. /**
  109610. * Creates a decal mesh.
  109611. * Please consider using the same method from the MeshBuilder class instead.
  109612. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109613. * @param name defines the name of the mesh
  109614. * @param sourceMesh defines the mesh receiving the decal
  109615. * @param position sets the position of the decal in world coordinates
  109616. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109617. * @param size sets the decal scaling
  109618. * @param angle sets the angle to rotate the decal
  109619. * @returns a new Mesh
  109620. */
  109621. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109622. /** Creates a Capsule Mesh
  109623. * @param name defines the name of the mesh.
  109624. * @param options the constructors options used to shape the mesh.
  109625. * @param scene defines the scene the mesh is scoped to.
  109626. * @returns the capsule mesh
  109627. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109628. */
  109629. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109630. /**
  109631. * Prepare internal position array for software CPU skinning
  109632. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109633. */
  109634. setPositionsForCPUSkinning(): Float32Array;
  109635. /**
  109636. * Prepare internal normal array for software CPU skinning
  109637. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109638. */
  109639. setNormalsForCPUSkinning(): Float32Array;
  109640. /**
  109641. * Updates the vertex buffer by applying transformation from the bones
  109642. * @param skeleton defines the skeleton to apply to current mesh
  109643. * @returns the current mesh
  109644. */
  109645. applySkeleton(skeleton: Skeleton): Mesh;
  109646. /**
  109647. * 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
  109648. * @param meshes defines the list of meshes to scan
  109649. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109650. */
  109651. static MinMax(meshes: AbstractMesh[]): {
  109652. min: Vector3;
  109653. max: Vector3;
  109654. };
  109655. /**
  109656. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109657. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109658. * @returns a vector3
  109659. */
  109660. static Center(meshesOrMinMaxVector: {
  109661. min: Vector3;
  109662. max: Vector3;
  109663. } | AbstractMesh[]): Vector3;
  109664. /**
  109665. * Merge the array of meshes into a single mesh for performance reasons.
  109666. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109667. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109668. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109669. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109670. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109671. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109672. * @returns a new mesh
  109673. */
  109674. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109675. /** @hidden */
  109676. addInstance(instance: InstancedMesh): void;
  109677. /** @hidden */
  109678. removeInstance(instance: InstancedMesh): void;
  109679. }
  109680. }
  109681. declare module BABYLON {
  109682. /**
  109683. * This is the base class of all the camera used in the application.
  109684. * @see https://doc.babylonjs.com/features/cameras
  109685. */
  109686. export class Camera extends Node {
  109687. /** @hidden */
  109688. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109689. /**
  109690. * This is the default projection mode used by the cameras.
  109691. * It helps recreating a feeling of perspective and better appreciate depth.
  109692. * This is the best way to simulate real life cameras.
  109693. */
  109694. static readonly PERSPECTIVE_CAMERA: number;
  109695. /**
  109696. * This helps creating camera with an orthographic mode.
  109697. * 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.
  109698. */
  109699. static readonly ORTHOGRAPHIC_CAMERA: number;
  109700. /**
  109701. * This is the default FOV mode for perspective cameras.
  109702. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109703. */
  109704. static readonly FOVMODE_VERTICAL_FIXED: number;
  109705. /**
  109706. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109707. */
  109708. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109709. /**
  109710. * This specifies ther is no need for a camera rig.
  109711. * Basically only one eye is rendered corresponding to the camera.
  109712. */
  109713. static readonly RIG_MODE_NONE: number;
  109714. /**
  109715. * Simulates a camera Rig with one blue eye and one red eye.
  109716. * This can be use with 3d blue and red glasses.
  109717. */
  109718. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109719. /**
  109720. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109721. */
  109722. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109723. /**
  109724. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109725. */
  109726. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109727. /**
  109728. * Defines that both eyes of the camera will be rendered over under each other.
  109729. */
  109730. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109731. /**
  109732. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109733. */
  109734. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109735. /**
  109736. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109737. */
  109738. static readonly RIG_MODE_VR: number;
  109739. /**
  109740. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109741. */
  109742. static readonly RIG_MODE_WEBVR: number;
  109743. /**
  109744. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109745. */
  109746. static readonly RIG_MODE_CUSTOM: number;
  109747. /**
  109748. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109749. */
  109750. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109751. /**
  109752. * Define the input manager associated with the camera.
  109753. */
  109754. inputs: CameraInputsManager<Camera>;
  109755. /** @hidden */
  109756. _position: Vector3;
  109757. /**
  109758. * Define the current local position of the camera in the scene
  109759. */
  109760. get position(): Vector3;
  109761. set position(newPosition: Vector3);
  109762. protected _upVector: Vector3;
  109763. /**
  109764. * The vector the camera should consider as up.
  109765. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109766. */
  109767. set upVector(vec: Vector3);
  109768. get upVector(): Vector3;
  109769. /**
  109770. * Define the current limit on the left side for an orthographic camera
  109771. * In scene unit
  109772. */
  109773. orthoLeft: Nullable<number>;
  109774. /**
  109775. * Define the current limit on the right side for an orthographic camera
  109776. * In scene unit
  109777. */
  109778. orthoRight: Nullable<number>;
  109779. /**
  109780. * Define the current limit on the bottom side for an orthographic camera
  109781. * In scene unit
  109782. */
  109783. orthoBottom: Nullable<number>;
  109784. /**
  109785. * Define the current limit on the top side for an orthographic camera
  109786. * In scene unit
  109787. */
  109788. orthoTop: Nullable<number>;
  109789. /**
  109790. * Field Of View is set in Radians. (default is 0.8)
  109791. */
  109792. fov: number;
  109793. /**
  109794. * Define the minimum distance the camera can see from.
  109795. * This is important to note that the depth buffer are not infinite and the closer it starts
  109796. * the more your scene might encounter depth fighting issue.
  109797. */
  109798. minZ: number;
  109799. /**
  109800. * Define the maximum distance the camera can see to.
  109801. * This is important to note that the depth buffer are not infinite and the further it end
  109802. * the more your scene might encounter depth fighting issue.
  109803. */
  109804. maxZ: number;
  109805. /**
  109806. * Define the default inertia of the camera.
  109807. * This helps giving a smooth feeling to the camera movement.
  109808. */
  109809. inertia: number;
  109810. /**
  109811. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109812. */
  109813. mode: number;
  109814. /**
  109815. * Define whether the camera is intermediate.
  109816. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109817. */
  109818. isIntermediate: boolean;
  109819. /**
  109820. * Define the viewport of the camera.
  109821. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109822. */
  109823. viewport: Viewport;
  109824. /**
  109825. * Restricts the camera to viewing objects with the same layerMask.
  109826. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109827. */
  109828. layerMask: number;
  109829. /**
  109830. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109831. */
  109832. fovMode: number;
  109833. /**
  109834. * Rig mode of the camera.
  109835. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109836. * This is normally controlled byt the camera themselves as internal use.
  109837. */
  109838. cameraRigMode: number;
  109839. /**
  109840. * Defines the distance between both "eyes" in case of a RIG
  109841. */
  109842. interaxialDistance: number;
  109843. /**
  109844. * Defines if stereoscopic rendering is done side by side or over under.
  109845. */
  109846. isStereoscopicSideBySide: boolean;
  109847. /**
  109848. * 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
  109849. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109850. * else in the scene. (Eg. security camera)
  109851. *
  109852. * 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)
  109853. */
  109854. customRenderTargets: RenderTargetTexture[];
  109855. /**
  109856. * When set, the camera will render to this render target instead of the default canvas
  109857. *
  109858. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109859. */
  109860. outputRenderTarget: Nullable<RenderTargetTexture>;
  109861. /**
  109862. * Observable triggered when the camera view matrix has changed.
  109863. */
  109864. onViewMatrixChangedObservable: Observable<Camera>;
  109865. /**
  109866. * Observable triggered when the camera Projection matrix has changed.
  109867. */
  109868. onProjectionMatrixChangedObservable: Observable<Camera>;
  109869. /**
  109870. * Observable triggered when the inputs have been processed.
  109871. */
  109872. onAfterCheckInputsObservable: Observable<Camera>;
  109873. /**
  109874. * Observable triggered when reset has been called and applied to the camera.
  109875. */
  109876. onRestoreStateObservable: Observable<Camera>;
  109877. /**
  109878. * Is this camera a part of a rig system?
  109879. */
  109880. isRigCamera: boolean;
  109881. /**
  109882. * If isRigCamera set to true this will be set with the parent camera.
  109883. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109884. */
  109885. rigParent?: Camera;
  109886. /** @hidden */
  109887. _cameraRigParams: any;
  109888. /** @hidden */
  109889. _rigCameras: Camera[];
  109890. /** @hidden */
  109891. _rigPostProcess: Nullable<PostProcess>;
  109892. protected _webvrViewMatrix: Matrix;
  109893. /** @hidden */
  109894. _skipRendering: boolean;
  109895. /** @hidden */
  109896. _projectionMatrix: Matrix;
  109897. /** @hidden */
  109898. _postProcesses: Nullable<PostProcess>[];
  109899. /** @hidden */
  109900. _activeMeshes: SmartArray<AbstractMesh>;
  109901. protected _globalPosition: Vector3;
  109902. /** @hidden */
  109903. _computedViewMatrix: Matrix;
  109904. private _doNotComputeProjectionMatrix;
  109905. private _transformMatrix;
  109906. private _frustumPlanes;
  109907. private _refreshFrustumPlanes;
  109908. private _storedFov;
  109909. private _stateStored;
  109910. /**
  109911. * Instantiates a new camera object.
  109912. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109913. * @see https://doc.babylonjs.com/features/cameras
  109914. * @param name Defines the name of the camera in the scene
  109915. * @param position Defines the position of the camera
  109916. * @param scene Defines the scene the camera belongs too
  109917. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109918. */
  109919. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109920. /**
  109921. * Store current camera state (fov, position, etc..)
  109922. * @returns the camera
  109923. */
  109924. storeState(): Camera;
  109925. /**
  109926. * Restores the camera state values if it has been stored. You must call storeState() first
  109927. */
  109928. protected _restoreStateValues(): boolean;
  109929. /**
  109930. * Restored camera state. You must call storeState() first.
  109931. * @returns true if restored and false otherwise
  109932. */
  109933. restoreState(): boolean;
  109934. /**
  109935. * Gets the class name of the camera.
  109936. * @returns the class name
  109937. */
  109938. getClassName(): string;
  109939. /** @hidden */
  109940. readonly _isCamera: boolean;
  109941. /**
  109942. * Gets a string representation of the camera useful for debug purpose.
  109943. * @param fullDetails Defines that a more verboe level of logging is required
  109944. * @returns the string representation
  109945. */
  109946. toString(fullDetails?: boolean): string;
  109947. /**
  109948. * Gets the current world space position of the camera.
  109949. */
  109950. get globalPosition(): Vector3;
  109951. /**
  109952. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109953. * @returns the active meshe list
  109954. */
  109955. getActiveMeshes(): SmartArray<AbstractMesh>;
  109956. /**
  109957. * Check whether a mesh is part of the current active mesh list of the camera
  109958. * @param mesh Defines the mesh to check
  109959. * @returns true if active, false otherwise
  109960. */
  109961. isActiveMesh(mesh: Mesh): boolean;
  109962. /**
  109963. * Is this camera ready to be used/rendered
  109964. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109965. * @return true if the camera is ready
  109966. */
  109967. isReady(completeCheck?: boolean): boolean;
  109968. /** @hidden */
  109969. _initCache(): void;
  109970. /** @hidden */
  109971. _updateCache(ignoreParentClass?: boolean): void;
  109972. /** @hidden */
  109973. _isSynchronized(): boolean;
  109974. /** @hidden */
  109975. _isSynchronizedViewMatrix(): boolean;
  109976. /** @hidden */
  109977. _isSynchronizedProjectionMatrix(): boolean;
  109978. /**
  109979. * Attach the input controls to a specific dom element to get the input from.
  109980. * @param element Defines the element the controls should be listened from
  109981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109982. */
  109983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109984. /**
  109985. * Detach the current controls from the specified dom element.
  109986. * @param element Defines the element to stop listening the inputs from
  109987. */
  109988. detachControl(element: HTMLElement): void;
  109989. /**
  109990. * Update the camera state according to the different inputs gathered during the frame.
  109991. */
  109992. update(): void;
  109993. /** @hidden */
  109994. _checkInputs(): void;
  109995. /** @hidden */
  109996. get rigCameras(): Camera[];
  109997. /**
  109998. * Gets the post process used by the rig cameras
  109999. */
  110000. get rigPostProcess(): Nullable<PostProcess>;
  110001. /**
  110002. * Internal, gets the first post proces.
  110003. * @returns the first post process to be run on this camera.
  110004. */
  110005. _getFirstPostProcess(): Nullable<PostProcess>;
  110006. private _cascadePostProcessesToRigCams;
  110007. /**
  110008. * Attach a post process to the camera.
  110009. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110010. * @param postProcess The post process to attach to the camera
  110011. * @param insertAt The position of the post process in case several of them are in use in the scene
  110012. * @returns the position the post process has been inserted at
  110013. */
  110014. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  110015. /**
  110016. * Detach a post process to the camera.
  110017. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110018. * @param postProcess The post process to detach from the camera
  110019. */
  110020. detachPostProcess(postProcess: PostProcess): void;
  110021. /**
  110022. * Gets the current world matrix of the camera
  110023. */
  110024. getWorldMatrix(): Matrix;
  110025. /** @hidden */
  110026. _getViewMatrix(): Matrix;
  110027. /**
  110028. * Gets the current view matrix of the camera.
  110029. * @param force forces the camera to recompute the matrix without looking at the cached state
  110030. * @returns the view matrix
  110031. */
  110032. getViewMatrix(force?: boolean): Matrix;
  110033. /**
  110034. * Freeze the projection matrix.
  110035. * It will prevent the cache check of the camera projection compute and can speed up perf
  110036. * if no parameter of the camera are meant to change
  110037. * @param projection Defines manually a projection if necessary
  110038. */
  110039. freezeProjectionMatrix(projection?: Matrix): void;
  110040. /**
  110041. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  110042. */
  110043. unfreezeProjectionMatrix(): void;
  110044. /**
  110045. * Gets the current projection matrix of the camera.
  110046. * @param force forces the camera to recompute the matrix without looking at the cached state
  110047. * @returns the projection matrix
  110048. */
  110049. getProjectionMatrix(force?: boolean): Matrix;
  110050. /**
  110051. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  110052. * @returns a Matrix
  110053. */
  110054. getTransformationMatrix(): Matrix;
  110055. private _updateFrustumPlanes;
  110056. /**
  110057. * Checks if a cullable object (mesh...) is in the camera frustum
  110058. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  110059. * @param target The object to check
  110060. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  110061. * @returns true if the object is in frustum otherwise false
  110062. */
  110063. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  110064. /**
  110065. * Checks if a cullable object (mesh...) is in the camera frustum
  110066. * Unlike isInFrustum this cheks the full bounding box
  110067. * @param target The object to check
  110068. * @returns true if the object is in frustum otherwise false
  110069. */
  110070. isCompletelyInFrustum(target: ICullable): boolean;
  110071. /**
  110072. * Gets a ray in the forward direction from the camera.
  110073. * @param length Defines the length of the ray to create
  110074. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110075. * @param origin Defines the start point of the ray which defaults to the camera position
  110076. * @returns the forward ray
  110077. */
  110078. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110079. /**
  110080. * Gets a ray in the forward direction from the camera.
  110081. * @param refRay the ray to (re)use when setting the values
  110082. * @param length Defines the length of the ray to create
  110083. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110084. * @param origin Defines the start point of the ray which defaults to the camera position
  110085. * @returns the forward ray
  110086. */
  110087. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110088. /**
  110089. * Releases resources associated with this node.
  110090. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110091. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110092. */
  110093. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110094. /** @hidden */
  110095. _isLeftCamera: boolean;
  110096. /**
  110097. * Gets the left camera of a rig setup in case of Rigged Camera
  110098. */
  110099. get isLeftCamera(): boolean;
  110100. /** @hidden */
  110101. _isRightCamera: boolean;
  110102. /**
  110103. * Gets the right camera of a rig setup in case of Rigged Camera
  110104. */
  110105. get isRightCamera(): boolean;
  110106. /**
  110107. * Gets the left camera of a rig setup in case of Rigged Camera
  110108. */
  110109. get leftCamera(): Nullable<FreeCamera>;
  110110. /**
  110111. * Gets the right camera of a rig setup in case of Rigged Camera
  110112. */
  110113. get rightCamera(): Nullable<FreeCamera>;
  110114. /**
  110115. * Gets the left camera target of a rig setup in case of Rigged Camera
  110116. * @returns the target position
  110117. */
  110118. getLeftTarget(): Nullable<Vector3>;
  110119. /**
  110120. * Gets the right camera target of a rig setup in case of Rigged Camera
  110121. * @returns the target position
  110122. */
  110123. getRightTarget(): Nullable<Vector3>;
  110124. /**
  110125. * @hidden
  110126. */
  110127. setCameraRigMode(mode: number, rigParams: any): void;
  110128. /** @hidden */
  110129. static _setStereoscopicRigMode(camera: Camera): void;
  110130. /** @hidden */
  110131. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  110132. /** @hidden */
  110133. static _setVRRigMode(camera: Camera, rigParams: any): void;
  110134. /** @hidden */
  110135. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  110136. /** @hidden */
  110137. _getVRProjectionMatrix(): Matrix;
  110138. protected _updateCameraRotationMatrix(): void;
  110139. protected _updateWebVRCameraRotationMatrix(): void;
  110140. /**
  110141. * This function MUST be overwritten by the different WebVR cameras available.
  110142. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110143. * @hidden
  110144. */
  110145. _getWebVRProjectionMatrix(): Matrix;
  110146. /**
  110147. * This function MUST be overwritten by the different WebVR cameras available.
  110148. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110149. * @hidden
  110150. */
  110151. _getWebVRViewMatrix(): Matrix;
  110152. /** @hidden */
  110153. setCameraRigParameter(name: string, value: any): void;
  110154. /**
  110155. * needs to be overridden by children so sub has required properties to be copied
  110156. * @hidden
  110157. */
  110158. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  110159. /**
  110160. * May need to be overridden by children
  110161. * @hidden
  110162. */
  110163. _updateRigCameras(): void;
  110164. /** @hidden */
  110165. _setupInputs(): void;
  110166. /**
  110167. * Serialiaze the camera setup to a json represention
  110168. * @returns the JSON representation
  110169. */
  110170. serialize(): any;
  110171. /**
  110172. * Clones the current camera.
  110173. * @param name The cloned camera name
  110174. * @returns the cloned camera
  110175. */
  110176. clone(name: string): Camera;
  110177. /**
  110178. * Gets the direction of the camera relative to a given local axis.
  110179. * @param localAxis Defines the reference axis to provide a relative direction.
  110180. * @return the direction
  110181. */
  110182. getDirection(localAxis: Vector3): Vector3;
  110183. /**
  110184. * Returns the current camera absolute rotation
  110185. */
  110186. get absoluteRotation(): Quaternion;
  110187. /**
  110188. * Gets the direction of the camera relative to a given local axis into a passed vector.
  110189. * @param localAxis Defines the reference axis to provide a relative direction.
  110190. * @param result Defines the vector to store the result in
  110191. */
  110192. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  110193. /**
  110194. * Gets a camera constructor for a given camera type
  110195. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  110196. * @param name The name of the camera the result will be able to instantiate
  110197. * @param scene The scene the result will construct the camera in
  110198. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  110199. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  110200. * @returns a factory method to construc the camera
  110201. */
  110202. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  110203. /**
  110204. * Compute the world matrix of the camera.
  110205. * @returns the camera world matrix
  110206. */
  110207. computeWorldMatrix(): Matrix;
  110208. /**
  110209. * Parse a JSON and creates the camera from the parsed information
  110210. * @param parsedCamera The JSON to parse
  110211. * @param scene The scene to instantiate the camera in
  110212. * @returns the newly constructed camera
  110213. */
  110214. static Parse(parsedCamera: any, scene: Scene): Camera;
  110215. }
  110216. }
  110217. declare module BABYLON {
  110218. /**
  110219. * Class containing static functions to help procedurally build meshes
  110220. */
  110221. export class DiscBuilder {
  110222. /**
  110223. * Creates a plane polygonal mesh. By default, this is a disc
  110224. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110225. * * 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
  110226. * * 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
  110227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110230. * @param name defines the name of the mesh
  110231. * @param options defines the options used to create the mesh
  110232. * @param scene defines the hosting scene
  110233. * @returns the plane polygonal mesh
  110234. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110235. */
  110236. static CreateDisc(name: string, options: {
  110237. radius?: number;
  110238. tessellation?: number;
  110239. arc?: number;
  110240. updatable?: boolean;
  110241. sideOrientation?: number;
  110242. frontUVs?: Vector4;
  110243. backUVs?: Vector4;
  110244. }, scene?: Nullable<Scene>): Mesh;
  110245. }
  110246. }
  110247. declare module BABYLON {
  110248. /**
  110249. * Options to be used when creating a FresnelParameters.
  110250. */
  110251. export type IFresnelParametersCreationOptions = {
  110252. /**
  110253. * Define the color used on edges (grazing angle)
  110254. */
  110255. leftColor?: Color3;
  110256. /**
  110257. * Define the color used on center
  110258. */
  110259. rightColor?: Color3;
  110260. /**
  110261. * Define bias applied to computed fresnel term
  110262. */
  110263. bias?: number;
  110264. /**
  110265. * Defined the power exponent applied to fresnel term
  110266. */
  110267. power?: number;
  110268. /**
  110269. * Define if the fresnel effect is enable or not.
  110270. */
  110271. isEnabled?: boolean;
  110272. };
  110273. /**
  110274. * Serialized format for FresnelParameters.
  110275. */
  110276. export type IFresnelParametersSerialized = {
  110277. /**
  110278. * Define the color used on edges (grazing angle) [as an array]
  110279. */
  110280. leftColor: number[];
  110281. /**
  110282. * Define the color used on center [as an array]
  110283. */
  110284. rightColor: number[];
  110285. /**
  110286. * Define bias applied to computed fresnel term
  110287. */
  110288. bias: number;
  110289. /**
  110290. * Defined the power exponent applied to fresnel term
  110291. */
  110292. power?: number;
  110293. /**
  110294. * Define if the fresnel effect is enable or not.
  110295. */
  110296. isEnabled: boolean;
  110297. };
  110298. /**
  110299. * This represents all the required information to add a fresnel effect on a material:
  110300. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110301. */
  110302. export class FresnelParameters {
  110303. private _isEnabled;
  110304. /**
  110305. * Define if the fresnel effect is enable or not.
  110306. */
  110307. get isEnabled(): boolean;
  110308. set isEnabled(value: boolean);
  110309. /**
  110310. * Define the color used on edges (grazing angle)
  110311. */
  110312. leftColor: Color3;
  110313. /**
  110314. * Define the color used on center
  110315. */
  110316. rightColor: Color3;
  110317. /**
  110318. * Define bias applied to computed fresnel term
  110319. */
  110320. bias: number;
  110321. /**
  110322. * Defined the power exponent applied to fresnel term
  110323. */
  110324. power: number;
  110325. /**
  110326. * Creates a new FresnelParameters object.
  110327. *
  110328. * @param options provide your own settings to optionally to override defaults
  110329. */
  110330. constructor(options?: IFresnelParametersCreationOptions);
  110331. /**
  110332. * Clones the current fresnel and its valuues
  110333. * @returns a clone fresnel configuration
  110334. */
  110335. clone(): FresnelParameters;
  110336. /**
  110337. * Determines equality between FresnelParameters objects
  110338. * @param otherFresnelParameters defines the second operand
  110339. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  110340. */
  110341. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  110342. /**
  110343. * Serializes the current fresnel parameters to a JSON representation.
  110344. * @return the JSON serialization
  110345. */
  110346. serialize(): IFresnelParametersSerialized;
  110347. /**
  110348. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  110349. * @param parsedFresnelParameters Define the JSON representation
  110350. * @returns the parsed parameters
  110351. */
  110352. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  110353. }
  110354. }
  110355. declare module BABYLON {
  110356. /**
  110357. * This groups all the flags used to control the materials channel.
  110358. */
  110359. export class MaterialFlags {
  110360. private static _DiffuseTextureEnabled;
  110361. /**
  110362. * Are diffuse textures enabled in the application.
  110363. */
  110364. static get DiffuseTextureEnabled(): boolean;
  110365. static set DiffuseTextureEnabled(value: boolean);
  110366. private static _DetailTextureEnabled;
  110367. /**
  110368. * Are detail textures enabled in the application.
  110369. */
  110370. static get DetailTextureEnabled(): boolean;
  110371. static set DetailTextureEnabled(value: boolean);
  110372. private static _AmbientTextureEnabled;
  110373. /**
  110374. * Are ambient textures enabled in the application.
  110375. */
  110376. static get AmbientTextureEnabled(): boolean;
  110377. static set AmbientTextureEnabled(value: boolean);
  110378. private static _OpacityTextureEnabled;
  110379. /**
  110380. * Are opacity textures enabled in the application.
  110381. */
  110382. static get OpacityTextureEnabled(): boolean;
  110383. static set OpacityTextureEnabled(value: boolean);
  110384. private static _ReflectionTextureEnabled;
  110385. /**
  110386. * Are reflection textures enabled in the application.
  110387. */
  110388. static get ReflectionTextureEnabled(): boolean;
  110389. static set ReflectionTextureEnabled(value: boolean);
  110390. private static _EmissiveTextureEnabled;
  110391. /**
  110392. * Are emissive textures enabled in the application.
  110393. */
  110394. static get EmissiveTextureEnabled(): boolean;
  110395. static set EmissiveTextureEnabled(value: boolean);
  110396. private static _SpecularTextureEnabled;
  110397. /**
  110398. * Are specular textures enabled in the application.
  110399. */
  110400. static get SpecularTextureEnabled(): boolean;
  110401. static set SpecularTextureEnabled(value: boolean);
  110402. private static _BumpTextureEnabled;
  110403. /**
  110404. * Are bump textures enabled in the application.
  110405. */
  110406. static get BumpTextureEnabled(): boolean;
  110407. static set BumpTextureEnabled(value: boolean);
  110408. private static _LightmapTextureEnabled;
  110409. /**
  110410. * Are lightmap textures enabled in the application.
  110411. */
  110412. static get LightmapTextureEnabled(): boolean;
  110413. static set LightmapTextureEnabled(value: boolean);
  110414. private static _RefractionTextureEnabled;
  110415. /**
  110416. * Are refraction textures enabled in the application.
  110417. */
  110418. static get RefractionTextureEnabled(): boolean;
  110419. static set RefractionTextureEnabled(value: boolean);
  110420. private static _ColorGradingTextureEnabled;
  110421. /**
  110422. * Are color grading textures enabled in the application.
  110423. */
  110424. static get ColorGradingTextureEnabled(): boolean;
  110425. static set ColorGradingTextureEnabled(value: boolean);
  110426. private static _FresnelEnabled;
  110427. /**
  110428. * Are fresnels enabled in the application.
  110429. */
  110430. static get FresnelEnabled(): boolean;
  110431. static set FresnelEnabled(value: boolean);
  110432. private static _ClearCoatTextureEnabled;
  110433. /**
  110434. * Are clear coat textures enabled in the application.
  110435. */
  110436. static get ClearCoatTextureEnabled(): boolean;
  110437. static set ClearCoatTextureEnabled(value: boolean);
  110438. private static _ClearCoatBumpTextureEnabled;
  110439. /**
  110440. * Are clear coat bump textures enabled in the application.
  110441. */
  110442. static get ClearCoatBumpTextureEnabled(): boolean;
  110443. static set ClearCoatBumpTextureEnabled(value: boolean);
  110444. private static _ClearCoatTintTextureEnabled;
  110445. /**
  110446. * Are clear coat tint textures enabled in the application.
  110447. */
  110448. static get ClearCoatTintTextureEnabled(): boolean;
  110449. static set ClearCoatTintTextureEnabled(value: boolean);
  110450. private static _SheenTextureEnabled;
  110451. /**
  110452. * Are sheen textures enabled in the application.
  110453. */
  110454. static get SheenTextureEnabled(): boolean;
  110455. static set SheenTextureEnabled(value: boolean);
  110456. private static _AnisotropicTextureEnabled;
  110457. /**
  110458. * Are anisotropic textures enabled in the application.
  110459. */
  110460. static get AnisotropicTextureEnabled(): boolean;
  110461. static set AnisotropicTextureEnabled(value: boolean);
  110462. private static _ThicknessTextureEnabled;
  110463. /**
  110464. * Are thickness textures enabled in the application.
  110465. */
  110466. static get ThicknessTextureEnabled(): boolean;
  110467. static set ThicknessTextureEnabled(value: boolean);
  110468. }
  110469. }
  110470. declare module BABYLON {
  110471. /** @hidden */
  110472. export var defaultFragmentDeclaration: {
  110473. name: string;
  110474. shader: string;
  110475. };
  110476. }
  110477. declare module BABYLON {
  110478. /** @hidden */
  110479. export var defaultUboDeclaration: {
  110480. name: string;
  110481. shader: string;
  110482. };
  110483. }
  110484. declare module BABYLON {
  110485. /** @hidden */
  110486. export var prePassDeclaration: {
  110487. name: string;
  110488. shader: string;
  110489. };
  110490. }
  110491. declare module BABYLON {
  110492. /** @hidden */
  110493. export var lightFragmentDeclaration: {
  110494. name: string;
  110495. shader: string;
  110496. };
  110497. }
  110498. declare module BABYLON {
  110499. /** @hidden */
  110500. export var lightUboDeclaration: {
  110501. name: string;
  110502. shader: string;
  110503. };
  110504. }
  110505. declare module BABYLON {
  110506. /** @hidden */
  110507. export var lightsFragmentFunctions: {
  110508. name: string;
  110509. shader: string;
  110510. };
  110511. }
  110512. declare module BABYLON {
  110513. /** @hidden */
  110514. export var shadowsFragmentFunctions: {
  110515. name: string;
  110516. shader: string;
  110517. };
  110518. }
  110519. declare module BABYLON {
  110520. /** @hidden */
  110521. export var fresnelFunction: {
  110522. name: string;
  110523. shader: string;
  110524. };
  110525. }
  110526. declare module BABYLON {
  110527. /** @hidden */
  110528. export var bumpFragmentMainFunctions: {
  110529. name: string;
  110530. shader: string;
  110531. };
  110532. }
  110533. declare module BABYLON {
  110534. /** @hidden */
  110535. export var bumpFragmentFunctions: {
  110536. name: string;
  110537. shader: string;
  110538. };
  110539. }
  110540. declare module BABYLON {
  110541. /** @hidden */
  110542. export var logDepthDeclaration: {
  110543. name: string;
  110544. shader: string;
  110545. };
  110546. }
  110547. declare module BABYLON {
  110548. /** @hidden */
  110549. export var bumpFragment: {
  110550. name: string;
  110551. shader: string;
  110552. };
  110553. }
  110554. declare module BABYLON {
  110555. /** @hidden */
  110556. export var depthPrePass: {
  110557. name: string;
  110558. shader: string;
  110559. };
  110560. }
  110561. declare module BABYLON {
  110562. /** @hidden */
  110563. export var lightFragment: {
  110564. name: string;
  110565. shader: string;
  110566. };
  110567. }
  110568. declare module BABYLON {
  110569. /** @hidden */
  110570. export var logDepthFragment: {
  110571. name: string;
  110572. shader: string;
  110573. };
  110574. }
  110575. declare module BABYLON {
  110576. /** @hidden */
  110577. export var defaultPixelShader: {
  110578. name: string;
  110579. shader: string;
  110580. };
  110581. }
  110582. declare module BABYLON {
  110583. /** @hidden */
  110584. export var defaultVertexDeclaration: {
  110585. name: string;
  110586. shader: string;
  110587. };
  110588. }
  110589. declare module BABYLON {
  110590. /** @hidden */
  110591. export var bumpVertexDeclaration: {
  110592. name: string;
  110593. shader: string;
  110594. };
  110595. }
  110596. declare module BABYLON {
  110597. /** @hidden */
  110598. export var bumpVertex: {
  110599. name: string;
  110600. shader: string;
  110601. };
  110602. }
  110603. declare module BABYLON {
  110604. /** @hidden */
  110605. export var fogVertex: {
  110606. name: string;
  110607. shader: string;
  110608. };
  110609. }
  110610. declare module BABYLON {
  110611. /** @hidden */
  110612. export var shadowsVertex: {
  110613. name: string;
  110614. shader: string;
  110615. };
  110616. }
  110617. declare module BABYLON {
  110618. /** @hidden */
  110619. export var pointCloudVertex: {
  110620. name: string;
  110621. shader: string;
  110622. };
  110623. }
  110624. declare module BABYLON {
  110625. /** @hidden */
  110626. export var logDepthVertex: {
  110627. name: string;
  110628. shader: string;
  110629. };
  110630. }
  110631. declare module BABYLON {
  110632. /** @hidden */
  110633. export var defaultVertexShader: {
  110634. name: string;
  110635. shader: string;
  110636. };
  110637. }
  110638. declare module BABYLON {
  110639. /**
  110640. * @hidden
  110641. */
  110642. export interface IMaterialDetailMapDefines {
  110643. DETAIL: boolean;
  110644. DETAILDIRECTUV: number;
  110645. DETAIL_NORMALBLENDMETHOD: number;
  110646. /** @hidden */
  110647. _areTexturesDirty: boolean;
  110648. }
  110649. /**
  110650. * Define the code related to the detail map parameters of a material
  110651. *
  110652. * Inspired from:
  110653. * 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
  110654. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110655. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110656. */
  110657. export class DetailMapConfiguration {
  110658. private _texture;
  110659. /**
  110660. * The detail texture of the material.
  110661. */
  110662. texture: Nullable<BaseTexture>;
  110663. /**
  110664. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110665. * Bigger values mean stronger blending
  110666. */
  110667. diffuseBlendLevel: number;
  110668. /**
  110669. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110670. * Bigger values mean stronger blending. Only used with PBR materials
  110671. */
  110672. roughnessBlendLevel: number;
  110673. /**
  110674. * Defines how strong the bump effect from the detail map is
  110675. * Bigger values mean stronger effect
  110676. */
  110677. bumpLevel: number;
  110678. private _normalBlendMethod;
  110679. /**
  110680. * The method used to blend the bump and detail normals together
  110681. */
  110682. normalBlendMethod: number;
  110683. private _isEnabled;
  110684. /**
  110685. * Enable or disable the detail map on this material
  110686. */
  110687. isEnabled: boolean;
  110688. /** @hidden */
  110689. private _internalMarkAllSubMeshesAsTexturesDirty;
  110690. /** @hidden */
  110691. _markAllSubMeshesAsTexturesDirty(): void;
  110692. /**
  110693. * Instantiate a new detail map
  110694. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110695. */
  110696. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110697. /**
  110698. * Gets whether the submesh is ready to be used or not.
  110699. * @param defines the list of "defines" to update.
  110700. * @param scene defines the scene the material belongs to.
  110701. * @returns - boolean indicating that the submesh is ready or not.
  110702. */
  110703. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110704. /**
  110705. * Update the defines for detail map usage
  110706. * @param defines the list of "defines" to update.
  110707. * @param scene defines the scene the material belongs to.
  110708. */
  110709. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110710. /**
  110711. * Binds the material data.
  110712. * @param uniformBuffer defines the Uniform buffer to fill in.
  110713. * @param scene defines the scene the material belongs to.
  110714. * @param isFrozen defines whether the material is frozen or not.
  110715. */
  110716. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110717. /**
  110718. * Checks to see if a texture is used in the material.
  110719. * @param texture - Base texture to use.
  110720. * @returns - Boolean specifying if a texture is used in the material.
  110721. */
  110722. hasTexture(texture: BaseTexture): boolean;
  110723. /**
  110724. * Returns an array of the actively used textures.
  110725. * @param activeTextures Array of BaseTextures
  110726. */
  110727. getActiveTextures(activeTextures: BaseTexture[]): void;
  110728. /**
  110729. * Returns the animatable textures.
  110730. * @param animatables Array of animatable textures.
  110731. */
  110732. getAnimatables(animatables: IAnimatable[]): void;
  110733. /**
  110734. * Disposes the resources of the material.
  110735. * @param forceDisposeTextures - Forces the disposal of all textures.
  110736. */
  110737. dispose(forceDisposeTextures?: boolean): void;
  110738. /**
  110739. * Get the current class name useful for serialization or dynamic coding.
  110740. * @returns "DetailMap"
  110741. */
  110742. getClassName(): string;
  110743. /**
  110744. * Add the required uniforms to the current list.
  110745. * @param uniforms defines the current uniform list.
  110746. */
  110747. static AddUniforms(uniforms: string[]): void;
  110748. /**
  110749. * Add the required samplers to the current list.
  110750. * @param samplers defines the current sampler list.
  110751. */
  110752. static AddSamplers(samplers: string[]): void;
  110753. /**
  110754. * Add the required uniforms to the current buffer.
  110755. * @param uniformBuffer defines the current uniform buffer.
  110756. */
  110757. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110758. /**
  110759. * Makes a duplicate of the current instance into another one.
  110760. * @param detailMap define the instance where to copy the info
  110761. */
  110762. copyTo(detailMap: DetailMapConfiguration): void;
  110763. /**
  110764. * Serializes this detail map instance
  110765. * @returns - An object with the serialized instance.
  110766. */
  110767. serialize(): any;
  110768. /**
  110769. * Parses a detail map setting from a serialized object.
  110770. * @param source - Serialized object.
  110771. * @param scene Defines the scene we are parsing for
  110772. * @param rootUrl Defines the rootUrl to load from
  110773. */
  110774. parse(source: any, scene: Scene, rootUrl: string): void;
  110775. }
  110776. }
  110777. declare module BABYLON {
  110778. /** @hidden */
  110779. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110780. MAINUV1: boolean;
  110781. MAINUV2: boolean;
  110782. DIFFUSE: boolean;
  110783. DIFFUSEDIRECTUV: number;
  110784. DETAIL: boolean;
  110785. DETAILDIRECTUV: number;
  110786. DETAIL_NORMALBLENDMETHOD: number;
  110787. AMBIENT: boolean;
  110788. AMBIENTDIRECTUV: number;
  110789. OPACITY: boolean;
  110790. OPACITYDIRECTUV: number;
  110791. OPACITYRGB: boolean;
  110792. REFLECTION: boolean;
  110793. EMISSIVE: boolean;
  110794. EMISSIVEDIRECTUV: number;
  110795. SPECULAR: boolean;
  110796. SPECULARDIRECTUV: number;
  110797. BUMP: boolean;
  110798. BUMPDIRECTUV: number;
  110799. PARALLAX: boolean;
  110800. PARALLAXOCCLUSION: boolean;
  110801. SPECULAROVERALPHA: boolean;
  110802. CLIPPLANE: boolean;
  110803. CLIPPLANE2: boolean;
  110804. CLIPPLANE3: boolean;
  110805. CLIPPLANE4: boolean;
  110806. CLIPPLANE5: boolean;
  110807. CLIPPLANE6: boolean;
  110808. ALPHATEST: boolean;
  110809. DEPTHPREPASS: boolean;
  110810. ALPHAFROMDIFFUSE: boolean;
  110811. POINTSIZE: boolean;
  110812. FOG: boolean;
  110813. SPECULARTERM: boolean;
  110814. DIFFUSEFRESNEL: boolean;
  110815. OPACITYFRESNEL: boolean;
  110816. REFLECTIONFRESNEL: boolean;
  110817. REFRACTIONFRESNEL: boolean;
  110818. EMISSIVEFRESNEL: boolean;
  110819. FRESNEL: boolean;
  110820. NORMAL: boolean;
  110821. UV1: boolean;
  110822. UV2: boolean;
  110823. VERTEXCOLOR: boolean;
  110824. VERTEXALPHA: boolean;
  110825. NUM_BONE_INFLUENCERS: number;
  110826. BonesPerMesh: number;
  110827. BONETEXTURE: boolean;
  110828. INSTANCES: boolean;
  110829. THIN_INSTANCES: boolean;
  110830. GLOSSINESS: boolean;
  110831. ROUGHNESS: boolean;
  110832. EMISSIVEASILLUMINATION: boolean;
  110833. LINKEMISSIVEWITHDIFFUSE: boolean;
  110834. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110835. LIGHTMAP: boolean;
  110836. LIGHTMAPDIRECTUV: number;
  110837. OBJECTSPACE_NORMALMAP: boolean;
  110838. USELIGHTMAPASSHADOWMAP: boolean;
  110839. REFLECTIONMAP_3D: boolean;
  110840. REFLECTIONMAP_SPHERICAL: boolean;
  110841. REFLECTIONMAP_PLANAR: boolean;
  110842. REFLECTIONMAP_CUBIC: boolean;
  110843. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110844. REFLECTIONMAP_PROJECTION: boolean;
  110845. REFLECTIONMAP_SKYBOX: boolean;
  110846. REFLECTIONMAP_EXPLICIT: boolean;
  110847. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110848. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110849. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110850. INVERTCUBICMAP: boolean;
  110851. LOGARITHMICDEPTH: boolean;
  110852. REFRACTION: boolean;
  110853. REFRACTIONMAP_3D: boolean;
  110854. REFLECTIONOVERALPHA: boolean;
  110855. TWOSIDEDLIGHTING: boolean;
  110856. SHADOWFLOAT: boolean;
  110857. MORPHTARGETS: boolean;
  110858. MORPHTARGETS_NORMAL: boolean;
  110859. MORPHTARGETS_TANGENT: boolean;
  110860. MORPHTARGETS_UV: boolean;
  110861. NUM_MORPH_INFLUENCERS: number;
  110862. NONUNIFORMSCALING: boolean;
  110863. PREMULTIPLYALPHA: boolean;
  110864. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110865. ALPHABLEND: boolean;
  110866. PREPASS: boolean;
  110867. PREPASS_IRRADIANCE: boolean;
  110868. PREPASS_IRRADIANCE_INDEX: number;
  110869. PREPASS_ALBEDO: boolean;
  110870. PREPASS_ALBEDO_INDEX: number;
  110871. PREPASS_DEPTHNORMAL: boolean;
  110872. PREPASS_DEPTHNORMAL_INDEX: number;
  110873. SCENE_MRT_COUNT: number;
  110874. RGBDLIGHTMAP: boolean;
  110875. RGBDREFLECTION: boolean;
  110876. RGBDREFRACTION: boolean;
  110877. IMAGEPROCESSING: boolean;
  110878. VIGNETTE: boolean;
  110879. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110880. VIGNETTEBLENDMODEOPAQUE: boolean;
  110881. TONEMAPPING: boolean;
  110882. TONEMAPPING_ACES: boolean;
  110883. CONTRAST: boolean;
  110884. COLORCURVES: boolean;
  110885. COLORGRADING: boolean;
  110886. COLORGRADING3D: boolean;
  110887. SAMPLER3DGREENDEPTH: boolean;
  110888. SAMPLER3DBGRMAP: boolean;
  110889. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110890. MULTIVIEW: boolean;
  110891. /**
  110892. * If the reflection texture on this material is in linear color space
  110893. * @hidden
  110894. */
  110895. IS_REFLECTION_LINEAR: boolean;
  110896. /**
  110897. * If the refraction texture on this material is in linear color space
  110898. * @hidden
  110899. */
  110900. IS_REFRACTION_LINEAR: boolean;
  110901. EXPOSURE: boolean;
  110902. constructor();
  110903. setReflectionMode(modeToEnable: string): void;
  110904. }
  110905. /**
  110906. * This is the default material used in Babylon. It is the best trade off between quality
  110907. * and performances.
  110908. * @see https://doc.babylonjs.com/babylon101/materials
  110909. */
  110910. export class StandardMaterial extends PushMaterial {
  110911. private _diffuseTexture;
  110912. /**
  110913. * The basic texture of the material as viewed under a light.
  110914. */
  110915. diffuseTexture: Nullable<BaseTexture>;
  110916. private _ambientTexture;
  110917. /**
  110918. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110919. */
  110920. ambientTexture: Nullable<BaseTexture>;
  110921. private _opacityTexture;
  110922. /**
  110923. * Define the transparency of the material from a texture.
  110924. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110925. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110926. */
  110927. opacityTexture: Nullable<BaseTexture>;
  110928. private _reflectionTexture;
  110929. /**
  110930. * Define the texture used to display the reflection.
  110931. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110932. */
  110933. reflectionTexture: Nullable<BaseTexture>;
  110934. private _emissiveTexture;
  110935. /**
  110936. * Define texture of the material as if self lit.
  110937. * This will be mixed in the final result even in the absence of light.
  110938. */
  110939. emissiveTexture: Nullable<BaseTexture>;
  110940. private _specularTexture;
  110941. /**
  110942. * Define how the color and intensity of the highlight given by the light in the material.
  110943. */
  110944. specularTexture: Nullable<BaseTexture>;
  110945. private _bumpTexture;
  110946. /**
  110947. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110948. * 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.
  110949. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110950. */
  110951. bumpTexture: Nullable<BaseTexture>;
  110952. private _lightmapTexture;
  110953. /**
  110954. * Complex lighting can be computationally expensive to compute at runtime.
  110955. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110956. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110957. */
  110958. lightmapTexture: Nullable<BaseTexture>;
  110959. private _refractionTexture;
  110960. /**
  110961. * Define the texture used to display the refraction.
  110962. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110963. */
  110964. refractionTexture: Nullable<BaseTexture>;
  110965. /**
  110966. * The color of the material lit by the environmental background lighting.
  110967. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110968. */
  110969. ambientColor: Color3;
  110970. /**
  110971. * The basic color of the material as viewed under a light.
  110972. */
  110973. diffuseColor: Color3;
  110974. /**
  110975. * Define how the color and intensity of the highlight given by the light in the material.
  110976. */
  110977. specularColor: Color3;
  110978. /**
  110979. * Define the color of the material as if self lit.
  110980. * This will be mixed in the final result even in the absence of light.
  110981. */
  110982. emissiveColor: Color3;
  110983. /**
  110984. * Defines how sharp are the highlights in the material.
  110985. * The bigger the value the sharper giving a more glossy feeling to the result.
  110986. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110987. */
  110988. specularPower: number;
  110989. private _useAlphaFromDiffuseTexture;
  110990. /**
  110991. * Does the transparency come from the diffuse texture alpha channel.
  110992. */
  110993. useAlphaFromDiffuseTexture: boolean;
  110994. private _useEmissiveAsIllumination;
  110995. /**
  110996. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110997. */
  110998. useEmissiveAsIllumination: boolean;
  110999. private _linkEmissiveWithDiffuse;
  111000. /**
  111001. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  111002. * the emissive level when the final color is close to one.
  111003. */
  111004. linkEmissiveWithDiffuse: boolean;
  111005. private _useSpecularOverAlpha;
  111006. /**
  111007. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  111008. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111009. */
  111010. useSpecularOverAlpha: boolean;
  111011. private _useReflectionOverAlpha;
  111012. /**
  111013. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111014. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111015. */
  111016. useReflectionOverAlpha: boolean;
  111017. private _disableLighting;
  111018. /**
  111019. * Does lights from the scene impacts this material.
  111020. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  111021. */
  111022. disableLighting: boolean;
  111023. private _useObjectSpaceNormalMap;
  111024. /**
  111025. * Allows using an object space normal map (instead of tangent space).
  111026. */
  111027. useObjectSpaceNormalMap: boolean;
  111028. private _useParallax;
  111029. /**
  111030. * Is parallax enabled or not.
  111031. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111032. */
  111033. useParallax: boolean;
  111034. private _useParallaxOcclusion;
  111035. /**
  111036. * Is parallax occlusion enabled or not.
  111037. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  111038. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111039. */
  111040. useParallaxOcclusion: boolean;
  111041. /**
  111042. * 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.
  111043. */
  111044. parallaxScaleBias: number;
  111045. private _roughness;
  111046. /**
  111047. * Helps to define how blurry the reflections should appears in the material.
  111048. */
  111049. roughness: number;
  111050. /**
  111051. * In case of refraction, define the value of the index of refraction.
  111052. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111053. */
  111054. indexOfRefraction: number;
  111055. /**
  111056. * Invert the refraction texture alongside the y axis.
  111057. * It can be useful with procedural textures or probe for instance.
  111058. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111059. */
  111060. invertRefractionY: boolean;
  111061. /**
  111062. * Defines the alpha limits in alpha test mode.
  111063. */
  111064. alphaCutOff: number;
  111065. private _useLightmapAsShadowmap;
  111066. /**
  111067. * In case of light mapping, define whether the map contains light or shadow informations.
  111068. */
  111069. useLightmapAsShadowmap: boolean;
  111070. private _diffuseFresnelParameters;
  111071. /**
  111072. * Define the diffuse fresnel parameters of the material.
  111073. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111074. */
  111075. diffuseFresnelParameters: FresnelParameters;
  111076. private _opacityFresnelParameters;
  111077. /**
  111078. * Define the opacity fresnel parameters of the material.
  111079. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111080. */
  111081. opacityFresnelParameters: FresnelParameters;
  111082. private _reflectionFresnelParameters;
  111083. /**
  111084. * Define the reflection fresnel parameters of the material.
  111085. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111086. */
  111087. reflectionFresnelParameters: FresnelParameters;
  111088. private _refractionFresnelParameters;
  111089. /**
  111090. * Define the refraction fresnel parameters of the material.
  111091. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111092. */
  111093. refractionFresnelParameters: FresnelParameters;
  111094. private _emissiveFresnelParameters;
  111095. /**
  111096. * Define the emissive fresnel parameters of the material.
  111097. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111098. */
  111099. emissiveFresnelParameters: FresnelParameters;
  111100. private _useReflectionFresnelFromSpecular;
  111101. /**
  111102. * If true automatically deducts the fresnels values from the material specularity.
  111103. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111104. */
  111105. useReflectionFresnelFromSpecular: boolean;
  111106. private _useGlossinessFromSpecularMapAlpha;
  111107. /**
  111108. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  111109. */
  111110. useGlossinessFromSpecularMapAlpha: boolean;
  111111. private _maxSimultaneousLights;
  111112. /**
  111113. * Defines the maximum number of lights that can be used in the material
  111114. */
  111115. maxSimultaneousLights: number;
  111116. private _invertNormalMapX;
  111117. /**
  111118. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111119. */
  111120. invertNormalMapX: boolean;
  111121. private _invertNormalMapY;
  111122. /**
  111123. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111124. */
  111125. invertNormalMapY: boolean;
  111126. private _twoSidedLighting;
  111127. /**
  111128. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111129. */
  111130. twoSidedLighting: boolean;
  111131. /**
  111132. * Default configuration related to image processing available in the standard Material.
  111133. */
  111134. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111135. /**
  111136. * Gets the image processing configuration used either in this material.
  111137. */
  111138. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111139. /**
  111140. * Sets the Default image processing configuration used either in the this material.
  111141. *
  111142. * If sets to null, the scene one is in use.
  111143. */
  111144. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  111145. /**
  111146. * Keep track of the image processing observer to allow dispose and replace.
  111147. */
  111148. private _imageProcessingObserver;
  111149. /**
  111150. * Attaches a new image processing configuration to the Standard Material.
  111151. * @param configuration
  111152. */
  111153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111154. /**
  111155. * Gets wether the color curves effect is enabled.
  111156. */
  111157. get cameraColorCurvesEnabled(): boolean;
  111158. /**
  111159. * Sets wether the color curves effect is enabled.
  111160. */
  111161. set cameraColorCurvesEnabled(value: boolean);
  111162. /**
  111163. * Gets wether the color grading effect is enabled.
  111164. */
  111165. get cameraColorGradingEnabled(): boolean;
  111166. /**
  111167. * Gets wether the color grading effect is enabled.
  111168. */
  111169. set cameraColorGradingEnabled(value: boolean);
  111170. /**
  111171. * Gets wether tonemapping is enabled or not.
  111172. */
  111173. get cameraToneMappingEnabled(): boolean;
  111174. /**
  111175. * Sets wether tonemapping is enabled or not
  111176. */
  111177. set cameraToneMappingEnabled(value: boolean);
  111178. /**
  111179. * The camera exposure used on this material.
  111180. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111181. * This corresponds to a photographic exposure.
  111182. */
  111183. get cameraExposure(): number;
  111184. /**
  111185. * The camera exposure used on this material.
  111186. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111187. * This corresponds to a photographic exposure.
  111188. */
  111189. set cameraExposure(value: number);
  111190. /**
  111191. * Gets The camera contrast used on this material.
  111192. */
  111193. get cameraContrast(): number;
  111194. /**
  111195. * Sets The camera contrast used on this material.
  111196. */
  111197. set cameraContrast(value: number);
  111198. /**
  111199. * Gets the Color Grading 2D Lookup Texture.
  111200. */
  111201. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  111202. /**
  111203. * Sets the Color Grading 2D Lookup Texture.
  111204. */
  111205. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  111206. /**
  111207. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111208. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111209. * 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;
  111210. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111211. */
  111212. get cameraColorCurves(): Nullable<ColorCurves>;
  111213. /**
  111214. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111215. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111216. * 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;
  111217. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111218. */
  111219. set cameraColorCurves(value: Nullable<ColorCurves>);
  111220. /**
  111221. * Can this material render to several textures at once
  111222. */
  111223. get canRenderToMRT(): boolean;
  111224. /**
  111225. * Defines the detail map parameters for the material.
  111226. */
  111227. readonly detailMap: DetailMapConfiguration;
  111228. protected _renderTargets: SmartArray<RenderTargetTexture>;
  111229. protected _worldViewProjectionMatrix: Matrix;
  111230. protected _globalAmbientColor: Color3;
  111231. protected _useLogarithmicDepth: boolean;
  111232. protected _rebuildInParallel: boolean;
  111233. /**
  111234. * Instantiates a new standard material.
  111235. * This is the default material used in Babylon. It is the best trade off between quality
  111236. * and performances.
  111237. * @see https://doc.babylonjs.com/babylon101/materials
  111238. * @param name Define the name of the material in the scene
  111239. * @param scene Define the scene the material belong to
  111240. */
  111241. constructor(name: string, scene: Scene);
  111242. /**
  111243. * Gets a boolean indicating that current material needs to register RTT
  111244. */
  111245. get hasRenderTargetTextures(): boolean;
  111246. /**
  111247. * Gets the current class name of the material e.g. "StandardMaterial"
  111248. * Mainly use in serialization.
  111249. * @returns the class name
  111250. */
  111251. getClassName(): string;
  111252. /**
  111253. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  111254. * You can try switching to logarithmic depth.
  111255. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  111256. */
  111257. get useLogarithmicDepth(): boolean;
  111258. set useLogarithmicDepth(value: boolean);
  111259. /**
  111260. * Specifies if the material will require alpha blending
  111261. * @returns a boolean specifying if alpha blending is needed
  111262. */
  111263. needAlphaBlending(): boolean;
  111264. /**
  111265. * Specifies if this material should be rendered in alpha test mode
  111266. * @returns a boolean specifying if an alpha test is needed.
  111267. */
  111268. needAlphaTesting(): boolean;
  111269. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  111270. /**
  111271. * Get the texture used for alpha test purpose.
  111272. * @returns the diffuse texture in case of the standard material.
  111273. */
  111274. getAlphaTestTexture(): Nullable<BaseTexture>;
  111275. /**
  111276. * Get if the submesh is ready to be used and all its information available.
  111277. * Child classes can use it to update shaders
  111278. * @param mesh defines the mesh to check
  111279. * @param subMesh defines which submesh to check
  111280. * @param useInstances specifies that instances should be used
  111281. * @returns a boolean indicating that the submesh is ready or not
  111282. */
  111283. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111284. /**
  111285. * Builds the material UBO layouts.
  111286. * Used internally during the effect preparation.
  111287. */
  111288. buildUniformLayout(): void;
  111289. /**
  111290. * Unbinds the material from the mesh
  111291. */
  111292. unbind(): void;
  111293. /**
  111294. * Binds the submesh to this material by preparing the effect and shader to draw
  111295. * @param world defines the world transformation matrix
  111296. * @param mesh defines the mesh containing the submesh
  111297. * @param subMesh defines the submesh to bind the material to
  111298. */
  111299. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111300. /**
  111301. * Get the list of animatables in the material.
  111302. * @returns the list of animatables object used in the material
  111303. */
  111304. getAnimatables(): IAnimatable[];
  111305. /**
  111306. * Gets the active textures from the material
  111307. * @returns an array of textures
  111308. */
  111309. getActiveTextures(): BaseTexture[];
  111310. /**
  111311. * Specifies if the material uses a texture
  111312. * @param texture defines the texture to check against the material
  111313. * @returns a boolean specifying if the material uses the texture
  111314. */
  111315. hasTexture(texture: BaseTexture): boolean;
  111316. /**
  111317. * Disposes the material
  111318. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111319. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111320. */
  111321. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111322. /**
  111323. * Makes a duplicate of the material, and gives it a new name
  111324. * @param name defines the new name for the duplicated material
  111325. * @returns the cloned material
  111326. */
  111327. clone(name: string): StandardMaterial;
  111328. /**
  111329. * Serializes this material in a JSON representation
  111330. * @returns the serialized material object
  111331. */
  111332. serialize(): any;
  111333. /**
  111334. * Creates a standard material from parsed material data
  111335. * @param source defines the JSON representation of the material
  111336. * @param scene defines the hosting scene
  111337. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  111338. * @returns a new standard material
  111339. */
  111340. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  111341. /**
  111342. * Are diffuse textures enabled in the application.
  111343. */
  111344. static get DiffuseTextureEnabled(): boolean;
  111345. static set DiffuseTextureEnabled(value: boolean);
  111346. /**
  111347. * Are detail textures enabled in the application.
  111348. */
  111349. static get DetailTextureEnabled(): boolean;
  111350. static set DetailTextureEnabled(value: boolean);
  111351. /**
  111352. * Are ambient textures enabled in the application.
  111353. */
  111354. static get AmbientTextureEnabled(): boolean;
  111355. static set AmbientTextureEnabled(value: boolean);
  111356. /**
  111357. * Are opacity textures enabled in the application.
  111358. */
  111359. static get OpacityTextureEnabled(): boolean;
  111360. static set OpacityTextureEnabled(value: boolean);
  111361. /**
  111362. * Are reflection textures enabled in the application.
  111363. */
  111364. static get ReflectionTextureEnabled(): boolean;
  111365. static set ReflectionTextureEnabled(value: boolean);
  111366. /**
  111367. * Are emissive textures enabled in the application.
  111368. */
  111369. static get EmissiveTextureEnabled(): boolean;
  111370. static set EmissiveTextureEnabled(value: boolean);
  111371. /**
  111372. * Are specular textures enabled in the application.
  111373. */
  111374. static get SpecularTextureEnabled(): boolean;
  111375. static set SpecularTextureEnabled(value: boolean);
  111376. /**
  111377. * Are bump textures enabled in the application.
  111378. */
  111379. static get BumpTextureEnabled(): boolean;
  111380. static set BumpTextureEnabled(value: boolean);
  111381. /**
  111382. * Are lightmap textures enabled in the application.
  111383. */
  111384. static get LightmapTextureEnabled(): boolean;
  111385. static set LightmapTextureEnabled(value: boolean);
  111386. /**
  111387. * Are refraction textures enabled in the application.
  111388. */
  111389. static get RefractionTextureEnabled(): boolean;
  111390. static set RefractionTextureEnabled(value: boolean);
  111391. /**
  111392. * Are color grading textures enabled in the application.
  111393. */
  111394. static get ColorGradingTextureEnabled(): boolean;
  111395. static set ColorGradingTextureEnabled(value: boolean);
  111396. /**
  111397. * Are fresnels enabled in the application.
  111398. */
  111399. static get FresnelEnabled(): boolean;
  111400. static set FresnelEnabled(value: boolean);
  111401. }
  111402. }
  111403. declare module BABYLON {
  111404. /**
  111405. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111406. *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.
  111407. * The SPS is also a particle system. It provides some methods to manage the particles.
  111408. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111409. *
  111410. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  111411. */
  111412. export class SolidParticleSystem implements IDisposable {
  111413. /**
  111414. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111415. * Example : var p = SPS.particles[i];
  111416. */
  111417. particles: SolidParticle[];
  111418. /**
  111419. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111420. */
  111421. nbParticles: number;
  111422. /**
  111423. * If the particles must ever face the camera (default false). Useful for planar particles.
  111424. */
  111425. billboard: boolean;
  111426. /**
  111427. * Recompute normals when adding a shape
  111428. */
  111429. recomputeNormals: boolean;
  111430. /**
  111431. * This a counter ofr your own usage. It's not set by any SPS functions.
  111432. */
  111433. counter: number;
  111434. /**
  111435. * The SPS name. This name is also given to the underlying mesh.
  111436. */
  111437. name: string;
  111438. /**
  111439. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  111440. */
  111441. mesh: Mesh;
  111442. /**
  111443. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111444. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  111445. */
  111446. vars: any;
  111447. /**
  111448. * This array is populated when the SPS is set as 'pickable'.
  111449. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  111450. * Each element of this array is an object `{idx: int, faceId: int}`.
  111451. * `idx` is the picked particle index in the `SPS.particles` array
  111452. * `faceId` is the picked face index counted within this particle.
  111453. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  111454. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  111455. * Use the method SPS.pickedParticle(pickingInfo) instead.
  111456. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111457. */
  111458. pickedParticles: {
  111459. idx: number;
  111460. faceId: number;
  111461. }[];
  111462. /**
  111463. * This array is populated when the SPS is set as 'pickable'
  111464. * Each key of this array is a submesh index.
  111465. * Each element of this array is a second array defined like this :
  111466. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  111467. * Each element of this second array is an object `{idx: int, faceId: int}`.
  111468. * `idx` is the picked particle index in the `SPS.particles` array
  111469. * `faceId` is the picked face index counted within this particle.
  111470. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111471. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111472. */
  111473. pickedBySubMesh: {
  111474. idx: number;
  111475. faceId: number;
  111476. }[][];
  111477. /**
  111478. * This array is populated when `enableDepthSort` is set to true.
  111479. * Each element of this array is an instance of the class DepthSortedParticle.
  111480. */
  111481. depthSortedParticles: DepthSortedParticle[];
  111482. /**
  111483. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111484. * @hidden
  111485. */
  111486. _bSphereOnly: boolean;
  111487. /**
  111488. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111489. * @hidden
  111490. */
  111491. _bSphereRadiusFactor: number;
  111492. private _scene;
  111493. private _positions;
  111494. private _indices;
  111495. private _normals;
  111496. private _colors;
  111497. private _uvs;
  111498. private _indices32;
  111499. private _positions32;
  111500. private _normals32;
  111501. private _fixedNormal32;
  111502. private _colors32;
  111503. private _uvs32;
  111504. private _index;
  111505. private _updatable;
  111506. private _pickable;
  111507. private _isVisibilityBoxLocked;
  111508. private _alwaysVisible;
  111509. private _depthSort;
  111510. private _expandable;
  111511. private _shapeCounter;
  111512. private _copy;
  111513. private _color;
  111514. private _computeParticleColor;
  111515. private _computeParticleTexture;
  111516. private _computeParticleRotation;
  111517. private _computeParticleVertex;
  111518. private _computeBoundingBox;
  111519. private _depthSortParticles;
  111520. private _camera;
  111521. private _mustUnrotateFixedNormals;
  111522. private _particlesIntersect;
  111523. private _needs32Bits;
  111524. private _isNotBuilt;
  111525. private _lastParticleId;
  111526. private _idxOfId;
  111527. private _multimaterialEnabled;
  111528. private _useModelMaterial;
  111529. private _indicesByMaterial;
  111530. private _materialIndexes;
  111531. private _depthSortFunction;
  111532. private _materialSortFunction;
  111533. private _materials;
  111534. private _multimaterial;
  111535. private _materialIndexesById;
  111536. private _defaultMaterial;
  111537. private _autoUpdateSubMeshes;
  111538. private _tmpVertex;
  111539. /**
  111540. * Creates a SPS (Solid Particle System) object.
  111541. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111542. * @param scene (Scene) is the scene in which the SPS is added.
  111543. * @param options defines the options of the sps e.g.
  111544. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111545. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111546. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111547. * * 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.
  111548. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111549. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111550. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111551. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111552. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111553. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111554. */
  111555. constructor(name: string, scene: Scene, options?: {
  111556. updatable?: boolean;
  111557. isPickable?: boolean;
  111558. enableDepthSort?: boolean;
  111559. particleIntersection?: boolean;
  111560. boundingSphereOnly?: boolean;
  111561. bSphereRadiusFactor?: number;
  111562. expandable?: boolean;
  111563. useModelMaterial?: boolean;
  111564. enableMultiMaterial?: boolean;
  111565. });
  111566. /**
  111567. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111568. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111569. * @returns the created mesh
  111570. */
  111571. buildMesh(): Mesh;
  111572. /**
  111573. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111574. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111575. * Thus the particles generated from `digest()` have their property `position` set yet.
  111576. * @param mesh ( Mesh ) is the mesh to be digested
  111577. * @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
  111578. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111579. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111580. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111581. * @returns the current SPS
  111582. */
  111583. digest(mesh: Mesh, options?: {
  111584. facetNb?: number;
  111585. number?: number;
  111586. delta?: number;
  111587. storage?: [];
  111588. }): SolidParticleSystem;
  111589. /**
  111590. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111591. * @hidden
  111592. */
  111593. private _unrotateFixedNormals;
  111594. /**
  111595. * Resets the temporary working copy particle
  111596. * @hidden
  111597. */
  111598. private _resetCopy;
  111599. /**
  111600. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111601. * @param p the current index in the positions array to be updated
  111602. * @param ind the current index in the indices array
  111603. * @param shape a Vector3 array, the shape geometry
  111604. * @param positions the positions array to be updated
  111605. * @param meshInd the shape indices array
  111606. * @param indices the indices array to be updated
  111607. * @param meshUV the shape uv array
  111608. * @param uvs the uv array to be updated
  111609. * @param meshCol the shape color array
  111610. * @param colors the color array to be updated
  111611. * @param meshNor the shape normals array
  111612. * @param normals the normals array to be updated
  111613. * @param idx the particle index
  111614. * @param idxInShape the particle index in its shape
  111615. * @param options the addShape() method passed options
  111616. * @model the particle model
  111617. * @hidden
  111618. */
  111619. private _meshBuilder;
  111620. /**
  111621. * Returns a shape Vector3 array from positions float array
  111622. * @param positions float array
  111623. * @returns a vector3 array
  111624. * @hidden
  111625. */
  111626. private _posToShape;
  111627. /**
  111628. * Returns a shapeUV array from a float uvs (array deep copy)
  111629. * @param uvs as a float array
  111630. * @returns a shapeUV array
  111631. * @hidden
  111632. */
  111633. private _uvsToShapeUV;
  111634. /**
  111635. * Adds a new particle object in the particles array
  111636. * @param idx particle index in particles array
  111637. * @param id particle id
  111638. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111639. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111640. * @param model particle ModelShape object
  111641. * @param shapeId model shape identifier
  111642. * @param idxInShape index of the particle in the current model
  111643. * @param bInfo model bounding info object
  111644. * @param storage target storage array, if any
  111645. * @hidden
  111646. */
  111647. private _addParticle;
  111648. /**
  111649. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111650. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111651. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111652. * @param nb (positive integer) the number of particles to be created from this model
  111653. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111654. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111655. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111656. * @returns the number of shapes in the system
  111657. */
  111658. addShape(mesh: Mesh, nb: number, options?: {
  111659. positionFunction?: any;
  111660. vertexFunction?: any;
  111661. storage?: [];
  111662. }): number;
  111663. /**
  111664. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111665. * @hidden
  111666. */
  111667. private _rebuildParticle;
  111668. /**
  111669. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111670. * @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.
  111671. * @returns the SPS.
  111672. */
  111673. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111674. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111675. * Returns an array with the removed particles.
  111676. * 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.
  111677. * The SPS can't be empty so at least one particle needs to remain in place.
  111678. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111679. * @param start index of the first particle to remove
  111680. * @param end index of the last particle to remove (included)
  111681. * @returns an array populated with the removed particles
  111682. */
  111683. removeParticles(start: number, end: number): SolidParticle[];
  111684. /**
  111685. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111686. * @param solidParticleArray an array populated with Solid Particles objects
  111687. * @returns the SPS
  111688. */
  111689. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111690. /**
  111691. * Creates a new particle and modifies the SPS mesh geometry :
  111692. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111693. * - calls _addParticle() to populate the particle array
  111694. * factorized code from addShape() and insertParticlesFromArray()
  111695. * @param idx particle index in the particles array
  111696. * @param i particle index in its shape
  111697. * @param modelShape particle ModelShape object
  111698. * @param shape shape vertex array
  111699. * @param meshInd shape indices array
  111700. * @param meshUV shape uv array
  111701. * @param meshCol shape color array
  111702. * @param meshNor shape normals array
  111703. * @param bbInfo shape bounding info
  111704. * @param storage target particle storage
  111705. * @options addShape() passed options
  111706. * @hidden
  111707. */
  111708. private _insertNewParticle;
  111709. /**
  111710. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111711. * This method calls `updateParticle()` for each particle of the SPS.
  111712. * For an animated SPS, it is usually called within the render loop.
  111713. * 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.
  111714. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111715. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111716. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111717. * @returns the SPS.
  111718. */
  111719. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111720. /**
  111721. * Disposes the SPS.
  111722. */
  111723. dispose(): void;
  111724. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111725. * idx is the particle index in the SPS
  111726. * faceId is the picked face index counted within this particle.
  111727. * Returns null if the pickInfo can't identify a picked particle.
  111728. * @param pickingInfo (PickingInfo object)
  111729. * @returns {idx: number, faceId: number} or null
  111730. */
  111731. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111732. idx: number;
  111733. faceId: number;
  111734. }>;
  111735. /**
  111736. * Returns a SolidParticle object from its identifier : particle.id
  111737. * @param id (integer) the particle Id
  111738. * @returns the searched particle or null if not found in the SPS.
  111739. */
  111740. getParticleById(id: number): Nullable<SolidParticle>;
  111741. /**
  111742. * Returns a new array populated with the particles having the passed shapeId.
  111743. * @param shapeId (integer) the shape identifier
  111744. * @returns a new solid particle array
  111745. */
  111746. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111747. /**
  111748. * Populates the passed array "ref" with the particles having the passed shapeId.
  111749. * @param shapeId the shape identifier
  111750. * @returns the SPS
  111751. * @param ref
  111752. */
  111753. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111754. /**
  111755. * Computes the required SubMeshes according the materials assigned to the particles.
  111756. * @returns the solid particle system.
  111757. * Does nothing if called before the SPS mesh is built.
  111758. */
  111759. computeSubMeshes(): SolidParticleSystem;
  111760. /**
  111761. * Sorts the solid particles by material when MultiMaterial is enabled.
  111762. * Updates the indices32 array.
  111763. * Updates the indicesByMaterial array.
  111764. * Updates the mesh indices array.
  111765. * @returns the SPS
  111766. * @hidden
  111767. */
  111768. private _sortParticlesByMaterial;
  111769. /**
  111770. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111771. * @hidden
  111772. */
  111773. private _setMaterialIndexesById;
  111774. /**
  111775. * Returns an array with unique values of Materials from the passed array
  111776. * @param array the material array to be checked and filtered
  111777. * @hidden
  111778. */
  111779. private _filterUniqueMaterialId;
  111780. /**
  111781. * Sets a new Standard Material as _defaultMaterial if not already set.
  111782. * @hidden
  111783. */
  111784. private _setDefaultMaterial;
  111785. /**
  111786. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111787. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111788. * @returns the SPS.
  111789. */
  111790. refreshVisibleSize(): SolidParticleSystem;
  111791. /**
  111792. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111793. * @param size the size (float) of the visibility box
  111794. * note : this doesn't lock the SPS mesh bounding box.
  111795. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111796. */
  111797. setVisibilityBox(size: number): void;
  111798. /**
  111799. * Gets whether the SPS as always visible or not
  111800. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111801. */
  111802. get isAlwaysVisible(): boolean;
  111803. /**
  111804. * Sets the SPS as always visible or not
  111805. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111806. */
  111807. set isAlwaysVisible(val: boolean);
  111808. /**
  111809. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111810. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111811. */
  111812. set isVisibilityBoxLocked(val: boolean);
  111813. /**
  111814. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111815. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111816. */
  111817. get isVisibilityBoxLocked(): boolean;
  111818. /**
  111819. * Tells to `setParticles()` to compute the particle rotations or not.
  111820. * Default value : true. The SPS is faster when it's set to false.
  111821. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111822. */
  111823. set computeParticleRotation(val: boolean);
  111824. /**
  111825. * Tells to `setParticles()` to compute the particle colors or not.
  111826. * Default value : true. The SPS is faster when it's set to false.
  111827. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111828. */
  111829. set computeParticleColor(val: boolean);
  111830. set computeParticleTexture(val: boolean);
  111831. /**
  111832. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111833. * Default value : false. The SPS is faster when it's set to false.
  111834. * Note : the particle custom vertex positions aren't stored values.
  111835. */
  111836. set computeParticleVertex(val: boolean);
  111837. /**
  111838. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111839. */
  111840. set computeBoundingBox(val: boolean);
  111841. /**
  111842. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111843. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111844. * Default : `true`
  111845. */
  111846. set depthSortParticles(val: boolean);
  111847. /**
  111848. * Gets if `setParticles()` computes the particle rotations or not.
  111849. * Default value : true. The SPS is faster when it's set to false.
  111850. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111851. */
  111852. get computeParticleRotation(): boolean;
  111853. /**
  111854. * Gets if `setParticles()` computes the particle colors or not.
  111855. * Default value : true. The SPS is faster when it's set to false.
  111856. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111857. */
  111858. get computeParticleColor(): boolean;
  111859. /**
  111860. * Gets if `setParticles()` computes the particle textures or not.
  111861. * Default value : true. The SPS is faster when it's set to false.
  111862. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111863. */
  111864. get computeParticleTexture(): boolean;
  111865. /**
  111866. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111867. * Default value : false. The SPS is faster when it's set to false.
  111868. * Note : the particle custom vertex positions aren't stored values.
  111869. */
  111870. get computeParticleVertex(): boolean;
  111871. /**
  111872. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111873. */
  111874. get computeBoundingBox(): boolean;
  111875. /**
  111876. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111877. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111878. * Default : `true`
  111879. */
  111880. get depthSortParticles(): boolean;
  111881. /**
  111882. * Gets if the SPS is created as expandable at construction time.
  111883. * Default : `false`
  111884. */
  111885. get expandable(): boolean;
  111886. /**
  111887. * Gets if the SPS supports the Multi Materials
  111888. */
  111889. get multimaterialEnabled(): boolean;
  111890. /**
  111891. * Gets if the SPS uses the model materials for its own multimaterial.
  111892. */
  111893. get useModelMaterial(): boolean;
  111894. /**
  111895. * The SPS used material array.
  111896. */
  111897. get materials(): Material[];
  111898. /**
  111899. * Sets the SPS MultiMaterial from the passed materials.
  111900. * Note : the passed array is internally copied and not used then by reference.
  111901. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111902. */
  111903. setMultiMaterial(materials: Material[]): void;
  111904. /**
  111905. * The SPS computed multimaterial object
  111906. */
  111907. get multimaterial(): MultiMaterial;
  111908. set multimaterial(mm: MultiMaterial);
  111909. /**
  111910. * If the subMeshes must be updated on the next call to setParticles()
  111911. */
  111912. get autoUpdateSubMeshes(): boolean;
  111913. set autoUpdateSubMeshes(val: boolean);
  111914. /**
  111915. * This function does nothing. It may be overwritten to set all the particle first values.
  111916. * The SPS doesn't call this function, you may have to call it by your own.
  111917. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111918. */
  111919. initParticles(): void;
  111920. /**
  111921. * This function does nothing. It may be overwritten to recycle a particle.
  111922. * The SPS doesn't call this function, you may have to call it by your own.
  111923. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111924. * @param particle The particle to recycle
  111925. * @returns the recycled particle
  111926. */
  111927. recycleParticle(particle: SolidParticle): SolidParticle;
  111928. /**
  111929. * Updates a particle : this function should be overwritten by the user.
  111930. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111931. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111932. * @example : just set a particle position or velocity and recycle conditions
  111933. * @param particle The particle to update
  111934. * @returns the updated particle
  111935. */
  111936. updateParticle(particle: SolidParticle): SolidParticle;
  111937. /**
  111938. * Updates a vertex of a particle : it can be overwritten by the user.
  111939. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111940. * @param particle the current particle
  111941. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111942. * @param pt the index of the current vertex in the particle shape
  111943. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111944. * @example : just set a vertex particle position or color
  111945. * @returns the sps
  111946. */
  111947. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111948. /**
  111949. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111950. * This does nothing and may be overwritten by the user.
  111951. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111952. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111953. * @param update the boolean update value actually passed to setParticles()
  111954. */
  111955. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111956. /**
  111957. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111958. * This will be passed three parameters.
  111959. * This does nothing and may be overwritten by the user.
  111960. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111961. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111962. * @param update the boolean update value actually passed to setParticles()
  111963. */
  111964. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111965. }
  111966. }
  111967. declare module BABYLON {
  111968. /**
  111969. * Represents one particle of a solid particle system.
  111970. */
  111971. export class SolidParticle {
  111972. /**
  111973. * particle global index
  111974. */
  111975. idx: number;
  111976. /**
  111977. * particle identifier
  111978. */
  111979. id: number;
  111980. /**
  111981. * The color of the particle
  111982. */
  111983. color: Nullable<Color4>;
  111984. /**
  111985. * The world space position of the particle.
  111986. */
  111987. position: Vector3;
  111988. /**
  111989. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111990. */
  111991. rotation: Vector3;
  111992. /**
  111993. * The world space rotation quaternion of the particle.
  111994. */
  111995. rotationQuaternion: Nullable<Quaternion>;
  111996. /**
  111997. * The scaling of the particle.
  111998. */
  111999. scaling: Vector3;
  112000. /**
  112001. * The uvs of the particle.
  112002. */
  112003. uvs: Vector4;
  112004. /**
  112005. * The current speed of the particle.
  112006. */
  112007. velocity: Vector3;
  112008. /**
  112009. * The pivot point in the particle local space.
  112010. */
  112011. pivot: Vector3;
  112012. /**
  112013. * Must the particle be translated from its pivot point in its local space ?
  112014. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  112015. * Default : false
  112016. */
  112017. translateFromPivot: boolean;
  112018. /**
  112019. * Is the particle active or not ?
  112020. */
  112021. alive: boolean;
  112022. /**
  112023. * Is the particle visible or not ?
  112024. */
  112025. isVisible: boolean;
  112026. /**
  112027. * Index of this particle in the global "positions" array (Internal use)
  112028. * @hidden
  112029. */
  112030. _pos: number;
  112031. /**
  112032. * @hidden Index of this particle in the global "indices" array (Internal use)
  112033. */
  112034. _ind: number;
  112035. /**
  112036. * @hidden ModelShape of this particle (Internal use)
  112037. */
  112038. _model: ModelShape;
  112039. /**
  112040. * ModelShape id of this particle
  112041. */
  112042. shapeId: number;
  112043. /**
  112044. * Index of the particle in its shape id
  112045. */
  112046. idxInShape: number;
  112047. /**
  112048. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  112049. */
  112050. _modelBoundingInfo: BoundingInfo;
  112051. /**
  112052. * @hidden Particle BoundingInfo object (Internal use)
  112053. */
  112054. _boundingInfo: BoundingInfo;
  112055. /**
  112056. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  112057. */
  112058. _sps: SolidParticleSystem;
  112059. /**
  112060. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112061. */
  112062. _stillInvisible: boolean;
  112063. /**
  112064. * @hidden Last computed particle rotation matrix
  112065. */
  112066. _rotationMatrix: number[];
  112067. /**
  112068. * Parent particle Id, if any.
  112069. * Default null.
  112070. */
  112071. parentId: Nullable<number>;
  112072. /**
  112073. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  112074. */
  112075. materialIndex: Nullable<number>;
  112076. /**
  112077. * Custom object or properties.
  112078. */
  112079. props: Nullable<any>;
  112080. /**
  112081. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112082. * The possible values are :
  112083. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112084. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112085. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112086. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112087. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112088. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112089. * */
  112090. cullingStrategy: number;
  112091. /**
  112092. * @hidden Internal global position in the SPS.
  112093. */
  112094. _globalPosition: Vector3;
  112095. /**
  112096. * Creates a Solid Particle object.
  112097. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112098. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  112099. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  112100. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112101. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112102. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112103. * @param shapeId (integer) is the model shape identifier in the SPS.
  112104. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112105. * @param sps defines the sps it is associated to
  112106. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112107. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  112108. */
  112109. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  112110. /**
  112111. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  112112. * @param target the particle target
  112113. * @returns the current particle
  112114. */
  112115. copyToRef(target: SolidParticle): SolidParticle;
  112116. /**
  112117. * Legacy support, changed scale to scaling
  112118. */
  112119. get scale(): Vector3;
  112120. /**
  112121. * Legacy support, changed scale to scaling
  112122. */
  112123. set scale(scale: Vector3);
  112124. /**
  112125. * Legacy support, changed quaternion to rotationQuaternion
  112126. */
  112127. get quaternion(): Nullable<Quaternion>;
  112128. /**
  112129. * Legacy support, changed quaternion to rotationQuaternion
  112130. */
  112131. set quaternion(q: Nullable<Quaternion>);
  112132. /**
  112133. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112134. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112135. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112136. * @returns true if it intersects
  112137. */
  112138. intersectsMesh(target: Mesh | SolidParticle): boolean;
  112139. /**
  112140. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112141. * A particle is in the frustum if its bounding box intersects the frustum
  112142. * @param frustumPlanes defines the frustum to test
  112143. * @returns true if the particle is in the frustum planes
  112144. */
  112145. isInFrustum(frustumPlanes: Plane[]): boolean;
  112146. /**
  112147. * get the rotation matrix of the particle
  112148. * @hidden
  112149. */
  112150. getRotationMatrix(m: Matrix): void;
  112151. }
  112152. /**
  112153. * Represents the shape of the model used by one particle of a solid particle system.
  112154. * SPS internal tool, don't use it manually.
  112155. */
  112156. export class ModelShape {
  112157. /**
  112158. * The shape id
  112159. * @hidden
  112160. */
  112161. shapeID: number;
  112162. /**
  112163. * flat array of model positions (internal use)
  112164. * @hidden
  112165. */
  112166. _shape: Vector3[];
  112167. /**
  112168. * flat array of model UVs (internal use)
  112169. * @hidden
  112170. */
  112171. _shapeUV: number[];
  112172. /**
  112173. * color array of the model
  112174. * @hidden
  112175. */
  112176. _shapeColors: number[];
  112177. /**
  112178. * indices array of the model
  112179. * @hidden
  112180. */
  112181. _indices: number[];
  112182. /**
  112183. * normals array of the model
  112184. * @hidden
  112185. */
  112186. _normals: number[];
  112187. /**
  112188. * length of the shape in the model indices array (internal use)
  112189. * @hidden
  112190. */
  112191. _indicesLength: number;
  112192. /**
  112193. * Custom position function (internal use)
  112194. * @hidden
  112195. */
  112196. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  112197. /**
  112198. * Custom vertex function (internal use)
  112199. * @hidden
  112200. */
  112201. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  112202. /**
  112203. * Model material (internal use)
  112204. * @hidden
  112205. */
  112206. _material: Nullable<Material>;
  112207. /**
  112208. * 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.
  112209. * SPS internal tool, don't use it manually.
  112210. * @hidden
  112211. */
  112212. 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>);
  112213. }
  112214. /**
  112215. * Represents a Depth Sorted Particle in the solid particle system.
  112216. * @hidden
  112217. */
  112218. export class DepthSortedParticle {
  112219. /**
  112220. * Particle index
  112221. */
  112222. idx: number;
  112223. /**
  112224. * Index of the particle in the "indices" array
  112225. */
  112226. ind: number;
  112227. /**
  112228. * Length of the particle shape in the "indices" array
  112229. */
  112230. indicesLength: number;
  112231. /**
  112232. * Squared distance from the particle to the camera
  112233. */
  112234. sqDistance: number;
  112235. /**
  112236. * Material index when used with MultiMaterials
  112237. */
  112238. materialIndex: number;
  112239. /**
  112240. * Creates a new sorted particle
  112241. * @param materialIndex
  112242. */
  112243. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  112244. }
  112245. /**
  112246. * Represents a solid particle vertex
  112247. */
  112248. export class SolidParticleVertex {
  112249. /**
  112250. * Vertex position
  112251. */
  112252. position: Vector3;
  112253. /**
  112254. * Vertex color
  112255. */
  112256. color: Color4;
  112257. /**
  112258. * Vertex UV
  112259. */
  112260. uv: Vector2;
  112261. /**
  112262. * Creates a new solid particle vertex
  112263. */
  112264. constructor();
  112265. /** Vertex x coordinate */
  112266. get x(): number;
  112267. set x(val: number);
  112268. /** Vertex y coordinate */
  112269. get y(): number;
  112270. set y(val: number);
  112271. /** Vertex z coordinate */
  112272. get z(): number;
  112273. set z(val: number);
  112274. }
  112275. }
  112276. declare module BABYLON {
  112277. /**
  112278. * @hidden
  112279. */
  112280. export class _MeshCollisionData {
  112281. _checkCollisions: boolean;
  112282. _collisionMask: number;
  112283. _collisionGroup: number;
  112284. _surroundingMeshes: Nullable<AbstractMesh[]>;
  112285. _collider: Nullable<Collider>;
  112286. _oldPositionForCollisions: Vector3;
  112287. _diffPositionForCollisions: Vector3;
  112288. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  112289. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  112290. _collisionResponse: boolean;
  112291. }
  112292. }
  112293. declare module BABYLON {
  112294. /** @hidden */
  112295. class _FacetDataStorage {
  112296. facetPositions: Vector3[];
  112297. facetNormals: Vector3[];
  112298. facetPartitioning: number[][];
  112299. facetNb: number;
  112300. partitioningSubdivisions: number;
  112301. partitioningBBoxRatio: number;
  112302. facetDataEnabled: boolean;
  112303. facetParameters: any;
  112304. bbSize: Vector3;
  112305. subDiv: {
  112306. max: number;
  112307. X: number;
  112308. Y: number;
  112309. Z: number;
  112310. };
  112311. facetDepthSort: boolean;
  112312. facetDepthSortEnabled: boolean;
  112313. depthSortedIndices: IndicesArray;
  112314. depthSortedFacets: {
  112315. ind: number;
  112316. sqDistance: number;
  112317. }[];
  112318. facetDepthSortFunction: (f1: {
  112319. ind: number;
  112320. sqDistance: number;
  112321. }, f2: {
  112322. ind: number;
  112323. sqDistance: number;
  112324. }) => number;
  112325. facetDepthSortFrom: Vector3;
  112326. facetDepthSortOrigin: Vector3;
  112327. invertedMatrix: Matrix;
  112328. }
  112329. /**
  112330. * @hidden
  112331. **/
  112332. class _InternalAbstractMeshDataInfo {
  112333. _hasVertexAlpha: boolean;
  112334. _useVertexColors: boolean;
  112335. _numBoneInfluencers: number;
  112336. _applyFog: boolean;
  112337. _receiveShadows: boolean;
  112338. _facetData: _FacetDataStorage;
  112339. _visibility: number;
  112340. _skeleton: Nullable<Skeleton>;
  112341. _layerMask: number;
  112342. _computeBonesUsingShaders: boolean;
  112343. _isActive: boolean;
  112344. _onlyForInstances: boolean;
  112345. _isActiveIntermediate: boolean;
  112346. _onlyForInstancesIntermediate: boolean;
  112347. _actAsRegularMesh: boolean;
  112348. }
  112349. /**
  112350. * Class used to store all common mesh properties
  112351. */
  112352. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  112353. /** No occlusion */
  112354. static OCCLUSION_TYPE_NONE: number;
  112355. /** Occlusion set to optimisitic */
  112356. static OCCLUSION_TYPE_OPTIMISTIC: number;
  112357. /** Occlusion set to strict */
  112358. static OCCLUSION_TYPE_STRICT: number;
  112359. /** Use an accurante occlusion algorithm */
  112360. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  112361. /** Use a conservative occlusion algorithm */
  112362. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  112363. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  112364. * Test order :
  112365. * Is the bounding sphere outside the frustum ?
  112366. * If not, are the bounding box vertices outside the frustum ?
  112367. * It not, then the cullable object is in the frustum.
  112368. */
  112369. static readonly CULLINGSTRATEGY_STANDARD: number;
  112370. /** Culling strategy : Bounding Sphere Only.
  112371. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  112372. * It's also less accurate than the standard because some not visible objects can still be selected.
  112373. * Test : is the bounding sphere outside the frustum ?
  112374. * If not, then the cullable object is in the frustum.
  112375. */
  112376. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  112377. /** Culling strategy : Optimistic Inclusion.
  112378. * This in an inclusion test first, then the standard exclusion test.
  112379. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  112380. * 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.
  112381. * Anyway, it's as accurate as the standard strategy.
  112382. * Test :
  112383. * Is the cullable object bounding sphere center in the frustum ?
  112384. * If not, apply the default culling strategy.
  112385. */
  112386. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  112387. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  112388. * This in an inclusion test first, then the bounding sphere only exclusion test.
  112389. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  112390. * 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.
  112391. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  112392. * Test :
  112393. * Is the cullable object bounding sphere center in the frustum ?
  112394. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  112395. */
  112396. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  112397. /**
  112398. * No billboard
  112399. */
  112400. static get BILLBOARDMODE_NONE(): number;
  112401. /** Billboard on X axis */
  112402. static get BILLBOARDMODE_X(): number;
  112403. /** Billboard on Y axis */
  112404. static get BILLBOARDMODE_Y(): number;
  112405. /** Billboard on Z axis */
  112406. static get BILLBOARDMODE_Z(): number;
  112407. /** Billboard on all axes */
  112408. static get BILLBOARDMODE_ALL(): number;
  112409. /** Billboard on using position instead of orientation */
  112410. static get BILLBOARDMODE_USE_POSITION(): number;
  112411. /** @hidden */
  112412. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  112413. /**
  112414. * The culling strategy to use to check whether the mesh must be rendered or not.
  112415. * This value can be changed at any time and will be used on the next render mesh selection.
  112416. * The possible values are :
  112417. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112418. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112419. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112420. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112421. * Please read each static variable documentation to get details about the culling process.
  112422. * */
  112423. cullingStrategy: number;
  112424. /**
  112425. * Gets the number of facets in the mesh
  112426. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112427. */
  112428. get facetNb(): number;
  112429. /**
  112430. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  112431. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112432. */
  112433. get partitioningSubdivisions(): number;
  112434. set partitioningSubdivisions(nb: number);
  112435. /**
  112436. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  112437. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  112438. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112439. */
  112440. get partitioningBBoxRatio(): number;
  112441. set partitioningBBoxRatio(ratio: number);
  112442. /**
  112443. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  112444. * Works only for updatable meshes.
  112445. * Doesn't work with multi-materials
  112446. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112447. */
  112448. get mustDepthSortFacets(): boolean;
  112449. set mustDepthSortFacets(sort: boolean);
  112450. /**
  112451. * The location (Vector3) where the facet depth sort must be computed from.
  112452. * By default, the active camera position.
  112453. * Used only when facet depth sort is enabled
  112454. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112455. */
  112456. get facetDepthSortFrom(): Vector3;
  112457. set facetDepthSortFrom(location: Vector3);
  112458. /**
  112459. * gets a boolean indicating if facetData is enabled
  112460. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112461. */
  112462. get isFacetDataEnabled(): boolean;
  112463. /** @hidden */
  112464. _updateNonUniformScalingState(value: boolean): boolean;
  112465. /**
  112466. * An event triggered when this mesh collides with another one
  112467. */
  112468. onCollideObservable: Observable<AbstractMesh>;
  112469. /** Set a function to call when this mesh collides with another one */
  112470. set onCollide(callback: () => void);
  112471. /**
  112472. * An event triggered when the collision's position changes
  112473. */
  112474. onCollisionPositionChangeObservable: Observable<Vector3>;
  112475. /** Set a function to call when the collision's position changes */
  112476. set onCollisionPositionChange(callback: () => void);
  112477. /**
  112478. * An event triggered when material is changed
  112479. */
  112480. onMaterialChangedObservable: Observable<AbstractMesh>;
  112481. /**
  112482. * Gets or sets the orientation for POV movement & rotation
  112483. */
  112484. definedFacingForward: boolean;
  112485. /** @hidden */
  112486. _occlusionQuery: Nullable<WebGLQuery>;
  112487. /** @hidden */
  112488. _renderingGroup: Nullable<RenderingGroup>;
  112489. /**
  112490. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112491. */
  112492. get visibility(): number;
  112493. /**
  112494. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112495. */
  112496. set visibility(value: number);
  112497. /** Gets or sets the alpha index used to sort transparent meshes
  112498. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112499. */
  112500. alphaIndex: number;
  112501. /**
  112502. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112503. */
  112504. isVisible: boolean;
  112505. /**
  112506. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112507. */
  112508. isPickable: boolean;
  112509. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112510. showSubMeshesBoundingBox: boolean;
  112511. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112512. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112513. */
  112514. isBlocker: boolean;
  112515. /**
  112516. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112517. */
  112518. enablePointerMoveEvents: boolean;
  112519. private _renderingGroupId;
  112520. /**
  112521. * Specifies the rendering group id for this mesh (0 by default)
  112522. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112523. */
  112524. get renderingGroupId(): number;
  112525. set renderingGroupId(value: number);
  112526. private _material;
  112527. /** Gets or sets current material */
  112528. get material(): Nullable<Material>;
  112529. set material(value: Nullable<Material>);
  112530. /**
  112531. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112532. * @see https://doc.babylonjs.com/babylon101/shadows
  112533. */
  112534. get receiveShadows(): boolean;
  112535. set receiveShadows(value: boolean);
  112536. /** Defines color to use when rendering outline */
  112537. outlineColor: Color3;
  112538. /** Define width to use when rendering outline */
  112539. outlineWidth: number;
  112540. /** Defines color to use when rendering overlay */
  112541. overlayColor: Color3;
  112542. /** Defines alpha to use when rendering overlay */
  112543. overlayAlpha: number;
  112544. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112545. get hasVertexAlpha(): boolean;
  112546. set hasVertexAlpha(value: boolean);
  112547. /** 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) */
  112548. get useVertexColors(): boolean;
  112549. set useVertexColors(value: boolean);
  112550. /**
  112551. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112552. */
  112553. get computeBonesUsingShaders(): boolean;
  112554. set computeBonesUsingShaders(value: boolean);
  112555. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112556. get numBoneInfluencers(): number;
  112557. set numBoneInfluencers(value: number);
  112558. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112559. get applyFog(): boolean;
  112560. set applyFog(value: boolean);
  112561. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112562. useOctreeForRenderingSelection: boolean;
  112563. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112564. useOctreeForPicking: boolean;
  112565. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112566. useOctreeForCollisions: boolean;
  112567. /**
  112568. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112569. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112570. */
  112571. get layerMask(): number;
  112572. set layerMask(value: number);
  112573. /**
  112574. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112575. */
  112576. alwaysSelectAsActiveMesh: boolean;
  112577. /**
  112578. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112579. */
  112580. doNotSyncBoundingInfo: boolean;
  112581. /**
  112582. * Gets or sets the current action manager
  112583. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112584. */
  112585. actionManager: Nullable<AbstractActionManager>;
  112586. private _meshCollisionData;
  112587. /**
  112588. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112589. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112590. */
  112591. ellipsoid: Vector3;
  112592. /**
  112593. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112594. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112595. */
  112596. ellipsoidOffset: Vector3;
  112597. /**
  112598. * Gets or sets a collision mask used to mask collisions (default is -1).
  112599. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112600. */
  112601. get collisionMask(): number;
  112602. set collisionMask(mask: number);
  112603. /**
  112604. * Gets or sets a collision response flag (default is true).
  112605. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112606. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112607. * to respond to the collision.
  112608. */
  112609. get collisionResponse(): boolean;
  112610. set collisionResponse(response: boolean);
  112611. /**
  112612. * Gets or sets the current collision group mask (-1 by default).
  112613. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112614. */
  112615. get collisionGroup(): number;
  112616. set collisionGroup(mask: number);
  112617. /**
  112618. * Gets or sets current surrounding meshes (null by default).
  112619. *
  112620. * By default collision detection is tested against every mesh in the scene.
  112621. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112622. * meshes will be tested for the collision.
  112623. *
  112624. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112625. */
  112626. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112627. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112628. /**
  112629. * Defines edge width used when edgesRenderer is enabled
  112630. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112631. */
  112632. edgesWidth: number;
  112633. /**
  112634. * Defines edge color used when edgesRenderer is enabled
  112635. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112636. */
  112637. edgesColor: Color4;
  112638. /** @hidden */
  112639. _edgesRenderer: Nullable<IEdgesRenderer>;
  112640. /** @hidden */
  112641. _masterMesh: Nullable<AbstractMesh>;
  112642. /** @hidden */
  112643. _boundingInfo: Nullable<BoundingInfo>;
  112644. /** @hidden */
  112645. _renderId: number;
  112646. /**
  112647. * Gets or sets the list of subMeshes
  112648. * @see https://doc.babylonjs.com/how_to/multi_materials
  112649. */
  112650. subMeshes: SubMesh[];
  112651. /** @hidden */
  112652. _intersectionsInProgress: AbstractMesh[];
  112653. /** @hidden */
  112654. _unIndexed: boolean;
  112655. /** @hidden */
  112656. _lightSources: Light[];
  112657. /** Gets the list of lights affecting that mesh */
  112658. get lightSources(): Light[];
  112659. /** @hidden */
  112660. get _positions(): Nullable<Vector3[]>;
  112661. /** @hidden */
  112662. _waitingData: {
  112663. lods: Nullable<any>;
  112664. actions: Nullable<any>;
  112665. freezeWorldMatrix: Nullable<boolean>;
  112666. };
  112667. /** @hidden */
  112668. _bonesTransformMatrices: Nullable<Float32Array>;
  112669. /** @hidden */
  112670. _transformMatrixTexture: Nullable<RawTexture>;
  112671. /**
  112672. * Gets or sets a skeleton to apply skining transformations
  112673. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112674. */
  112675. set skeleton(value: Nullable<Skeleton>);
  112676. get skeleton(): Nullable<Skeleton>;
  112677. /**
  112678. * An event triggered when the mesh is rebuilt.
  112679. */
  112680. onRebuildObservable: Observable<AbstractMesh>;
  112681. /**
  112682. * Creates a new AbstractMesh
  112683. * @param name defines the name of the mesh
  112684. * @param scene defines the hosting scene
  112685. */
  112686. constructor(name: string, scene?: Nullable<Scene>);
  112687. /**
  112688. * Returns the string "AbstractMesh"
  112689. * @returns "AbstractMesh"
  112690. */
  112691. getClassName(): string;
  112692. /**
  112693. * Gets a string representation of the current mesh
  112694. * @param fullDetails defines a boolean indicating if full details must be included
  112695. * @returns a string representation of the current mesh
  112696. */
  112697. toString(fullDetails?: boolean): string;
  112698. /**
  112699. * @hidden
  112700. */
  112701. protected _getEffectiveParent(): Nullable<Node>;
  112702. /** @hidden */
  112703. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112704. /** @hidden */
  112705. _rebuild(): void;
  112706. /** @hidden */
  112707. _resyncLightSources(): void;
  112708. /** @hidden */
  112709. _resyncLightSource(light: Light): void;
  112710. /** @hidden */
  112711. _unBindEffect(): void;
  112712. /** @hidden */
  112713. _removeLightSource(light: Light, dispose: boolean): void;
  112714. private _markSubMeshesAsDirty;
  112715. /** @hidden */
  112716. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112717. /** @hidden */
  112718. _markSubMeshesAsAttributesDirty(): void;
  112719. /** @hidden */
  112720. _markSubMeshesAsMiscDirty(): void;
  112721. /**
  112722. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112723. */
  112724. get scaling(): Vector3;
  112725. set scaling(newScaling: Vector3);
  112726. /**
  112727. * Returns true if the mesh is blocked. Implemented by child classes
  112728. */
  112729. get isBlocked(): boolean;
  112730. /**
  112731. * Returns the mesh itself by default. Implemented by child classes
  112732. * @param camera defines the camera to use to pick the right LOD level
  112733. * @returns the currentAbstractMesh
  112734. */
  112735. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112736. /**
  112737. * Returns 0 by default. Implemented by child classes
  112738. * @returns an integer
  112739. */
  112740. getTotalVertices(): number;
  112741. /**
  112742. * Returns a positive integer : the total number of indices in this mesh geometry.
  112743. * @returns the numner of indices or zero if the mesh has no geometry.
  112744. */
  112745. getTotalIndices(): number;
  112746. /**
  112747. * Returns null by default. Implemented by child classes
  112748. * @returns null
  112749. */
  112750. getIndices(): Nullable<IndicesArray>;
  112751. /**
  112752. * Returns the array of the requested vertex data kind. Implemented by child classes
  112753. * @param kind defines the vertex data kind to use
  112754. * @returns null
  112755. */
  112756. getVerticesData(kind: string): Nullable<FloatArray>;
  112757. /**
  112758. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112759. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112760. * Note that a new underlying VertexBuffer object is created each call.
  112761. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112762. * @param kind defines vertex data kind:
  112763. * * VertexBuffer.PositionKind
  112764. * * VertexBuffer.UVKind
  112765. * * VertexBuffer.UV2Kind
  112766. * * VertexBuffer.UV3Kind
  112767. * * VertexBuffer.UV4Kind
  112768. * * VertexBuffer.UV5Kind
  112769. * * VertexBuffer.UV6Kind
  112770. * * VertexBuffer.ColorKind
  112771. * * VertexBuffer.MatricesIndicesKind
  112772. * * VertexBuffer.MatricesIndicesExtraKind
  112773. * * VertexBuffer.MatricesWeightsKind
  112774. * * VertexBuffer.MatricesWeightsExtraKind
  112775. * @param data defines the data source
  112776. * @param updatable defines if the data must be flagged as updatable (or static)
  112777. * @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
  112778. * @returns the current mesh
  112779. */
  112780. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112781. /**
  112782. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112783. * If the mesh has no geometry, it is simply returned as it is.
  112784. * @param kind defines vertex data kind:
  112785. * * VertexBuffer.PositionKind
  112786. * * VertexBuffer.UVKind
  112787. * * VertexBuffer.UV2Kind
  112788. * * VertexBuffer.UV3Kind
  112789. * * VertexBuffer.UV4Kind
  112790. * * VertexBuffer.UV5Kind
  112791. * * VertexBuffer.UV6Kind
  112792. * * VertexBuffer.ColorKind
  112793. * * VertexBuffer.MatricesIndicesKind
  112794. * * VertexBuffer.MatricesIndicesExtraKind
  112795. * * VertexBuffer.MatricesWeightsKind
  112796. * * VertexBuffer.MatricesWeightsExtraKind
  112797. * @param data defines the data source
  112798. * @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
  112799. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112800. * @returns the current mesh
  112801. */
  112802. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112803. /**
  112804. * Sets the mesh indices,
  112805. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112806. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112807. * @param totalVertices Defines the total number of vertices
  112808. * @returns the current mesh
  112809. */
  112810. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112811. /**
  112812. * Gets a boolean indicating if specific vertex data is present
  112813. * @param kind defines the vertex data kind to use
  112814. * @returns true is data kind is present
  112815. */
  112816. isVerticesDataPresent(kind: string): boolean;
  112817. /**
  112818. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112819. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112820. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112821. * @returns a BoundingInfo
  112822. */
  112823. getBoundingInfo(): BoundingInfo;
  112824. /**
  112825. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112826. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112827. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112828. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112829. * @returns the current mesh
  112830. */
  112831. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112832. /**
  112833. * Overwrite the current bounding info
  112834. * @param boundingInfo defines the new bounding info
  112835. * @returns the current mesh
  112836. */
  112837. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112838. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112839. get useBones(): boolean;
  112840. /** @hidden */
  112841. _preActivate(): void;
  112842. /** @hidden */
  112843. _preActivateForIntermediateRendering(renderId: number): void;
  112844. /** @hidden */
  112845. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112846. /** @hidden */
  112847. _postActivate(): void;
  112848. /** @hidden */
  112849. _freeze(): void;
  112850. /** @hidden */
  112851. _unFreeze(): void;
  112852. /**
  112853. * Gets the current world matrix
  112854. * @returns a Matrix
  112855. */
  112856. getWorldMatrix(): Matrix;
  112857. /** @hidden */
  112858. _getWorldMatrixDeterminant(): number;
  112859. /**
  112860. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112861. */
  112862. get isAnInstance(): boolean;
  112863. /**
  112864. * Gets a boolean indicating if this mesh has instances
  112865. */
  112866. get hasInstances(): boolean;
  112867. /**
  112868. * Gets a boolean indicating if this mesh has thin instances
  112869. */
  112870. get hasThinInstances(): boolean;
  112871. /**
  112872. * Perform relative position change from the point of view of behind the front of the mesh.
  112873. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112874. * Supports definition of mesh facing forward or backward
  112875. * @param amountRight defines the distance on the right axis
  112876. * @param amountUp defines the distance on the up axis
  112877. * @param amountForward defines the distance on the forward axis
  112878. * @returns the current mesh
  112879. */
  112880. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112881. /**
  112882. * Calculate relative position change from the point of view of behind the front of the mesh.
  112883. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112884. * Supports definition of mesh facing forward or backward
  112885. * @param amountRight defines the distance on the right axis
  112886. * @param amountUp defines the distance on the up axis
  112887. * @param amountForward defines the distance on the forward axis
  112888. * @returns the new displacement vector
  112889. */
  112890. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112891. /**
  112892. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112893. * Supports definition of mesh facing forward or backward
  112894. * @param flipBack defines the flip
  112895. * @param twirlClockwise defines the twirl
  112896. * @param tiltRight defines the tilt
  112897. * @returns the current mesh
  112898. */
  112899. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112900. /**
  112901. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112902. * Supports definition of mesh facing forward or backward.
  112903. * @param flipBack defines the flip
  112904. * @param twirlClockwise defines the twirl
  112905. * @param tiltRight defines the tilt
  112906. * @returns the new rotation vector
  112907. */
  112908. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112909. /**
  112910. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112911. * This means the mesh underlying bounding box and sphere are recomputed.
  112912. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112913. * @returns the current mesh
  112914. */
  112915. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112916. /** @hidden */
  112917. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112918. /** @hidden */
  112919. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112920. /** @hidden */
  112921. _updateBoundingInfo(): AbstractMesh;
  112922. /** @hidden */
  112923. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112924. /** @hidden */
  112925. protected _afterComputeWorldMatrix(): void;
  112926. /** @hidden */
  112927. get _effectiveMesh(): AbstractMesh;
  112928. /**
  112929. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112930. * A mesh is in the frustum if its bounding box intersects the frustum
  112931. * @param frustumPlanes defines the frustum to test
  112932. * @returns true if the mesh is in the frustum planes
  112933. */
  112934. isInFrustum(frustumPlanes: Plane[]): boolean;
  112935. /**
  112936. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112937. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112938. * @param frustumPlanes defines the frustum to test
  112939. * @returns true if the mesh is completely in the frustum planes
  112940. */
  112941. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112942. /**
  112943. * True if the mesh intersects another mesh or a SolidParticle object
  112944. * @param mesh defines a target mesh or SolidParticle to test
  112945. * @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)
  112946. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112947. * @returns true if there is an intersection
  112948. */
  112949. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112950. /**
  112951. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112952. * @param point defines the point to test
  112953. * @returns true if there is an intersection
  112954. */
  112955. intersectsPoint(point: Vector3): boolean;
  112956. /**
  112957. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112958. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112959. */
  112960. get checkCollisions(): boolean;
  112961. set checkCollisions(collisionEnabled: boolean);
  112962. /**
  112963. * Gets Collider object used to compute collisions (not physics)
  112964. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112965. */
  112966. get collider(): Nullable<Collider>;
  112967. /**
  112968. * Move the mesh using collision engine
  112969. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112970. * @param displacement defines the requested displacement vector
  112971. * @returns the current mesh
  112972. */
  112973. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112974. private _onCollisionPositionChange;
  112975. /** @hidden */
  112976. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112977. /** @hidden */
  112978. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112979. /** @hidden */
  112980. _checkCollision(collider: Collider): AbstractMesh;
  112981. /** @hidden */
  112982. _generatePointsArray(): boolean;
  112983. /**
  112984. * Checks if the passed Ray intersects with the mesh
  112985. * @param ray defines the ray to use
  112986. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112987. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112988. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112989. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112990. * @returns the picking info
  112991. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112992. */
  112993. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112994. /**
  112995. * Clones the current mesh
  112996. * @param name defines the mesh name
  112997. * @param newParent defines the new mesh parent
  112998. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112999. * @returns the new mesh
  113000. */
  113001. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  113002. /**
  113003. * Disposes all the submeshes of the current meshnp
  113004. * @returns the current mesh
  113005. */
  113006. releaseSubMeshes(): AbstractMesh;
  113007. /**
  113008. * Releases resources associated with this abstract mesh.
  113009. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113010. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113011. */
  113012. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113013. /**
  113014. * Adds the passed mesh as a child to the current mesh
  113015. * @param mesh defines the child mesh
  113016. * @returns the current mesh
  113017. */
  113018. addChild(mesh: AbstractMesh): AbstractMesh;
  113019. /**
  113020. * Removes the passed mesh from the current mesh children list
  113021. * @param mesh defines the child mesh
  113022. * @returns the current mesh
  113023. */
  113024. removeChild(mesh: AbstractMesh): AbstractMesh;
  113025. /** @hidden */
  113026. private _initFacetData;
  113027. /**
  113028. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  113029. * This method can be called within the render loop.
  113030. * 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
  113031. * @returns the current mesh
  113032. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113033. */
  113034. updateFacetData(): AbstractMesh;
  113035. /**
  113036. * Returns the facetLocalNormals array.
  113037. * The normals are expressed in the mesh local spac
  113038. * @returns an array of Vector3
  113039. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113040. */
  113041. getFacetLocalNormals(): Vector3[];
  113042. /**
  113043. * Returns the facetLocalPositions array.
  113044. * The facet positions are expressed in the mesh local space
  113045. * @returns an array of Vector3
  113046. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113047. */
  113048. getFacetLocalPositions(): Vector3[];
  113049. /**
  113050. * Returns the facetLocalPartioning array
  113051. * @returns an array of array of numbers
  113052. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113053. */
  113054. getFacetLocalPartitioning(): number[][];
  113055. /**
  113056. * Returns the i-th facet position in the world system.
  113057. * This method allocates a new Vector3 per call
  113058. * @param i defines the facet index
  113059. * @returns a new Vector3
  113060. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113061. */
  113062. getFacetPosition(i: number): Vector3;
  113063. /**
  113064. * Sets the reference Vector3 with the i-th facet position in the world system
  113065. * @param i defines the facet index
  113066. * @param ref defines the target vector
  113067. * @returns the current mesh
  113068. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113069. */
  113070. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  113071. /**
  113072. * Returns the i-th facet normal in the world system.
  113073. * This method allocates a new Vector3 per call
  113074. * @param i defines the facet index
  113075. * @returns a new Vector3
  113076. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113077. */
  113078. getFacetNormal(i: number): Vector3;
  113079. /**
  113080. * Sets the reference Vector3 with the i-th facet normal in the world system
  113081. * @param i defines the facet index
  113082. * @param ref defines the target vector
  113083. * @returns the current mesh
  113084. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113085. */
  113086. getFacetNormalToRef(i: number, ref: Vector3): this;
  113087. /**
  113088. * 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)
  113089. * @param x defines x coordinate
  113090. * @param y defines y coordinate
  113091. * @param z defines z coordinate
  113092. * @returns the array of facet indexes
  113093. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113094. */
  113095. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  113096. /**
  113097. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  113098. * @param projected sets as the (x,y,z) world projection on the facet
  113099. * @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
  113100. * @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
  113101. * @param x defines x coordinate
  113102. * @param y defines y coordinate
  113103. * @param z defines z coordinate
  113104. * @returns the face index if found (or null instead)
  113105. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113106. */
  113107. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113108. /**
  113109. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  113110. * @param projected sets as the (x,y,z) local projection on the facet
  113111. * @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
  113112. * @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
  113113. * @param x defines x coordinate
  113114. * @param y defines y coordinate
  113115. * @param z defines z coordinate
  113116. * @returns the face index if found (or null instead)
  113117. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113118. */
  113119. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113120. /**
  113121. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  113122. * @returns the parameters
  113123. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113124. */
  113125. getFacetDataParameters(): any;
  113126. /**
  113127. * Disables the feature FacetData and frees the related memory
  113128. * @returns the current mesh
  113129. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113130. */
  113131. disableFacetData(): AbstractMesh;
  113132. /**
  113133. * Updates the AbstractMesh indices array
  113134. * @param indices defines the data source
  113135. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113136. * @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)
  113137. * @returns the current mesh
  113138. */
  113139. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113140. /**
  113141. * Creates new normals data for the mesh
  113142. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  113143. * @returns the current mesh
  113144. */
  113145. createNormals(updatable: boolean): AbstractMesh;
  113146. /**
  113147. * Align the mesh with a normal
  113148. * @param normal defines the normal to use
  113149. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  113150. * @returns the current mesh
  113151. */
  113152. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  113153. /** @hidden */
  113154. _checkOcclusionQuery(): boolean;
  113155. /**
  113156. * Disables the mesh edge rendering mode
  113157. * @returns the currentAbstractMesh
  113158. */
  113159. disableEdgesRendering(): AbstractMesh;
  113160. /**
  113161. * Enables the edge rendering mode on the mesh.
  113162. * This mode makes the mesh edges visible
  113163. * @param epsilon defines the maximal distance between two angles to detect a face
  113164. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113165. * @returns the currentAbstractMesh
  113166. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113167. */
  113168. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113169. /**
  113170. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  113171. * @returns an array of particle systems in the scene that use the mesh as an emitter
  113172. */
  113173. getConnectedParticleSystems(): IParticleSystem[];
  113174. }
  113175. }
  113176. declare module BABYLON {
  113177. /**
  113178. * Interface used to define ActionEvent
  113179. */
  113180. export interface IActionEvent {
  113181. /** The mesh or sprite that triggered the action */
  113182. source: any;
  113183. /** The X mouse cursor position at the time of the event */
  113184. pointerX: number;
  113185. /** The Y mouse cursor position at the time of the event */
  113186. pointerY: number;
  113187. /** The mesh that is currently pointed at (can be null) */
  113188. meshUnderPointer: Nullable<AbstractMesh>;
  113189. /** the original (browser) event that triggered the ActionEvent */
  113190. sourceEvent?: any;
  113191. /** additional data for the event */
  113192. additionalData?: any;
  113193. }
  113194. /**
  113195. * ActionEvent is the event being sent when an action is triggered.
  113196. */
  113197. export class ActionEvent implements IActionEvent {
  113198. /** The mesh or sprite that triggered the action */
  113199. source: any;
  113200. /** The X mouse cursor position at the time of the event */
  113201. pointerX: number;
  113202. /** The Y mouse cursor position at the time of the event */
  113203. pointerY: number;
  113204. /** The mesh that is currently pointed at (can be null) */
  113205. meshUnderPointer: Nullable<AbstractMesh>;
  113206. /** the original (browser) event that triggered the ActionEvent */
  113207. sourceEvent?: any;
  113208. /** additional data for the event */
  113209. additionalData?: any;
  113210. /**
  113211. * Creates a new ActionEvent
  113212. * @param source The mesh or sprite that triggered the action
  113213. * @param pointerX The X mouse cursor position at the time of the event
  113214. * @param pointerY The Y mouse cursor position at the time of the event
  113215. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  113216. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  113217. * @param additionalData additional data for the event
  113218. */
  113219. constructor(
  113220. /** The mesh or sprite that triggered the action */
  113221. source: any,
  113222. /** The X mouse cursor position at the time of the event */
  113223. pointerX: number,
  113224. /** The Y mouse cursor position at the time of the event */
  113225. pointerY: number,
  113226. /** The mesh that is currently pointed at (can be null) */
  113227. meshUnderPointer: Nullable<AbstractMesh>,
  113228. /** the original (browser) event that triggered the ActionEvent */
  113229. sourceEvent?: any,
  113230. /** additional data for the event */
  113231. additionalData?: any);
  113232. /**
  113233. * Helper function to auto-create an ActionEvent from a source mesh.
  113234. * @param source The source mesh that triggered the event
  113235. * @param evt The original (browser) event
  113236. * @param additionalData additional data for the event
  113237. * @returns the new ActionEvent
  113238. */
  113239. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  113240. /**
  113241. * Helper function to auto-create an ActionEvent from a source sprite
  113242. * @param source The source sprite that triggered the event
  113243. * @param scene Scene associated with the sprite
  113244. * @param evt The original (browser) event
  113245. * @param additionalData additional data for the event
  113246. * @returns the new ActionEvent
  113247. */
  113248. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  113249. /**
  113250. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  113251. * @param scene the scene where the event occurred
  113252. * @param evt The original (browser) event
  113253. * @returns the new ActionEvent
  113254. */
  113255. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  113256. /**
  113257. * Helper function to auto-create an ActionEvent from a primitive
  113258. * @param prim defines the target primitive
  113259. * @param pointerPos defines the pointer position
  113260. * @param evt The original (browser) event
  113261. * @param additionalData additional data for the event
  113262. * @returns the new ActionEvent
  113263. */
  113264. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  113265. }
  113266. }
  113267. declare module BABYLON {
  113268. /**
  113269. * Abstract class used to decouple action Manager from scene and meshes.
  113270. * Do not instantiate.
  113271. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  113272. */
  113273. export abstract class AbstractActionManager implements IDisposable {
  113274. /** Gets the list of active triggers */
  113275. static Triggers: {
  113276. [key: string]: number;
  113277. };
  113278. /** Gets the cursor to use when hovering items */
  113279. hoverCursor: string;
  113280. /** Gets the list of actions */
  113281. actions: IAction[];
  113282. /**
  113283. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  113284. */
  113285. isRecursive: boolean;
  113286. /**
  113287. * Releases all associated resources
  113288. */
  113289. abstract dispose(): void;
  113290. /**
  113291. * Does this action manager has pointer triggers
  113292. */
  113293. abstract get hasPointerTriggers(): boolean;
  113294. /**
  113295. * Does this action manager has pick triggers
  113296. */
  113297. abstract get hasPickTriggers(): boolean;
  113298. /**
  113299. * Process a specific trigger
  113300. * @param trigger defines the trigger to process
  113301. * @param evt defines the event details to be processed
  113302. */
  113303. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  113304. /**
  113305. * Does this action manager handles actions of any of the given triggers
  113306. * @param triggers defines the triggers to be tested
  113307. * @return a boolean indicating whether one (or more) of the triggers is handled
  113308. */
  113309. abstract hasSpecificTriggers(triggers: number[]): boolean;
  113310. /**
  113311. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  113312. * speed.
  113313. * @param triggerA defines the trigger to be tested
  113314. * @param triggerB defines the trigger to be tested
  113315. * @return a boolean indicating whether one (or more) of the triggers is handled
  113316. */
  113317. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  113318. /**
  113319. * Does this action manager handles actions of a given trigger
  113320. * @param trigger defines the trigger to be tested
  113321. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  113322. * @return whether the trigger is handled
  113323. */
  113324. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  113325. /**
  113326. * Serialize this manager to a JSON object
  113327. * @param name defines the property name to store this manager
  113328. * @returns a JSON representation of this manager
  113329. */
  113330. abstract serialize(name: string): any;
  113331. /**
  113332. * Registers an action to this action manager
  113333. * @param action defines the action to be registered
  113334. * @return the action amended (prepared) after registration
  113335. */
  113336. abstract registerAction(action: IAction): Nullable<IAction>;
  113337. /**
  113338. * Unregisters an action to this action manager
  113339. * @param action defines the action to be unregistered
  113340. * @return a boolean indicating whether the action has been unregistered
  113341. */
  113342. abstract unregisterAction(action: IAction): Boolean;
  113343. /**
  113344. * Does exist one action manager with at least one trigger
  113345. **/
  113346. static get HasTriggers(): boolean;
  113347. /**
  113348. * Does exist one action manager with at least one pick trigger
  113349. **/
  113350. static get HasPickTriggers(): boolean;
  113351. /**
  113352. * Does exist one action manager that handles actions of a given trigger
  113353. * @param trigger defines the trigger to be tested
  113354. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  113355. **/
  113356. static HasSpecificTrigger(trigger: number): boolean;
  113357. }
  113358. }
  113359. declare module BABYLON {
  113360. /**
  113361. * Defines how a node can be built from a string name.
  113362. */
  113363. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  113364. /**
  113365. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  113366. */
  113367. export class Node implements IBehaviorAware<Node> {
  113368. /** @hidden */
  113369. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  113370. private static _NodeConstructors;
  113371. /**
  113372. * Add a new node constructor
  113373. * @param type defines the type name of the node to construct
  113374. * @param constructorFunc defines the constructor function
  113375. */
  113376. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  113377. /**
  113378. * Returns a node constructor based on type name
  113379. * @param type defines the type name
  113380. * @param name defines the new node name
  113381. * @param scene defines the hosting scene
  113382. * @param options defines optional options to transmit to constructors
  113383. * @returns the new constructor or null
  113384. */
  113385. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  113386. /**
  113387. * Gets or sets the name of the node
  113388. */
  113389. name: string;
  113390. /**
  113391. * Gets or sets the id of the node
  113392. */
  113393. id: string;
  113394. /**
  113395. * Gets or sets the unique id of the node
  113396. */
  113397. uniqueId: number;
  113398. /**
  113399. * Gets or sets a string used to store user defined state for the node
  113400. */
  113401. state: string;
  113402. /**
  113403. * Gets or sets an object used to store user defined information for the node
  113404. */
  113405. metadata: any;
  113406. /**
  113407. * For internal use only. Please do not use.
  113408. */
  113409. reservedDataStore: any;
  113410. /**
  113411. * List of inspectable custom properties (used by the Inspector)
  113412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113413. */
  113414. inspectableCustomProperties: IInspectable[];
  113415. private _doNotSerialize;
  113416. /**
  113417. * Gets or sets a boolean used to define if the node must be serialized
  113418. */
  113419. get doNotSerialize(): boolean;
  113420. set doNotSerialize(value: boolean);
  113421. /** @hidden */
  113422. _isDisposed: boolean;
  113423. /**
  113424. * Gets a list of Animations associated with the node
  113425. */
  113426. animations: Animation[];
  113427. protected _ranges: {
  113428. [name: string]: Nullable<AnimationRange>;
  113429. };
  113430. /**
  113431. * Callback raised when the node is ready to be used
  113432. */
  113433. onReady: Nullable<(node: Node) => void>;
  113434. private _isEnabled;
  113435. private _isParentEnabled;
  113436. private _isReady;
  113437. /** @hidden */
  113438. _currentRenderId: number;
  113439. private _parentUpdateId;
  113440. /** @hidden */
  113441. _childUpdateId: number;
  113442. /** @hidden */
  113443. _waitingParentId: Nullable<string>;
  113444. /** @hidden */
  113445. _scene: Scene;
  113446. /** @hidden */
  113447. _cache: any;
  113448. private _parentNode;
  113449. private _children;
  113450. /** @hidden */
  113451. _worldMatrix: Matrix;
  113452. /** @hidden */
  113453. _worldMatrixDeterminant: number;
  113454. /** @hidden */
  113455. _worldMatrixDeterminantIsDirty: boolean;
  113456. /** @hidden */
  113457. private _sceneRootNodesIndex;
  113458. /**
  113459. * Gets a boolean indicating if the node has been disposed
  113460. * @returns true if the node was disposed
  113461. */
  113462. isDisposed(): boolean;
  113463. /**
  113464. * Gets or sets the parent of the node (without keeping the current position in the scene)
  113465. * @see https://doc.babylonjs.com/how_to/parenting
  113466. */
  113467. set parent(parent: Nullable<Node>);
  113468. get parent(): Nullable<Node>;
  113469. /** @hidden */
  113470. _addToSceneRootNodes(): void;
  113471. /** @hidden */
  113472. _removeFromSceneRootNodes(): void;
  113473. private _animationPropertiesOverride;
  113474. /**
  113475. * Gets or sets the animation properties override
  113476. */
  113477. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113478. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113479. /**
  113480. * Gets a string identifying the name of the class
  113481. * @returns "Node" string
  113482. */
  113483. getClassName(): string;
  113484. /** @hidden */
  113485. readonly _isNode: boolean;
  113486. /**
  113487. * An event triggered when the mesh is disposed
  113488. */
  113489. onDisposeObservable: Observable<Node>;
  113490. private _onDisposeObserver;
  113491. /**
  113492. * Sets a callback that will be raised when the node will be disposed
  113493. */
  113494. set onDispose(callback: () => void);
  113495. /**
  113496. * Creates a new Node
  113497. * @param name the name and id to be given to this node
  113498. * @param scene the scene this node will be added to
  113499. */
  113500. constructor(name: string, scene?: Nullable<Scene>);
  113501. /**
  113502. * Gets the scene of the node
  113503. * @returns a scene
  113504. */
  113505. getScene(): Scene;
  113506. /**
  113507. * Gets the engine of the node
  113508. * @returns a Engine
  113509. */
  113510. getEngine(): Engine;
  113511. private _behaviors;
  113512. /**
  113513. * Attach a behavior to the node
  113514. * @see https://doc.babylonjs.com/features/behaviour
  113515. * @param behavior defines the behavior to attach
  113516. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113517. * @returns the current Node
  113518. */
  113519. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113520. /**
  113521. * Remove an attached behavior
  113522. * @see https://doc.babylonjs.com/features/behaviour
  113523. * @param behavior defines the behavior to attach
  113524. * @returns the current Node
  113525. */
  113526. removeBehavior(behavior: Behavior<Node>): Node;
  113527. /**
  113528. * Gets the list of attached behaviors
  113529. * @see https://doc.babylonjs.com/features/behaviour
  113530. */
  113531. get behaviors(): Behavior<Node>[];
  113532. /**
  113533. * Gets an attached behavior by name
  113534. * @param name defines the name of the behavior to look for
  113535. * @see https://doc.babylonjs.com/features/behaviour
  113536. * @returns null if behavior was not found else the requested behavior
  113537. */
  113538. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113539. /**
  113540. * Returns the latest update of the World matrix
  113541. * @returns a Matrix
  113542. */
  113543. getWorldMatrix(): Matrix;
  113544. /** @hidden */
  113545. _getWorldMatrixDeterminant(): number;
  113546. /**
  113547. * Returns directly the latest state of the mesh World matrix.
  113548. * A Matrix is returned.
  113549. */
  113550. get worldMatrixFromCache(): Matrix;
  113551. /** @hidden */
  113552. _initCache(): void;
  113553. /** @hidden */
  113554. updateCache(force?: boolean): void;
  113555. /** @hidden */
  113556. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113557. /** @hidden */
  113558. _updateCache(ignoreParentClass?: boolean): void;
  113559. /** @hidden */
  113560. _isSynchronized(): boolean;
  113561. /** @hidden */
  113562. _markSyncedWithParent(): void;
  113563. /** @hidden */
  113564. isSynchronizedWithParent(): boolean;
  113565. /** @hidden */
  113566. isSynchronized(): boolean;
  113567. /**
  113568. * Is this node ready to be used/rendered
  113569. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113570. * @return true if the node is ready
  113571. */
  113572. isReady(completeCheck?: boolean): boolean;
  113573. /**
  113574. * Is this node enabled?
  113575. * 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
  113576. * @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
  113577. * @return whether this node (and its parent) is enabled
  113578. */
  113579. isEnabled(checkAncestors?: boolean): boolean;
  113580. /** @hidden */
  113581. protected _syncParentEnabledState(): void;
  113582. /**
  113583. * Set the enabled state of this node
  113584. * @param value defines the new enabled state
  113585. */
  113586. setEnabled(value: boolean): void;
  113587. /**
  113588. * Is this node a descendant of the given node?
  113589. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113590. * @param ancestor defines the parent node to inspect
  113591. * @returns a boolean indicating if this node is a descendant of the given node
  113592. */
  113593. isDescendantOf(ancestor: Node): boolean;
  113594. /** @hidden */
  113595. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113596. /**
  113597. * Will return all nodes that have this node as ascendant
  113598. * @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
  113599. * @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
  113600. * @return all children nodes of all types
  113601. */
  113602. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113603. /**
  113604. * Get all child-meshes of this node
  113605. * @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)
  113606. * @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
  113607. * @returns an array of AbstractMesh
  113608. */
  113609. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113610. /**
  113611. * Get all direct children of this node
  113612. * @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
  113613. * @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)
  113614. * @returns an array of Node
  113615. */
  113616. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113617. /** @hidden */
  113618. _setReady(state: boolean): void;
  113619. /**
  113620. * Get an animation by name
  113621. * @param name defines the name of the animation to look for
  113622. * @returns null if not found else the requested animation
  113623. */
  113624. getAnimationByName(name: string): Nullable<Animation>;
  113625. /**
  113626. * Creates an animation range for this node
  113627. * @param name defines the name of the range
  113628. * @param from defines the starting key
  113629. * @param to defines the end key
  113630. */
  113631. createAnimationRange(name: string, from: number, to: number): void;
  113632. /**
  113633. * Delete a specific animation range
  113634. * @param name defines the name of the range to delete
  113635. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113636. */
  113637. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113638. /**
  113639. * Get an animation range by name
  113640. * @param name defines the name of the animation range to look for
  113641. * @returns null if not found else the requested animation range
  113642. */
  113643. getAnimationRange(name: string): Nullable<AnimationRange>;
  113644. /**
  113645. * Gets the list of all animation ranges defined on this node
  113646. * @returns an array
  113647. */
  113648. getAnimationRanges(): Nullable<AnimationRange>[];
  113649. /**
  113650. * Will start the animation sequence
  113651. * @param name defines the range frames for animation sequence
  113652. * @param loop defines if the animation should loop (false by default)
  113653. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113654. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113655. * @returns the object created for this animation. If range does not exist, it will return null
  113656. */
  113657. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113658. /**
  113659. * Serialize animation ranges into a JSON compatible object
  113660. * @returns serialization object
  113661. */
  113662. serializeAnimationRanges(): any;
  113663. /**
  113664. * Computes the world matrix of the node
  113665. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113666. * @returns the world matrix
  113667. */
  113668. computeWorldMatrix(force?: boolean): Matrix;
  113669. /**
  113670. * Releases resources associated with this node.
  113671. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113672. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113673. */
  113674. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113675. /**
  113676. * Parse animation range data from a serialization object and store them into a given node
  113677. * @param node defines where to store the animation ranges
  113678. * @param parsedNode defines the serialization object to read data from
  113679. * @param scene defines the hosting scene
  113680. */
  113681. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113682. /**
  113683. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113684. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113685. * @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
  113686. * @returns the new bounding vectors
  113687. */
  113688. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113689. min: Vector3;
  113690. max: Vector3;
  113691. };
  113692. }
  113693. }
  113694. declare module BABYLON {
  113695. /**
  113696. * @hidden
  113697. */
  113698. export class _IAnimationState {
  113699. key: number;
  113700. repeatCount: number;
  113701. workValue?: any;
  113702. loopMode?: number;
  113703. offsetValue?: any;
  113704. highLimitValue?: any;
  113705. }
  113706. /**
  113707. * Class used to store any kind of animation
  113708. */
  113709. export class Animation {
  113710. /**Name of the animation */
  113711. name: string;
  113712. /**Property to animate */
  113713. targetProperty: string;
  113714. /**The frames per second of the animation */
  113715. framePerSecond: number;
  113716. /**The data type of the animation */
  113717. dataType: number;
  113718. /**The loop mode of the animation */
  113719. loopMode?: number | undefined;
  113720. /**Specifies if blending should be enabled */
  113721. enableBlending?: boolean | undefined;
  113722. /**
  113723. * Use matrix interpolation instead of using direct key value when animating matrices
  113724. */
  113725. static AllowMatricesInterpolation: boolean;
  113726. /**
  113727. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113728. */
  113729. static AllowMatrixDecomposeForInterpolation: boolean;
  113730. /** Define the Url to load snippets */
  113731. static SnippetUrl: string;
  113732. /** Snippet ID if the animation was created from the snippet server */
  113733. snippetId: string;
  113734. /**
  113735. * Stores the key frames of the animation
  113736. */
  113737. private _keys;
  113738. /**
  113739. * Stores the easing function of the animation
  113740. */
  113741. private _easingFunction;
  113742. /**
  113743. * @hidden Internal use only
  113744. */
  113745. _runtimeAnimations: RuntimeAnimation[];
  113746. /**
  113747. * The set of event that will be linked to this animation
  113748. */
  113749. private _events;
  113750. /**
  113751. * Stores an array of target property paths
  113752. */
  113753. targetPropertyPath: string[];
  113754. /**
  113755. * Stores the blending speed of the animation
  113756. */
  113757. blendingSpeed: number;
  113758. /**
  113759. * Stores the animation ranges for the animation
  113760. */
  113761. private _ranges;
  113762. /**
  113763. * @hidden Internal use
  113764. */
  113765. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113766. /**
  113767. * Sets up an animation
  113768. * @param property The property to animate
  113769. * @param animationType The animation type to apply
  113770. * @param framePerSecond The frames per second of the animation
  113771. * @param easingFunction The easing function used in the animation
  113772. * @returns The created animation
  113773. */
  113774. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113775. /**
  113776. * Create and start an animation on a node
  113777. * @param name defines the name of the global animation that will be run on all nodes
  113778. * @param node defines the root node where the animation will take place
  113779. * @param targetProperty defines property to animate
  113780. * @param framePerSecond defines the number of frame per second yo use
  113781. * @param totalFrame defines the number of frames in total
  113782. * @param from defines the initial value
  113783. * @param to defines the final value
  113784. * @param loopMode defines which loop mode you want to use (off by default)
  113785. * @param easingFunction defines the easing function to use (linear by default)
  113786. * @param onAnimationEnd defines the callback to call when animation end
  113787. * @returns the animatable created for this animation
  113788. */
  113789. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113790. /**
  113791. * Create and start an animation on a node and its descendants
  113792. * @param name defines the name of the global animation that will be run on all nodes
  113793. * @param node defines the root node where the animation will take place
  113794. * @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
  113795. * @param targetProperty defines property to animate
  113796. * @param framePerSecond defines the number of frame per second to use
  113797. * @param totalFrame defines the number of frames in total
  113798. * @param from defines the initial value
  113799. * @param to defines the final value
  113800. * @param loopMode defines which loop mode you want to use (off by default)
  113801. * @param easingFunction defines the easing function to use (linear by default)
  113802. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113803. * @returns the list of animatables created for all nodes
  113804. * @example https://www.babylonjs-playground.com/#MH0VLI
  113805. */
  113806. 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[]>;
  113807. /**
  113808. * Creates a new animation, merges it with the existing animations and starts it
  113809. * @param name Name of the animation
  113810. * @param node Node which contains the scene that begins the animations
  113811. * @param targetProperty Specifies which property to animate
  113812. * @param framePerSecond The frames per second of the animation
  113813. * @param totalFrame The total number of frames
  113814. * @param from The frame at the beginning of the animation
  113815. * @param to The frame at the end of the animation
  113816. * @param loopMode Specifies the loop mode of the animation
  113817. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113818. * @param onAnimationEnd Callback to run once the animation is complete
  113819. * @returns Nullable animation
  113820. */
  113821. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113822. /**
  113823. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113824. * @param sourceAnimation defines the Animation containing keyframes to convert
  113825. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113826. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113827. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113828. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113829. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113830. */
  113831. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113832. /**
  113833. * Transition property of an host to the target Value
  113834. * @param property The property to transition
  113835. * @param targetValue The target Value of the property
  113836. * @param host The object where the property to animate belongs
  113837. * @param scene Scene used to run the animation
  113838. * @param frameRate Framerate (in frame/s) to use
  113839. * @param transition The transition type we want to use
  113840. * @param duration The duration of the animation, in milliseconds
  113841. * @param onAnimationEnd Callback trigger at the end of the animation
  113842. * @returns Nullable animation
  113843. */
  113844. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113845. /**
  113846. * Return the array of runtime animations currently using this animation
  113847. */
  113848. get runtimeAnimations(): RuntimeAnimation[];
  113849. /**
  113850. * Specifies if any of the runtime animations are currently running
  113851. */
  113852. get hasRunningRuntimeAnimations(): boolean;
  113853. /**
  113854. * Initializes the animation
  113855. * @param name Name of the animation
  113856. * @param targetProperty Property to animate
  113857. * @param framePerSecond The frames per second of the animation
  113858. * @param dataType The data type of the animation
  113859. * @param loopMode The loop mode of the animation
  113860. * @param enableBlending Specifies if blending should be enabled
  113861. */
  113862. constructor(
  113863. /**Name of the animation */
  113864. name: string,
  113865. /**Property to animate */
  113866. targetProperty: string,
  113867. /**The frames per second of the animation */
  113868. framePerSecond: number,
  113869. /**The data type of the animation */
  113870. dataType: number,
  113871. /**The loop mode of the animation */
  113872. loopMode?: number | undefined,
  113873. /**Specifies if blending should be enabled */
  113874. enableBlending?: boolean | undefined);
  113875. /**
  113876. * Converts the animation to a string
  113877. * @param fullDetails support for multiple levels of logging within scene loading
  113878. * @returns String form of the animation
  113879. */
  113880. toString(fullDetails?: boolean): string;
  113881. /**
  113882. * Add an event to this animation
  113883. * @param event Event to add
  113884. */
  113885. addEvent(event: AnimationEvent): void;
  113886. /**
  113887. * Remove all events found at the given frame
  113888. * @param frame The frame to remove events from
  113889. */
  113890. removeEvents(frame: number): void;
  113891. /**
  113892. * Retrieves all the events from the animation
  113893. * @returns Events from the animation
  113894. */
  113895. getEvents(): AnimationEvent[];
  113896. /**
  113897. * Creates an animation range
  113898. * @param name Name of the animation range
  113899. * @param from Starting frame of the animation range
  113900. * @param to Ending frame of the animation
  113901. */
  113902. createRange(name: string, from: number, to: number): void;
  113903. /**
  113904. * Deletes an animation range by name
  113905. * @param name Name of the animation range to delete
  113906. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113907. */
  113908. deleteRange(name: string, deleteFrames?: boolean): void;
  113909. /**
  113910. * Gets the animation range by name, or null if not defined
  113911. * @param name Name of the animation range
  113912. * @returns Nullable animation range
  113913. */
  113914. getRange(name: string): Nullable<AnimationRange>;
  113915. /**
  113916. * Gets the key frames from the animation
  113917. * @returns The key frames of the animation
  113918. */
  113919. getKeys(): Array<IAnimationKey>;
  113920. /**
  113921. * Gets the highest frame rate of the animation
  113922. * @returns Highest frame rate of the animation
  113923. */
  113924. getHighestFrame(): number;
  113925. /**
  113926. * Gets the easing function of the animation
  113927. * @returns Easing function of the animation
  113928. */
  113929. getEasingFunction(): IEasingFunction;
  113930. /**
  113931. * Sets the easing function of the animation
  113932. * @param easingFunction A custom mathematical formula for animation
  113933. */
  113934. setEasingFunction(easingFunction: EasingFunction): void;
  113935. /**
  113936. * Interpolates a scalar linearly
  113937. * @param startValue Start value of the animation curve
  113938. * @param endValue End value of the animation curve
  113939. * @param gradient Scalar amount to interpolate
  113940. * @returns Interpolated scalar value
  113941. */
  113942. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113943. /**
  113944. * Interpolates a scalar cubically
  113945. * @param startValue Start value of the animation curve
  113946. * @param outTangent End tangent of the animation
  113947. * @param endValue End value of the animation curve
  113948. * @param inTangent Start tangent of the animation curve
  113949. * @param gradient Scalar amount to interpolate
  113950. * @returns Interpolated scalar value
  113951. */
  113952. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113953. /**
  113954. * Interpolates a quaternion using a spherical linear interpolation
  113955. * @param startValue Start value of the animation curve
  113956. * @param endValue End value of the animation curve
  113957. * @param gradient Scalar amount to interpolate
  113958. * @returns Interpolated quaternion value
  113959. */
  113960. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113961. /**
  113962. * Interpolates a quaternion cubically
  113963. * @param startValue Start value of the animation curve
  113964. * @param outTangent End tangent of the animation curve
  113965. * @param endValue End value of the animation curve
  113966. * @param inTangent Start tangent of the animation curve
  113967. * @param gradient Scalar amount to interpolate
  113968. * @returns Interpolated quaternion value
  113969. */
  113970. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113971. /**
  113972. * Interpolates a Vector3 linearl
  113973. * @param startValue Start value of the animation curve
  113974. * @param endValue End value of the animation curve
  113975. * @param gradient Scalar amount to interpolate
  113976. * @returns Interpolated scalar value
  113977. */
  113978. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113979. /**
  113980. * Interpolates a Vector3 cubically
  113981. * @param startValue Start value of the animation curve
  113982. * @param outTangent End tangent of the animation
  113983. * @param endValue End value of the animation curve
  113984. * @param inTangent Start tangent of the animation curve
  113985. * @param gradient Scalar amount to interpolate
  113986. * @returns InterpolatedVector3 value
  113987. */
  113988. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113989. /**
  113990. * Interpolates a Vector2 linearly
  113991. * @param startValue Start value of the animation curve
  113992. * @param endValue End value of the animation curve
  113993. * @param gradient Scalar amount to interpolate
  113994. * @returns Interpolated Vector2 value
  113995. */
  113996. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113997. /**
  113998. * Interpolates a Vector2 cubically
  113999. * @param startValue Start value of the animation curve
  114000. * @param outTangent End tangent of the animation
  114001. * @param endValue End value of the animation curve
  114002. * @param inTangent Start tangent of the animation curve
  114003. * @param gradient Scalar amount to interpolate
  114004. * @returns Interpolated Vector2 value
  114005. */
  114006. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  114007. /**
  114008. * Interpolates a size linearly
  114009. * @param startValue Start value of the animation curve
  114010. * @param endValue End value of the animation curve
  114011. * @param gradient Scalar amount to interpolate
  114012. * @returns Interpolated Size value
  114013. */
  114014. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  114015. /**
  114016. * Interpolates a Color3 linearly
  114017. * @param startValue Start value of the animation curve
  114018. * @param endValue End value of the animation curve
  114019. * @param gradient Scalar amount to interpolate
  114020. * @returns Interpolated Color3 value
  114021. */
  114022. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  114023. /**
  114024. * Interpolates a Color4 linearly
  114025. * @param startValue Start value of the animation curve
  114026. * @param endValue End value of the animation curve
  114027. * @param gradient Scalar amount to interpolate
  114028. * @returns Interpolated Color3 value
  114029. */
  114030. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  114031. /**
  114032. * @hidden Internal use only
  114033. */
  114034. _getKeyValue(value: any): any;
  114035. /**
  114036. * @hidden Internal use only
  114037. */
  114038. _interpolate(currentFrame: number, state: _IAnimationState): any;
  114039. /**
  114040. * Defines the function to use to interpolate matrices
  114041. * @param startValue defines the start matrix
  114042. * @param endValue defines the end matrix
  114043. * @param gradient defines the gradient between both matrices
  114044. * @param result defines an optional target matrix where to store the interpolation
  114045. * @returns the interpolated matrix
  114046. */
  114047. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  114048. /**
  114049. * Makes a copy of the animation
  114050. * @returns Cloned animation
  114051. */
  114052. clone(): Animation;
  114053. /**
  114054. * Sets the key frames of the animation
  114055. * @param values The animation key frames to set
  114056. */
  114057. setKeys(values: Array<IAnimationKey>): void;
  114058. /**
  114059. * Serializes the animation to an object
  114060. * @returns Serialized object
  114061. */
  114062. serialize(): any;
  114063. /**
  114064. * Float animation type
  114065. */
  114066. static readonly ANIMATIONTYPE_FLOAT: number;
  114067. /**
  114068. * Vector3 animation type
  114069. */
  114070. static readonly ANIMATIONTYPE_VECTOR3: number;
  114071. /**
  114072. * Quaternion animation type
  114073. */
  114074. static readonly ANIMATIONTYPE_QUATERNION: number;
  114075. /**
  114076. * Matrix animation type
  114077. */
  114078. static readonly ANIMATIONTYPE_MATRIX: number;
  114079. /**
  114080. * Color3 animation type
  114081. */
  114082. static readonly ANIMATIONTYPE_COLOR3: number;
  114083. /**
  114084. * Color3 animation type
  114085. */
  114086. static readonly ANIMATIONTYPE_COLOR4: number;
  114087. /**
  114088. * Vector2 animation type
  114089. */
  114090. static readonly ANIMATIONTYPE_VECTOR2: number;
  114091. /**
  114092. * Size animation type
  114093. */
  114094. static readonly ANIMATIONTYPE_SIZE: number;
  114095. /**
  114096. * Relative Loop Mode
  114097. */
  114098. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  114099. /**
  114100. * Cycle Loop Mode
  114101. */
  114102. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  114103. /**
  114104. * Constant Loop Mode
  114105. */
  114106. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  114107. /** @hidden */
  114108. static _UniversalLerp(left: any, right: any, amount: number): any;
  114109. /**
  114110. * Parses an animation object and creates an animation
  114111. * @param parsedAnimation Parsed animation object
  114112. * @returns Animation object
  114113. */
  114114. static Parse(parsedAnimation: any): Animation;
  114115. /**
  114116. * Appends the serialized animations from the source animations
  114117. * @param source Source containing the animations
  114118. * @param destination Target to store the animations
  114119. */
  114120. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114121. /**
  114122. * Creates a new animation or an array of animations from a snippet saved in a remote file
  114123. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  114124. * @param url defines the url to load from
  114125. * @returns a promise that will resolve to the new animation or an array of animations
  114126. */
  114127. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  114128. /**
  114129. * Creates an animation or an array of animations from a snippet saved by the Inspector
  114130. * @param snippetId defines the snippet to load
  114131. * @returns a promise that will resolve to the new animation or a new array of animations
  114132. */
  114133. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  114134. }
  114135. }
  114136. declare module BABYLON {
  114137. /**
  114138. * Interface containing an array of animations
  114139. */
  114140. export interface IAnimatable {
  114141. /**
  114142. * Array of animations
  114143. */
  114144. animations: Nullable<Array<Animation>>;
  114145. }
  114146. }
  114147. declare module BABYLON {
  114148. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  114149. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114150. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114151. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114152. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114153. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114154. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114155. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114156. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114157. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114158. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114159. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114160. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114161. /**
  114162. * Decorator used to define property that can be serialized as reference to a camera
  114163. * @param sourceName defines the name of the property to decorate
  114164. */
  114165. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114166. /**
  114167. * Class used to help serialization objects
  114168. */
  114169. export class SerializationHelper {
  114170. /** @hidden */
  114171. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  114172. /** @hidden */
  114173. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  114174. /** @hidden */
  114175. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  114176. /** @hidden */
  114177. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  114178. /**
  114179. * Appends the serialized animations from the source animations
  114180. * @param source Source containing the animations
  114181. * @param destination Target to store the animations
  114182. */
  114183. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114184. /**
  114185. * Static function used to serialized a specific entity
  114186. * @param entity defines the entity to serialize
  114187. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  114188. * @returns a JSON compatible object representing the serialization of the entity
  114189. */
  114190. static Serialize<T>(entity: T, serializationObject?: any): any;
  114191. /**
  114192. * Creates a new entity from a serialization data object
  114193. * @param creationFunction defines a function used to instanciated the new entity
  114194. * @param source defines the source serialization data
  114195. * @param scene defines the hosting scene
  114196. * @param rootUrl defines the root url for resources
  114197. * @returns a new entity
  114198. */
  114199. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  114200. /**
  114201. * Clones an object
  114202. * @param creationFunction defines the function used to instanciate the new object
  114203. * @param source defines the source object
  114204. * @returns the cloned object
  114205. */
  114206. static Clone<T>(creationFunction: () => T, source: T): T;
  114207. /**
  114208. * Instanciates a new object based on a source one (some data will be shared between both object)
  114209. * @param creationFunction defines the function used to instanciate the new object
  114210. * @param source defines the source object
  114211. * @returns the new object
  114212. */
  114213. static Instanciate<T>(creationFunction: () => T, source: T): T;
  114214. }
  114215. }
  114216. declare module BABYLON {
  114217. /**
  114218. * Base class of all the textures in babylon.
  114219. * It groups all the common properties the materials, post process, lights... might need
  114220. * in order to make a correct use of the texture.
  114221. */
  114222. export class BaseTexture implements IAnimatable {
  114223. /**
  114224. * Default anisotropic filtering level for the application.
  114225. * It is set to 4 as a good tradeoff between perf and quality.
  114226. */
  114227. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  114228. /**
  114229. * Gets or sets the unique id of the texture
  114230. */
  114231. uniqueId: number;
  114232. /**
  114233. * Define the name of the texture.
  114234. */
  114235. name: string;
  114236. /**
  114237. * Gets or sets an object used to store user defined information.
  114238. */
  114239. metadata: any;
  114240. /**
  114241. * For internal use only. Please do not use.
  114242. */
  114243. reservedDataStore: any;
  114244. private _hasAlpha;
  114245. /**
  114246. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  114247. */
  114248. set hasAlpha(value: boolean);
  114249. get hasAlpha(): boolean;
  114250. /**
  114251. * Defines if the alpha value should be determined via the rgb values.
  114252. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  114253. */
  114254. getAlphaFromRGB: boolean;
  114255. /**
  114256. * Intensity or strength of the texture.
  114257. * It is commonly used by materials to fine tune the intensity of the texture
  114258. */
  114259. level: number;
  114260. /**
  114261. * Define the UV chanel to use starting from 0 and defaulting to 0.
  114262. * This is part of the texture as textures usually maps to one uv set.
  114263. */
  114264. coordinatesIndex: number;
  114265. protected _coordinatesMode: number;
  114266. /**
  114267. * How a texture is mapped.
  114268. *
  114269. * | Value | Type | Description |
  114270. * | ----- | ----------------------------------- | ----------- |
  114271. * | 0 | EXPLICIT_MODE | |
  114272. * | 1 | SPHERICAL_MODE | |
  114273. * | 2 | PLANAR_MODE | |
  114274. * | 3 | CUBIC_MODE | |
  114275. * | 4 | PROJECTION_MODE | |
  114276. * | 5 | SKYBOX_MODE | |
  114277. * | 6 | INVCUBIC_MODE | |
  114278. * | 7 | EQUIRECTANGULAR_MODE | |
  114279. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  114280. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  114281. */
  114282. set coordinatesMode(value: number);
  114283. get coordinatesMode(): number;
  114284. private _wrapU;
  114285. /**
  114286. * | Value | Type | Description |
  114287. * | ----- | ------------------ | ----------- |
  114288. * | 0 | CLAMP_ADDRESSMODE | |
  114289. * | 1 | WRAP_ADDRESSMODE | |
  114290. * | 2 | MIRROR_ADDRESSMODE | |
  114291. */
  114292. get wrapU(): number;
  114293. set wrapU(value: number);
  114294. private _wrapV;
  114295. /**
  114296. * | Value | Type | Description |
  114297. * | ----- | ------------------ | ----------- |
  114298. * | 0 | CLAMP_ADDRESSMODE | |
  114299. * | 1 | WRAP_ADDRESSMODE | |
  114300. * | 2 | MIRROR_ADDRESSMODE | |
  114301. */
  114302. get wrapV(): number;
  114303. set wrapV(value: number);
  114304. /**
  114305. * | Value | Type | Description |
  114306. * | ----- | ------------------ | ----------- |
  114307. * | 0 | CLAMP_ADDRESSMODE | |
  114308. * | 1 | WRAP_ADDRESSMODE | |
  114309. * | 2 | MIRROR_ADDRESSMODE | |
  114310. */
  114311. wrapR: number;
  114312. /**
  114313. * With compliant hardware and browser (supporting anisotropic filtering)
  114314. * this defines the level of anisotropic filtering in the texture.
  114315. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  114316. */
  114317. anisotropicFilteringLevel: number;
  114318. /**
  114319. * Define if the texture is a cube texture or if false a 2d texture.
  114320. */
  114321. get isCube(): boolean;
  114322. set isCube(value: boolean);
  114323. /**
  114324. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  114325. */
  114326. get is3D(): boolean;
  114327. set is3D(value: boolean);
  114328. /**
  114329. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  114330. */
  114331. get is2DArray(): boolean;
  114332. set is2DArray(value: boolean);
  114333. private _gammaSpace;
  114334. /**
  114335. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  114336. * HDR texture are usually stored in linear space.
  114337. * This only impacts the PBR and Background materials
  114338. */
  114339. get gammaSpace(): boolean;
  114340. set gammaSpace(gamma: boolean);
  114341. /**
  114342. * Gets or sets whether or not the texture contains RGBD data.
  114343. */
  114344. get isRGBD(): boolean;
  114345. set isRGBD(value: boolean);
  114346. /**
  114347. * Is Z inverted in the texture (useful in a cube texture).
  114348. */
  114349. invertZ: boolean;
  114350. /**
  114351. * Are mip maps generated for this texture or not.
  114352. */
  114353. get noMipmap(): boolean;
  114354. /**
  114355. * @hidden
  114356. */
  114357. lodLevelInAlpha: boolean;
  114358. /**
  114359. * With prefiltered texture, defined the offset used during the prefiltering steps.
  114360. */
  114361. get lodGenerationOffset(): number;
  114362. set lodGenerationOffset(value: number);
  114363. /**
  114364. * With prefiltered texture, defined the scale used during the prefiltering steps.
  114365. */
  114366. get lodGenerationScale(): number;
  114367. set lodGenerationScale(value: number);
  114368. /**
  114369. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  114370. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  114371. * average roughness values.
  114372. */
  114373. get linearSpecularLOD(): boolean;
  114374. set linearSpecularLOD(value: boolean);
  114375. /**
  114376. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  114377. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  114378. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  114379. */
  114380. get irradianceTexture(): Nullable<BaseTexture>;
  114381. set irradianceTexture(value: Nullable<BaseTexture>);
  114382. /**
  114383. * Define if the texture is a render target.
  114384. */
  114385. isRenderTarget: boolean;
  114386. /**
  114387. * Define the unique id of the texture in the scene.
  114388. */
  114389. get uid(): string;
  114390. /** @hidden */
  114391. _prefiltered: boolean;
  114392. /**
  114393. * Return a string representation of the texture.
  114394. * @returns the texture as a string
  114395. */
  114396. toString(): string;
  114397. /**
  114398. * Get the class name of the texture.
  114399. * @returns "BaseTexture"
  114400. */
  114401. getClassName(): string;
  114402. /**
  114403. * Define the list of animation attached to the texture.
  114404. */
  114405. animations: Animation[];
  114406. /**
  114407. * An event triggered when the texture is disposed.
  114408. */
  114409. onDisposeObservable: Observable<BaseTexture>;
  114410. private _onDisposeObserver;
  114411. /**
  114412. * Callback triggered when the texture has been disposed.
  114413. * Kept for back compatibility, you can use the onDisposeObservable instead.
  114414. */
  114415. set onDispose(callback: () => void);
  114416. /**
  114417. * Define the current state of the loading sequence when in delayed load mode.
  114418. */
  114419. delayLoadState: number;
  114420. protected _scene: Nullable<Scene>;
  114421. protected _engine: Nullable<ThinEngine>;
  114422. /** @hidden */
  114423. _texture: Nullable<InternalTexture>;
  114424. private _uid;
  114425. /**
  114426. * Define if the texture is preventinga material to render or not.
  114427. * If not and the texture is not ready, the engine will use a default black texture instead.
  114428. */
  114429. get isBlocking(): boolean;
  114430. /**
  114431. * Instantiates a new BaseTexture.
  114432. * Base class of all the textures in babylon.
  114433. * It groups all the common properties the materials, post process, lights... might need
  114434. * in order to make a correct use of the texture.
  114435. * @param sceneOrEngine Define the scene or engine the texture blongs to
  114436. */
  114437. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  114438. /**
  114439. * Get the scene the texture belongs to.
  114440. * @returns the scene or null if undefined
  114441. */
  114442. getScene(): Nullable<Scene>;
  114443. /** @hidden */
  114444. protected _getEngine(): Nullable<ThinEngine>;
  114445. /**
  114446. * Get the texture transform matrix used to offset tile the texture for istance.
  114447. * @returns the transformation matrix
  114448. */
  114449. getTextureMatrix(): Matrix;
  114450. /**
  114451. * Get the texture reflection matrix used to rotate/transform the reflection.
  114452. * @returns the reflection matrix
  114453. */
  114454. getReflectionTextureMatrix(): Matrix;
  114455. /**
  114456. * Get the underlying lower level texture from Babylon.
  114457. * @returns the insternal texture
  114458. */
  114459. getInternalTexture(): Nullable<InternalTexture>;
  114460. /**
  114461. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  114462. * @returns true if ready or not blocking
  114463. */
  114464. isReadyOrNotBlocking(): boolean;
  114465. /**
  114466. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  114467. * @returns true if fully ready
  114468. */
  114469. isReady(): boolean;
  114470. private _cachedSize;
  114471. /**
  114472. * Get the size of the texture.
  114473. * @returns the texture size.
  114474. */
  114475. getSize(): ISize;
  114476. /**
  114477. * Get the base size of the texture.
  114478. * It can be different from the size if the texture has been resized for POT for instance
  114479. * @returns the base size
  114480. */
  114481. getBaseSize(): ISize;
  114482. /**
  114483. * Update the sampling mode of the texture.
  114484. * Default is Trilinear mode.
  114485. *
  114486. * | Value | Type | Description |
  114487. * | ----- | ------------------ | ----------- |
  114488. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114489. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114490. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114491. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114492. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114493. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114494. * | 7 | NEAREST_LINEAR | |
  114495. * | 8 | NEAREST_NEAREST | |
  114496. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114497. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114498. * | 11 | LINEAR_LINEAR | |
  114499. * | 12 | LINEAR_NEAREST | |
  114500. *
  114501. * > _mag_: magnification filter (close to the viewer)
  114502. * > _min_: minification filter (far from the viewer)
  114503. * > _mip_: filter used between mip map levels
  114504. *@param samplingMode Define the new sampling mode of the texture
  114505. */
  114506. updateSamplingMode(samplingMode: number): void;
  114507. /**
  114508. * Scales the texture if is `canRescale()`
  114509. * @param ratio the resize factor we want to use to rescale
  114510. */
  114511. scale(ratio: number): void;
  114512. /**
  114513. * Get if the texture can rescale.
  114514. */
  114515. get canRescale(): boolean;
  114516. /** @hidden */
  114517. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114518. /** @hidden */
  114519. _rebuild(): void;
  114520. /**
  114521. * Triggers the load sequence in delayed load mode.
  114522. */
  114523. delayLoad(): void;
  114524. /**
  114525. * Clones the texture.
  114526. * @returns the cloned texture
  114527. */
  114528. clone(): Nullable<BaseTexture>;
  114529. /**
  114530. * Get the texture underlying type (INT, FLOAT...)
  114531. */
  114532. get textureType(): number;
  114533. /**
  114534. * Get the texture underlying format (RGB, RGBA...)
  114535. */
  114536. get textureFormat(): number;
  114537. /**
  114538. * Indicates that textures need to be re-calculated for all materials
  114539. */
  114540. protected _markAllSubMeshesAsTexturesDirty(): void;
  114541. /**
  114542. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114543. * This will returns an RGBA array buffer containing either in values (0-255) or
  114544. * float values (0-1) depending of the underlying buffer type.
  114545. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114546. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114547. * @param buffer defines a user defined buffer to fill with data (can be null)
  114548. * @returns The Array buffer containing the pixels data.
  114549. */
  114550. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114551. /**
  114552. * Release and destroy the underlying lower level texture aka internalTexture.
  114553. */
  114554. releaseInternalTexture(): void;
  114555. /** @hidden */
  114556. get _lodTextureHigh(): Nullable<BaseTexture>;
  114557. /** @hidden */
  114558. get _lodTextureMid(): Nullable<BaseTexture>;
  114559. /** @hidden */
  114560. get _lodTextureLow(): Nullable<BaseTexture>;
  114561. /**
  114562. * Dispose the texture and release its associated resources.
  114563. */
  114564. dispose(): void;
  114565. /**
  114566. * Serialize the texture into a JSON representation that can be parsed later on.
  114567. * @returns the JSON representation of the texture
  114568. */
  114569. serialize(): any;
  114570. /**
  114571. * Helper function to be called back once a list of texture contains only ready textures.
  114572. * @param textures Define the list of textures to wait for
  114573. * @param callback Define the callback triggered once the entire list will be ready
  114574. */
  114575. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114576. private static _isScene;
  114577. }
  114578. }
  114579. declare module BABYLON {
  114580. /**
  114581. * Options to be used when creating an effect.
  114582. */
  114583. export interface IEffectCreationOptions {
  114584. /**
  114585. * Atrributes that will be used in the shader.
  114586. */
  114587. attributes: string[];
  114588. /**
  114589. * Uniform varible names that will be set in the shader.
  114590. */
  114591. uniformsNames: string[];
  114592. /**
  114593. * Uniform buffer variable names that will be set in the shader.
  114594. */
  114595. uniformBuffersNames: string[];
  114596. /**
  114597. * Sampler texture variable names that will be set in the shader.
  114598. */
  114599. samplers: string[];
  114600. /**
  114601. * Define statements that will be set in the shader.
  114602. */
  114603. defines: any;
  114604. /**
  114605. * Possible fallbacks for this effect to improve performance when needed.
  114606. */
  114607. fallbacks: Nullable<IEffectFallbacks>;
  114608. /**
  114609. * Callback that will be called when the shader is compiled.
  114610. */
  114611. onCompiled: Nullable<(effect: Effect) => void>;
  114612. /**
  114613. * Callback that will be called if an error occurs during shader compilation.
  114614. */
  114615. onError: Nullable<(effect: Effect, errors: string) => void>;
  114616. /**
  114617. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114618. */
  114619. indexParameters?: any;
  114620. /**
  114621. * Max number of lights that can be used in the shader.
  114622. */
  114623. maxSimultaneousLights?: number;
  114624. /**
  114625. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114626. */
  114627. transformFeedbackVaryings?: Nullable<string[]>;
  114628. /**
  114629. * 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
  114630. */
  114631. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114632. /**
  114633. * Is this effect rendering to several color attachments ?
  114634. */
  114635. multiTarget?: boolean;
  114636. }
  114637. /**
  114638. * Effect containing vertex and fragment shader that can be executed on an object.
  114639. */
  114640. export class Effect implements IDisposable {
  114641. /**
  114642. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114643. */
  114644. static ShadersRepository: string;
  114645. /**
  114646. * Enable logging of the shader code when a compilation error occurs
  114647. */
  114648. static LogShaderCodeOnCompilationError: boolean;
  114649. /**
  114650. * Name of the effect.
  114651. */
  114652. name: any;
  114653. /**
  114654. * String container all the define statements that should be set on the shader.
  114655. */
  114656. defines: string;
  114657. /**
  114658. * Callback that will be called when the shader is compiled.
  114659. */
  114660. onCompiled: Nullable<(effect: Effect) => void>;
  114661. /**
  114662. * Callback that will be called if an error occurs during shader compilation.
  114663. */
  114664. onError: Nullable<(effect: Effect, errors: string) => void>;
  114665. /**
  114666. * Callback that will be called when effect is bound.
  114667. */
  114668. onBind: Nullable<(effect: Effect) => void>;
  114669. /**
  114670. * Unique ID of the effect.
  114671. */
  114672. uniqueId: number;
  114673. /**
  114674. * Observable that will be called when the shader is compiled.
  114675. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114676. */
  114677. onCompileObservable: Observable<Effect>;
  114678. /**
  114679. * Observable that will be called if an error occurs during shader compilation.
  114680. */
  114681. onErrorObservable: Observable<Effect>;
  114682. /** @hidden */
  114683. _onBindObservable: Nullable<Observable<Effect>>;
  114684. /**
  114685. * @hidden
  114686. * Specifies if the effect was previously ready
  114687. */
  114688. _wasPreviouslyReady: boolean;
  114689. /**
  114690. * Observable that will be called when effect is bound.
  114691. */
  114692. get onBindObservable(): Observable<Effect>;
  114693. /** @hidden */
  114694. _bonesComputationForcedToCPU: boolean;
  114695. /** @hidden */
  114696. _multiTarget: boolean;
  114697. private static _uniqueIdSeed;
  114698. private _engine;
  114699. private _uniformBuffersNames;
  114700. private _uniformBuffersNamesList;
  114701. private _uniformsNames;
  114702. private _samplerList;
  114703. private _samplers;
  114704. private _isReady;
  114705. private _compilationError;
  114706. private _allFallbacksProcessed;
  114707. private _attributesNames;
  114708. private _attributes;
  114709. private _attributeLocationByName;
  114710. private _uniforms;
  114711. /**
  114712. * Key for the effect.
  114713. * @hidden
  114714. */
  114715. _key: string;
  114716. private _indexParameters;
  114717. private _fallbacks;
  114718. private _vertexSourceCode;
  114719. private _fragmentSourceCode;
  114720. private _vertexSourceCodeOverride;
  114721. private _fragmentSourceCodeOverride;
  114722. private _transformFeedbackVaryings;
  114723. /**
  114724. * Compiled shader to webGL program.
  114725. * @hidden
  114726. */
  114727. _pipelineContext: Nullable<IPipelineContext>;
  114728. private _valueCache;
  114729. private static _baseCache;
  114730. /**
  114731. * Instantiates an effect.
  114732. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114733. * @param baseName Name of the effect.
  114734. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114735. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114736. * @param samplers List of sampler variables that will be passed to the shader.
  114737. * @param engine Engine to be used to render the effect
  114738. * @param defines Define statements to be added to the shader.
  114739. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114740. * @param onCompiled Callback that will be called when the shader is compiled.
  114741. * @param onError Callback that will be called if an error occurs during shader compilation.
  114742. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114743. */
  114744. 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);
  114745. private _useFinalCode;
  114746. /**
  114747. * Unique key for this effect
  114748. */
  114749. get key(): string;
  114750. /**
  114751. * If the effect has been compiled and prepared.
  114752. * @returns if the effect is compiled and prepared.
  114753. */
  114754. isReady(): boolean;
  114755. private _isReadyInternal;
  114756. /**
  114757. * The engine the effect was initialized with.
  114758. * @returns the engine.
  114759. */
  114760. getEngine(): Engine;
  114761. /**
  114762. * The pipeline context for this effect
  114763. * @returns the associated pipeline context
  114764. */
  114765. getPipelineContext(): Nullable<IPipelineContext>;
  114766. /**
  114767. * The set of names of attribute variables for the shader.
  114768. * @returns An array of attribute names.
  114769. */
  114770. getAttributesNames(): string[];
  114771. /**
  114772. * Returns the attribute at the given index.
  114773. * @param index The index of the attribute.
  114774. * @returns The location of the attribute.
  114775. */
  114776. getAttributeLocation(index: number): number;
  114777. /**
  114778. * Returns the attribute based on the name of the variable.
  114779. * @param name of the attribute to look up.
  114780. * @returns the attribute location.
  114781. */
  114782. getAttributeLocationByName(name: string): number;
  114783. /**
  114784. * The number of attributes.
  114785. * @returns the numnber of attributes.
  114786. */
  114787. getAttributesCount(): number;
  114788. /**
  114789. * Gets the index of a uniform variable.
  114790. * @param uniformName of the uniform to look up.
  114791. * @returns the index.
  114792. */
  114793. getUniformIndex(uniformName: string): number;
  114794. /**
  114795. * Returns the attribute based on the name of the variable.
  114796. * @param uniformName of the uniform to look up.
  114797. * @returns the location of the uniform.
  114798. */
  114799. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114800. /**
  114801. * Returns an array of sampler variable names
  114802. * @returns The array of sampler variable names.
  114803. */
  114804. getSamplers(): string[];
  114805. /**
  114806. * Returns an array of uniform variable names
  114807. * @returns The array of uniform variable names.
  114808. */
  114809. getUniformNames(): string[];
  114810. /**
  114811. * Returns an array of uniform buffer variable names
  114812. * @returns The array of uniform buffer variable names.
  114813. */
  114814. getUniformBuffersNames(): string[];
  114815. /**
  114816. * Returns the index parameters used to create the effect
  114817. * @returns The index parameters object
  114818. */
  114819. getIndexParameters(): any;
  114820. /**
  114821. * The error from the last compilation.
  114822. * @returns the error string.
  114823. */
  114824. getCompilationError(): string;
  114825. /**
  114826. * Gets a boolean indicating that all fallbacks were used during compilation
  114827. * @returns true if all fallbacks were used
  114828. */
  114829. allFallbacksProcessed(): boolean;
  114830. /**
  114831. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114832. * @param func The callback to be used.
  114833. */
  114834. executeWhenCompiled(func: (effect: Effect) => void): void;
  114835. private _checkIsReady;
  114836. private _loadShader;
  114837. /**
  114838. * Gets the vertex shader source code of this effect
  114839. */
  114840. get vertexSourceCode(): string;
  114841. /**
  114842. * Gets the fragment shader source code of this effect
  114843. */
  114844. get fragmentSourceCode(): string;
  114845. /**
  114846. * Recompiles the webGL program
  114847. * @param vertexSourceCode The source code for the vertex shader.
  114848. * @param fragmentSourceCode The source code for the fragment shader.
  114849. * @param onCompiled Callback called when completed.
  114850. * @param onError Callback called on error.
  114851. * @hidden
  114852. */
  114853. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114854. /**
  114855. * Prepares the effect
  114856. * @hidden
  114857. */
  114858. _prepareEffect(): void;
  114859. private _getShaderCodeAndErrorLine;
  114860. private _processCompilationErrors;
  114861. /**
  114862. * Checks if the effect is supported. (Must be called after compilation)
  114863. */
  114864. get isSupported(): boolean;
  114865. /**
  114866. * Binds a texture to the engine to be used as output of the shader.
  114867. * @param channel Name of the output variable.
  114868. * @param texture Texture to bind.
  114869. * @hidden
  114870. */
  114871. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114872. /**
  114873. * Sets a texture on the engine to be used in the shader.
  114874. * @param channel Name of the sampler variable.
  114875. * @param texture Texture to set.
  114876. */
  114877. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114878. /**
  114879. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114880. * @param channel Name of the sampler variable.
  114881. * @param texture Texture to set.
  114882. */
  114883. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114884. /**
  114885. * Sets an array of textures on the engine to be used in the shader.
  114886. * @param channel Name of the variable.
  114887. * @param textures Textures to set.
  114888. */
  114889. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114890. /**
  114891. * 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)
  114892. * @param channel Name of the sampler variable.
  114893. * @param postProcess Post process to get the input texture from.
  114894. */
  114895. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114896. /**
  114897. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114898. * 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)
  114899. * @param channel Name of the sampler variable.
  114900. * @param postProcess Post process to get the output texture from.
  114901. */
  114902. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114903. /** @hidden */
  114904. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114905. /** @hidden */
  114906. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114907. /** @hidden */
  114908. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114909. /** @hidden */
  114910. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114911. /**
  114912. * Binds a buffer to a uniform.
  114913. * @param buffer Buffer to bind.
  114914. * @param name Name of the uniform variable to bind to.
  114915. */
  114916. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114917. /**
  114918. * Binds block to a uniform.
  114919. * @param blockName Name of the block to bind.
  114920. * @param index Index to bind.
  114921. */
  114922. bindUniformBlock(blockName: string, index: number): void;
  114923. /**
  114924. * Sets an interger value on a uniform variable.
  114925. * @param uniformName Name of the variable.
  114926. * @param value Value to be set.
  114927. * @returns this effect.
  114928. */
  114929. setInt(uniformName: string, value: number): Effect;
  114930. /**
  114931. * Sets an int array on a uniform variable.
  114932. * @param uniformName Name of the variable.
  114933. * @param array array to be set.
  114934. * @returns this effect.
  114935. */
  114936. setIntArray(uniformName: string, array: Int32Array): Effect;
  114937. /**
  114938. * 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)
  114939. * @param uniformName Name of the variable.
  114940. * @param array array to be set.
  114941. * @returns this effect.
  114942. */
  114943. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114944. /**
  114945. * 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)
  114946. * @param uniformName Name of the variable.
  114947. * @param array array to be set.
  114948. * @returns this effect.
  114949. */
  114950. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114951. /**
  114952. * 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)
  114953. * @param uniformName Name of the variable.
  114954. * @param array array to be set.
  114955. * @returns this effect.
  114956. */
  114957. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114958. /**
  114959. * Sets an float array on a uniform variable.
  114960. * @param uniformName Name of the variable.
  114961. * @param array array to be set.
  114962. * @returns this effect.
  114963. */
  114964. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114965. /**
  114966. * 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)
  114967. * @param uniformName Name of the variable.
  114968. * @param array array to be set.
  114969. * @returns this effect.
  114970. */
  114971. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114972. /**
  114973. * 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)
  114974. * @param uniformName Name of the variable.
  114975. * @param array array to be set.
  114976. * @returns this effect.
  114977. */
  114978. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114979. /**
  114980. * 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)
  114981. * @param uniformName Name of the variable.
  114982. * @param array array to be set.
  114983. * @returns this effect.
  114984. */
  114985. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114986. /**
  114987. * Sets an array on a uniform variable.
  114988. * @param uniformName Name of the variable.
  114989. * @param array array to be set.
  114990. * @returns this effect.
  114991. */
  114992. setArray(uniformName: string, array: number[]): Effect;
  114993. /**
  114994. * 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)
  114995. * @param uniformName Name of the variable.
  114996. * @param array array to be set.
  114997. * @returns this effect.
  114998. */
  114999. setArray2(uniformName: string, array: number[]): Effect;
  115000. /**
  115001. * 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)
  115002. * @param uniformName Name of the variable.
  115003. * @param array array to be set.
  115004. * @returns this effect.
  115005. */
  115006. setArray3(uniformName: string, array: number[]): Effect;
  115007. /**
  115008. * 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)
  115009. * @param uniformName Name of the variable.
  115010. * @param array array to be set.
  115011. * @returns this effect.
  115012. */
  115013. setArray4(uniformName: string, array: number[]): Effect;
  115014. /**
  115015. * Sets matrices on a uniform variable.
  115016. * @param uniformName Name of the variable.
  115017. * @param matrices matrices to be set.
  115018. * @returns this effect.
  115019. */
  115020. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  115021. /**
  115022. * Sets matrix on a uniform variable.
  115023. * @param uniformName Name of the variable.
  115024. * @param matrix matrix to be set.
  115025. * @returns this effect.
  115026. */
  115027. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  115028. /**
  115029. * 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)
  115030. * @param uniformName Name of the variable.
  115031. * @param matrix matrix to be set.
  115032. * @returns this effect.
  115033. */
  115034. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115035. /**
  115036. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  115037. * @param uniformName Name of the variable.
  115038. * @param matrix matrix to be set.
  115039. * @returns this effect.
  115040. */
  115041. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115042. /**
  115043. * Sets a float on a uniform variable.
  115044. * @param uniformName Name of the variable.
  115045. * @param value value to be set.
  115046. * @returns this effect.
  115047. */
  115048. setFloat(uniformName: string, value: number): Effect;
  115049. /**
  115050. * Sets a boolean on a uniform variable.
  115051. * @param uniformName Name of the variable.
  115052. * @param bool value to be set.
  115053. * @returns this effect.
  115054. */
  115055. setBool(uniformName: string, bool: boolean): Effect;
  115056. /**
  115057. * Sets a Vector2 on a uniform variable.
  115058. * @param uniformName Name of the variable.
  115059. * @param vector2 vector2 to be set.
  115060. * @returns this effect.
  115061. */
  115062. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  115063. /**
  115064. * Sets a float2 on a uniform variable.
  115065. * @param uniformName Name of the variable.
  115066. * @param x First float in float2.
  115067. * @param y Second float in float2.
  115068. * @returns this effect.
  115069. */
  115070. setFloat2(uniformName: string, x: number, y: number): Effect;
  115071. /**
  115072. * Sets a Vector3 on a uniform variable.
  115073. * @param uniformName Name of the variable.
  115074. * @param vector3 Value to be set.
  115075. * @returns this effect.
  115076. */
  115077. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  115078. /**
  115079. * Sets a float3 on a uniform variable.
  115080. * @param uniformName Name of the variable.
  115081. * @param x First float in float3.
  115082. * @param y Second float in float3.
  115083. * @param z Third float in float3.
  115084. * @returns this effect.
  115085. */
  115086. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  115087. /**
  115088. * Sets a Vector4 on a uniform variable.
  115089. * @param uniformName Name of the variable.
  115090. * @param vector4 Value to be set.
  115091. * @returns this effect.
  115092. */
  115093. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  115094. /**
  115095. * Sets a float4 on a uniform variable.
  115096. * @param uniformName Name of the variable.
  115097. * @param x First float in float4.
  115098. * @param y Second float in float4.
  115099. * @param z Third float in float4.
  115100. * @param w Fourth float in float4.
  115101. * @returns this effect.
  115102. */
  115103. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  115104. /**
  115105. * Sets a Color3 on a uniform variable.
  115106. * @param uniformName Name of the variable.
  115107. * @param color3 Value to be set.
  115108. * @returns this effect.
  115109. */
  115110. setColor3(uniformName: string, color3: IColor3Like): Effect;
  115111. /**
  115112. * Sets a Color4 on a uniform variable.
  115113. * @param uniformName Name of the variable.
  115114. * @param color3 Value to be set.
  115115. * @param alpha Alpha value to be set.
  115116. * @returns this effect.
  115117. */
  115118. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  115119. /**
  115120. * Sets a Color4 on a uniform variable
  115121. * @param uniformName defines the name of the variable
  115122. * @param color4 defines the value to be set
  115123. * @returns this effect.
  115124. */
  115125. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  115126. /** Release all associated resources */
  115127. dispose(): void;
  115128. /**
  115129. * This function will add a new shader to the shader store
  115130. * @param name the name of the shader
  115131. * @param pixelShader optional pixel shader content
  115132. * @param vertexShader optional vertex shader content
  115133. */
  115134. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  115135. /**
  115136. * Store of each shader (The can be looked up using effect.key)
  115137. */
  115138. static ShadersStore: {
  115139. [key: string]: string;
  115140. };
  115141. /**
  115142. * Store of each included file for a shader (The can be looked up using effect.key)
  115143. */
  115144. static IncludesShadersStore: {
  115145. [key: string]: string;
  115146. };
  115147. /**
  115148. * Resets the cache of effects.
  115149. */
  115150. static ResetCache(): void;
  115151. }
  115152. }
  115153. declare module BABYLON {
  115154. /**
  115155. * Interface used to describe the capabilities of the engine relatively to the current browser
  115156. */
  115157. export interface EngineCapabilities {
  115158. /** Maximum textures units per fragment shader */
  115159. maxTexturesImageUnits: number;
  115160. /** Maximum texture units per vertex shader */
  115161. maxVertexTextureImageUnits: number;
  115162. /** Maximum textures units in the entire pipeline */
  115163. maxCombinedTexturesImageUnits: number;
  115164. /** Maximum texture size */
  115165. maxTextureSize: number;
  115166. /** Maximum texture samples */
  115167. maxSamples?: number;
  115168. /** Maximum cube texture size */
  115169. maxCubemapTextureSize: number;
  115170. /** Maximum render texture size */
  115171. maxRenderTextureSize: number;
  115172. /** Maximum number of vertex attributes */
  115173. maxVertexAttribs: number;
  115174. /** Maximum number of varyings */
  115175. maxVaryingVectors: number;
  115176. /** Maximum number of uniforms per vertex shader */
  115177. maxVertexUniformVectors: number;
  115178. /** Maximum number of uniforms per fragment shader */
  115179. maxFragmentUniformVectors: number;
  115180. /** Defines if standard derivates (dx/dy) are supported */
  115181. standardDerivatives: boolean;
  115182. /** Defines if s3tc texture compression is supported */
  115183. s3tc?: WEBGL_compressed_texture_s3tc;
  115184. /** Defines if pvrtc texture compression is supported */
  115185. pvrtc: any;
  115186. /** Defines if etc1 texture compression is supported */
  115187. etc1: any;
  115188. /** Defines if etc2 texture compression is supported */
  115189. etc2: any;
  115190. /** Defines if astc texture compression is supported */
  115191. astc: any;
  115192. /** Defines if bptc texture compression is supported */
  115193. bptc: any;
  115194. /** Defines if float textures are supported */
  115195. textureFloat: boolean;
  115196. /** Defines if vertex array objects are supported */
  115197. vertexArrayObject: boolean;
  115198. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  115199. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  115200. /** Gets the maximum level of anisotropy supported */
  115201. maxAnisotropy: number;
  115202. /** Defines if instancing is supported */
  115203. instancedArrays: boolean;
  115204. /** Defines if 32 bits indices are supported */
  115205. uintIndices: boolean;
  115206. /** Defines if high precision shaders are supported */
  115207. highPrecisionShaderSupported: boolean;
  115208. /** Defines if depth reading in the fragment shader is supported */
  115209. fragmentDepthSupported: boolean;
  115210. /** Defines if float texture linear filtering is supported*/
  115211. textureFloatLinearFiltering: boolean;
  115212. /** Defines if rendering to float textures is supported */
  115213. textureFloatRender: boolean;
  115214. /** Defines if half float textures are supported*/
  115215. textureHalfFloat: boolean;
  115216. /** Defines if half float texture linear filtering is supported*/
  115217. textureHalfFloatLinearFiltering: boolean;
  115218. /** Defines if rendering to half float textures is supported */
  115219. textureHalfFloatRender: boolean;
  115220. /** Defines if textureLOD shader command is supported */
  115221. textureLOD: boolean;
  115222. /** Defines if draw buffers extension is supported */
  115223. drawBuffersExtension: boolean;
  115224. /** Defines if depth textures are supported */
  115225. depthTextureExtension: boolean;
  115226. /** Defines if float color buffer are supported */
  115227. colorBufferFloat: boolean;
  115228. /** Gets disjoint timer query extension (null if not supported) */
  115229. timerQuery?: EXT_disjoint_timer_query;
  115230. /** Defines if timestamp can be used with timer query */
  115231. canUseTimestampForTimerQuery: boolean;
  115232. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  115233. multiview?: any;
  115234. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  115235. oculusMultiview?: any;
  115236. /** Function used to let the system compiles shaders in background */
  115237. parallelShaderCompile?: {
  115238. COMPLETION_STATUS_KHR: number;
  115239. };
  115240. /** Max number of texture samples for MSAA */
  115241. maxMSAASamples: number;
  115242. /** Defines if the blend min max extension is supported */
  115243. blendMinMax: boolean;
  115244. }
  115245. }
  115246. declare module BABYLON {
  115247. /**
  115248. * @hidden
  115249. **/
  115250. export class DepthCullingState {
  115251. private _isDepthTestDirty;
  115252. private _isDepthMaskDirty;
  115253. private _isDepthFuncDirty;
  115254. private _isCullFaceDirty;
  115255. private _isCullDirty;
  115256. private _isZOffsetDirty;
  115257. private _isFrontFaceDirty;
  115258. private _depthTest;
  115259. private _depthMask;
  115260. private _depthFunc;
  115261. private _cull;
  115262. private _cullFace;
  115263. private _zOffset;
  115264. private _frontFace;
  115265. /**
  115266. * Initializes the state.
  115267. */
  115268. constructor();
  115269. get isDirty(): boolean;
  115270. get zOffset(): number;
  115271. set zOffset(value: number);
  115272. get cullFace(): Nullable<number>;
  115273. set cullFace(value: Nullable<number>);
  115274. get cull(): Nullable<boolean>;
  115275. set cull(value: Nullable<boolean>);
  115276. get depthFunc(): Nullable<number>;
  115277. set depthFunc(value: Nullable<number>);
  115278. get depthMask(): boolean;
  115279. set depthMask(value: boolean);
  115280. get depthTest(): boolean;
  115281. set depthTest(value: boolean);
  115282. get frontFace(): Nullable<number>;
  115283. set frontFace(value: Nullable<number>);
  115284. reset(): void;
  115285. apply(gl: WebGLRenderingContext): void;
  115286. }
  115287. }
  115288. declare module BABYLON {
  115289. /**
  115290. * @hidden
  115291. **/
  115292. export class StencilState {
  115293. /** 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 */
  115294. static readonly ALWAYS: number;
  115295. /** Passed to stencilOperation to specify that stencil value must be kept */
  115296. static readonly KEEP: number;
  115297. /** Passed to stencilOperation to specify that stencil value must be replaced */
  115298. static readonly REPLACE: number;
  115299. private _isStencilTestDirty;
  115300. private _isStencilMaskDirty;
  115301. private _isStencilFuncDirty;
  115302. private _isStencilOpDirty;
  115303. private _stencilTest;
  115304. private _stencilMask;
  115305. private _stencilFunc;
  115306. private _stencilFuncRef;
  115307. private _stencilFuncMask;
  115308. private _stencilOpStencilFail;
  115309. private _stencilOpDepthFail;
  115310. private _stencilOpStencilDepthPass;
  115311. get isDirty(): boolean;
  115312. get stencilFunc(): number;
  115313. set stencilFunc(value: number);
  115314. get stencilFuncRef(): number;
  115315. set stencilFuncRef(value: number);
  115316. get stencilFuncMask(): number;
  115317. set stencilFuncMask(value: number);
  115318. get stencilOpStencilFail(): number;
  115319. set stencilOpStencilFail(value: number);
  115320. get stencilOpDepthFail(): number;
  115321. set stencilOpDepthFail(value: number);
  115322. get stencilOpStencilDepthPass(): number;
  115323. set stencilOpStencilDepthPass(value: number);
  115324. get stencilMask(): number;
  115325. set stencilMask(value: number);
  115326. get stencilTest(): boolean;
  115327. set stencilTest(value: boolean);
  115328. constructor();
  115329. reset(): void;
  115330. apply(gl: WebGLRenderingContext): void;
  115331. }
  115332. }
  115333. declare module BABYLON {
  115334. /**
  115335. * @hidden
  115336. **/
  115337. export class AlphaState {
  115338. private _isAlphaBlendDirty;
  115339. private _isBlendFunctionParametersDirty;
  115340. private _isBlendEquationParametersDirty;
  115341. private _isBlendConstantsDirty;
  115342. private _alphaBlend;
  115343. private _blendFunctionParameters;
  115344. private _blendEquationParameters;
  115345. private _blendConstants;
  115346. /**
  115347. * Initializes the state.
  115348. */
  115349. constructor();
  115350. get isDirty(): boolean;
  115351. get alphaBlend(): boolean;
  115352. set alphaBlend(value: boolean);
  115353. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  115354. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  115355. setAlphaEquationParameters(rgb: number, alpha: number): void;
  115356. reset(): void;
  115357. apply(gl: WebGLRenderingContext): void;
  115358. }
  115359. }
  115360. declare module BABYLON {
  115361. /** @hidden */
  115362. export class WebGL2ShaderProcessor implements IShaderProcessor {
  115363. attributeProcessor(attribute: string): string;
  115364. varyingProcessor(varying: string, isFragment: boolean): string;
  115365. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115366. }
  115367. }
  115368. declare module BABYLON {
  115369. /**
  115370. * Interface for attribute information associated with buffer instanciation
  115371. */
  115372. export interface InstancingAttributeInfo {
  115373. /**
  115374. * Name of the GLSL attribute
  115375. * if attribute index is not specified, this is used to retrieve the index from the effect
  115376. */
  115377. attributeName: string;
  115378. /**
  115379. * Index/offset of the attribute in the vertex shader
  115380. * if not specified, this will be computes from the name.
  115381. */
  115382. index?: number;
  115383. /**
  115384. * size of the attribute, 1, 2, 3 or 4
  115385. */
  115386. attributeSize: number;
  115387. /**
  115388. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  115389. */
  115390. offset: number;
  115391. /**
  115392. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  115393. * default to 1
  115394. */
  115395. divisor?: number;
  115396. /**
  115397. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  115398. * default is FLOAT
  115399. */
  115400. attributeType?: number;
  115401. /**
  115402. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  115403. */
  115404. normalized?: boolean;
  115405. }
  115406. }
  115407. declare module BABYLON {
  115408. interface ThinEngine {
  115409. /**
  115410. * Update a video texture
  115411. * @param texture defines the texture to update
  115412. * @param video defines the video element to use
  115413. * @param invertY defines if data must be stored with Y axis inverted
  115414. */
  115415. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  115416. }
  115417. }
  115418. declare module BABYLON {
  115419. interface ThinEngine {
  115420. /**
  115421. * Creates a dynamic texture
  115422. * @param width defines the width of the texture
  115423. * @param height defines the height of the texture
  115424. * @param generateMipMaps defines if the engine should generate the mip levels
  115425. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  115426. * @returns the dynamic texture inside an InternalTexture
  115427. */
  115428. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  115429. /**
  115430. * Update the content of a dynamic texture
  115431. * @param texture defines the texture to update
  115432. * @param canvas defines the canvas containing the source
  115433. * @param invertY defines if data must be stored with Y axis inverted
  115434. * @param premulAlpha defines if alpha is stored as premultiplied
  115435. * @param format defines the format of the data
  115436. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115437. */
  115438. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  115439. }
  115440. }
  115441. declare module BABYLON {
  115442. /**
  115443. * Settings for finer control over video usage
  115444. */
  115445. export interface VideoTextureSettings {
  115446. /**
  115447. * Applies `autoplay` to video, if specified
  115448. */
  115449. autoPlay?: boolean;
  115450. /**
  115451. * Applies `loop` to video, if specified
  115452. */
  115453. loop?: boolean;
  115454. /**
  115455. * Automatically updates internal texture from video at every frame in the render loop
  115456. */
  115457. autoUpdateTexture: boolean;
  115458. /**
  115459. * Image src displayed during the video loading or until the user interacts with the video.
  115460. */
  115461. poster?: string;
  115462. }
  115463. /**
  115464. * If you want to display a video in your scene, this is the special texture for that.
  115465. * This special texture works similar to other textures, with the exception of a few parameters.
  115466. * @see https://doc.babylonjs.com/how_to/video_texture
  115467. */
  115468. export class VideoTexture extends Texture {
  115469. /**
  115470. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115471. */
  115472. readonly autoUpdateTexture: boolean;
  115473. /**
  115474. * The video instance used by the texture internally
  115475. */
  115476. readonly video: HTMLVideoElement;
  115477. private _onUserActionRequestedObservable;
  115478. /**
  115479. * Event triggerd when a dom action is required by the user to play the video.
  115480. * This happens due to recent changes in browser policies preventing video to auto start.
  115481. */
  115482. get onUserActionRequestedObservable(): Observable<Texture>;
  115483. private _generateMipMaps;
  115484. private _stillImageCaptured;
  115485. private _displayingPosterTexture;
  115486. private _settings;
  115487. private _createInternalTextureOnEvent;
  115488. private _frameId;
  115489. private _currentSrc;
  115490. /**
  115491. * Creates a video texture.
  115492. * If you want to display a video in your scene, this is the special texture for that.
  115493. * This special texture works similar to other textures, with the exception of a few parameters.
  115494. * @see https://doc.babylonjs.com/how_to/video_texture
  115495. * @param name optional name, will detect from video source, if not defined
  115496. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115497. * @param scene is obviously the current scene.
  115498. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115499. * @param invertY is false by default but can be used to invert video on Y axis
  115500. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115501. * @param settings allows finer control over video usage
  115502. */
  115503. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115504. private _getName;
  115505. private _getVideo;
  115506. private _createInternalTexture;
  115507. private reset;
  115508. /**
  115509. * @hidden Internal method to initiate `update`.
  115510. */
  115511. _rebuild(): void;
  115512. /**
  115513. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115514. */
  115515. update(): void;
  115516. /**
  115517. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115518. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115519. */
  115520. updateTexture(isVisible: boolean): void;
  115521. protected _updateInternalTexture: () => void;
  115522. /**
  115523. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115524. * @param url New url.
  115525. */
  115526. updateURL(url: string): void;
  115527. /**
  115528. * Clones the texture.
  115529. * @returns the cloned texture
  115530. */
  115531. clone(): VideoTexture;
  115532. /**
  115533. * Dispose the texture and release its associated resources.
  115534. */
  115535. dispose(): void;
  115536. /**
  115537. * Creates a video texture straight from a stream.
  115538. * @param scene Define the scene the texture should be created in
  115539. * @param stream Define the stream the texture should be created from
  115540. * @returns The created video texture as a promise
  115541. */
  115542. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115543. /**
  115544. * Creates a video texture straight from your WebCam video feed.
  115545. * @param scene Define the scene the texture should be created in
  115546. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115547. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115548. * @returns The created video texture as a promise
  115549. */
  115550. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115551. minWidth: number;
  115552. maxWidth: number;
  115553. minHeight: number;
  115554. maxHeight: number;
  115555. deviceId: string;
  115556. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115557. /**
  115558. * Creates a video texture straight from your WebCam video feed.
  115559. * @param scene Define the scene the texture should be created in
  115560. * @param onReady Define a callback to triggered once the texture will be ready
  115561. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115562. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115563. */
  115564. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115565. minWidth: number;
  115566. maxWidth: number;
  115567. minHeight: number;
  115568. maxHeight: number;
  115569. deviceId: string;
  115570. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115571. }
  115572. }
  115573. declare module BABYLON {
  115574. /**
  115575. * Defines the interface used by objects working like Scene
  115576. * @hidden
  115577. */
  115578. export interface ISceneLike {
  115579. _addPendingData(data: any): void;
  115580. _removePendingData(data: any): void;
  115581. offlineProvider: IOfflineProvider;
  115582. }
  115583. /**
  115584. * Information about the current host
  115585. */
  115586. export interface HostInformation {
  115587. /**
  115588. * Defines if the current host is a mobile
  115589. */
  115590. isMobile: boolean;
  115591. }
  115592. /** Interface defining initialization parameters for Engine class */
  115593. export interface EngineOptions extends WebGLContextAttributes {
  115594. /**
  115595. * Defines if the engine should no exceed a specified device ratio
  115596. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115597. */
  115598. limitDeviceRatio?: number;
  115599. /**
  115600. * Defines if webvr should be enabled automatically
  115601. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115602. */
  115603. autoEnableWebVR?: boolean;
  115604. /**
  115605. * Defines if webgl2 should be turned off even if supported
  115606. * @see https://doc.babylonjs.com/features/webgl2
  115607. */
  115608. disableWebGL2Support?: boolean;
  115609. /**
  115610. * Defines if webaudio should be initialized as well
  115611. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115612. */
  115613. audioEngine?: boolean;
  115614. /**
  115615. * Defines if animations should run using a deterministic lock step
  115616. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115617. */
  115618. deterministicLockstep?: boolean;
  115619. /** Defines the maximum steps to use with deterministic lock step mode */
  115620. lockstepMaxSteps?: number;
  115621. /** Defines the seconds between each deterministic lock step */
  115622. timeStep?: number;
  115623. /**
  115624. * Defines that engine should ignore context lost events
  115625. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115626. */
  115627. doNotHandleContextLost?: boolean;
  115628. /**
  115629. * Defines that engine should ignore modifying touch action attribute and style
  115630. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115631. */
  115632. doNotHandleTouchAction?: boolean;
  115633. /**
  115634. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115635. */
  115636. useHighPrecisionFloats?: boolean;
  115637. /**
  115638. * Make the canvas XR Compatible for XR sessions
  115639. */
  115640. xrCompatible?: boolean;
  115641. /**
  115642. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115643. */
  115644. useHighPrecisionMatrix?: boolean;
  115645. }
  115646. /**
  115647. * The base engine class (root of all engines)
  115648. */
  115649. export class ThinEngine {
  115650. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115651. static ExceptionList: ({
  115652. key: string;
  115653. capture: string;
  115654. captureConstraint: number;
  115655. targets: string[];
  115656. } | {
  115657. key: string;
  115658. capture: null;
  115659. captureConstraint: null;
  115660. targets: string[];
  115661. })[];
  115662. /** @hidden */
  115663. static _TextureLoaders: IInternalTextureLoader[];
  115664. /**
  115665. * Returns the current npm package of the sdk
  115666. */
  115667. static get NpmPackage(): string;
  115668. /**
  115669. * Returns the current version of the framework
  115670. */
  115671. static get Version(): string;
  115672. /**
  115673. * Returns a string describing the current engine
  115674. */
  115675. get description(): string;
  115676. /**
  115677. * Gets or sets the epsilon value used by collision engine
  115678. */
  115679. static CollisionsEpsilon: number;
  115680. /**
  115681. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115682. */
  115683. static get ShadersRepository(): string;
  115684. static set ShadersRepository(value: string);
  115685. /** @hidden */
  115686. _shaderProcessor: IShaderProcessor;
  115687. /**
  115688. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115689. */
  115690. forcePOTTextures: boolean;
  115691. /**
  115692. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115693. */
  115694. isFullscreen: boolean;
  115695. /**
  115696. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115697. */
  115698. cullBackFaces: boolean;
  115699. /**
  115700. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115701. */
  115702. renderEvenInBackground: boolean;
  115703. /**
  115704. * Gets or sets a boolean indicating that cache can be kept between frames
  115705. */
  115706. preventCacheWipeBetweenFrames: boolean;
  115707. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  115708. validateShaderPrograms: boolean;
  115709. /**
  115710. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  115711. * This can provide greater z depth for distant objects.
  115712. */
  115713. useReverseDepthBuffer: boolean;
  115714. /**
  115715. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  115716. */
  115717. disableUniformBuffers: boolean;
  115718. /** @hidden */
  115719. _uniformBuffers: UniformBuffer[];
  115720. /**
  115721. * Gets a boolean indicating that the engine supports uniform buffers
  115722. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115723. */
  115724. get supportsUniformBuffers(): boolean;
  115725. /** @hidden */
  115726. _gl: WebGLRenderingContext;
  115727. /** @hidden */
  115728. _webGLVersion: number;
  115729. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115730. protected _windowIsBackground: boolean;
  115731. protected _creationOptions: EngineOptions;
  115732. protected _highPrecisionShadersAllowed: boolean;
  115733. /** @hidden */
  115734. get _shouldUseHighPrecisionShader(): boolean;
  115735. /**
  115736. * Gets a boolean indicating that only power of 2 textures are supported
  115737. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115738. */
  115739. get needPOTTextures(): boolean;
  115740. /** @hidden */
  115741. _badOS: boolean;
  115742. /** @hidden */
  115743. _badDesktopOS: boolean;
  115744. private _hardwareScalingLevel;
  115745. /** @hidden */
  115746. _caps: EngineCapabilities;
  115747. private _isStencilEnable;
  115748. private _glVersion;
  115749. private _glRenderer;
  115750. private _glVendor;
  115751. /** @hidden */
  115752. _videoTextureSupported: boolean;
  115753. protected _renderingQueueLaunched: boolean;
  115754. protected _activeRenderLoops: (() => void)[];
  115755. /**
  115756. * Observable signaled when a context lost event is raised
  115757. */
  115758. onContextLostObservable: Observable<ThinEngine>;
  115759. /**
  115760. * Observable signaled when a context restored event is raised
  115761. */
  115762. onContextRestoredObservable: Observable<ThinEngine>;
  115763. private _onContextLost;
  115764. private _onContextRestored;
  115765. protected _contextWasLost: boolean;
  115766. /** @hidden */
  115767. _doNotHandleContextLost: boolean;
  115768. /**
  115769. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115770. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115771. */
  115772. get doNotHandleContextLost(): boolean;
  115773. set doNotHandleContextLost(value: boolean);
  115774. /**
  115775. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115776. */
  115777. disableVertexArrayObjects: boolean;
  115778. /** @hidden */
  115779. protected _colorWrite: boolean;
  115780. /** @hidden */
  115781. protected _colorWriteChanged: boolean;
  115782. /** @hidden */
  115783. protected _depthCullingState: DepthCullingState;
  115784. /** @hidden */
  115785. protected _stencilState: StencilState;
  115786. /** @hidden */
  115787. _alphaState: AlphaState;
  115788. /** @hidden */
  115789. _alphaMode: number;
  115790. /** @hidden */
  115791. _alphaEquation: number;
  115792. /** @hidden */
  115793. _internalTexturesCache: InternalTexture[];
  115794. /** @hidden */
  115795. protected _activeChannel: number;
  115796. private _currentTextureChannel;
  115797. /** @hidden */
  115798. protected _boundTexturesCache: {
  115799. [key: string]: Nullable<InternalTexture>;
  115800. };
  115801. /** @hidden */
  115802. protected _currentEffect: Nullable<Effect>;
  115803. /** @hidden */
  115804. protected _currentProgram: Nullable<WebGLProgram>;
  115805. private _compiledEffects;
  115806. private _vertexAttribArraysEnabled;
  115807. /** @hidden */
  115808. protected _cachedViewport: Nullable<IViewportLike>;
  115809. private _cachedVertexArrayObject;
  115810. /** @hidden */
  115811. protected _cachedVertexBuffers: any;
  115812. /** @hidden */
  115813. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115814. /** @hidden */
  115815. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115816. /** @hidden */
  115817. _currentRenderTarget: Nullable<InternalTexture>;
  115818. private _uintIndicesCurrentlySet;
  115819. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115820. /** @hidden */
  115821. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115822. /** @hidden */
  115823. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115824. private _currentBufferPointers;
  115825. private _currentInstanceLocations;
  115826. private _currentInstanceBuffers;
  115827. private _textureUnits;
  115828. /** @hidden */
  115829. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115830. /** @hidden */
  115831. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115832. /** @hidden */
  115833. _boundRenderFunction: any;
  115834. private _vaoRecordInProgress;
  115835. private _mustWipeVertexAttributes;
  115836. private _emptyTexture;
  115837. private _emptyCubeTexture;
  115838. private _emptyTexture3D;
  115839. private _emptyTexture2DArray;
  115840. /** @hidden */
  115841. _frameHandler: number;
  115842. private _nextFreeTextureSlots;
  115843. private _maxSimultaneousTextures;
  115844. private _activeRequests;
  115845. /** @hidden */
  115846. _transformTextureUrl: Nullable<(url: string) => string>;
  115847. /**
  115848. * Gets information about the current host
  115849. */
  115850. hostInformation: HostInformation;
  115851. protected get _supportsHardwareTextureRescaling(): boolean;
  115852. private _framebufferDimensionsObject;
  115853. /**
  115854. * sets the object from which width and height will be taken from when getting render width and height
  115855. * Will fallback to the gl object
  115856. * @param dimensions the framebuffer width and height that will be used.
  115857. */
  115858. set framebufferDimensionsObject(dimensions: Nullable<{
  115859. framebufferWidth: number;
  115860. framebufferHeight: number;
  115861. }>);
  115862. /**
  115863. * Gets the current viewport
  115864. */
  115865. get currentViewport(): Nullable<IViewportLike>;
  115866. /**
  115867. * Gets the default empty texture
  115868. */
  115869. get emptyTexture(): InternalTexture;
  115870. /**
  115871. * Gets the default empty 3D texture
  115872. */
  115873. get emptyTexture3D(): InternalTexture;
  115874. /**
  115875. * Gets the default empty 2D array texture
  115876. */
  115877. get emptyTexture2DArray(): InternalTexture;
  115878. /**
  115879. * Gets the default empty cube texture
  115880. */
  115881. get emptyCubeTexture(): InternalTexture;
  115882. /**
  115883. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115884. */
  115885. readonly premultipliedAlpha: boolean;
  115886. /**
  115887. * Observable event triggered before each texture is initialized
  115888. */
  115889. onBeforeTextureInitObservable: Observable<Texture>;
  115890. /**
  115891. * Creates a new engine
  115892. * @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
  115893. * @param antialias defines enable antialiasing (default: false)
  115894. * @param options defines further options to be sent to the getContext() function
  115895. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115896. */
  115897. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115898. private _rebuildInternalTextures;
  115899. private _rebuildEffects;
  115900. /**
  115901. * Gets a boolean indicating if all created effects are ready
  115902. * @returns true if all effects are ready
  115903. */
  115904. areAllEffectsReady(): boolean;
  115905. protected _rebuildBuffers(): void;
  115906. protected _initGLContext(): void;
  115907. /**
  115908. * Gets version of the current webGL context
  115909. */
  115910. get webGLVersion(): number;
  115911. /**
  115912. * Gets a string identifying the name of the class
  115913. * @returns "Engine" string
  115914. */
  115915. getClassName(): string;
  115916. /**
  115917. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115918. */
  115919. get isStencilEnable(): boolean;
  115920. /** @hidden */
  115921. _prepareWorkingCanvas(): void;
  115922. /**
  115923. * Reset the texture cache to empty state
  115924. */
  115925. resetTextureCache(): void;
  115926. /**
  115927. * Gets an object containing information about the current webGL context
  115928. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115929. */
  115930. getGlInfo(): {
  115931. vendor: string;
  115932. renderer: string;
  115933. version: string;
  115934. };
  115935. /**
  115936. * Defines the hardware scaling level.
  115937. * By default the hardware scaling level is computed from the window device ratio.
  115938. * 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.
  115939. * @param level defines the level to use
  115940. */
  115941. setHardwareScalingLevel(level: number): void;
  115942. /**
  115943. * Gets the current hardware scaling level.
  115944. * By default the hardware scaling level is computed from the window device ratio.
  115945. * 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.
  115946. * @returns a number indicating the current hardware scaling level
  115947. */
  115948. getHardwareScalingLevel(): number;
  115949. /**
  115950. * Gets the list of loaded textures
  115951. * @returns an array containing all loaded textures
  115952. */
  115953. getLoadedTexturesCache(): InternalTexture[];
  115954. /**
  115955. * Gets the object containing all engine capabilities
  115956. * @returns the EngineCapabilities object
  115957. */
  115958. getCaps(): EngineCapabilities;
  115959. /**
  115960. * stop executing a render loop function and remove it from the execution array
  115961. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115962. */
  115963. stopRenderLoop(renderFunction?: () => void): void;
  115964. /** @hidden */
  115965. _renderLoop(): void;
  115966. /**
  115967. * Gets the HTML canvas attached with the current webGL context
  115968. * @returns a HTML canvas
  115969. */
  115970. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115971. /**
  115972. * Gets host window
  115973. * @returns the host window object
  115974. */
  115975. getHostWindow(): Nullable<Window>;
  115976. /**
  115977. * Gets the current render width
  115978. * @param useScreen defines if screen size must be used (or the current render target if any)
  115979. * @returns a number defining the current render width
  115980. */
  115981. getRenderWidth(useScreen?: boolean): number;
  115982. /**
  115983. * Gets the current render height
  115984. * @param useScreen defines if screen size must be used (or the current render target if any)
  115985. * @returns a number defining the current render height
  115986. */
  115987. getRenderHeight(useScreen?: boolean): number;
  115988. /**
  115989. * Can be used to override the current requestAnimationFrame requester.
  115990. * @hidden
  115991. */
  115992. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115993. /**
  115994. * Register and execute a render loop. The engine can have more than one render function
  115995. * @param renderFunction defines the function to continuously execute
  115996. */
  115997. runRenderLoop(renderFunction: () => void): void;
  115998. /**
  115999. * Clear the current render buffer or the current render target (if any is set up)
  116000. * @param color defines the color to use
  116001. * @param backBuffer defines if the back buffer must be cleared
  116002. * @param depth defines if the depth buffer must be cleared
  116003. * @param stencil defines if the stencil buffer must be cleared
  116004. */
  116005. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116006. private _viewportCached;
  116007. /** @hidden */
  116008. _viewport(x: number, y: number, width: number, height: number): void;
  116009. /**
  116010. * Set the WebGL's viewport
  116011. * @param viewport defines the viewport element to be used
  116012. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116013. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116014. */
  116015. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116016. /**
  116017. * Begin a new frame
  116018. */
  116019. beginFrame(): void;
  116020. /**
  116021. * Enf the current frame
  116022. */
  116023. endFrame(): void;
  116024. /**
  116025. * Resize the view according to the canvas' size
  116026. */
  116027. resize(): void;
  116028. /**
  116029. * Force a specific size of the canvas
  116030. * @param width defines the new canvas' width
  116031. * @param height defines the new canvas' height
  116032. * @returns true if the size was changed
  116033. */
  116034. setSize(width: number, height: number): boolean;
  116035. /**
  116036. * Binds the frame buffer to the specified texture.
  116037. * @param texture The texture to render to or null for the default canvas
  116038. * @param faceIndex The face of the texture to render to in case of cube texture
  116039. * @param requiredWidth The width of the target to render to
  116040. * @param requiredHeight The height of the target to render to
  116041. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116042. * @param lodLevel defines the lod level to bind to the frame buffer
  116043. * @param layer defines the 2d array index to bind to frame buffer to
  116044. */
  116045. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  116046. /** @hidden */
  116047. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  116048. /**
  116049. * Unbind the current render target texture from the webGL context
  116050. * @param texture defines the render target texture to unbind
  116051. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116052. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116053. */
  116054. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116055. /**
  116056. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  116057. */
  116058. flushFramebuffer(): void;
  116059. /**
  116060. * Unbind the current render target and bind the default framebuffer
  116061. */
  116062. restoreDefaultFramebuffer(): void;
  116063. /** @hidden */
  116064. protected _resetVertexBufferBinding(): void;
  116065. /**
  116066. * Creates a vertex buffer
  116067. * @param data the data for the vertex buffer
  116068. * @returns the new WebGL static buffer
  116069. */
  116070. createVertexBuffer(data: DataArray): DataBuffer;
  116071. private _createVertexBuffer;
  116072. /**
  116073. * Creates a dynamic vertex buffer
  116074. * @param data the data for the dynamic vertex buffer
  116075. * @returns the new WebGL dynamic buffer
  116076. */
  116077. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  116078. protected _resetIndexBufferBinding(): void;
  116079. /**
  116080. * Creates a new index buffer
  116081. * @param indices defines the content of the index buffer
  116082. * @param updatable defines if the index buffer must be updatable
  116083. * @returns a new webGL buffer
  116084. */
  116085. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  116086. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  116087. /**
  116088. * Bind a webGL buffer to the webGL context
  116089. * @param buffer defines the buffer to bind
  116090. */
  116091. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  116092. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  116093. private bindBuffer;
  116094. /**
  116095. * update the bound buffer with the given data
  116096. * @param data defines the data to update
  116097. */
  116098. updateArrayBuffer(data: Float32Array): void;
  116099. private _vertexAttribPointer;
  116100. /** @hidden */
  116101. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  116102. private _bindVertexBuffersAttributes;
  116103. /**
  116104. * Records a vertex array object
  116105. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116106. * @param vertexBuffers defines the list of vertex buffers to store
  116107. * @param indexBuffer defines the index buffer to store
  116108. * @param effect defines the effect to store
  116109. * @returns the new vertex array object
  116110. */
  116111. recordVertexArrayObject(vertexBuffers: {
  116112. [key: string]: VertexBuffer;
  116113. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  116114. /**
  116115. * Bind a specific vertex array object
  116116. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116117. * @param vertexArrayObject defines the vertex array object to bind
  116118. * @param indexBuffer defines the index buffer to bind
  116119. */
  116120. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  116121. /**
  116122. * Bind webGl buffers directly to the webGL context
  116123. * @param vertexBuffer defines the vertex buffer to bind
  116124. * @param indexBuffer defines the index buffer to bind
  116125. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116126. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116127. * @param effect defines the effect associated with the vertex buffer
  116128. */
  116129. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  116130. private _unbindVertexArrayObject;
  116131. /**
  116132. * Bind a list of vertex buffers to the webGL context
  116133. * @param vertexBuffers defines the list of vertex buffers to bind
  116134. * @param indexBuffer defines the index buffer to bind
  116135. * @param effect defines the effect associated with the vertex buffers
  116136. */
  116137. bindBuffers(vertexBuffers: {
  116138. [key: string]: Nullable<VertexBuffer>;
  116139. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  116140. /**
  116141. * Unbind all instance attributes
  116142. */
  116143. unbindInstanceAttributes(): void;
  116144. /**
  116145. * Release and free the memory of a vertex array object
  116146. * @param vao defines the vertex array object to delete
  116147. */
  116148. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  116149. /** @hidden */
  116150. _releaseBuffer(buffer: DataBuffer): boolean;
  116151. protected _deleteBuffer(buffer: DataBuffer): void;
  116152. /**
  116153. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  116154. * @param instancesBuffer defines the webGL buffer to update and bind
  116155. * @param data defines the data to store in the buffer
  116156. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  116157. */
  116158. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  116159. /**
  116160. * Bind the content of a webGL buffer used with instantiation
  116161. * @param instancesBuffer defines the webGL buffer to bind
  116162. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  116163. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  116164. */
  116165. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  116166. /**
  116167. * Disable the instance attribute corresponding to the name in parameter
  116168. * @param name defines the name of the attribute to disable
  116169. */
  116170. disableInstanceAttributeByName(name: string): void;
  116171. /**
  116172. * Disable the instance attribute corresponding to the location in parameter
  116173. * @param attributeLocation defines the attribute location of the attribute to disable
  116174. */
  116175. disableInstanceAttribute(attributeLocation: number): void;
  116176. /**
  116177. * Disable the attribute corresponding to the location in parameter
  116178. * @param attributeLocation defines the attribute location of the attribute to disable
  116179. */
  116180. disableAttributeByIndex(attributeLocation: number): void;
  116181. /**
  116182. * Send a draw order
  116183. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116184. * @param indexStart defines the starting index
  116185. * @param indexCount defines the number of index to draw
  116186. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116187. */
  116188. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116189. /**
  116190. * Draw a list of points
  116191. * @param verticesStart defines the index of first vertex to draw
  116192. * @param verticesCount defines the count of vertices to draw
  116193. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116194. */
  116195. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116196. /**
  116197. * Draw a list of unindexed primitives
  116198. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116199. * @param verticesStart defines the index of first vertex to draw
  116200. * @param verticesCount defines the count of vertices to draw
  116201. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116202. */
  116203. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116204. /**
  116205. * Draw a list of indexed primitives
  116206. * @param fillMode defines the primitive to use
  116207. * @param indexStart defines the starting index
  116208. * @param indexCount defines the number of index to draw
  116209. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116210. */
  116211. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116212. /**
  116213. * Draw a list of unindexed primitives
  116214. * @param fillMode defines the primitive to use
  116215. * @param verticesStart defines the index of first vertex to draw
  116216. * @param verticesCount defines the count of vertices to draw
  116217. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116218. */
  116219. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116220. private _drawMode;
  116221. /** @hidden */
  116222. protected _reportDrawCall(): void;
  116223. /** @hidden */
  116224. _releaseEffect(effect: Effect): void;
  116225. /** @hidden */
  116226. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116227. /**
  116228. * Create a new effect (used to store vertex/fragment shaders)
  116229. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  116230. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  116231. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  116232. * @param samplers defines an array of string used to represent textures
  116233. * @param defines defines the string containing the defines to use to compile the shaders
  116234. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116235. * @param onCompiled defines a function to call when the effect creation is successful
  116236. * @param onError defines a function to call when the effect creation has failed
  116237. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  116238. * @returns the new Effect
  116239. */
  116240. 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;
  116241. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  116242. private _compileShader;
  116243. private _compileRawShader;
  116244. /** @hidden */
  116245. _getShaderSource(shader: WebGLShader): Nullable<string>;
  116246. /**
  116247. * Directly creates a webGL program
  116248. * @param pipelineContext defines the pipeline context to attach to
  116249. * @param vertexCode defines the vertex shader code to use
  116250. * @param fragmentCode defines the fragment shader code to use
  116251. * @param context defines the webGL context to use (if not set, the current one will be used)
  116252. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116253. * @returns the new webGL program
  116254. */
  116255. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116256. /**
  116257. * Creates a webGL program
  116258. * @param pipelineContext defines the pipeline context to attach to
  116259. * @param vertexCode defines the vertex shader code to use
  116260. * @param fragmentCode defines the fragment shader code to use
  116261. * @param defines defines the string containing the defines to use to compile the shaders
  116262. * @param context defines the webGL context to use (if not set, the current one will be used)
  116263. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116264. * @returns the new webGL program
  116265. */
  116266. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116267. /**
  116268. * Creates a new pipeline context
  116269. * @returns the new pipeline
  116270. */
  116271. createPipelineContext(): IPipelineContext;
  116272. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116273. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  116274. /** @hidden */
  116275. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  116276. /** @hidden */
  116277. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  116278. /** @hidden */
  116279. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  116280. /**
  116281. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116282. * @param pipelineContext defines the pipeline context to use
  116283. * @param uniformsNames defines the list of uniform names
  116284. * @returns an array of webGL uniform locations
  116285. */
  116286. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116287. /**
  116288. * Gets the lsit of active attributes for a given webGL program
  116289. * @param pipelineContext defines the pipeline context to use
  116290. * @param attributesNames defines the list of attribute names to get
  116291. * @returns an array of indices indicating the offset of each attribute
  116292. */
  116293. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116294. /**
  116295. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116296. * @param effect defines the effect to activate
  116297. */
  116298. enableEffect(effect: Nullable<Effect>): void;
  116299. /**
  116300. * Set the value of an uniform to a number (int)
  116301. * @param uniform defines the webGL uniform location where to store the value
  116302. * @param value defines the int number to store
  116303. * @returns true if the value was set
  116304. */
  116305. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116306. /**
  116307. * Set the value of an uniform to an array of int32
  116308. * @param uniform defines the webGL uniform location where to store the value
  116309. * @param array defines the array of int32 to store
  116310. * @returns true if the value was set
  116311. */
  116312. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116313. /**
  116314. * Set the value of an uniform to an array of int32 (stored as vec2)
  116315. * @param uniform defines the webGL uniform location where to store the value
  116316. * @param array defines the array of int32 to store
  116317. * @returns true if the value was set
  116318. */
  116319. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116320. /**
  116321. * Set the value of an uniform to an array of int32 (stored as vec3)
  116322. * @param uniform defines the webGL uniform location where to store the value
  116323. * @param array defines the array of int32 to store
  116324. * @returns true if the value was set
  116325. */
  116326. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116327. /**
  116328. * Set the value of an uniform to an array of int32 (stored as vec4)
  116329. * @param uniform defines the webGL uniform location where to store the value
  116330. * @param array defines the array of int32 to store
  116331. * @returns true if the value was set
  116332. */
  116333. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116334. /**
  116335. * Set the value of an uniform to an array of number
  116336. * @param uniform defines the webGL uniform location where to store the value
  116337. * @param array defines the array of number to store
  116338. * @returns true if the value was set
  116339. */
  116340. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116341. /**
  116342. * Set the value of an uniform to an array of number (stored as vec2)
  116343. * @param uniform defines the webGL uniform location where to store the value
  116344. * @param array defines the array of number to store
  116345. * @returns true if the value was set
  116346. */
  116347. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116348. /**
  116349. * Set the value of an uniform to an array of number (stored as vec3)
  116350. * @param uniform defines the webGL uniform location where to store the value
  116351. * @param array defines the array of number to store
  116352. * @returns true if the value was set
  116353. */
  116354. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116355. /**
  116356. * Set the value of an uniform to an array of number (stored as vec4)
  116357. * @param uniform defines the webGL uniform location where to store the value
  116358. * @param array defines the array of number to store
  116359. * @returns true if the value was set
  116360. */
  116361. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116362. /**
  116363. * Set the value of an uniform to an array of float32 (stored as matrices)
  116364. * @param uniform defines the webGL uniform location where to store the value
  116365. * @param matrices defines the array of float32 to store
  116366. * @returns true if the value was set
  116367. */
  116368. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  116369. /**
  116370. * Set the value of an uniform to a matrix (3x3)
  116371. * @param uniform defines the webGL uniform location where to store the value
  116372. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116373. * @returns true if the value was set
  116374. */
  116375. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116376. /**
  116377. * Set the value of an uniform to a matrix (2x2)
  116378. * @param uniform defines the webGL uniform location where to store the value
  116379. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116380. * @returns true if the value was set
  116381. */
  116382. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116383. /**
  116384. * Set the value of an uniform to a number (float)
  116385. * @param uniform defines the webGL uniform location where to store the value
  116386. * @param value defines the float number to store
  116387. * @returns true if the value was transfered
  116388. */
  116389. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116390. /**
  116391. * Set the value of an uniform to a vec2
  116392. * @param uniform defines the webGL uniform location where to store the value
  116393. * @param x defines the 1st component of the value
  116394. * @param y defines the 2nd component of the value
  116395. * @returns true if the value was set
  116396. */
  116397. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  116398. /**
  116399. * Set the value of an uniform to a vec3
  116400. * @param uniform defines the webGL uniform location where to store the value
  116401. * @param x defines the 1st component of the value
  116402. * @param y defines the 2nd component of the value
  116403. * @param z defines the 3rd component of the value
  116404. * @returns true if the value was set
  116405. */
  116406. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  116407. /**
  116408. * Set the value of an uniform to a vec4
  116409. * @param uniform defines the webGL uniform location where to store the value
  116410. * @param x defines the 1st component of the value
  116411. * @param y defines the 2nd component of the value
  116412. * @param z defines the 3rd component of the value
  116413. * @param w defines the 4th component of the value
  116414. * @returns true if the value was set
  116415. */
  116416. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  116417. /**
  116418. * Apply all cached states (depth, culling, stencil and alpha)
  116419. */
  116420. applyStates(): void;
  116421. /**
  116422. * Enable or disable color writing
  116423. * @param enable defines the state to set
  116424. */
  116425. setColorWrite(enable: boolean): void;
  116426. /**
  116427. * Gets a boolean indicating if color writing is enabled
  116428. * @returns the current color writing state
  116429. */
  116430. getColorWrite(): boolean;
  116431. /**
  116432. * Gets the depth culling state manager
  116433. */
  116434. get depthCullingState(): DepthCullingState;
  116435. /**
  116436. * Gets the alpha state manager
  116437. */
  116438. get alphaState(): AlphaState;
  116439. /**
  116440. * Gets the stencil state manager
  116441. */
  116442. get stencilState(): StencilState;
  116443. /**
  116444. * Clears the list of texture accessible through engine.
  116445. * This can help preventing texture load conflict due to name collision.
  116446. */
  116447. clearInternalTexturesCache(): void;
  116448. /**
  116449. * Force the entire cache to be cleared
  116450. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116451. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116452. */
  116453. wipeCaches(bruteForce?: boolean): void;
  116454. /** @hidden */
  116455. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  116456. min: number;
  116457. mag: number;
  116458. };
  116459. /** @hidden */
  116460. _createTexture(): WebGLTexture;
  116461. /**
  116462. * Usually called from Texture.ts.
  116463. * Passed information to create a WebGLTexture
  116464. * @param url defines a value which contains one of the following:
  116465. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116466. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116467. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116468. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116469. * @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)
  116470. * @param scene needed for loading to the correct scene
  116471. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116472. * @param onLoad optional callback to be called upon successful completion
  116473. * @param onError optional callback to be called upon failure
  116474. * @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
  116475. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116476. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116477. * @param forcedExtension defines the extension to use to pick the right loader
  116478. * @param mimeType defines an optional mime type
  116479. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116480. */
  116481. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  116482. /**
  116483. * Loads an image as an HTMLImageElement.
  116484. * @param input url string, ArrayBuffer, or Blob to load
  116485. * @param onLoad callback called when the image successfully loads
  116486. * @param onError callback called when the image fails to load
  116487. * @param offlineProvider offline provider for caching
  116488. * @param mimeType optional mime type
  116489. * @returns the HTMLImageElement of the loaded image
  116490. * @hidden
  116491. */
  116492. 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>;
  116493. /**
  116494. * @hidden
  116495. */
  116496. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116497. private _unpackFlipYCached;
  116498. /**
  116499. * In case you are sharing the context with other applications, it might
  116500. * be interested to not cache the unpack flip y state to ensure a consistent
  116501. * value would be set.
  116502. */
  116503. enableUnpackFlipYCached: boolean;
  116504. /** @hidden */
  116505. _unpackFlipY(value: boolean): void;
  116506. /** @hidden */
  116507. _getUnpackAlignement(): number;
  116508. private _getTextureTarget;
  116509. /**
  116510. * Update the sampling mode of a given texture
  116511. * @param samplingMode defines the required sampling mode
  116512. * @param texture defines the texture to update
  116513. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116514. */
  116515. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116516. /**
  116517. * Update the sampling mode of a given texture
  116518. * @param texture defines the texture to update
  116519. * @param wrapU defines the texture wrap mode of the u coordinates
  116520. * @param wrapV defines the texture wrap mode of the v coordinates
  116521. * @param wrapR defines the texture wrap mode of the r coordinates
  116522. */
  116523. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116524. /** @hidden */
  116525. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116526. width: number;
  116527. height: number;
  116528. layers?: number;
  116529. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116530. /** @hidden */
  116531. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116532. /** @hidden */
  116533. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116534. /**
  116535. * Update a portion of an internal texture
  116536. * @param texture defines the texture to update
  116537. * @param imageData defines the data to store into the texture
  116538. * @param xOffset defines the x coordinates of the update rectangle
  116539. * @param yOffset defines the y coordinates of the update rectangle
  116540. * @param width defines the width of the update rectangle
  116541. * @param height defines the height of the update rectangle
  116542. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116543. * @param lod defines the lod level to update (0 by default)
  116544. */
  116545. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116546. /** @hidden */
  116547. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116548. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116549. private _prepareWebGLTexture;
  116550. /** @hidden */
  116551. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116552. private _getDepthStencilBuffer;
  116553. /** @hidden */
  116554. _releaseFramebufferObjects(texture: InternalTexture): void;
  116555. /** @hidden */
  116556. _releaseTexture(texture: InternalTexture): void;
  116557. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116558. protected _setProgram(program: WebGLProgram): void;
  116559. protected _boundUniforms: {
  116560. [key: number]: WebGLUniformLocation;
  116561. };
  116562. /**
  116563. * Binds an effect to the webGL context
  116564. * @param effect defines the effect to bind
  116565. */
  116566. bindSamplers(effect: Effect): void;
  116567. private _activateCurrentTexture;
  116568. /** @hidden */
  116569. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116570. /** @hidden */
  116571. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116572. /**
  116573. * Unbind all textures from the webGL context
  116574. */
  116575. unbindAllTextures(): void;
  116576. /**
  116577. * Sets a texture to the according uniform.
  116578. * @param channel The texture channel
  116579. * @param uniform The uniform to set
  116580. * @param texture The texture to apply
  116581. */
  116582. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116583. private _bindSamplerUniformToChannel;
  116584. private _getTextureWrapMode;
  116585. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116586. /**
  116587. * Sets an array of texture to the webGL context
  116588. * @param channel defines the channel where the texture array must be set
  116589. * @param uniform defines the associated uniform location
  116590. * @param textures defines the array of textures to bind
  116591. */
  116592. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116593. /** @hidden */
  116594. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116595. private _setTextureParameterFloat;
  116596. private _setTextureParameterInteger;
  116597. /**
  116598. * Unbind all vertex attributes from the webGL context
  116599. */
  116600. unbindAllAttributes(): void;
  116601. /**
  116602. * 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
  116603. */
  116604. releaseEffects(): void;
  116605. /**
  116606. * Dispose and release all associated resources
  116607. */
  116608. dispose(): void;
  116609. /**
  116610. * Attach a new callback raised when context lost event is fired
  116611. * @param callback defines the callback to call
  116612. */
  116613. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116614. /**
  116615. * Attach a new callback raised when context restored event is fired
  116616. * @param callback defines the callback to call
  116617. */
  116618. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116619. /**
  116620. * Get the current error code of the webGL context
  116621. * @returns the error code
  116622. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116623. */
  116624. getError(): number;
  116625. private _canRenderToFloatFramebuffer;
  116626. private _canRenderToHalfFloatFramebuffer;
  116627. private _canRenderToFramebuffer;
  116628. /** @hidden */
  116629. _getWebGLTextureType(type: number): number;
  116630. /** @hidden */
  116631. _getInternalFormat(format: number): number;
  116632. /** @hidden */
  116633. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116634. /** @hidden */
  116635. _getRGBAMultiSampleBufferFormat(type: number): number;
  116636. /** @hidden */
  116637. _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;
  116638. /**
  116639. * Loads a file from a url
  116640. * @param url url to load
  116641. * @param onSuccess callback called when the file successfully loads
  116642. * @param onProgress callback called while file is loading (if the server supports this mode)
  116643. * @param offlineProvider defines the offline provider for caching
  116644. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116645. * @param onError callback called when the file fails to load
  116646. * @returns a file request object
  116647. * @hidden
  116648. */
  116649. 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;
  116650. /**
  116651. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116652. * @param x defines the x coordinate of the rectangle where pixels must be read
  116653. * @param y defines the y coordinate of the rectangle where pixels must be read
  116654. * @param width defines the width of the rectangle where pixels must be read
  116655. * @param height defines the height of the rectangle where pixels must be read
  116656. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116657. * @returns a Uint8Array containing RGBA colors
  116658. */
  116659. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116660. private static _isSupported;
  116661. /**
  116662. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116663. * @returns true if the engine can be created
  116664. * @ignorenaming
  116665. */
  116666. static isSupported(): boolean;
  116667. /**
  116668. * Find the next highest power of two.
  116669. * @param x Number to start search from.
  116670. * @return Next highest power of two.
  116671. */
  116672. static CeilingPOT(x: number): number;
  116673. /**
  116674. * Find the next lowest power of two.
  116675. * @param x Number to start search from.
  116676. * @return Next lowest power of two.
  116677. */
  116678. static FloorPOT(x: number): number;
  116679. /**
  116680. * Find the nearest power of two.
  116681. * @param x Number to start search from.
  116682. * @return Next nearest power of two.
  116683. */
  116684. static NearestPOT(x: number): number;
  116685. /**
  116686. * Get the closest exponent of two
  116687. * @param value defines the value to approximate
  116688. * @param max defines the maximum value to return
  116689. * @param mode defines how to define the closest value
  116690. * @returns closest exponent of two of the given value
  116691. */
  116692. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116693. /**
  116694. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116695. * @param func - the function to be called
  116696. * @param requester - the object that will request the next frame. Falls back to window.
  116697. * @returns frame number
  116698. */
  116699. static QueueNewFrame(func: () => void, requester?: any): number;
  116700. /**
  116701. * Gets host document
  116702. * @returns the host document object
  116703. */
  116704. getHostDocument(): Nullable<Document>;
  116705. }
  116706. }
  116707. declare module BABYLON {
  116708. /**
  116709. * Class representing spherical harmonics coefficients to the 3rd degree
  116710. */
  116711. export class SphericalHarmonics {
  116712. /**
  116713. * Defines whether or not the harmonics have been prescaled for rendering.
  116714. */
  116715. preScaled: boolean;
  116716. /**
  116717. * The l0,0 coefficients of the spherical harmonics
  116718. */
  116719. l00: Vector3;
  116720. /**
  116721. * The l1,-1 coefficients of the spherical harmonics
  116722. */
  116723. l1_1: Vector3;
  116724. /**
  116725. * The l1,0 coefficients of the spherical harmonics
  116726. */
  116727. l10: Vector3;
  116728. /**
  116729. * The l1,1 coefficients of the spherical harmonics
  116730. */
  116731. l11: Vector3;
  116732. /**
  116733. * The l2,-2 coefficients of the spherical harmonics
  116734. */
  116735. l2_2: Vector3;
  116736. /**
  116737. * The l2,-1 coefficients of the spherical harmonics
  116738. */
  116739. l2_1: Vector3;
  116740. /**
  116741. * The l2,0 coefficients of the spherical harmonics
  116742. */
  116743. l20: Vector3;
  116744. /**
  116745. * The l2,1 coefficients of the spherical harmonics
  116746. */
  116747. l21: Vector3;
  116748. /**
  116749. * The l2,2 coefficients of the spherical harmonics
  116750. */
  116751. l22: Vector3;
  116752. /**
  116753. * Adds a light to the spherical harmonics
  116754. * @param direction the direction of the light
  116755. * @param color the color of the light
  116756. * @param deltaSolidAngle the delta solid angle of the light
  116757. */
  116758. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116759. /**
  116760. * Scales the spherical harmonics by the given amount
  116761. * @param scale the amount to scale
  116762. */
  116763. scaleInPlace(scale: number): void;
  116764. /**
  116765. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116766. *
  116767. * ```
  116768. * E_lm = A_l * L_lm
  116769. * ```
  116770. *
  116771. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116772. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116773. * the scaling factors are given in equation 9.
  116774. */
  116775. convertIncidentRadianceToIrradiance(): void;
  116776. /**
  116777. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116778. *
  116779. * ```
  116780. * L = (1/pi) * E * rho
  116781. * ```
  116782. *
  116783. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116784. */
  116785. convertIrradianceToLambertianRadiance(): void;
  116786. /**
  116787. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116788. * required operations at run time.
  116789. *
  116790. * This is simply done by scaling back the SH with Ylm constants parameter.
  116791. * The trigonometric part being applied by the shader at run time.
  116792. */
  116793. preScaleForRendering(): void;
  116794. /**
  116795. * Constructs a spherical harmonics from an array.
  116796. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116797. * @returns the spherical harmonics
  116798. */
  116799. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116800. /**
  116801. * Gets the spherical harmonics from polynomial
  116802. * @param polynomial the spherical polynomial
  116803. * @returns the spherical harmonics
  116804. */
  116805. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116806. }
  116807. /**
  116808. * Class representing spherical polynomial coefficients to the 3rd degree
  116809. */
  116810. export class SphericalPolynomial {
  116811. private _harmonics;
  116812. /**
  116813. * The spherical harmonics used to create the polynomials.
  116814. */
  116815. get preScaledHarmonics(): SphericalHarmonics;
  116816. /**
  116817. * The x coefficients of the spherical polynomial
  116818. */
  116819. x: Vector3;
  116820. /**
  116821. * The y coefficients of the spherical polynomial
  116822. */
  116823. y: Vector3;
  116824. /**
  116825. * The z coefficients of the spherical polynomial
  116826. */
  116827. z: Vector3;
  116828. /**
  116829. * The xx coefficients of the spherical polynomial
  116830. */
  116831. xx: Vector3;
  116832. /**
  116833. * The yy coefficients of the spherical polynomial
  116834. */
  116835. yy: Vector3;
  116836. /**
  116837. * The zz coefficients of the spherical polynomial
  116838. */
  116839. zz: Vector3;
  116840. /**
  116841. * The xy coefficients of the spherical polynomial
  116842. */
  116843. xy: Vector3;
  116844. /**
  116845. * The yz coefficients of the spherical polynomial
  116846. */
  116847. yz: Vector3;
  116848. /**
  116849. * The zx coefficients of the spherical polynomial
  116850. */
  116851. zx: Vector3;
  116852. /**
  116853. * Adds an ambient color to the spherical polynomial
  116854. * @param color the color to add
  116855. */
  116856. addAmbient(color: Color3): void;
  116857. /**
  116858. * Scales the spherical polynomial by the given amount
  116859. * @param scale the amount to scale
  116860. */
  116861. scaleInPlace(scale: number): void;
  116862. /**
  116863. * Gets the spherical polynomial from harmonics
  116864. * @param harmonics the spherical harmonics
  116865. * @returns the spherical polynomial
  116866. */
  116867. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116868. /**
  116869. * Constructs a spherical polynomial from an array.
  116870. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116871. * @returns the spherical polynomial
  116872. */
  116873. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116874. }
  116875. }
  116876. declare module BABYLON {
  116877. /**
  116878. * Defines the source of the internal texture
  116879. */
  116880. export enum InternalTextureSource {
  116881. /**
  116882. * The source of the texture data is unknown
  116883. */
  116884. Unknown = 0,
  116885. /**
  116886. * Texture data comes from an URL
  116887. */
  116888. Url = 1,
  116889. /**
  116890. * Texture data is only used for temporary storage
  116891. */
  116892. Temp = 2,
  116893. /**
  116894. * Texture data comes from raw data (ArrayBuffer)
  116895. */
  116896. Raw = 3,
  116897. /**
  116898. * Texture content is dynamic (video or dynamic texture)
  116899. */
  116900. Dynamic = 4,
  116901. /**
  116902. * Texture content is generated by rendering to it
  116903. */
  116904. RenderTarget = 5,
  116905. /**
  116906. * Texture content is part of a multi render target process
  116907. */
  116908. MultiRenderTarget = 6,
  116909. /**
  116910. * Texture data comes from a cube data file
  116911. */
  116912. Cube = 7,
  116913. /**
  116914. * Texture data comes from a raw cube data
  116915. */
  116916. CubeRaw = 8,
  116917. /**
  116918. * Texture data come from a prefiltered cube data file
  116919. */
  116920. CubePrefiltered = 9,
  116921. /**
  116922. * Texture content is raw 3D data
  116923. */
  116924. Raw3D = 10,
  116925. /**
  116926. * Texture content is raw 2D array data
  116927. */
  116928. Raw2DArray = 11,
  116929. /**
  116930. * Texture content is a depth texture
  116931. */
  116932. Depth = 12,
  116933. /**
  116934. * Texture data comes from a raw cube data encoded with RGBD
  116935. */
  116936. CubeRawRGBD = 13
  116937. }
  116938. /**
  116939. * Class used to store data associated with WebGL texture data for the engine
  116940. * This class should not be used directly
  116941. */
  116942. export class InternalTexture {
  116943. /** @hidden */
  116944. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116945. /**
  116946. * Defines if the texture is ready
  116947. */
  116948. isReady: boolean;
  116949. /**
  116950. * Defines if the texture is a cube texture
  116951. */
  116952. isCube: boolean;
  116953. /**
  116954. * Defines if the texture contains 3D data
  116955. */
  116956. is3D: boolean;
  116957. /**
  116958. * Defines if the texture contains 2D array data
  116959. */
  116960. is2DArray: boolean;
  116961. /**
  116962. * Defines if the texture contains multiview data
  116963. */
  116964. isMultiview: boolean;
  116965. /**
  116966. * Gets the URL used to load this texture
  116967. */
  116968. url: string;
  116969. /**
  116970. * Gets the sampling mode of the texture
  116971. */
  116972. samplingMode: number;
  116973. /**
  116974. * Gets a boolean indicating if the texture needs mipmaps generation
  116975. */
  116976. generateMipMaps: boolean;
  116977. /**
  116978. * Gets the number of samples used by the texture (WebGL2+ only)
  116979. */
  116980. samples: number;
  116981. /**
  116982. * Gets the type of the texture (int, float...)
  116983. */
  116984. type: number;
  116985. /**
  116986. * Gets the format of the texture (RGB, RGBA...)
  116987. */
  116988. format: number;
  116989. /**
  116990. * Observable called when the texture is loaded
  116991. */
  116992. onLoadedObservable: Observable<InternalTexture>;
  116993. /**
  116994. * Gets the width of the texture
  116995. */
  116996. width: number;
  116997. /**
  116998. * Gets the height of the texture
  116999. */
  117000. height: number;
  117001. /**
  117002. * Gets the depth of the texture
  117003. */
  117004. depth: number;
  117005. /**
  117006. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  117007. */
  117008. baseWidth: number;
  117009. /**
  117010. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  117011. */
  117012. baseHeight: number;
  117013. /**
  117014. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  117015. */
  117016. baseDepth: number;
  117017. /**
  117018. * Gets a boolean indicating if the texture is inverted on Y axis
  117019. */
  117020. invertY: boolean;
  117021. /** @hidden */
  117022. _invertVScale: boolean;
  117023. /** @hidden */
  117024. _associatedChannel: number;
  117025. /** @hidden */
  117026. _source: InternalTextureSource;
  117027. /** @hidden */
  117028. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  117029. /** @hidden */
  117030. _bufferView: Nullable<ArrayBufferView>;
  117031. /** @hidden */
  117032. _bufferViewArray: Nullable<ArrayBufferView[]>;
  117033. /** @hidden */
  117034. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  117035. /** @hidden */
  117036. _size: number;
  117037. /** @hidden */
  117038. _extension: string;
  117039. /** @hidden */
  117040. _files: Nullable<string[]>;
  117041. /** @hidden */
  117042. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  117043. /** @hidden */
  117044. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  117045. /** @hidden */
  117046. _framebuffer: Nullable<WebGLFramebuffer>;
  117047. /** @hidden */
  117048. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  117049. /** @hidden */
  117050. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  117051. /** @hidden */
  117052. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  117053. /** @hidden */
  117054. _attachments: Nullable<number[]>;
  117055. /** @hidden */
  117056. _textureArray: Nullable<InternalTexture[]>;
  117057. /** @hidden */
  117058. _cachedCoordinatesMode: Nullable<number>;
  117059. /** @hidden */
  117060. _cachedWrapU: Nullable<number>;
  117061. /** @hidden */
  117062. _cachedWrapV: Nullable<number>;
  117063. /** @hidden */
  117064. _cachedWrapR: Nullable<number>;
  117065. /** @hidden */
  117066. _cachedAnisotropicFilteringLevel: Nullable<number>;
  117067. /** @hidden */
  117068. _isDisabled: boolean;
  117069. /** @hidden */
  117070. _compression: Nullable<string>;
  117071. /** @hidden */
  117072. _generateStencilBuffer: boolean;
  117073. /** @hidden */
  117074. _generateDepthBuffer: boolean;
  117075. /** @hidden */
  117076. _comparisonFunction: number;
  117077. /** @hidden */
  117078. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  117079. /** @hidden */
  117080. _lodGenerationScale: number;
  117081. /** @hidden */
  117082. _lodGenerationOffset: number;
  117083. /** @hidden */
  117084. _depthStencilTexture: Nullable<InternalTexture>;
  117085. /** @hidden */
  117086. _colorTextureArray: Nullable<WebGLTexture>;
  117087. /** @hidden */
  117088. _depthStencilTextureArray: Nullable<WebGLTexture>;
  117089. /** @hidden */
  117090. _lodTextureHigh: Nullable<BaseTexture>;
  117091. /** @hidden */
  117092. _lodTextureMid: Nullable<BaseTexture>;
  117093. /** @hidden */
  117094. _lodTextureLow: Nullable<BaseTexture>;
  117095. /** @hidden */
  117096. _isRGBD: boolean;
  117097. /** @hidden */
  117098. _linearSpecularLOD: boolean;
  117099. /** @hidden */
  117100. _irradianceTexture: Nullable<BaseTexture>;
  117101. /** @hidden */
  117102. _webGLTexture: Nullable<WebGLTexture>;
  117103. /** @hidden */
  117104. _references: number;
  117105. /** @hidden */
  117106. _gammaSpace: Nullable<boolean>;
  117107. private _engine;
  117108. /**
  117109. * Gets the Engine the texture belongs to.
  117110. * @returns The babylon engine
  117111. */
  117112. getEngine(): ThinEngine;
  117113. /**
  117114. * Gets the data source type of the texture
  117115. */
  117116. get source(): InternalTextureSource;
  117117. /**
  117118. * Creates a new InternalTexture
  117119. * @param engine defines the engine to use
  117120. * @param source defines the type of data that will be used
  117121. * @param delayAllocation if the texture allocation should be delayed (default: false)
  117122. */
  117123. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  117124. /**
  117125. * Increments the number of references (ie. the number of Texture that point to it)
  117126. */
  117127. incrementReferences(): void;
  117128. /**
  117129. * Change the size of the texture (not the size of the content)
  117130. * @param width defines the new width
  117131. * @param height defines the new height
  117132. * @param depth defines the new depth (1 by default)
  117133. */
  117134. updateSize(width: int, height: int, depth?: int): void;
  117135. /** @hidden */
  117136. _rebuild(): void;
  117137. /** @hidden */
  117138. _swapAndDie(target: InternalTexture): void;
  117139. /**
  117140. * Dispose the current allocated resources
  117141. */
  117142. dispose(): void;
  117143. }
  117144. }
  117145. declare module BABYLON {
  117146. /**
  117147. * Class used to work with sound analyzer using fast fourier transform (FFT)
  117148. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117149. */
  117150. export class Analyser {
  117151. /**
  117152. * Gets or sets the smoothing
  117153. * @ignorenaming
  117154. */
  117155. SMOOTHING: number;
  117156. /**
  117157. * Gets or sets the FFT table size
  117158. * @ignorenaming
  117159. */
  117160. FFT_SIZE: number;
  117161. /**
  117162. * Gets or sets the bar graph amplitude
  117163. * @ignorenaming
  117164. */
  117165. BARGRAPHAMPLITUDE: number;
  117166. /**
  117167. * Gets or sets the position of the debug canvas
  117168. * @ignorenaming
  117169. */
  117170. DEBUGCANVASPOS: {
  117171. x: number;
  117172. y: number;
  117173. };
  117174. /**
  117175. * Gets or sets the debug canvas size
  117176. * @ignorenaming
  117177. */
  117178. DEBUGCANVASSIZE: {
  117179. width: number;
  117180. height: number;
  117181. };
  117182. private _byteFreqs;
  117183. private _byteTime;
  117184. private _floatFreqs;
  117185. private _webAudioAnalyser;
  117186. private _debugCanvas;
  117187. private _debugCanvasContext;
  117188. private _scene;
  117189. private _registerFunc;
  117190. private _audioEngine;
  117191. /**
  117192. * Creates a new analyser
  117193. * @param scene defines hosting scene
  117194. */
  117195. constructor(scene: Scene);
  117196. /**
  117197. * Get the number of data values you will have to play with for the visualization
  117198. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  117199. * @returns a number
  117200. */
  117201. getFrequencyBinCount(): number;
  117202. /**
  117203. * Gets the current frequency data as a byte array
  117204. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117205. * @returns a Uint8Array
  117206. */
  117207. getByteFrequencyData(): Uint8Array;
  117208. /**
  117209. * Gets the current waveform as a byte array
  117210. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  117211. * @returns a Uint8Array
  117212. */
  117213. getByteTimeDomainData(): Uint8Array;
  117214. /**
  117215. * Gets the current frequency data as a float array
  117216. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117217. * @returns a Float32Array
  117218. */
  117219. getFloatFrequencyData(): Float32Array;
  117220. /**
  117221. * Renders the debug canvas
  117222. */
  117223. drawDebugCanvas(): void;
  117224. /**
  117225. * Stops rendering the debug canvas and removes it
  117226. */
  117227. stopDebugCanvas(): void;
  117228. /**
  117229. * Connects two audio nodes
  117230. * @param inputAudioNode defines first node to connect
  117231. * @param outputAudioNode defines second node to connect
  117232. */
  117233. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  117234. /**
  117235. * Releases all associated resources
  117236. */
  117237. dispose(): void;
  117238. }
  117239. }
  117240. declare module BABYLON {
  117241. /**
  117242. * This represents an audio engine and it is responsible
  117243. * to play, synchronize and analyse sounds throughout the application.
  117244. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117245. */
  117246. export interface IAudioEngine extends IDisposable {
  117247. /**
  117248. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117249. */
  117250. readonly canUseWebAudio: boolean;
  117251. /**
  117252. * Gets the current AudioContext if available.
  117253. */
  117254. readonly audioContext: Nullable<AudioContext>;
  117255. /**
  117256. * The master gain node defines the global audio volume of your audio engine.
  117257. */
  117258. readonly masterGain: GainNode;
  117259. /**
  117260. * Gets whether or not mp3 are supported by your browser.
  117261. */
  117262. readonly isMP3supported: boolean;
  117263. /**
  117264. * Gets whether or not ogg are supported by your browser.
  117265. */
  117266. readonly isOGGsupported: boolean;
  117267. /**
  117268. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117269. * @ignoreNaming
  117270. */
  117271. WarnedWebAudioUnsupported: boolean;
  117272. /**
  117273. * Defines if the audio engine relies on a custom unlocked button.
  117274. * In this case, the embedded button will not be displayed.
  117275. */
  117276. useCustomUnlockedButton: boolean;
  117277. /**
  117278. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  117279. */
  117280. readonly unlocked: boolean;
  117281. /**
  117282. * Event raised when audio has been unlocked on the browser.
  117283. */
  117284. onAudioUnlockedObservable: Observable<AudioEngine>;
  117285. /**
  117286. * Event raised when audio has been locked on the browser.
  117287. */
  117288. onAudioLockedObservable: Observable<AudioEngine>;
  117289. /**
  117290. * Flags the audio engine in Locked state.
  117291. * This happens due to new browser policies preventing audio to autoplay.
  117292. */
  117293. lock(): void;
  117294. /**
  117295. * Unlocks the audio engine once a user action has been done on the dom.
  117296. * This is helpful to resume play once browser policies have been satisfied.
  117297. */
  117298. unlock(): void;
  117299. /**
  117300. * Gets the global volume sets on the master gain.
  117301. * @returns the global volume if set or -1 otherwise
  117302. */
  117303. getGlobalVolume(): number;
  117304. /**
  117305. * Sets the global volume of your experience (sets on the master gain).
  117306. * @param newVolume Defines the new global volume of the application
  117307. */
  117308. setGlobalVolume(newVolume: number): void;
  117309. /**
  117310. * Connect the audio engine to an audio analyser allowing some amazing
  117311. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117312. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117313. * @param analyser The analyser to connect to the engine
  117314. */
  117315. connectToAnalyser(analyser: Analyser): void;
  117316. }
  117317. /**
  117318. * This represents the default audio engine used in babylon.
  117319. * It is responsible to play, synchronize and analyse sounds throughout the application.
  117320. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117321. */
  117322. export class AudioEngine implements IAudioEngine {
  117323. private _audioContext;
  117324. private _audioContextInitialized;
  117325. private _muteButton;
  117326. private _hostElement;
  117327. /**
  117328. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117329. */
  117330. canUseWebAudio: boolean;
  117331. /**
  117332. * The master gain node defines the global audio volume of your audio engine.
  117333. */
  117334. masterGain: GainNode;
  117335. /**
  117336. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117337. * @ignoreNaming
  117338. */
  117339. WarnedWebAudioUnsupported: boolean;
  117340. /**
  117341. * Gets whether or not mp3 are supported by your browser.
  117342. */
  117343. isMP3supported: boolean;
  117344. /**
  117345. * Gets whether or not ogg are supported by your browser.
  117346. */
  117347. isOGGsupported: boolean;
  117348. /**
  117349. * Gets whether audio has been unlocked on the device.
  117350. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  117351. * a user interaction has happened.
  117352. */
  117353. unlocked: boolean;
  117354. /**
  117355. * Defines if the audio engine relies on a custom unlocked button.
  117356. * In this case, the embedded button will not be displayed.
  117357. */
  117358. useCustomUnlockedButton: boolean;
  117359. /**
  117360. * Event raised when audio has been unlocked on the browser.
  117361. */
  117362. onAudioUnlockedObservable: Observable<AudioEngine>;
  117363. /**
  117364. * Event raised when audio has been locked on the browser.
  117365. */
  117366. onAudioLockedObservable: Observable<AudioEngine>;
  117367. /**
  117368. * Gets the current AudioContext if available.
  117369. */
  117370. get audioContext(): Nullable<AudioContext>;
  117371. private _connectedAnalyser;
  117372. /**
  117373. * Instantiates a new audio engine.
  117374. *
  117375. * There should be only one per page as some browsers restrict the number
  117376. * of audio contexts you can create.
  117377. * @param hostElement defines the host element where to display the mute icon if necessary
  117378. */
  117379. constructor(hostElement?: Nullable<HTMLElement>);
  117380. /**
  117381. * Flags the audio engine in Locked state.
  117382. * This happens due to new browser policies preventing audio to autoplay.
  117383. */
  117384. lock(): void;
  117385. /**
  117386. * Unlocks the audio engine once a user action has been done on the dom.
  117387. * This is helpful to resume play once browser policies have been satisfied.
  117388. */
  117389. unlock(): void;
  117390. private _resumeAudioContext;
  117391. private _initializeAudioContext;
  117392. private _tryToRun;
  117393. private _triggerRunningState;
  117394. private _triggerSuspendedState;
  117395. private _displayMuteButton;
  117396. private _moveButtonToTopLeft;
  117397. private _onResize;
  117398. private _hideMuteButton;
  117399. /**
  117400. * Destroy and release the resources associated with the audio ccontext.
  117401. */
  117402. dispose(): void;
  117403. /**
  117404. * Gets the global volume sets on the master gain.
  117405. * @returns the global volume if set or -1 otherwise
  117406. */
  117407. getGlobalVolume(): number;
  117408. /**
  117409. * Sets the global volume of your experience (sets on the master gain).
  117410. * @param newVolume Defines the new global volume of the application
  117411. */
  117412. setGlobalVolume(newVolume: number): void;
  117413. /**
  117414. * Connect the audio engine to an audio analyser allowing some amazing
  117415. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117416. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117417. * @param analyser The analyser to connect to the engine
  117418. */
  117419. connectToAnalyser(analyser: Analyser): void;
  117420. }
  117421. }
  117422. declare module BABYLON {
  117423. /**
  117424. * Interface used to present a loading screen while loading a scene
  117425. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117426. */
  117427. export interface ILoadingScreen {
  117428. /**
  117429. * Function called to display the loading screen
  117430. */
  117431. displayLoadingUI: () => void;
  117432. /**
  117433. * Function called to hide the loading screen
  117434. */
  117435. hideLoadingUI: () => void;
  117436. /**
  117437. * Gets or sets the color to use for the background
  117438. */
  117439. loadingUIBackgroundColor: string;
  117440. /**
  117441. * Gets or sets the text to display while loading
  117442. */
  117443. loadingUIText: string;
  117444. }
  117445. /**
  117446. * Class used for the default loading screen
  117447. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117448. */
  117449. export class DefaultLoadingScreen implements ILoadingScreen {
  117450. private _renderingCanvas;
  117451. private _loadingText;
  117452. private _loadingDivBackgroundColor;
  117453. private _loadingDiv;
  117454. private _loadingTextDiv;
  117455. /** Gets or sets the logo url to use for the default loading screen */
  117456. static DefaultLogoUrl: string;
  117457. /** Gets or sets the spinner url to use for the default loading screen */
  117458. static DefaultSpinnerUrl: string;
  117459. /**
  117460. * Creates a new default loading screen
  117461. * @param _renderingCanvas defines the canvas used to render the scene
  117462. * @param _loadingText defines the default text to display
  117463. * @param _loadingDivBackgroundColor defines the default background color
  117464. */
  117465. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  117466. /**
  117467. * Function called to display the loading screen
  117468. */
  117469. displayLoadingUI(): void;
  117470. /**
  117471. * Function called to hide the loading screen
  117472. */
  117473. hideLoadingUI(): void;
  117474. /**
  117475. * Gets or sets the text to display while loading
  117476. */
  117477. set loadingUIText(text: string);
  117478. get loadingUIText(): string;
  117479. /**
  117480. * Gets or sets the color to use for the background
  117481. */
  117482. get loadingUIBackgroundColor(): string;
  117483. set loadingUIBackgroundColor(color: string);
  117484. private _resizeLoadingUI;
  117485. }
  117486. }
  117487. declare module BABYLON {
  117488. /**
  117489. * Interface for any object that can request an animation frame
  117490. */
  117491. export interface ICustomAnimationFrameRequester {
  117492. /**
  117493. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117494. */
  117495. renderFunction?: Function;
  117496. /**
  117497. * Called to request the next frame to render to
  117498. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117499. */
  117500. requestAnimationFrame: Function;
  117501. /**
  117502. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117503. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117504. */
  117505. requestID?: number;
  117506. }
  117507. }
  117508. declare module BABYLON {
  117509. /**
  117510. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117511. */
  117512. export class PerformanceMonitor {
  117513. private _enabled;
  117514. private _rollingFrameTime;
  117515. private _lastFrameTimeMs;
  117516. /**
  117517. * constructor
  117518. * @param frameSampleSize The number of samples required to saturate the sliding window
  117519. */
  117520. constructor(frameSampleSize?: number);
  117521. /**
  117522. * Samples current frame
  117523. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117524. */
  117525. sampleFrame(timeMs?: number): void;
  117526. /**
  117527. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117528. */
  117529. get averageFrameTime(): number;
  117530. /**
  117531. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117532. */
  117533. get averageFrameTimeVariance(): number;
  117534. /**
  117535. * Returns the frame time of the most recent frame
  117536. */
  117537. get instantaneousFrameTime(): number;
  117538. /**
  117539. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117540. */
  117541. get averageFPS(): number;
  117542. /**
  117543. * Returns the average framerate in frames per second using the most recent frame time
  117544. */
  117545. get instantaneousFPS(): number;
  117546. /**
  117547. * Returns true if enough samples have been taken to completely fill the sliding window
  117548. */
  117549. get isSaturated(): boolean;
  117550. /**
  117551. * Enables contributions to the sliding window sample set
  117552. */
  117553. enable(): void;
  117554. /**
  117555. * Disables contributions to the sliding window sample set
  117556. * Samples will not be interpolated over the disabled period
  117557. */
  117558. disable(): void;
  117559. /**
  117560. * Returns true if sampling is enabled
  117561. */
  117562. get isEnabled(): boolean;
  117563. /**
  117564. * Resets performance monitor
  117565. */
  117566. reset(): void;
  117567. }
  117568. /**
  117569. * RollingAverage
  117570. *
  117571. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117572. */
  117573. export class RollingAverage {
  117574. /**
  117575. * Current average
  117576. */
  117577. average: number;
  117578. /**
  117579. * Current variance
  117580. */
  117581. variance: number;
  117582. protected _samples: Array<number>;
  117583. protected _sampleCount: number;
  117584. protected _pos: number;
  117585. protected _m2: number;
  117586. /**
  117587. * constructor
  117588. * @param length The number of samples required to saturate the sliding window
  117589. */
  117590. constructor(length: number);
  117591. /**
  117592. * Adds a sample to the sample set
  117593. * @param v The sample value
  117594. */
  117595. add(v: number): void;
  117596. /**
  117597. * Returns previously added values or null if outside of history or outside the sliding window domain
  117598. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117599. * @return Value previously recorded with add() or null if outside of range
  117600. */
  117601. history(i: number): number;
  117602. /**
  117603. * Returns true if enough samples have been taken to completely fill the sliding window
  117604. * @return true if sample-set saturated
  117605. */
  117606. isSaturated(): boolean;
  117607. /**
  117608. * Resets the rolling average (equivalent to 0 samples taken so far)
  117609. */
  117610. reset(): void;
  117611. /**
  117612. * Wraps a value around the sample range boundaries
  117613. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117614. * @return Wrapped position in sample range
  117615. */
  117616. protected _wrapPosition(i: number): number;
  117617. }
  117618. }
  117619. declare module BABYLON {
  117620. /**
  117621. * This class is used to track a performance counter which is number based.
  117622. * The user has access to many properties which give statistics of different nature.
  117623. *
  117624. * The implementer can track two kinds of Performance Counter: time and count.
  117625. * 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.
  117626. * 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.
  117627. */
  117628. export class PerfCounter {
  117629. /**
  117630. * Gets or sets a global boolean to turn on and off all the counters
  117631. */
  117632. static Enabled: boolean;
  117633. /**
  117634. * Returns the smallest value ever
  117635. */
  117636. get min(): number;
  117637. /**
  117638. * Returns the biggest value ever
  117639. */
  117640. get max(): number;
  117641. /**
  117642. * Returns the average value since the performance counter is running
  117643. */
  117644. get average(): number;
  117645. /**
  117646. * Returns the average value of the last second the counter was monitored
  117647. */
  117648. get lastSecAverage(): number;
  117649. /**
  117650. * Returns the current value
  117651. */
  117652. get current(): number;
  117653. /**
  117654. * Gets the accumulated total
  117655. */
  117656. get total(): number;
  117657. /**
  117658. * Gets the total value count
  117659. */
  117660. get count(): number;
  117661. /**
  117662. * Creates a new counter
  117663. */
  117664. constructor();
  117665. /**
  117666. * Call this method to start monitoring a new frame.
  117667. * 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.
  117668. */
  117669. fetchNewFrame(): void;
  117670. /**
  117671. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117672. * @param newCount the count value to add to the monitored count
  117673. * @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.
  117674. */
  117675. addCount(newCount: number, fetchResult: boolean): void;
  117676. /**
  117677. * Start monitoring this performance counter
  117678. */
  117679. beginMonitoring(): void;
  117680. /**
  117681. * Compute the time lapsed since the previous beginMonitoring() call.
  117682. * @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
  117683. */
  117684. endMonitoring(newFrame?: boolean): void;
  117685. private _fetchResult;
  117686. private _startMonitoringTime;
  117687. private _min;
  117688. private _max;
  117689. private _average;
  117690. private _current;
  117691. private _totalValueCount;
  117692. private _totalAccumulated;
  117693. private _lastSecAverage;
  117694. private _lastSecAccumulated;
  117695. private _lastSecTime;
  117696. private _lastSecValueCount;
  117697. }
  117698. }
  117699. declare module BABYLON {
  117700. interface ThinEngine {
  117701. /** @hidden */
  117702. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  117703. }
  117704. }
  117705. declare module BABYLON {
  117706. /**
  117707. * Defines the interface used by display changed events
  117708. */
  117709. export interface IDisplayChangedEventArgs {
  117710. /** Gets the vrDisplay object (if any) */
  117711. vrDisplay: Nullable<any>;
  117712. /** Gets a boolean indicating if webVR is supported */
  117713. vrSupported: boolean;
  117714. }
  117715. /**
  117716. * Defines the interface used by objects containing a viewport (like a camera)
  117717. */
  117718. interface IViewportOwnerLike {
  117719. /**
  117720. * Gets or sets the viewport
  117721. */
  117722. viewport: IViewportLike;
  117723. }
  117724. /**
  117725. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  117726. */
  117727. export class Engine extends ThinEngine {
  117728. /** Defines that alpha blending is disabled */
  117729. static readonly ALPHA_DISABLE: number;
  117730. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  117731. static readonly ALPHA_ADD: number;
  117732. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  117733. static readonly ALPHA_COMBINE: number;
  117734. /** Defines that alpha blending to DEST - SRC * DEST */
  117735. static readonly ALPHA_SUBTRACT: number;
  117736. /** Defines that alpha blending to SRC * DEST */
  117737. static readonly ALPHA_MULTIPLY: number;
  117738. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117739. static readonly ALPHA_MAXIMIZED: number;
  117740. /** Defines that alpha blending to SRC + DEST */
  117741. static readonly ALPHA_ONEONE: number;
  117742. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117743. static readonly ALPHA_PREMULTIPLIED: number;
  117744. /**
  117745. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117746. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117747. */
  117748. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117749. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117750. static readonly ALPHA_INTERPOLATE: number;
  117751. /**
  117752. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117753. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117754. */
  117755. static readonly ALPHA_SCREENMODE: number;
  117756. /** Defines that the ressource is not delayed*/
  117757. static readonly DELAYLOADSTATE_NONE: number;
  117758. /** Defines that the ressource was successfully delay loaded */
  117759. static readonly DELAYLOADSTATE_LOADED: number;
  117760. /** Defines that the ressource is currently delay loading */
  117761. static readonly DELAYLOADSTATE_LOADING: number;
  117762. /** Defines that the ressource is delayed and has not started loading */
  117763. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117764. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117765. static readonly NEVER: number;
  117766. /** 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 */
  117767. static readonly ALWAYS: number;
  117768. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117769. static readonly LESS: number;
  117770. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117771. static readonly EQUAL: number;
  117772. /** 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 */
  117773. static readonly LEQUAL: number;
  117774. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117775. static readonly GREATER: number;
  117776. /** 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 */
  117777. static readonly GEQUAL: number;
  117778. /** 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 */
  117779. static readonly NOTEQUAL: number;
  117780. /** Passed to stencilOperation to specify that stencil value must be kept */
  117781. static readonly KEEP: number;
  117782. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117783. static readonly REPLACE: number;
  117784. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117785. static readonly INCR: number;
  117786. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117787. static readonly DECR: number;
  117788. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117789. static readonly INVERT: number;
  117790. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117791. static readonly INCR_WRAP: number;
  117792. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117793. static readonly DECR_WRAP: number;
  117794. /** Texture is not repeating outside of 0..1 UVs */
  117795. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117796. /** Texture is repeating outside of 0..1 UVs */
  117797. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117798. /** Texture is repeating and mirrored */
  117799. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117800. /** ALPHA */
  117801. static readonly TEXTUREFORMAT_ALPHA: number;
  117802. /** LUMINANCE */
  117803. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117804. /** LUMINANCE_ALPHA */
  117805. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117806. /** RGB */
  117807. static readonly TEXTUREFORMAT_RGB: number;
  117808. /** RGBA */
  117809. static readonly TEXTUREFORMAT_RGBA: number;
  117810. /** RED */
  117811. static readonly TEXTUREFORMAT_RED: number;
  117812. /** RED (2nd reference) */
  117813. static readonly TEXTUREFORMAT_R: number;
  117814. /** RG */
  117815. static readonly TEXTUREFORMAT_RG: number;
  117816. /** RED_INTEGER */
  117817. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117818. /** RED_INTEGER (2nd reference) */
  117819. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117820. /** RG_INTEGER */
  117821. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117822. /** RGB_INTEGER */
  117823. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117824. /** RGBA_INTEGER */
  117825. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117826. /** UNSIGNED_BYTE */
  117827. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117828. /** UNSIGNED_BYTE (2nd reference) */
  117829. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117830. /** FLOAT */
  117831. static readonly TEXTURETYPE_FLOAT: number;
  117832. /** HALF_FLOAT */
  117833. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117834. /** BYTE */
  117835. static readonly TEXTURETYPE_BYTE: number;
  117836. /** SHORT */
  117837. static readonly TEXTURETYPE_SHORT: number;
  117838. /** UNSIGNED_SHORT */
  117839. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117840. /** INT */
  117841. static readonly TEXTURETYPE_INT: number;
  117842. /** UNSIGNED_INT */
  117843. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117844. /** UNSIGNED_SHORT_4_4_4_4 */
  117845. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117846. /** UNSIGNED_SHORT_5_5_5_1 */
  117847. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117848. /** UNSIGNED_SHORT_5_6_5 */
  117849. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117850. /** UNSIGNED_INT_2_10_10_10_REV */
  117851. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117852. /** UNSIGNED_INT_24_8 */
  117853. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117854. /** UNSIGNED_INT_10F_11F_11F_REV */
  117855. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117856. /** UNSIGNED_INT_5_9_9_9_REV */
  117857. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117858. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117859. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117860. /** nearest is mag = nearest and min = nearest and mip = linear */
  117861. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117862. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117863. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117864. /** Trilinear is mag = linear and min = linear and mip = linear */
  117865. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117866. /** nearest is mag = nearest and min = nearest and mip = linear */
  117867. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117868. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117869. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117870. /** Trilinear is mag = linear and min = linear and mip = linear */
  117871. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117872. /** mag = nearest and min = nearest and mip = nearest */
  117873. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117874. /** mag = nearest and min = linear and mip = nearest */
  117875. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117876. /** mag = nearest and min = linear and mip = linear */
  117877. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117878. /** mag = nearest and min = linear and mip = none */
  117879. static readonly TEXTURE_NEAREST_LINEAR: number;
  117880. /** mag = nearest and min = nearest and mip = none */
  117881. static readonly TEXTURE_NEAREST_NEAREST: number;
  117882. /** mag = linear and min = nearest and mip = nearest */
  117883. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117884. /** mag = linear and min = nearest and mip = linear */
  117885. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117886. /** mag = linear and min = linear and mip = none */
  117887. static readonly TEXTURE_LINEAR_LINEAR: number;
  117888. /** mag = linear and min = nearest and mip = none */
  117889. static readonly TEXTURE_LINEAR_NEAREST: number;
  117890. /** Explicit coordinates mode */
  117891. static readonly TEXTURE_EXPLICIT_MODE: number;
  117892. /** Spherical coordinates mode */
  117893. static readonly TEXTURE_SPHERICAL_MODE: number;
  117894. /** Planar coordinates mode */
  117895. static readonly TEXTURE_PLANAR_MODE: number;
  117896. /** Cubic coordinates mode */
  117897. static readonly TEXTURE_CUBIC_MODE: number;
  117898. /** Projection coordinates mode */
  117899. static readonly TEXTURE_PROJECTION_MODE: number;
  117900. /** Skybox coordinates mode */
  117901. static readonly TEXTURE_SKYBOX_MODE: number;
  117902. /** Inverse Cubic coordinates mode */
  117903. static readonly TEXTURE_INVCUBIC_MODE: number;
  117904. /** Equirectangular coordinates mode */
  117905. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117906. /** Equirectangular Fixed coordinates mode */
  117907. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117908. /** Equirectangular Fixed Mirrored coordinates mode */
  117909. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117910. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117911. static readonly SCALEMODE_FLOOR: number;
  117912. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117913. static readonly SCALEMODE_NEAREST: number;
  117914. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117915. static readonly SCALEMODE_CEILING: number;
  117916. /**
  117917. * Returns the current npm package of the sdk
  117918. */
  117919. static get NpmPackage(): string;
  117920. /**
  117921. * Returns the current version of the framework
  117922. */
  117923. static get Version(): string;
  117924. /** Gets the list of created engines */
  117925. static get Instances(): Engine[];
  117926. /**
  117927. * Gets the latest created engine
  117928. */
  117929. static get LastCreatedEngine(): Nullable<Engine>;
  117930. /**
  117931. * Gets the latest created scene
  117932. */
  117933. static get LastCreatedScene(): Nullable<Scene>;
  117934. /**
  117935. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117936. * @param flag defines which part of the materials must be marked as dirty
  117937. * @param predicate defines a predicate used to filter which materials should be affected
  117938. */
  117939. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117940. /**
  117941. * Method called to create the default loading screen.
  117942. * This can be overriden in your own app.
  117943. * @param canvas The rendering canvas element
  117944. * @returns The loading screen
  117945. */
  117946. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117947. /**
  117948. * Method called to create the default rescale post process on each engine.
  117949. */
  117950. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117951. /**
  117952. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117953. **/
  117954. enableOfflineSupport: boolean;
  117955. /**
  117956. * 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)
  117957. **/
  117958. disableManifestCheck: boolean;
  117959. /**
  117960. * Gets the list of created scenes
  117961. */
  117962. scenes: Scene[];
  117963. /**
  117964. * Event raised when a new scene is created
  117965. */
  117966. onNewSceneAddedObservable: Observable<Scene>;
  117967. /**
  117968. * Gets the list of created postprocesses
  117969. */
  117970. postProcesses: PostProcess[];
  117971. /**
  117972. * Gets a boolean indicating if the pointer is currently locked
  117973. */
  117974. isPointerLock: boolean;
  117975. /**
  117976. * Observable event triggered each time the rendering canvas is resized
  117977. */
  117978. onResizeObservable: Observable<Engine>;
  117979. /**
  117980. * Observable event triggered each time the canvas loses focus
  117981. */
  117982. onCanvasBlurObservable: Observable<Engine>;
  117983. /**
  117984. * Observable event triggered each time the canvas gains focus
  117985. */
  117986. onCanvasFocusObservable: Observable<Engine>;
  117987. /**
  117988. * Observable event triggered each time the canvas receives pointerout event
  117989. */
  117990. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117991. /**
  117992. * Observable raised when the engine begins a new frame
  117993. */
  117994. onBeginFrameObservable: Observable<Engine>;
  117995. /**
  117996. * If set, will be used to request the next animation frame for the render loop
  117997. */
  117998. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117999. /**
  118000. * Observable raised when the engine ends the current frame
  118001. */
  118002. onEndFrameObservable: Observable<Engine>;
  118003. /**
  118004. * Observable raised when the engine is about to compile a shader
  118005. */
  118006. onBeforeShaderCompilationObservable: Observable<Engine>;
  118007. /**
  118008. * Observable raised when the engine has jsut compiled a shader
  118009. */
  118010. onAfterShaderCompilationObservable: Observable<Engine>;
  118011. /**
  118012. * Gets the audio engine
  118013. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118014. * @ignorenaming
  118015. */
  118016. static audioEngine: IAudioEngine;
  118017. /**
  118018. * Default AudioEngine factory responsible of creating the Audio Engine.
  118019. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  118020. */
  118021. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  118022. /**
  118023. * Default offline support factory responsible of creating a tool used to store data locally.
  118024. * By default, this will create a Database object if the workload has been embedded.
  118025. */
  118026. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  118027. private _loadingScreen;
  118028. private _pointerLockRequested;
  118029. private _rescalePostProcess;
  118030. private _deterministicLockstep;
  118031. private _lockstepMaxSteps;
  118032. private _timeStep;
  118033. protected get _supportsHardwareTextureRescaling(): boolean;
  118034. private _fps;
  118035. private _deltaTime;
  118036. /** @hidden */
  118037. _drawCalls: PerfCounter;
  118038. /** 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 */
  118039. canvasTabIndex: number;
  118040. /**
  118041. * Turn this value on if you want to pause FPS computation when in background
  118042. */
  118043. disablePerformanceMonitorInBackground: boolean;
  118044. private _performanceMonitor;
  118045. /**
  118046. * Gets the performance monitor attached to this engine
  118047. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118048. */
  118049. get performanceMonitor(): PerformanceMonitor;
  118050. private _onFocus;
  118051. private _onBlur;
  118052. private _onCanvasPointerOut;
  118053. private _onCanvasBlur;
  118054. private _onCanvasFocus;
  118055. private _onFullscreenChange;
  118056. private _onPointerLockChange;
  118057. /**
  118058. * Gets the HTML element used to attach event listeners
  118059. * @returns a HTML element
  118060. */
  118061. getInputElement(): Nullable<HTMLElement>;
  118062. /**
  118063. * Creates a new engine
  118064. * @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
  118065. * @param antialias defines enable antialiasing (default: false)
  118066. * @param options defines further options to be sent to the getContext() function
  118067. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  118068. */
  118069. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  118070. /**
  118071. * Gets current aspect ratio
  118072. * @param viewportOwner defines the camera to use to get the aspect ratio
  118073. * @param useScreen defines if screen size must be used (or the current render target if any)
  118074. * @returns a number defining the aspect ratio
  118075. */
  118076. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  118077. /**
  118078. * Gets current screen aspect ratio
  118079. * @returns a number defining the aspect ratio
  118080. */
  118081. getScreenAspectRatio(): number;
  118082. /**
  118083. * Gets the client rect of the HTML canvas attached with the current webGL context
  118084. * @returns a client rectanglee
  118085. */
  118086. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  118087. /**
  118088. * Gets the client rect of the HTML element used for events
  118089. * @returns a client rectanglee
  118090. */
  118091. getInputElementClientRect(): Nullable<ClientRect>;
  118092. /**
  118093. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  118094. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118095. * @returns true if engine is in deterministic lock step mode
  118096. */
  118097. isDeterministicLockStep(): boolean;
  118098. /**
  118099. * Gets the max steps when engine is running in deterministic lock step
  118100. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118101. * @returns the max steps
  118102. */
  118103. getLockstepMaxSteps(): number;
  118104. /**
  118105. * Returns the time in ms between steps when using deterministic lock step.
  118106. * @returns time step in (ms)
  118107. */
  118108. getTimeStep(): number;
  118109. /**
  118110. * Force the mipmap generation for the given render target texture
  118111. * @param texture defines the render target texture to use
  118112. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  118113. */
  118114. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  118115. /** States */
  118116. /**
  118117. * Set various states to the webGL context
  118118. * @param culling defines backface culling state
  118119. * @param zOffset defines the value to apply to zOffset (0 by default)
  118120. * @param force defines if states must be applied even if cache is up to date
  118121. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  118122. */
  118123. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118124. /**
  118125. * Set the z offset to apply to current rendering
  118126. * @param value defines the offset to apply
  118127. */
  118128. setZOffset(value: number): void;
  118129. /**
  118130. * Gets the current value of the zOffset
  118131. * @returns the current zOffset state
  118132. */
  118133. getZOffset(): number;
  118134. /**
  118135. * Enable or disable depth buffering
  118136. * @param enable defines the state to set
  118137. */
  118138. setDepthBuffer(enable: boolean): void;
  118139. /**
  118140. * Gets a boolean indicating if depth writing is enabled
  118141. * @returns the current depth writing state
  118142. */
  118143. getDepthWrite(): boolean;
  118144. /**
  118145. * Enable or disable depth writing
  118146. * @param enable defines the state to set
  118147. */
  118148. setDepthWrite(enable: boolean): void;
  118149. /**
  118150. * Gets a boolean indicating if stencil buffer is enabled
  118151. * @returns the current stencil buffer state
  118152. */
  118153. getStencilBuffer(): boolean;
  118154. /**
  118155. * Enable or disable the stencil buffer
  118156. * @param enable defines if the stencil buffer must be enabled or disabled
  118157. */
  118158. setStencilBuffer(enable: boolean): void;
  118159. /**
  118160. * Gets the current stencil mask
  118161. * @returns a number defining the new stencil mask to use
  118162. */
  118163. getStencilMask(): number;
  118164. /**
  118165. * Sets the current stencil mask
  118166. * @param mask defines the new stencil mask to use
  118167. */
  118168. setStencilMask(mask: number): void;
  118169. /**
  118170. * Gets the current stencil function
  118171. * @returns a number defining the stencil function to use
  118172. */
  118173. getStencilFunction(): number;
  118174. /**
  118175. * Gets the current stencil reference value
  118176. * @returns a number defining the stencil reference value to use
  118177. */
  118178. getStencilFunctionReference(): number;
  118179. /**
  118180. * Gets the current stencil mask
  118181. * @returns a number defining the stencil mask to use
  118182. */
  118183. getStencilFunctionMask(): number;
  118184. /**
  118185. * Sets the current stencil function
  118186. * @param stencilFunc defines the new stencil function to use
  118187. */
  118188. setStencilFunction(stencilFunc: number): void;
  118189. /**
  118190. * Sets the current stencil reference
  118191. * @param reference defines the new stencil reference to use
  118192. */
  118193. setStencilFunctionReference(reference: number): void;
  118194. /**
  118195. * Sets the current stencil mask
  118196. * @param mask defines the new stencil mask to use
  118197. */
  118198. setStencilFunctionMask(mask: number): void;
  118199. /**
  118200. * Gets the current stencil operation when stencil fails
  118201. * @returns a number defining stencil operation to use when stencil fails
  118202. */
  118203. getStencilOperationFail(): number;
  118204. /**
  118205. * Gets the current stencil operation when depth fails
  118206. * @returns a number defining stencil operation to use when depth fails
  118207. */
  118208. getStencilOperationDepthFail(): number;
  118209. /**
  118210. * Gets the current stencil operation when stencil passes
  118211. * @returns a number defining stencil operation to use when stencil passes
  118212. */
  118213. getStencilOperationPass(): number;
  118214. /**
  118215. * Sets the stencil operation to use when stencil fails
  118216. * @param operation defines the stencil operation to use when stencil fails
  118217. */
  118218. setStencilOperationFail(operation: number): void;
  118219. /**
  118220. * Sets the stencil operation to use when depth fails
  118221. * @param operation defines the stencil operation to use when depth fails
  118222. */
  118223. setStencilOperationDepthFail(operation: number): void;
  118224. /**
  118225. * Sets the stencil operation to use when stencil passes
  118226. * @param operation defines the stencil operation to use when stencil passes
  118227. */
  118228. setStencilOperationPass(operation: number): void;
  118229. /**
  118230. * Sets a boolean indicating if the dithering state is enabled or disabled
  118231. * @param value defines the dithering state
  118232. */
  118233. setDitheringState(value: boolean): void;
  118234. /**
  118235. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  118236. * @param value defines the rasterizer state
  118237. */
  118238. setRasterizerState(value: boolean): void;
  118239. /**
  118240. * Gets the current depth function
  118241. * @returns a number defining the depth function
  118242. */
  118243. getDepthFunction(): Nullable<number>;
  118244. /**
  118245. * Sets the current depth function
  118246. * @param depthFunc defines the function to use
  118247. */
  118248. setDepthFunction(depthFunc: number): void;
  118249. /**
  118250. * Sets the current depth function to GREATER
  118251. */
  118252. setDepthFunctionToGreater(): void;
  118253. /**
  118254. * Sets the current depth function to GEQUAL
  118255. */
  118256. setDepthFunctionToGreaterOrEqual(): void;
  118257. /**
  118258. * Sets the current depth function to LESS
  118259. */
  118260. setDepthFunctionToLess(): void;
  118261. /**
  118262. * Sets the current depth function to LEQUAL
  118263. */
  118264. setDepthFunctionToLessOrEqual(): void;
  118265. private _cachedStencilBuffer;
  118266. private _cachedStencilFunction;
  118267. private _cachedStencilMask;
  118268. private _cachedStencilOperationPass;
  118269. private _cachedStencilOperationFail;
  118270. private _cachedStencilOperationDepthFail;
  118271. private _cachedStencilReference;
  118272. /**
  118273. * Caches the the state of the stencil buffer
  118274. */
  118275. cacheStencilState(): void;
  118276. /**
  118277. * Restores the state of the stencil buffer
  118278. */
  118279. restoreStencilState(): void;
  118280. /**
  118281. * Directly set the WebGL Viewport
  118282. * @param x defines the x coordinate of the viewport (in screen space)
  118283. * @param y defines the y coordinate of the viewport (in screen space)
  118284. * @param width defines the width of the viewport (in screen space)
  118285. * @param height defines the height of the viewport (in screen space)
  118286. * @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
  118287. */
  118288. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  118289. /**
  118290. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  118291. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118292. * @param y defines the y-coordinate of the corner of the clear rectangle
  118293. * @param width defines the width of the clear rectangle
  118294. * @param height defines the height of the clear rectangle
  118295. * @param clearColor defines the clear color
  118296. */
  118297. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  118298. /**
  118299. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  118300. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118301. * @param y defines the y-coordinate of the corner of the clear rectangle
  118302. * @param width defines the width of the clear rectangle
  118303. * @param height defines the height of the clear rectangle
  118304. */
  118305. enableScissor(x: number, y: number, width: number, height: number): void;
  118306. /**
  118307. * Disable previously set scissor test rectangle
  118308. */
  118309. disableScissor(): void;
  118310. protected _reportDrawCall(): void;
  118311. /**
  118312. * Initializes a webVR display and starts listening to display change events
  118313. * The onVRDisplayChangedObservable will be notified upon these changes
  118314. * @returns The onVRDisplayChangedObservable
  118315. */
  118316. initWebVR(): Observable<IDisplayChangedEventArgs>;
  118317. /** @hidden */
  118318. _prepareVRComponent(): void;
  118319. /** @hidden */
  118320. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  118321. /** @hidden */
  118322. _submitVRFrame(): void;
  118323. /**
  118324. * Call this function to leave webVR mode
  118325. * Will do nothing if webVR is not supported or if there is no webVR device
  118326. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118327. */
  118328. disableVR(): void;
  118329. /**
  118330. * Gets a boolean indicating that the system is in VR mode and is presenting
  118331. * @returns true if VR mode is engaged
  118332. */
  118333. isVRPresenting(): boolean;
  118334. /** @hidden */
  118335. _requestVRFrame(): void;
  118336. /** @hidden */
  118337. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118338. /**
  118339. * Gets the source code of the vertex shader associated with a specific webGL program
  118340. * @param program defines the program to use
  118341. * @returns a string containing the source code of the vertex shader associated with the program
  118342. */
  118343. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  118344. /**
  118345. * Gets the source code of the fragment shader associated with a specific webGL program
  118346. * @param program defines the program to use
  118347. * @returns a string containing the source code of the fragment shader associated with the program
  118348. */
  118349. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  118350. /**
  118351. * Sets a depth stencil texture from a render target to the according uniform.
  118352. * @param channel The texture channel
  118353. * @param uniform The uniform to set
  118354. * @param texture The render target texture containing the depth stencil texture to apply
  118355. */
  118356. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  118357. /**
  118358. * Sets a texture to the webGL context from a postprocess
  118359. * @param channel defines the channel to use
  118360. * @param postProcess defines the source postprocess
  118361. */
  118362. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  118363. /**
  118364. * Binds the output of the passed in post process to the texture channel specified
  118365. * @param channel The channel the texture should be bound to
  118366. * @param postProcess The post process which's output should be bound
  118367. */
  118368. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  118369. protected _rebuildBuffers(): void;
  118370. /** @hidden */
  118371. _renderFrame(): void;
  118372. _renderLoop(): void;
  118373. /** @hidden */
  118374. _renderViews(): boolean;
  118375. /**
  118376. * Toggle full screen mode
  118377. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118378. */
  118379. switchFullscreen(requestPointerLock: boolean): void;
  118380. /**
  118381. * Enters full screen mode
  118382. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118383. */
  118384. enterFullscreen(requestPointerLock: boolean): void;
  118385. /**
  118386. * Exits full screen mode
  118387. */
  118388. exitFullscreen(): void;
  118389. /**
  118390. * Enters Pointerlock mode
  118391. */
  118392. enterPointerlock(): void;
  118393. /**
  118394. * Exits Pointerlock mode
  118395. */
  118396. exitPointerlock(): void;
  118397. /**
  118398. * Begin a new frame
  118399. */
  118400. beginFrame(): void;
  118401. /**
  118402. * Enf the current frame
  118403. */
  118404. endFrame(): void;
  118405. resize(): void;
  118406. /**
  118407. * Force a specific size of the canvas
  118408. * @param width defines the new canvas' width
  118409. * @param height defines the new canvas' height
  118410. * @returns true if the size was changed
  118411. */
  118412. setSize(width: number, height: number): boolean;
  118413. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118414. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118415. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118416. _releaseTexture(texture: InternalTexture): void;
  118417. /**
  118418. * @hidden
  118419. * Rescales a texture
  118420. * @param source input texutre
  118421. * @param destination destination texture
  118422. * @param scene scene to use to render the resize
  118423. * @param internalFormat format to use when resizing
  118424. * @param onComplete callback to be called when resize has completed
  118425. */
  118426. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  118427. /**
  118428. * Gets the current framerate
  118429. * @returns a number representing the framerate
  118430. */
  118431. getFps(): number;
  118432. /**
  118433. * Gets the time spent between current and previous frame
  118434. * @returns a number representing the delta time in ms
  118435. */
  118436. getDeltaTime(): number;
  118437. private _measureFps;
  118438. /** @hidden */
  118439. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  118440. /**
  118441. * Updates the sample count of a render target texture
  118442. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118443. * @param texture defines the texture to update
  118444. * @param samples defines the sample count to set
  118445. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118446. */
  118447. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  118448. /**
  118449. * Updates a depth texture Comparison Mode and Function.
  118450. * If the comparison Function is equal to 0, the mode will be set to none.
  118451. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  118452. * @param texture The texture to set the comparison function for
  118453. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  118454. */
  118455. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  118456. /**
  118457. * Creates a webGL buffer to use with instanciation
  118458. * @param capacity defines the size of the buffer
  118459. * @returns the webGL buffer
  118460. */
  118461. createInstancesBuffer(capacity: number): DataBuffer;
  118462. /**
  118463. * Delete a webGL buffer used with instanciation
  118464. * @param buffer defines the webGL buffer to delete
  118465. */
  118466. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  118467. private _clientWaitAsync;
  118468. /** @hidden */
  118469. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  118470. dispose(): void;
  118471. private _disableTouchAction;
  118472. /**
  118473. * Display the loading screen
  118474. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118475. */
  118476. displayLoadingUI(): void;
  118477. /**
  118478. * Hide the loading screen
  118479. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118480. */
  118481. hideLoadingUI(): void;
  118482. /**
  118483. * Gets the current loading screen object
  118484. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118485. */
  118486. get loadingScreen(): ILoadingScreen;
  118487. /**
  118488. * Sets the current loading screen object
  118489. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118490. */
  118491. set loadingScreen(loadingScreen: ILoadingScreen);
  118492. /**
  118493. * Sets the current loading screen text
  118494. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118495. */
  118496. set loadingUIText(text: string);
  118497. /**
  118498. * Sets the current loading screen background color
  118499. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118500. */
  118501. set loadingUIBackgroundColor(color: string);
  118502. /** Pointerlock and fullscreen */
  118503. /**
  118504. * Ask the browser to promote the current element to pointerlock mode
  118505. * @param element defines the DOM element to promote
  118506. */
  118507. static _RequestPointerlock(element: HTMLElement): void;
  118508. /**
  118509. * Asks the browser to exit pointerlock mode
  118510. */
  118511. static _ExitPointerlock(): void;
  118512. /**
  118513. * Ask the browser to promote the current element to fullscreen rendering mode
  118514. * @param element defines the DOM element to promote
  118515. */
  118516. static _RequestFullscreen(element: HTMLElement): void;
  118517. /**
  118518. * Asks the browser to exit fullscreen mode
  118519. */
  118520. static _ExitFullscreen(): void;
  118521. }
  118522. }
  118523. declare module BABYLON {
  118524. /**
  118525. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118526. * during the life time of the application.
  118527. */
  118528. export class EngineStore {
  118529. /** Gets the list of created engines */
  118530. static Instances: Engine[];
  118531. /** @hidden */
  118532. static _LastCreatedScene: Nullable<Scene>;
  118533. /**
  118534. * Gets the latest created engine
  118535. */
  118536. static get LastCreatedEngine(): Nullable<Engine>;
  118537. /**
  118538. * Gets the latest created scene
  118539. */
  118540. static get LastCreatedScene(): Nullable<Scene>;
  118541. /**
  118542. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118543. * @ignorenaming
  118544. */
  118545. static UseFallbackTexture: boolean;
  118546. /**
  118547. * Texture content used if a texture cannot loaded
  118548. * @ignorenaming
  118549. */
  118550. static FallbackTexture: string;
  118551. }
  118552. }
  118553. declare module BABYLON {
  118554. /**
  118555. * Helper class that provides a small promise polyfill
  118556. */
  118557. export class PromisePolyfill {
  118558. /**
  118559. * Static function used to check if the polyfill is required
  118560. * If this is the case then the function will inject the polyfill to window.Promise
  118561. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118562. */
  118563. static Apply(force?: boolean): void;
  118564. }
  118565. }
  118566. declare module BABYLON {
  118567. /**
  118568. * Interface for screenshot methods with describe argument called `size` as object with options
  118569. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118570. */
  118571. export interface IScreenshotSize {
  118572. /**
  118573. * number in pixels for canvas height
  118574. */
  118575. height?: number;
  118576. /**
  118577. * multiplier allowing render at a higher or lower resolution
  118578. * If value is defined then height and width will be ignored and taken from camera
  118579. */
  118580. precision?: number;
  118581. /**
  118582. * number in pixels for canvas width
  118583. */
  118584. width?: number;
  118585. }
  118586. }
  118587. declare module BABYLON {
  118588. interface IColor4Like {
  118589. r: float;
  118590. g: float;
  118591. b: float;
  118592. a: float;
  118593. }
  118594. /**
  118595. * Class containing a set of static utilities functions
  118596. */
  118597. export class Tools {
  118598. /**
  118599. * Gets or sets the base URL to use to load assets
  118600. */
  118601. static get BaseUrl(): string;
  118602. static set BaseUrl(value: string);
  118603. /**
  118604. * Enable/Disable Custom HTTP Request Headers globally.
  118605. * default = false
  118606. * @see CustomRequestHeaders
  118607. */
  118608. static UseCustomRequestHeaders: boolean;
  118609. /**
  118610. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118611. * i.e. when loading files, where the server/service expects an Authorization header
  118612. */
  118613. static CustomRequestHeaders: {
  118614. [key: string]: string;
  118615. };
  118616. /**
  118617. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118618. */
  118619. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118620. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118621. /**
  118622. * Default behaviour for cors in the application.
  118623. * It can be a string if the expected behavior is identical in the entire app.
  118624. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118625. */
  118626. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118627. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118628. /**
  118629. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118630. * @ignorenaming
  118631. */
  118632. static get UseFallbackTexture(): boolean;
  118633. static set UseFallbackTexture(value: boolean);
  118634. /**
  118635. * Use this object to register external classes like custom textures or material
  118636. * to allow the laoders to instantiate them
  118637. */
  118638. static get RegisteredExternalClasses(): {
  118639. [key: string]: Object;
  118640. };
  118641. static set RegisteredExternalClasses(classes: {
  118642. [key: string]: Object;
  118643. });
  118644. /**
  118645. * Texture content used if a texture cannot loaded
  118646. * @ignorenaming
  118647. */
  118648. static get fallbackTexture(): string;
  118649. static set fallbackTexture(value: string);
  118650. /**
  118651. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118652. * @param u defines the coordinate on X axis
  118653. * @param v defines the coordinate on Y axis
  118654. * @param width defines the width of the source data
  118655. * @param height defines the height of the source data
  118656. * @param pixels defines the source byte array
  118657. * @param color defines the output color
  118658. */
  118659. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118660. /**
  118661. * Interpolates between a and b via alpha
  118662. * @param a The lower value (returned when alpha = 0)
  118663. * @param b The upper value (returned when alpha = 1)
  118664. * @param alpha The interpolation-factor
  118665. * @return The mixed value
  118666. */
  118667. static Mix(a: number, b: number, alpha: number): number;
  118668. /**
  118669. * Tries to instantiate a new object from a given class name
  118670. * @param className defines the class name to instantiate
  118671. * @returns the new object or null if the system was not able to do the instantiation
  118672. */
  118673. static Instantiate(className: string): any;
  118674. /**
  118675. * Provides a slice function that will work even on IE
  118676. * @param data defines the array to slice
  118677. * @param start defines the start of the data (optional)
  118678. * @param end defines the end of the data (optional)
  118679. * @returns the new sliced array
  118680. */
  118681. static Slice<T>(data: T, start?: number, end?: number): T;
  118682. /**
  118683. * Polyfill for setImmediate
  118684. * @param action defines the action to execute after the current execution block
  118685. */
  118686. static SetImmediate(action: () => void): void;
  118687. /**
  118688. * Function indicating if a number is an exponent of 2
  118689. * @param value defines the value to test
  118690. * @returns true if the value is an exponent of 2
  118691. */
  118692. static IsExponentOfTwo(value: number): boolean;
  118693. private static _tmpFloatArray;
  118694. /**
  118695. * Returns the nearest 32-bit single precision float representation of a Number
  118696. * @param value A Number. If the parameter is of a different type, it will get converted
  118697. * to a number or to NaN if it cannot be converted
  118698. * @returns number
  118699. */
  118700. static FloatRound(value: number): number;
  118701. /**
  118702. * Extracts the filename from a path
  118703. * @param path defines the path to use
  118704. * @returns the filename
  118705. */
  118706. static GetFilename(path: string): string;
  118707. /**
  118708. * Extracts the "folder" part of a path (everything before the filename).
  118709. * @param uri The URI to extract the info from
  118710. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  118711. * @returns The "folder" part of the path
  118712. */
  118713. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  118714. /**
  118715. * Extracts text content from a DOM element hierarchy
  118716. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  118717. */
  118718. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  118719. /**
  118720. * Convert an angle in radians to degrees
  118721. * @param angle defines the angle to convert
  118722. * @returns the angle in degrees
  118723. */
  118724. static ToDegrees(angle: number): number;
  118725. /**
  118726. * Convert an angle in degrees to radians
  118727. * @param angle defines the angle to convert
  118728. * @returns the angle in radians
  118729. */
  118730. static ToRadians(angle: number): number;
  118731. /**
  118732. * Returns an array if obj is not an array
  118733. * @param obj defines the object to evaluate as an array
  118734. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  118735. * @returns either obj directly if obj is an array or a new array containing obj
  118736. */
  118737. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118738. /**
  118739. * Gets the pointer prefix to use
  118740. * @param engine defines the engine we are finding the prefix for
  118741. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118742. */
  118743. static GetPointerPrefix(engine: Engine): string;
  118744. /**
  118745. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118746. * @param url define the url we are trying
  118747. * @param element define the dom element where to configure the cors policy
  118748. */
  118749. static SetCorsBehavior(url: string | string[], element: {
  118750. crossOrigin: string | null;
  118751. }): void;
  118752. /**
  118753. * Removes unwanted characters from an url
  118754. * @param url defines the url to clean
  118755. * @returns the cleaned url
  118756. */
  118757. static CleanUrl(url: string): string;
  118758. /**
  118759. * Gets or sets a function used to pre-process url before using them to load assets
  118760. */
  118761. static get PreprocessUrl(): (url: string) => string;
  118762. static set PreprocessUrl(processor: (url: string) => string);
  118763. /**
  118764. * Loads an image as an HTMLImageElement.
  118765. * @param input url string, ArrayBuffer, or Blob to load
  118766. * @param onLoad callback called when the image successfully loads
  118767. * @param onError callback called when the image fails to load
  118768. * @param offlineProvider offline provider for caching
  118769. * @param mimeType optional mime type
  118770. * @returns the HTMLImageElement of the loaded image
  118771. */
  118772. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118773. /**
  118774. * Loads a file from a url
  118775. * @param url url string, ArrayBuffer, or Blob to load
  118776. * @param onSuccess callback called when the file successfully loads
  118777. * @param onProgress callback called while file is loading (if the server supports this mode)
  118778. * @param offlineProvider defines the offline provider for caching
  118779. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118780. * @param onError callback called when the file fails to load
  118781. * @returns a file request object
  118782. */
  118783. 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;
  118784. /**
  118785. * Loads a file from a url
  118786. * @param url the file url to load
  118787. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118788. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118789. */
  118790. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118791. /**
  118792. * Load a script (identified by an url). When the url returns, the
  118793. * content of this file is added into a new script element, attached to the DOM (body element)
  118794. * @param scriptUrl defines the url of the script to laod
  118795. * @param onSuccess defines the callback called when the script is loaded
  118796. * @param onError defines the callback to call if an error occurs
  118797. * @param scriptId defines the id of the script element
  118798. */
  118799. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118800. /**
  118801. * Load an asynchronous script (identified by an url). When the url returns, the
  118802. * content of this file is added into a new script element, attached to the DOM (body element)
  118803. * @param scriptUrl defines the url of the script to laod
  118804. * @param scriptId defines the id of the script element
  118805. * @returns a promise request object
  118806. */
  118807. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118808. /**
  118809. * Loads a file from a blob
  118810. * @param fileToLoad defines the blob to use
  118811. * @param callback defines the callback to call when data is loaded
  118812. * @param progressCallback defines the callback to call during loading process
  118813. * @returns a file request object
  118814. */
  118815. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118816. /**
  118817. * Reads a file from a File object
  118818. * @param file defines the file to load
  118819. * @param onSuccess defines the callback to call when data is loaded
  118820. * @param onProgress defines the callback to call during loading process
  118821. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118822. * @param onError defines the callback to call when an error occurs
  118823. * @returns a file request object
  118824. */
  118825. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118826. /**
  118827. * Creates a data url from a given string content
  118828. * @param content defines the content to convert
  118829. * @returns the new data url link
  118830. */
  118831. static FileAsURL(content: string): string;
  118832. /**
  118833. * Format the given number to a specific decimal format
  118834. * @param value defines the number to format
  118835. * @param decimals defines the number of decimals to use
  118836. * @returns the formatted string
  118837. */
  118838. static Format(value: number, decimals?: number): string;
  118839. /**
  118840. * Tries to copy an object by duplicating every property
  118841. * @param source defines the source object
  118842. * @param destination defines the target object
  118843. * @param doNotCopyList defines a list of properties to avoid
  118844. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118845. */
  118846. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118847. /**
  118848. * Gets a boolean indicating if the given object has no own property
  118849. * @param obj defines the object to test
  118850. * @returns true if object has no own property
  118851. */
  118852. static IsEmpty(obj: any): boolean;
  118853. /**
  118854. * Function used to register events at window level
  118855. * @param windowElement defines the Window object to use
  118856. * @param events defines the events to register
  118857. */
  118858. static RegisterTopRootEvents(windowElement: Window, events: {
  118859. name: string;
  118860. handler: Nullable<(e: FocusEvent) => any>;
  118861. }[]): void;
  118862. /**
  118863. * Function used to unregister events from window level
  118864. * @param windowElement defines the Window object to use
  118865. * @param events defines the events to unregister
  118866. */
  118867. static UnregisterTopRootEvents(windowElement: Window, events: {
  118868. name: string;
  118869. handler: Nullable<(e: FocusEvent) => any>;
  118870. }[]): void;
  118871. /**
  118872. * @ignore
  118873. */
  118874. static _ScreenshotCanvas: HTMLCanvasElement;
  118875. /**
  118876. * Dumps the current bound framebuffer
  118877. * @param width defines the rendering width
  118878. * @param height defines the rendering height
  118879. * @param engine defines the hosting engine
  118880. * @param successCallback defines the callback triggered once the data are available
  118881. * @param mimeType defines the mime type of the result
  118882. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118883. */
  118884. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118885. /**
  118886. * Converts the canvas data to blob.
  118887. * This acts as a polyfill for browsers not supporting the to blob function.
  118888. * @param canvas Defines the canvas to extract the data from
  118889. * @param successCallback Defines the callback triggered once the data are available
  118890. * @param mimeType Defines the mime type of the result
  118891. */
  118892. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118893. /**
  118894. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118895. * @param successCallback defines the callback triggered once the data are available
  118896. * @param mimeType defines the mime type of the result
  118897. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118898. */
  118899. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118900. /**
  118901. * Downloads a blob in the browser
  118902. * @param blob defines the blob to download
  118903. * @param fileName defines the name of the downloaded file
  118904. */
  118905. static Download(blob: Blob, fileName: string): void;
  118906. /**
  118907. * Captures a screenshot of the current rendering
  118908. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118909. * @param engine defines the rendering engine
  118910. * @param camera defines the source camera
  118911. * @param size This parameter can be set to a single number or to an object with the
  118912. * following (optional) properties: precision, width, height. If a single number is passed,
  118913. * it will be used for both width and height. If an object is passed, the screenshot size
  118914. * will be derived from the parameters. The precision property is a multiplier allowing
  118915. * rendering at a higher or lower resolution
  118916. * @param successCallback defines the callback receives a single parameter which contains the
  118917. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118918. * src parameter of an <img> to display it
  118919. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118920. * Check your browser for supported MIME types
  118921. */
  118922. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118923. /**
  118924. * Captures a screenshot of the current rendering
  118925. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118926. * @param engine defines the rendering engine
  118927. * @param camera defines the source camera
  118928. * @param size This parameter can be set to a single number or to an object with the
  118929. * following (optional) properties: precision, width, height. If a single number is passed,
  118930. * it will be used for both width and height. If an object is passed, the screenshot size
  118931. * will be derived from the parameters. The precision property is a multiplier allowing
  118932. * rendering at a higher or lower resolution
  118933. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118934. * Check your browser for supported MIME types
  118935. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118936. * to the src parameter of an <img> to display it
  118937. */
  118938. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118939. /**
  118940. * Generates an image screenshot from the specified camera.
  118941. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118942. * @param engine The engine to use for rendering
  118943. * @param camera The camera to use for rendering
  118944. * @param size This parameter can be set to a single number or to an object with the
  118945. * following (optional) properties: precision, width, height. If a single number is passed,
  118946. * it will be used for both width and height. If an object is passed, the screenshot size
  118947. * will be derived from the parameters. The precision property is a multiplier allowing
  118948. * rendering at a higher or lower resolution
  118949. * @param successCallback The callback receives a single parameter which contains the
  118950. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118951. * src parameter of an <img> to display it
  118952. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118953. * Check your browser for supported MIME types
  118954. * @param samples Texture samples (default: 1)
  118955. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118956. * @param fileName A name for for the downloaded file.
  118957. */
  118958. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118959. /**
  118960. * Generates an image screenshot from the specified camera.
  118961. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118962. * @param engine The engine to use for rendering
  118963. * @param camera The camera to use for rendering
  118964. * @param size This parameter can be set to a single number or to an object with the
  118965. * following (optional) properties: precision, width, height. If a single number is passed,
  118966. * it will be used for both width and height. If an object is passed, the screenshot size
  118967. * will be derived from the parameters. The precision property is a multiplier allowing
  118968. * rendering at a higher or lower resolution
  118969. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118970. * Check your browser for supported MIME types
  118971. * @param samples Texture samples (default: 1)
  118972. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118973. * @param fileName A name for for the downloaded file.
  118974. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118975. * to the src parameter of an <img> to display it
  118976. */
  118977. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118978. /**
  118979. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118980. * Be aware Math.random() could cause collisions, but:
  118981. * "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"
  118982. * @returns a pseudo random id
  118983. */
  118984. static RandomId(): string;
  118985. /**
  118986. * Test if the given uri is a base64 string
  118987. * @param uri The uri to test
  118988. * @return True if the uri is a base64 string or false otherwise
  118989. */
  118990. static IsBase64(uri: string): boolean;
  118991. /**
  118992. * Decode the given base64 uri.
  118993. * @param uri The uri to decode
  118994. * @return The decoded base64 data.
  118995. */
  118996. static DecodeBase64(uri: string): ArrayBuffer;
  118997. /**
  118998. * Gets the absolute url.
  118999. * @param url the input url
  119000. * @return the absolute url
  119001. */
  119002. static GetAbsoluteUrl(url: string): string;
  119003. /**
  119004. * No log
  119005. */
  119006. static readonly NoneLogLevel: number;
  119007. /**
  119008. * Only message logs
  119009. */
  119010. static readonly MessageLogLevel: number;
  119011. /**
  119012. * Only warning logs
  119013. */
  119014. static readonly WarningLogLevel: number;
  119015. /**
  119016. * Only error logs
  119017. */
  119018. static readonly ErrorLogLevel: number;
  119019. /**
  119020. * All logs
  119021. */
  119022. static readonly AllLogLevel: number;
  119023. /**
  119024. * Gets a value indicating the number of loading errors
  119025. * @ignorenaming
  119026. */
  119027. static get errorsCount(): number;
  119028. /**
  119029. * Callback called when a new log is added
  119030. */
  119031. static OnNewCacheEntry: (entry: string) => void;
  119032. /**
  119033. * Log a message to the console
  119034. * @param message defines the message to log
  119035. */
  119036. static Log(message: string): void;
  119037. /**
  119038. * Write a warning message to the console
  119039. * @param message defines the message to log
  119040. */
  119041. static Warn(message: string): void;
  119042. /**
  119043. * Write an error message to the console
  119044. * @param message defines the message to log
  119045. */
  119046. static Error(message: string): void;
  119047. /**
  119048. * Gets current log cache (list of logs)
  119049. */
  119050. static get LogCache(): string;
  119051. /**
  119052. * Clears the log cache
  119053. */
  119054. static ClearLogCache(): void;
  119055. /**
  119056. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  119057. */
  119058. static set LogLevels(level: number);
  119059. /**
  119060. * Checks if the window object exists
  119061. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  119062. */
  119063. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  119064. /**
  119065. * No performance log
  119066. */
  119067. static readonly PerformanceNoneLogLevel: number;
  119068. /**
  119069. * Use user marks to log performance
  119070. */
  119071. static readonly PerformanceUserMarkLogLevel: number;
  119072. /**
  119073. * Log performance to the console
  119074. */
  119075. static readonly PerformanceConsoleLogLevel: number;
  119076. private static _performance;
  119077. /**
  119078. * Sets the current performance log level
  119079. */
  119080. static set PerformanceLogLevel(level: number);
  119081. private static _StartPerformanceCounterDisabled;
  119082. private static _EndPerformanceCounterDisabled;
  119083. private static _StartUserMark;
  119084. private static _EndUserMark;
  119085. private static _StartPerformanceConsole;
  119086. private static _EndPerformanceConsole;
  119087. /**
  119088. * Starts a performance counter
  119089. */
  119090. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119091. /**
  119092. * Ends a specific performance coutner
  119093. */
  119094. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119095. /**
  119096. * Gets either window.performance.now() if supported or Date.now() else
  119097. */
  119098. static get Now(): number;
  119099. /**
  119100. * This method will return the name of the class used to create the instance of the given object.
  119101. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  119102. * @param object the object to get the class name from
  119103. * @param isType defines if the object is actually a type
  119104. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  119105. */
  119106. static GetClassName(object: any, isType?: boolean): string;
  119107. /**
  119108. * Gets the first element of an array satisfying a given predicate
  119109. * @param array defines the array to browse
  119110. * @param predicate defines the predicate to use
  119111. * @returns null if not found or the element
  119112. */
  119113. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  119114. /**
  119115. * This method will return the name of the full name of the class, including its owning module (if any).
  119116. * 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).
  119117. * @param object the object to get the class name from
  119118. * @param isType defines if the object is actually a type
  119119. * @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.
  119120. * @ignorenaming
  119121. */
  119122. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  119123. /**
  119124. * Returns a promise that resolves after the given amount of time.
  119125. * @param delay Number of milliseconds to delay
  119126. * @returns Promise that resolves after the given amount of time
  119127. */
  119128. static DelayAsync(delay: number): Promise<void>;
  119129. /**
  119130. * Utility function to detect if the current user agent is Safari
  119131. * @returns whether or not the current user agent is safari
  119132. */
  119133. static IsSafari(): boolean;
  119134. }
  119135. /**
  119136. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  119137. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  119138. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  119139. * @param name The name of the class, case should be preserved
  119140. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  119141. */
  119142. export function className(name: string, module?: string): (target: Object) => void;
  119143. /**
  119144. * An implementation of a loop for asynchronous functions.
  119145. */
  119146. export class AsyncLoop {
  119147. /**
  119148. * Defines the number of iterations for the loop
  119149. */
  119150. iterations: number;
  119151. /**
  119152. * Defines the current index of the loop.
  119153. */
  119154. index: number;
  119155. private _done;
  119156. private _fn;
  119157. private _successCallback;
  119158. /**
  119159. * Constructor.
  119160. * @param iterations the number of iterations.
  119161. * @param func the function to run each iteration
  119162. * @param successCallback the callback that will be called upon succesful execution
  119163. * @param offset starting offset.
  119164. */
  119165. constructor(
  119166. /**
  119167. * Defines the number of iterations for the loop
  119168. */
  119169. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  119170. /**
  119171. * Execute the next iteration. Must be called after the last iteration was finished.
  119172. */
  119173. executeNext(): void;
  119174. /**
  119175. * Break the loop and run the success callback.
  119176. */
  119177. breakLoop(): void;
  119178. /**
  119179. * Create and run an async loop.
  119180. * @param iterations the number of iterations.
  119181. * @param fn the function to run each iteration
  119182. * @param successCallback the callback that will be called upon succesful execution
  119183. * @param offset starting offset.
  119184. * @returns the created async loop object
  119185. */
  119186. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  119187. /**
  119188. * A for-loop that will run a given number of iterations synchronous and the rest async.
  119189. * @param iterations total number of iterations
  119190. * @param syncedIterations number of synchronous iterations in each async iteration.
  119191. * @param fn the function to call each iteration.
  119192. * @param callback a success call back that will be called when iterating stops.
  119193. * @param breakFunction a break condition (optional)
  119194. * @param timeout timeout settings for the setTimeout function. default - 0.
  119195. * @returns the created async loop object
  119196. */
  119197. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  119198. }
  119199. }
  119200. declare module BABYLON {
  119201. /**
  119202. * This class implement a typical dictionary using a string as key and the generic type T as value.
  119203. * The underlying implementation relies on an associative array to ensure the best performances.
  119204. * The value can be anything including 'null' but except 'undefined'
  119205. */
  119206. export class StringDictionary<T> {
  119207. /**
  119208. * This will clear this dictionary and copy the content from the 'source' one.
  119209. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  119210. * @param source the dictionary to take the content from and copy to this dictionary
  119211. */
  119212. copyFrom(source: StringDictionary<T>): void;
  119213. /**
  119214. * Get a value based from its key
  119215. * @param key the given key to get the matching value from
  119216. * @return the value if found, otherwise undefined is returned
  119217. */
  119218. get(key: string): T | undefined;
  119219. /**
  119220. * Get a value from its key or add it if it doesn't exist.
  119221. * This method will ensure you that a given key/data will be present in the dictionary.
  119222. * @param key the given key to get the matching value from
  119223. * @param factory the factory that will create the value if the key is not present in the dictionary.
  119224. * The factory will only be invoked if there's no data for the given key.
  119225. * @return the value corresponding to the key.
  119226. */
  119227. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  119228. /**
  119229. * Get a value from its key if present in the dictionary otherwise add it
  119230. * @param key the key to get the value from
  119231. * @param val if there's no such key/value pair in the dictionary add it with this value
  119232. * @return the value corresponding to the key
  119233. */
  119234. getOrAdd(key: string, val: T): T;
  119235. /**
  119236. * Check if there's a given key in the dictionary
  119237. * @param key the key to check for
  119238. * @return true if the key is present, false otherwise
  119239. */
  119240. contains(key: string): boolean;
  119241. /**
  119242. * Add a new key and its corresponding value
  119243. * @param key the key to add
  119244. * @param value the value corresponding to the key
  119245. * @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
  119246. */
  119247. add(key: string, value: T): boolean;
  119248. /**
  119249. * Update a specific value associated to a key
  119250. * @param key defines the key to use
  119251. * @param value defines the value to store
  119252. * @returns true if the value was updated (or false if the key was not found)
  119253. */
  119254. set(key: string, value: T): boolean;
  119255. /**
  119256. * Get the element of the given key and remove it from the dictionary
  119257. * @param key defines the key to search
  119258. * @returns the value associated with the key or null if not found
  119259. */
  119260. getAndRemove(key: string): Nullable<T>;
  119261. /**
  119262. * Remove a key/value from the dictionary.
  119263. * @param key the key to remove
  119264. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  119265. */
  119266. remove(key: string): boolean;
  119267. /**
  119268. * Clear the whole content of the dictionary
  119269. */
  119270. clear(): void;
  119271. /**
  119272. * Gets the current count
  119273. */
  119274. get count(): number;
  119275. /**
  119276. * Execute a callback on each key/val of the dictionary.
  119277. * Note that you can remove any element in this dictionary in the callback implementation
  119278. * @param callback the callback to execute on a given key/value pair
  119279. */
  119280. forEach(callback: (key: string, val: T) => void): void;
  119281. /**
  119282. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  119283. * If the callback returns null or undefined the method will iterate to the next key/value pair
  119284. * Note that you can remove any element in this dictionary in the callback implementation
  119285. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  119286. * @returns the first item
  119287. */
  119288. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  119289. private _count;
  119290. private _data;
  119291. }
  119292. }
  119293. declare module BABYLON {
  119294. /** @hidden */
  119295. export interface ICollisionCoordinator {
  119296. createCollider(): Collider;
  119297. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119298. init(scene: Scene): void;
  119299. }
  119300. /** @hidden */
  119301. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  119302. private _scene;
  119303. private _scaledPosition;
  119304. private _scaledVelocity;
  119305. private _finalPosition;
  119306. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119307. createCollider(): Collider;
  119308. init(scene: Scene): void;
  119309. private _collideWithWorld;
  119310. }
  119311. }
  119312. declare module BABYLON {
  119313. /**
  119314. * Class used to manage all inputs for the scene.
  119315. */
  119316. export class InputManager {
  119317. /** The distance in pixel that you have to move to prevent some events */
  119318. static DragMovementThreshold: number;
  119319. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  119320. static LongPressDelay: number;
  119321. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  119322. static DoubleClickDelay: number;
  119323. /** If you need to check double click without raising a single click at first click, enable this flag */
  119324. static ExclusiveDoubleClickMode: boolean;
  119325. /** 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. */
  119326. private _alreadyAttached;
  119327. private _wheelEventName;
  119328. private _onPointerMove;
  119329. private _onPointerDown;
  119330. private _onPointerUp;
  119331. private _initClickEvent;
  119332. private _initActionManager;
  119333. private _delayedSimpleClick;
  119334. private _delayedSimpleClickTimeout;
  119335. private _previousDelayedSimpleClickTimeout;
  119336. private _meshPickProceed;
  119337. private _previousButtonPressed;
  119338. private _currentPickResult;
  119339. private _previousPickResult;
  119340. private _totalPointersPressed;
  119341. private _doubleClickOccured;
  119342. private _pointerOverMesh;
  119343. private _pickedDownMesh;
  119344. private _pickedUpMesh;
  119345. private _pointerX;
  119346. private _pointerY;
  119347. private _unTranslatedPointerX;
  119348. private _unTranslatedPointerY;
  119349. private _startingPointerPosition;
  119350. private _previousStartingPointerPosition;
  119351. private _startingPointerTime;
  119352. private _previousStartingPointerTime;
  119353. private _pointerCaptures;
  119354. private _meshUnderPointerId;
  119355. private _onKeyDown;
  119356. private _onKeyUp;
  119357. private _onCanvasFocusObserver;
  119358. private _onCanvasBlurObserver;
  119359. private _scene;
  119360. /**
  119361. * Creates a new InputManager
  119362. * @param scene defines the hosting scene
  119363. */
  119364. constructor(scene: Scene);
  119365. /**
  119366. * Gets the mesh that is currently under the pointer
  119367. */
  119368. get meshUnderPointer(): Nullable<AbstractMesh>;
  119369. /**
  119370. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  119371. * @param pointerId the pointer id to use
  119372. * @returns The mesh under this pointer id or null if not found
  119373. */
  119374. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  119375. /**
  119376. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  119377. */
  119378. get unTranslatedPointer(): Vector2;
  119379. /**
  119380. * Gets or sets the current on-screen X position of the pointer
  119381. */
  119382. get pointerX(): number;
  119383. set pointerX(value: number);
  119384. /**
  119385. * Gets or sets the current on-screen Y position of the pointer
  119386. */
  119387. get pointerY(): number;
  119388. set pointerY(value: number);
  119389. private _updatePointerPosition;
  119390. private _processPointerMove;
  119391. private _setRayOnPointerInfo;
  119392. private _checkPrePointerObservable;
  119393. /**
  119394. * Use this method to simulate a pointer move on a mesh
  119395. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119396. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119397. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119398. */
  119399. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119400. /**
  119401. * Use this method to simulate a pointer down on a mesh
  119402. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119403. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119404. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119405. */
  119406. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119407. private _processPointerDown;
  119408. /** @hidden */
  119409. _isPointerSwiping(): boolean;
  119410. /**
  119411. * Use this method to simulate a pointer up on a mesh
  119412. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119413. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119414. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119415. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119416. */
  119417. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  119418. private _processPointerUp;
  119419. /**
  119420. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119421. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119422. * @returns true if the pointer was captured
  119423. */
  119424. isPointerCaptured(pointerId?: number): boolean;
  119425. /**
  119426. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119427. * @param attachUp defines if you want to attach events to pointerup
  119428. * @param attachDown defines if you want to attach events to pointerdown
  119429. * @param attachMove defines if you want to attach events to pointermove
  119430. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  119431. */
  119432. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  119433. /**
  119434. * Detaches all event handlers
  119435. */
  119436. detachControl(): void;
  119437. /**
  119438. * Force the value of meshUnderPointer
  119439. * @param mesh defines the mesh to use
  119440. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  119441. */
  119442. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  119443. /**
  119444. * Gets the mesh under the pointer
  119445. * @returns a Mesh or null if no mesh is under the pointer
  119446. */
  119447. getPointerOverMesh(): Nullable<AbstractMesh>;
  119448. }
  119449. }
  119450. declare module BABYLON {
  119451. /**
  119452. * This class defines the direct association between an animation and a target
  119453. */
  119454. export class TargetedAnimation {
  119455. /**
  119456. * Animation to perform
  119457. */
  119458. animation: Animation;
  119459. /**
  119460. * Target to animate
  119461. */
  119462. target: any;
  119463. /**
  119464. * Returns the string "TargetedAnimation"
  119465. * @returns "TargetedAnimation"
  119466. */
  119467. getClassName(): string;
  119468. /**
  119469. * Serialize the object
  119470. * @returns the JSON object representing the current entity
  119471. */
  119472. serialize(): any;
  119473. }
  119474. /**
  119475. * Use this class to create coordinated animations on multiple targets
  119476. */
  119477. export class AnimationGroup implements IDisposable {
  119478. /** The name of the animation group */
  119479. name: string;
  119480. private _scene;
  119481. private _targetedAnimations;
  119482. private _animatables;
  119483. private _from;
  119484. private _to;
  119485. private _isStarted;
  119486. private _isPaused;
  119487. private _speedRatio;
  119488. private _loopAnimation;
  119489. private _isAdditive;
  119490. /**
  119491. * Gets or sets the unique id of the node
  119492. */
  119493. uniqueId: number;
  119494. /**
  119495. * This observable will notify when one animation have ended
  119496. */
  119497. onAnimationEndObservable: Observable<TargetedAnimation>;
  119498. /**
  119499. * Observer raised when one animation loops
  119500. */
  119501. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119502. /**
  119503. * Observer raised when all animations have looped
  119504. */
  119505. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119506. /**
  119507. * This observable will notify when all animations have ended.
  119508. */
  119509. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119510. /**
  119511. * This observable will notify when all animations have paused.
  119512. */
  119513. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119514. /**
  119515. * This observable will notify when all animations are playing.
  119516. */
  119517. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119518. /**
  119519. * Gets the first frame
  119520. */
  119521. get from(): number;
  119522. /**
  119523. * Gets the last frame
  119524. */
  119525. get to(): number;
  119526. /**
  119527. * Define if the animations are started
  119528. */
  119529. get isStarted(): boolean;
  119530. /**
  119531. * Gets a value indicating that the current group is playing
  119532. */
  119533. get isPlaying(): boolean;
  119534. /**
  119535. * Gets or sets the speed ratio to use for all animations
  119536. */
  119537. get speedRatio(): number;
  119538. /**
  119539. * Gets or sets the speed ratio to use for all animations
  119540. */
  119541. set speedRatio(value: number);
  119542. /**
  119543. * Gets or sets if all animations should loop or not
  119544. */
  119545. get loopAnimation(): boolean;
  119546. set loopAnimation(value: boolean);
  119547. /**
  119548. * Gets or sets if all animations should be evaluated additively
  119549. */
  119550. get isAdditive(): boolean;
  119551. set isAdditive(value: boolean);
  119552. /**
  119553. * Gets the targeted animations for this animation group
  119554. */
  119555. get targetedAnimations(): Array<TargetedAnimation>;
  119556. /**
  119557. * returning the list of animatables controlled by this animation group.
  119558. */
  119559. get animatables(): Array<Animatable>;
  119560. /**
  119561. * Gets the list of target animations
  119562. */
  119563. get children(): TargetedAnimation[];
  119564. /**
  119565. * Instantiates a new Animation Group.
  119566. * This helps managing several animations at once.
  119567. * @see https://doc.babylonjs.com/how_to/group
  119568. * @param name Defines the name of the group
  119569. * @param scene Defines the scene the group belongs to
  119570. */
  119571. constructor(
  119572. /** The name of the animation group */
  119573. name: string, scene?: Nullable<Scene>);
  119574. /**
  119575. * Add an animation (with its target) in the group
  119576. * @param animation defines the animation we want to add
  119577. * @param target defines the target of the animation
  119578. * @returns the TargetedAnimation object
  119579. */
  119580. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119581. /**
  119582. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119583. * It can add constant keys at begin or end
  119584. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119585. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119586. * @returns the animation group
  119587. */
  119588. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119589. private _animationLoopCount;
  119590. private _animationLoopFlags;
  119591. private _processLoop;
  119592. /**
  119593. * Start all animations on given targets
  119594. * @param loop defines if animations must loop
  119595. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119596. * @param from defines the from key (optional)
  119597. * @param to defines the to key (optional)
  119598. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119599. * @returns the current animation group
  119600. */
  119601. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119602. /**
  119603. * Pause all animations
  119604. * @returns the animation group
  119605. */
  119606. pause(): AnimationGroup;
  119607. /**
  119608. * Play all animations to initial state
  119609. * This function will start() the animations if they were not started or will restart() them if they were paused
  119610. * @param loop defines if animations must loop
  119611. * @returns the animation group
  119612. */
  119613. play(loop?: boolean): AnimationGroup;
  119614. /**
  119615. * Reset all animations to initial state
  119616. * @returns the animation group
  119617. */
  119618. reset(): AnimationGroup;
  119619. /**
  119620. * Restart animations from key 0
  119621. * @returns the animation group
  119622. */
  119623. restart(): AnimationGroup;
  119624. /**
  119625. * Stop all animations
  119626. * @returns the animation group
  119627. */
  119628. stop(): AnimationGroup;
  119629. /**
  119630. * Set animation weight for all animatables
  119631. * @param weight defines the weight to use
  119632. * @return the animationGroup
  119633. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119634. */
  119635. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119636. /**
  119637. * Synchronize and normalize all animatables with a source animatable
  119638. * @param root defines the root animatable to synchronize with
  119639. * @return the animationGroup
  119640. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119641. */
  119642. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119643. /**
  119644. * Goes to a specific frame in this animation group
  119645. * @param frame the frame number to go to
  119646. * @return the animationGroup
  119647. */
  119648. goToFrame(frame: number): AnimationGroup;
  119649. /**
  119650. * Dispose all associated resources
  119651. */
  119652. dispose(): void;
  119653. private _checkAnimationGroupEnded;
  119654. /**
  119655. * Clone the current animation group and returns a copy
  119656. * @param newName defines the name of the new group
  119657. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119658. * @returns the new aniamtion group
  119659. */
  119660. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119661. /**
  119662. * Serializes the animationGroup to an object
  119663. * @returns Serialized object
  119664. */
  119665. serialize(): any;
  119666. /**
  119667. * Returns a new AnimationGroup object parsed from the source provided.
  119668. * @param parsedAnimationGroup defines the source
  119669. * @param scene defines the scene that will receive the animationGroup
  119670. * @returns a new AnimationGroup
  119671. */
  119672. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119673. /**
  119674. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119675. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119676. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119677. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119678. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119679. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119680. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119681. */
  119682. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119683. /**
  119684. * Returns the string "AnimationGroup"
  119685. * @returns "AnimationGroup"
  119686. */
  119687. getClassName(): string;
  119688. /**
  119689. * Creates a detailled string about the object
  119690. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119691. * @returns a string representing the object
  119692. */
  119693. toString(fullDetails?: boolean): string;
  119694. }
  119695. }
  119696. declare module BABYLON {
  119697. /**
  119698. * Define an interface for all classes that will hold resources
  119699. */
  119700. export interface IDisposable {
  119701. /**
  119702. * Releases all held resources
  119703. */
  119704. dispose(): void;
  119705. }
  119706. /** Interface defining initialization parameters for Scene class */
  119707. export interface SceneOptions {
  119708. /**
  119709. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  119710. * It will improve performance when the number of geometries becomes important.
  119711. */
  119712. useGeometryUniqueIdsMap?: boolean;
  119713. /**
  119714. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  119715. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119716. */
  119717. useMaterialMeshMap?: boolean;
  119718. /**
  119719. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  119720. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119721. */
  119722. useClonedMeshMap?: boolean;
  119723. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  119724. virtual?: boolean;
  119725. }
  119726. /**
  119727. * Represents a scene to be rendered by the engine.
  119728. * @see https://doc.babylonjs.com/features/scene
  119729. */
  119730. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  119731. /** The fog is deactivated */
  119732. static readonly FOGMODE_NONE: number;
  119733. /** The fog density is following an exponential function */
  119734. static readonly FOGMODE_EXP: number;
  119735. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  119736. static readonly FOGMODE_EXP2: number;
  119737. /** The fog density is following a linear function. */
  119738. static readonly FOGMODE_LINEAR: number;
  119739. /**
  119740. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119741. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119742. */
  119743. static MinDeltaTime: number;
  119744. /**
  119745. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119746. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119747. */
  119748. static MaxDeltaTime: number;
  119749. /**
  119750. * Factory used to create the default material.
  119751. * @param name The name of the material to create
  119752. * @param scene The scene to create the material for
  119753. * @returns The default material
  119754. */
  119755. static DefaultMaterialFactory(scene: Scene): Material;
  119756. /**
  119757. * Factory used to create the a collision coordinator.
  119758. * @returns The collision coordinator
  119759. */
  119760. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119761. /** @hidden */
  119762. _inputManager: InputManager;
  119763. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119764. cameraToUseForPointers: Nullable<Camera>;
  119765. /** @hidden */
  119766. readonly _isScene: boolean;
  119767. /** @hidden */
  119768. _blockEntityCollection: boolean;
  119769. /**
  119770. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119771. */
  119772. autoClear: boolean;
  119773. /**
  119774. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119775. */
  119776. autoClearDepthAndStencil: boolean;
  119777. /**
  119778. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119779. */
  119780. clearColor: Color4;
  119781. /**
  119782. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119783. */
  119784. ambientColor: Color3;
  119785. /**
  119786. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119787. * It should only be one of the following (if not the default embedded one):
  119788. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119789. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119790. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119791. * The material properties need to be setup according to the type of texture in use.
  119792. */
  119793. environmentBRDFTexture: BaseTexture;
  119794. /**
  119795. * Texture used in all pbr material as the reflection texture.
  119796. * As in the majority of the scene they are the same (exception for multi room and so on),
  119797. * this is easier to reference from here than from all the materials.
  119798. */
  119799. get environmentTexture(): Nullable<BaseTexture>;
  119800. /**
  119801. * Texture used in all pbr material as the reflection texture.
  119802. * As in the majority of the scene they are the same (exception for multi room and so on),
  119803. * this is easier to set here than in all the materials.
  119804. */
  119805. set environmentTexture(value: Nullable<BaseTexture>);
  119806. /** @hidden */
  119807. protected _environmentIntensity: number;
  119808. /**
  119809. * Intensity of the environment in all pbr material.
  119810. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119811. * As in the majority of the scene they are the same (exception for multi room and so on),
  119812. * this is easier to reference from here than from all the materials.
  119813. */
  119814. get environmentIntensity(): number;
  119815. /**
  119816. * Intensity of the environment in all pbr material.
  119817. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119818. * As in the majority of the scene they are the same (exception for multi room and so on),
  119819. * this is easier to set here than in all the materials.
  119820. */
  119821. set environmentIntensity(value: number);
  119822. /** @hidden */
  119823. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119824. /**
  119825. * Default image processing configuration used either in the rendering
  119826. * Forward main pass or through the imageProcessingPostProcess if present.
  119827. * As in the majority of the scene they are the same (exception for multi camera),
  119828. * this is easier to reference from here than from all the materials and post process.
  119829. *
  119830. * No setter as we it is a shared configuration, you can set the values instead.
  119831. */
  119832. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119833. private _forceWireframe;
  119834. /**
  119835. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119836. */
  119837. set forceWireframe(value: boolean);
  119838. get forceWireframe(): boolean;
  119839. private _skipFrustumClipping;
  119840. /**
  119841. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119842. */
  119843. set skipFrustumClipping(value: boolean);
  119844. get skipFrustumClipping(): boolean;
  119845. private _forcePointsCloud;
  119846. /**
  119847. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119848. */
  119849. set forcePointsCloud(value: boolean);
  119850. get forcePointsCloud(): boolean;
  119851. /**
  119852. * Gets or sets the active clipplane 1
  119853. */
  119854. clipPlane: Nullable<Plane>;
  119855. /**
  119856. * Gets or sets the active clipplane 2
  119857. */
  119858. clipPlane2: Nullable<Plane>;
  119859. /**
  119860. * Gets or sets the active clipplane 3
  119861. */
  119862. clipPlane3: Nullable<Plane>;
  119863. /**
  119864. * Gets or sets the active clipplane 4
  119865. */
  119866. clipPlane4: Nullable<Plane>;
  119867. /**
  119868. * Gets or sets the active clipplane 5
  119869. */
  119870. clipPlane5: Nullable<Plane>;
  119871. /**
  119872. * Gets or sets the active clipplane 6
  119873. */
  119874. clipPlane6: Nullable<Plane>;
  119875. /**
  119876. * Gets or sets a boolean indicating if animations are enabled
  119877. */
  119878. animationsEnabled: boolean;
  119879. private _animationPropertiesOverride;
  119880. /**
  119881. * Gets or sets the animation properties override
  119882. */
  119883. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119884. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119885. /**
  119886. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119887. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119888. */
  119889. useConstantAnimationDeltaTime: boolean;
  119890. /**
  119891. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119892. * Please note that it requires to run a ray cast through the scene on every frame
  119893. */
  119894. constantlyUpdateMeshUnderPointer: boolean;
  119895. /**
  119896. * Defines the HTML cursor to use when hovering over interactive elements
  119897. */
  119898. hoverCursor: string;
  119899. /**
  119900. * Defines the HTML default cursor to use (empty by default)
  119901. */
  119902. defaultCursor: string;
  119903. /**
  119904. * Defines whether cursors are handled by the scene.
  119905. */
  119906. doNotHandleCursors: boolean;
  119907. /**
  119908. * This is used to call preventDefault() on pointer down
  119909. * in order to block unwanted artifacts like system double clicks
  119910. */
  119911. preventDefaultOnPointerDown: boolean;
  119912. /**
  119913. * This is used to call preventDefault() on pointer up
  119914. * in order to block unwanted artifacts like system double clicks
  119915. */
  119916. preventDefaultOnPointerUp: boolean;
  119917. /**
  119918. * Gets or sets user defined metadata
  119919. */
  119920. metadata: any;
  119921. /**
  119922. * For internal use only. Please do not use.
  119923. */
  119924. reservedDataStore: any;
  119925. /**
  119926. * Gets the name of the plugin used to load this scene (null by default)
  119927. */
  119928. loadingPluginName: string;
  119929. /**
  119930. * Use this array to add regular expressions used to disable offline support for specific urls
  119931. */
  119932. disableOfflineSupportExceptionRules: RegExp[];
  119933. /**
  119934. * An event triggered when the scene is disposed.
  119935. */
  119936. onDisposeObservable: Observable<Scene>;
  119937. private _onDisposeObserver;
  119938. /** Sets a function to be executed when this scene is disposed. */
  119939. set onDispose(callback: () => void);
  119940. /**
  119941. * An event triggered before rendering the scene (right after animations and physics)
  119942. */
  119943. onBeforeRenderObservable: Observable<Scene>;
  119944. private _onBeforeRenderObserver;
  119945. /** Sets a function to be executed before rendering this scene */
  119946. set beforeRender(callback: Nullable<() => void>);
  119947. /**
  119948. * An event triggered after rendering the scene
  119949. */
  119950. onAfterRenderObservable: Observable<Scene>;
  119951. /**
  119952. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119953. */
  119954. onAfterRenderCameraObservable: Observable<Camera>;
  119955. private _onAfterRenderObserver;
  119956. /** Sets a function to be executed after rendering this scene */
  119957. set afterRender(callback: Nullable<() => void>);
  119958. /**
  119959. * An event triggered before animating the scene
  119960. */
  119961. onBeforeAnimationsObservable: Observable<Scene>;
  119962. /**
  119963. * An event triggered after animations processing
  119964. */
  119965. onAfterAnimationsObservable: Observable<Scene>;
  119966. /**
  119967. * An event triggered before draw calls are ready to be sent
  119968. */
  119969. onBeforeDrawPhaseObservable: Observable<Scene>;
  119970. /**
  119971. * An event triggered after draw calls have been sent
  119972. */
  119973. onAfterDrawPhaseObservable: Observable<Scene>;
  119974. /**
  119975. * An event triggered when the scene is ready
  119976. */
  119977. onReadyObservable: Observable<Scene>;
  119978. /**
  119979. * An event triggered before rendering a camera
  119980. */
  119981. onBeforeCameraRenderObservable: Observable<Camera>;
  119982. private _onBeforeCameraRenderObserver;
  119983. /** Sets a function to be executed before rendering a camera*/
  119984. set beforeCameraRender(callback: () => void);
  119985. /**
  119986. * An event triggered after rendering a camera
  119987. */
  119988. onAfterCameraRenderObservable: Observable<Camera>;
  119989. private _onAfterCameraRenderObserver;
  119990. /** Sets a function to be executed after rendering a camera*/
  119991. set afterCameraRender(callback: () => void);
  119992. /**
  119993. * An event triggered when active meshes evaluation is about to start
  119994. */
  119995. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119996. /**
  119997. * An event triggered when active meshes evaluation is done
  119998. */
  119999. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  120000. /**
  120001. * An event triggered when particles rendering is about to start
  120002. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  120003. */
  120004. onBeforeParticlesRenderingObservable: Observable<Scene>;
  120005. /**
  120006. * An event triggered when particles rendering is done
  120007. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  120008. */
  120009. onAfterParticlesRenderingObservable: Observable<Scene>;
  120010. /**
  120011. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  120012. */
  120013. onDataLoadedObservable: Observable<Scene>;
  120014. /**
  120015. * An event triggered when a camera is created
  120016. */
  120017. onNewCameraAddedObservable: Observable<Camera>;
  120018. /**
  120019. * An event triggered when a camera is removed
  120020. */
  120021. onCameraRemovedObservable: Observable<Camera>;
  120022. /**
  120023. * An event triggered when a light is created
  120024. */
  120025. onNewLightAddedObservable: Observable<Light>;
  120026. /**
  120027. * An event triggered when a light is removed
  120028. */
  120029. onLightRemovedObservable: Observable<Light>;
  120030. /**
  120031. * An event triggered when a geometry is created
  120032. */
  120033. onNewGeometryAddedObservable: Observable<Geometry>;
  120034. /**
  120035. * An event triggered when a geometry is removed
  120036. */
  120037. onGeometryRemovedObservable: Observable<Geometry>;
  120038. /**
  120039. * An event triggered when a transform node is created
  120040. */
  120041. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  120042. /**
  120043. * An event triggered when a transform node is removed
  120044. */
  120045. onTransformNodeRemovedObservable: Observable<TransformNode>;
  120046. /**
  120047. * An event triggered when a mesh is created
  120048. */
  120049. onNewMeshAddedObservable: Observable<AbstractMesh>;
  120050. /**
  120051. * An event triggered when a mesh is removed
  120052. */
  120053. onMeshRemovedObservable: Observable<AbstractMesh>;
  120054. /**
  120055. * An event triggered when a skeleton is created
  120056. */
  120057. onNewSkeletonAddedObservable: Observable<Skeleton>;
  120058. /**
  120059. * An event triggered when a skeleton is removed
  120060. */
  120061. onSkeletonRemovedObservable: Observable<Skeleton>;
  120062. /**
  120063. * An event triggered when a material is created
  120064. */
  120065. onNewMaterialAddedObservable: Observable<Material>;
  120066. /**
  120067. * An event triggered when a material is removed
  120068. */
  120069. onMaterialRemovedObservable: Observable<Material>;
  120070. /**
  120071. * An event triggered when a texture is created
  120072. */
  120073. onNewTextureAddedObservable: Observable<BaseTexture>;
  120074. /**
  120075. * An event triggered when a texture is removed
  120076. */
  120077. onTextureRemovedObservable: Observable<BaseTexture>;
  120078. /**
  120079. * An event triggered when render targets are about to be rendered
  120080. * Can happen multiple times per frame.
  120081. */
  120082. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  120083. /**
  120084. * An event triggered when render targets were rendered.
  120085. * Can happen multiple times per frame.
  120086. */
  120087. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  120088. /**
  120089. * An event triggered before calculating deterministic simulation step
  120090. */
  120091. onBeforeStepObservable: Observable<Scene>;
  120092. /**
  120093. * An event triggered after calculating deterministic simulation step
  120094. */
  120095. onAfterStepObservable: Observable<Scene>;
  120096. /**
  120097. * An event triggered when the activeCamera property is updated
  120098. */
  120099. onActiveCameraChanged: Observable<Scene>;
  120100. /**
  120101. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  120102. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120103. * 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)
  120104. */
  120105. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120106. /**
  120107. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  120108. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120109. * 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)
  120110. */
  120111. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120112. /**
  120113. * This Observable will when a mesh has been imported into the scene.
  120114. */
  120115. onMeshImportedObservable: Observable<AbstractMesh>;
  120116. /**
  120117. * This Observable will when an animation file has been imported into the scene.
  120118. */
  120119. onAnimationFileImportedObservable: Observable<Scene>;
  120120. /**
  120121. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  120122. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  120123. */
  120124. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  120125. /** @hidden */
  120126. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  120127. /**
  120128. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  120129. */
  120130. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  120131. /**
  120132. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  120133. */
  120134. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  120135. /**
  120136. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  120137. */
  120138. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  120139. /** Callback called when a pointer move is detected */
  120140. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120141. /** Callback called when a pointer down is detected */
  120142. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120143. /** Callback called when a pointer up is detected */
  120144. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  120145. /** Callback called when a pointer pick is detected */
  120146. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  120147. /**
  120148. * 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).
  120149. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  120150. */
  120151. onPrePointerObservable: Observable<PointerInfoPre>;
  120152. /**
  120153. * Observable event triggered each time an input event is received from the rendering canvas
  120154. */
  120155. onPointerObservable: Observable<PointerInfo>;
  120156. /**
  120157. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  120158. */
  120159. get unTranslatedPointer(): Vector2;
  120160. /**
  120161. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  120162. */
  120163. static get DragMovementThreshold(): number;
  120164. static set DragMovementThreshold(value: number);
  120165. /**
  120166. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  120167. */
  120168. static get LongPressDelay(): number;
  120169. static set LongPressDelay(value: number);
  120170. /**
  120171. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  120172. */
  120173. static get DoubleClickDelay(): number;
  120174. static set DoubleClickDelay(value: number);
  120175. /** If you need to check double click without raising a single click at first click, enable this flag */
  120176. static get ExclusiveDoubleClickMode(): boolean;
  120177. static set ExclusiveDoubleClickMode(value: boolean);
  120178. /** @hidden */
  120179. _mirroredCameraPosition: Nullable<Vector3>;
  120180. /**
  120181. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  120182. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  120183. */
  120184. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  120185. /**
  120186. * Observable event triggered each time an keyboard event is received from the hosting window
  120187. */
  120188. onKeyboardObservable: Observable<KeyboardInfo>;
  120189. private _useRightHandedSystem;
  120190. /**
  120191. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  120192. */
  120193. set useRightHandedSystem(value: boolean);
  120194. get useRightHandedSystem(): boolean;
  120195. private _timeAccumulator;
  120196. private _currentStepId;
  120197. private _currentInternalStep;
  120198. /**
  120199. * Sets the step Id used by deterministic lock step
  120200. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120201. * @param newStepId defines the step Id
  120202. */
  120203. setStepId(newStepId: number): void;
  120204. /**
  120205. * Gets the step Id used by deterministic lock step
  120206. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120207. * @returns the step Id
  120208. */
  120209. getStepId(): number;
  120210. /**
  120211. * Gets the internal step used by deterministic lock step
  120212. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120213. * @returns the internal step
  120214. */
  120215. getInternalStep(): number;
  120216. private _fogEnabled;
  120217. /**
  120218. * Gets or sets a boolean indicating if fog is enabled on this scene
  120219. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120220. * (Default is true)
  120221. */
  120222. set fogEnabled(value: boolean);
  120223. get fogEnabled(): boolean;
  120224. private _fogMode;
  120225. /**
  120226. * Gets or sets the fog mode to use
  120227. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120228. * | mode | value |
  120229. * | --- | --- |
  120230. * | FOGMODE_NONE | 0 |
  120231. * | FOGMODE_EXP | 1 |
  120232. * | FOGMODE_EXP2 | 2 |
  120233. * | FOGMODE_LINEAR | 3 |
  120234. */
  120235. set fogMode(value: number);
  120236. get fogMode(): number;
  120237. /**
  120238. * Gets or sets the fog color to use
  120239. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120240. * (Default is Color3(0.2, 0.2, 0.3))
  120241. */
  120242. fogColor: Color3;
  120243. /**
  120244. * Gets or sets the fog density to use
  120245. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120246. * (Default is 0.1)
  120247. */
  120248. fogDensity: number;
  120249. /**
  120250. * Gets or sets the fog start distance to use
  120251. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120252. * (Default is 0)
  120253. */
  120254. fogStart: number;
  120255. /**
  120256. * Gets or sets the fog end distance to use
  120257. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120258. * (Default is 1000)
  120259. */
  120260. fogEnd: number;
  120261. /**
  120262. * Flag indicating that the frame buffer binding is handled by another component
  120263. */
  120264. prePass: boolean;
  120265. private _shadowsEnabled;
  120266. /**
  120267. * Gets or sets a boolean indicating if shadows are enabled on this scene
  120268. */
  120269. set shadowsEnabled(value: boolean);
  120270. get shadowsEnabled(): boolean;
  120271. private _lightsEnabled;
  120272. /**
  120273. * Gets or sets a boolean indicating if lights are enabled on this scene
  120274. */
  120275. set lightsEnabled(value: boolean);
  120276. get lightsEnabled(): boolean;
  120277. /** All of the active cameras added to this scene. */
  120278. activeCameras: Camera[];
  120279. /** @hidden */
  120280. _activeCamera: Nullable<Camera>;
  120281. /** Gets or sets the current active camera */
  120282. get activeCamera(): Nullable<Camera>;
  120283. set activeCamera(value: Nullable<Camera>);
  120284. private _defaultMaterial;
  120285. /** The default material used on meshes when no material is affected */
  120286. get defaultMaterial(): Material;
  120287. /** The default material used on meshes when no material is affected */
  120288. set defaultMaterial(value: Material);
  120289. private _texturesEnabled;
  120290. /**
  120291. * Gets or sets a boolean indicating if textures are enabled on this scene
  120292. */
  120293. set texturesEnabled(value: boolean);
  120294. get texturesEnabled(): boolean;
  120295. /**
  120296. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  120297. */
  120298. physicsEnabled: boolean;
  120299. /**
  120300. * Gets or sets a boolean indicating if particles are enabled on this scene
  120301. */
  120302. particlesEnabled: boolean;
  120303. /**
  120304. * Gets or sets a boolean indicating if sprites are enabled on this scene
  120305. */
  120306. spritesEnabled: boolean;
  120307. private _skeletonsEnabled;
  120308. /**
  120309. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  120310. */
  120311. set skeletonsEnabled(value: boolean);
  120312. get skeletonsEnabled(): boolean;
  120313. /**
  120314. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  120315. */
  120316. lensFlaresEnabled: boolean;
  120317. /**
  120318. * Gets or sets a boolean indicating if collisions are enabled on this scene
  120319. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120320. */
  120321. collisionsEnabled: boolean;
  120322. private _collisionCoordinator;
  120323. /** @hidden */
  120324. get collisionCoordinator(): ICollisionCoordinator;
  120325. /**
  120326. * Defines the gravity applied to this scene (used only for collisions)
  120327. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120328. */
  120329. gravity: Vector3;
  120330. /**
  120331. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  120332. */
  120333. postProcessesEnabled: boolean;
  120334. /**
  120335. * Gets the current postprocess manager
  120336. */
  120337. postProcessManager: PostProcessManager;
  120338. /**
  120339. * Gets or sets a boolean indicating if render targets are enabled on this scene
  120340. */
  120341. renderTargetsEnabled: boolean;
  120342. /**
  120343. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  120344. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  120345. */
  120346. dumpNextRenderTargets: boolean;
  120347. /**
  120348. * The list of user defined render targets added to the scene
  120349. */
  120350. customRenderTargets: RenderTargetTexture[];
  120351. /**
  120352. * Defines if texture loading must be delayed
  120353. * If true, textures will only be loaded when they need to be rendered
  120354. */
  120355. useDelayedTextureLoading: boolean;
  120356. /**
  120357. * Gets the list of meshes imported to the scene through SceneLoader
  120358. */
  120359. importedMeshesFiles: String[];
  120360. /**
  120361. * Gets or sets a boolean indicating if probes are enabled on this scene
  120362. */
  120363. probesEnabled: boolean;
  120364. /**
  120365. * Gets or sets the current offline provider to use to store scene data
  120366. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120367. */
  120368. offlineProvider: IOfflineProvider;
  120369. /**
  120370. * Gets or sets the action manager associated with the scene
  120371. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120372. */
  120373. actionManager: AbstractActionManager;
  120374. private _meshesForIntersections;
  120375. /**
  120376. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  120377. */
  120378. proceduralTexturesEnabled: boolean;
  120379. private _engine;
  120380. private _totalVertices;
  120381. /** @hidden */
  120382. _activeIndices: PerfCounter;
  120383. /** @hidden */
  120384. _activeParticles: PerfCounter;
  120385. /** @hidden */
  120386. _activeBones: PerfCounter;
  120387. private _animationRatio;
  120388. /** @hidden */
  120389. _animationTimeLast: number;
  120390. /** @hidden */
  120391. _animationTime: number;
  120392. /**
  120393. * Gets or sets a general scale for animation speed
  120394. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  120395. */
  120396. animationTimeScale: number;
  120397. /** @hidden */
  120398. _cachedMaterial: Nullable<Material>;
  120399. /** @hidden */
  120400. _cachedEffect: Nullable<Effect>;
  120401. /** @hidden */
  120402. _cachedVisibility: Nullable<number>;
  120403. private _renderId;
  120404. private _frameId;
  120405. private _executeWhenReadyTimeoutId;
  120406. private _intermediateRendering;
  120407. private _viewUpdateFlag;
  120408. private _projectionUpdateFlag;
  120409. /** @hidden */
  120410. _toBeDisposed: Nullable<IDisposable>[];
  120411. private _activeRequests;
  120412. /** @hidden */
  120413. _pendingData: any[];
  120414. private _isDisposed;
  120415. /**
  120416. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  120417. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  120418. */
  120419. dispatchAllSubMeshesOfActiveMeshes: boolean;
  120420. private _activeMeshes;
  120421. private _processedMaterials;
  120422. private _renderTargets;
  120423. /** @hidden */
  120424. _activeParticleSystems: SmartArray<IParticleSystem>;
  120425. private _activeSkeletons;
  120426. private _softwareSkinnedMeshes;
  120427. private _renderingManager;
  120428. /** @hidden */
  120429. _activeAnimatables: Animatable[];
  120430. private _transformMatrix;
  120431. private _sceneUbo;
  120432. /** @hidden */
  120433. _viewMatrix: Matrix;
  120434. private _projectionMatrix;
  120435. /** @hidden */
  120436. _forcedViewPosition: Nullable<Vector3>;
  120437. /** @hidden */
  120438. _frustumPlanes: Plane[];
  120439. /**
  120440. * Gets the list of frustum planes (built from the active camera)
  120441. */
  120442. get frustumPlanes(): Plane[];
  120443. /**
  120444. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  120445. * This is useful if there are more lights that the maximum simulteanous authorized
  120446. */
  120447. requireLightSorting: boolean;
  120448. /** @hidden */
  120449. readonly useMaterialMeshMap: boolean;
  120450. /** @hidden */
  120451. readonly useClonedMeshMap: boolean;
  120452. private _externalData;
  120453. private _uid;
  120454. /**
  120455. * @hidden
  120456. * Backing store of defined scene components.
  120457. */
  120458. _components: ISceneComponent[];
  120459. /**
  120460. * @hidden
  120461. * Backing store of defined scene components.
  120462. */
  120463. _serializableComponents: ISceneSerializableComponent[];
  120464. /**
  120465. * List of components to register on the next registration step.
  120466. */
  120467. private _transientComponents;
  120468. /**
  120469. * Registers the transient components if needed.
  120470. */
  120471. private _registerTransientComponents;
  120472. /**
  120473. * @hidden
  120474. * Add a component to the scene.
  120475. * Note that the ccomponent could be registered on th next frame if this is called after
  120476. * the register component stage.
  120477. * @param component Defines the component to add to the scene
  120478. */
  120479. _addComponent(component: ISceneComponent): void;
  120480. /**
  120481. * @hidden
  120482. * Gets a component from the scene.
  120483. * @param name defines the name of the component to retrieve
  120484. * @returns the component or null if not present
  120485. */
  120486. _getComponent(name: string): Nullable<ISceneComponent>;
  120487. /**
  120488. * @hidden
  120489. * Defines the actions happening before camera updates.
  120490. */
  120491. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120492. /**
  120493. * @hidden
  120494. * Defines the actions happening before clear the canvas.
  120495. */
  120496. _beforeClearStage: Stage<SimpleStageAction>;
  120497. /**
  120498. * @hidden
  120499. * Defines the actions when collecting render targets for the frame.
  120500. */
  120501. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120502. /**
  120503. * @hidden
  120504. * Defines the actions happening for one camera in the frame.
  120505. */
  120506. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120507. /**
  120508. * @hidden
  120509. * Defines the actions happening during the per mesh ready checks.
  120510. */
  120511. _isReadyForMeshStage: Stage<MeshStageAction>;
  120512. /**
  120513. * @hidden
  120514. * Defines the actions happening before evaluate active mesh checks.
  120515. */
  120516. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120517. /**
  120518. * @hidden
  120519. * Defines the actions happening during the evaluate sub mesh checks.
  120520. */
  120521. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120522. /**
  120523. * @hidden
  120524. * Defines the actions happening during the active mesh stage.
  120525. */
  120526. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120527. /**
  120528. * @hidden
  120529. * Defines the actions happening during the per camera render target step.
  120530. */
  120531. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120532. /**
  120533. * @hidden
  120534. * Defines the actions happening just before the active camera is drawing.
  120535. */
  120536. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120537. /**
  120538. * @hidden
  120539. * Defines the actions happening just before a render target is drawing.
  120540. */
  120541. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120542. /**
  120543. * @hidden
  120544. * Defines the actions happening just before a rendering group is drawing.
  120545. */
  120546. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120547. /**
  120548. * @hidden
  120549. * Defines the actions happening just before a mesh is drawing.
  120550. */
  120551. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120552. /**
  120553. * @hidden
  120554. * Defines the actions happening just after a mesh has been drawn.
  120555. */
  120556. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120557. /**
  120558. * @hidden
  120559. * Defines the actions happening just after a rendering group has been drawn.
  120560. */
  120561. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120562. /**
  120563. * @hidden
  120564. * Defines the actions happening just after the active camera has been drawn.
  120565. */
  120566. _afterCameraDrawStage: Stage<CameraStageAction>;
  120567. /**
  120568. * @hidden
  120569. * Defines the actions happening just after a render target has been drawn.
  120570. */
  120571. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120572. /**
  120573. * @hidden
  120574. * Defines the actions happening just after rendering all cameras and computing intersections.
  120575. */
  120576. _afterRenderStage: Stage<SimpleStageAction>;
  120577. /**
  120578. * @hidden
  120579. * Defines the actions happening when a pointer move event happens.
  120580. */
  120581. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120582. /**
  120583. * @hidden
  120584. * Defines the actions happening when a pointer down event happens.
  120585. */
  120586. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120587. /**
  120588. * @hidden
  120589. * Defines the actions happening when a pointer up event happens.
  120590. */
  120591. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120592. /**
  120593. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120594. */
  120595. private geometriesByUniqueId;
  120596. /**
  120597. * Creates a new Scene
  120598. * @param engine defines the engine to use to render this scene
  120599. * @param options defines the scene options
  120600. */
  120601. constructor(engine: Engine, options?: SceneOptions);
  120602. /**
  120603. * Gets a string identifying the name of the class
  120604. * @returns "Scene" string
  120605. */
  120606. getClassName(): string;
  120607. private _defaultMeshCandidates;
  120608. /**
  120609. * @hidden
  120610. */
  120611. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120612. private _defaultSubMeshCandidates;
  120613. /**
  120614. * @hidden
  120615. */
  120616. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120617. /**
  120618. * Sets the default candidate providers for the scene.
  120619. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120620. * and getCollidingSubMeshCandidates to their default function
  120621. */
  120622. setDefaultCandidateProviders(): void;
  120623. /**
  120624. * Gets the mesh that is currently under the pointer
  120625. */
  120626. get meshUnderPointer(): Nullable<AbstractMesh>;
  120627. /**
  120628. * Gets or sets the current on-screen X position of the pointer
  120629. */
  120630. get pointerX(): number;
  120631. set pointerX(value: number);
  120632. /**
  120633. * Gets or sets the current on-screen Y position of the pointer
  120634. */
  120635. get pointerY(): number;
  120636. set pointerY(value: number);
  120637. /**
  120638. * Gets the cached material (ie. the latest rendered one)
  120639. * @returns the cached material
  120640. */
  120641. getCachedMaterial(): Nullable<Material>;
  120642. /**
  120643. * Gets the cached effect (ie. the latest rendered one)
  120644. * @returns the cached effect
  120645. */
  120646. getCachedEffect(): Nullable<Effect>;
  120647. /**
  120648. * Gets the cached visibility state (ie. the latest rendered one)
  120649. * @returns the cached visibility state
  120650. */
  120651. getCachedVisibility(): Nullable<number>;
  120652. /**
  120653. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120654. * @param material defines the current material
  120655. * @param effect defines the current effect
  120656. * @param visibility defines the current visibility state
  120657. * @returns true if one parameter is not cached
  120658. */
  120659. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120660. /**
  120661. * Gets the engine associated with the scene
  120662. * @returns an Engine
  120663. */
  120664. getEngine(): Engine;
  120665. /**
  120666. * Gets the total number of vertices rendered per frame
  120667. * @returns the total number of vertices rendered per frame
  120668. */
  120669. getTotalVertices(): number;
  120670. /**
  120671. * Gets the performance counter for total vertices
  120672. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120673. */
  120674. get totalVerticesPerfCounter(): PerfCounter;
  120675. /**
  120676. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120677. * @returns the total number of active indices rendered per frame
  120678. */
  120679. getActiveIndices(): number;
  120680. /**
  120681. * Gets the performance counter for active indices
  120682. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120683. */
  120684. get totalActiveIndicesPerfCounter(): PerfCounter;
  120685. /**
  120686. * Gets the total number of active particles rendered per frame
  120687. * @returns the total number of active particles rendered per frame
  120688. */
  120689. getActiveParticles(): number;
  120690. /**
  120691. * Gets the performance counter for active particles
  120692. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120693. */
  120694. get activeParticlesPerfCounter(): PerfCounter;
  120695. /**
  120696. * Gets the total number of active bones rendered per frame
  120697. * @returns the total number of active bones rendered per frame
  120698. */
  120699. getActiveBones(): number;
  120700. /**
  120701. * Gets the performance counter for active bones
  120702. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120703. */
  120704. get activeBonesPerfCounter(): PerfCounter;
  120705. /**
  120706. * Gets the array of active meshes
  120707. * @returns an array of AbstractMesh
  120708. */
  120709. getActiveMeshes(): SmartArray<AbstractMesh>;
  120710. /**
  120711. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  120712. * @returns a number
  120713. */
  120714. getAnimationRatio(): number;
  120715. /**
  120716. * Gets an unique Id for the current render phase
  120717. * @returns a number
  120718. */
  120719. getRenderId(): number;
  120720. /**
  120721. * Gets an unique Id for the current frame
  120722. * @returns a number
  120723. */
  120724. getFrameId(): number;
  120725. /** Call this function if you want to manually increment the render Id*/
  120726. incrementRenderId(): void;
  120727. private _createUbo;
  120728. /**
  120729. * Use this method to simulate a pointer move on a mesh
  120730. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120731. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120732. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120733. * @returns the current scene
  120734. */
  120735. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120736. /**
  120737. * Use this method to simulate a pointer down on a mesh
  120738. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120739. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120740. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120741. * @returns the current scene
  120742. */
  120743. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120744. /**
  120745. * Use this method to simulate a pointer up on a mesh
  120746. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120747. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120748. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120749. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120750. * @returns the current scene
  120751. */
  120752. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120753. /**
  120754. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120755. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120756. * @returns true if the pointer was captured
  120757. */
  120758. isPointerCaptured(pointerId?: number): boolean;
  120759. /**
  120760. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120761. * @param attachUp defines if you want to attach events to pointerup
  120762. * @param attachDown defines if you want to attach events to pointerdown
  120763. * @param attachMove defines if you want to attach events to pointermove
  120764. */
  120765. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120766. /** Detaches all event handlers*/
  120767. detachControl(): void;
  120768. /**
  120769. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120770. * Delay loaded resources are not taking in account
  120771. * @return true if all required resources are ready
  120772. */
  120773. isReady(): boolean;
  120774. /** Resets all cached information relative to material (including effect and visibility) */
  120775. resetCachedMaterial(): void;
  120776. /**
  120777. * Registers a function to be called before every frame render
  120778. * @param func defines the function to register
  120779. */
  120780. registerBeforeRender(func: () => void): void;
  120781. /**
  120782. * Unregisters a function called before every frame render
  120783. * @param func defines the function to unregister
  120784. */
  120785. unregisterBeforeRender(func: () => void): void;
  120786. /**
  120787. * Registers a function to be called after every frame render
  120788. * @param func defines the function to register
  120789. */
  120790. registerAfterRender(func: () => void): void;
  120791. /**
  120792. * Unregisters a function called after every frame render
  120793. * @param func defines the function to unregister
  120794. */
  120795. unregisterAfterRender(func: () => void): void;
  120796. private _executeOnceBeforeRender;
  120797. /**
  120798. * The provided function will run before render once and will be disposed afterwards.
  120799. * A timeout delay can be provided so that the function will be executed in N ms.
  120800. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120801. * @param func The function to be executed.
  120802. * @param timeout optional delay in ms
  120803. */
  120804. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120805. /** @hidden */
  120806. _addPendingData(data: any): void;
  120807. /** @hidden */
  120808. _removePendingData(data: any): void;
  120809. /**
  120810. * Returns the number of items waiting to be loaded
  120811. * @returns the number of items waiting to be loaded
  120812. */
  120813. getWaitingItemsCount(): number;
  120814. /**
  120815. * Returns a boolean indicating if the scene is still loading data
  120816. */
  120817. get isLoading(): boolean;
  120818. /**
  120819. * Registers a function to be executed when the scene is ready
  120820. * @param {Function} func - the function to be executed
  120821. */
  120822. executeWhenReady(func: () => void): void;
  120823. /**
  120824. * Returns a promise that resolves when the scene is ready
  120825. * @returns A promise that resolves when the scene is ready
  120826. */
  120827. whenReadyAsync(): Promise<void>;
  120828. /** @hidden */
  120829. _checkIsReady(): void;
  120830. /**
  120831. * Gets all animatable attached to the scene
  120832. */
  120833. get animatables(): Animatable[];
  120834. /**
  120835. * Resets the last animation time frame.
  120836. * Useful to override when animations start running when loading a scene for the first time.
  120837. */
  120838. resetLastAnimationTimeFrame(): void;
  120839. /**
  120840. * Gets the current view matrix
  120841. * @returns a Matrix
  120842. */
  120843. getViewMatrix(): Matrix;
  120844. /**
  120845. * Gets the current projection matrix
  120846. * @returns a Matrix
  120847. */
  120848. getProjectionMatrix(): Matrix;
  120849. /**
  120850. * Gets the current transform matrix
  120851. * @returns a Matrix made of View * Projection
  120852. */
  120853. getTransformMatrix(): Matrix;
  120854. /**
  120855. * Sets the current transform matrix
  120856. * @param viewL defines the View matrix to use
  120857. * @param projectionL defines the Projection matrix to use
  120858. * @param viewR defines the right View matrix to use (if provided)
  120859. * @param projectionR defines the right Projection matrix to use (if provided)
  120860. */
  120861. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120862. /**
  120863. * Gets the uniform buffer used to store scene data
  120864. * @returns a UniformBuffer
  120865. */
  120866. getSceneUniformBuffer(): UniformBuffer;
  120867. /**
  120868. * Gets an unique (relatively to the current scene) Id
  120869. * @returns an unique number for the scene
  120870. */
  120871. getUniqueId(): number;
  120872. /**
  120873. * Add a mesh to the list of scene's meshes
  120874. * @param newMesh defines the mesh to add
  120875. * @param recursive if all child meshes should also be added to the scene
  120876. */
  120877. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120878. /**
  120879. * Remove a mesh for the list of scene's meshes
  120880. * @param toRemove defines the mesh to remove
  120881. * @param recursive if all child meshes should also be removed from the scene
  120882. * @returns the index where the mesh was in the mesh list
  120883. */
  120884. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120885. /**
  120886. * Add a transform node to the list of scene's transform nodes
  120887. * @param newTransformNode defines the transform node to add
  120888. */
  120889. addTransformNode(newTransformNode: TransformNode): void;
  120890. /**
  120891. * Remove a transform node for the list of scene's transform nodes
  120892. * @param toRemove defines the transform node to remove
  120893. * @returns the index where the transform node was in the transform node list
  120894. */
  120895. removeTransformNode(toRemove: TransformNode): number;
  120896. /**
  120897. * Remove a skeleton for the list of scene's skeletons
  120898. * @param toRemove defines the skeleton to remove
  120899. * @returns the index where the skeleton was in the skeleton list
  120900. */
  120901. removeSkeleton(toRemove: Skeleton): number;
  120902. /**
  120903. * Remove a morph target for the list of scene's morph targets
  120904. * @param toRemove defines the morph target to remove
  120905. * @returns the index where the morph target was in the morph target list
  120906. */
  120907. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120908. /**
  120909. * Remove a light for the list of scene's lights
  120910. * @param toRemove defines the light to remove
  120911. * @returns the index where the light was in the light list
  120912. */
  120913. removeLight(toRemove: Light): number;
  120914. /**
  120915. * Remove a camera for the list of scene's cameras
  120916. * @param toRemove defines the camera to remove
  120917. * @returns the index where the camera was in the camera list
  120918. */
  120919. removeCamera(toRemove: Camera): number;
  120920. /**
  120921. * Remove a particle system for the list of scene's particle systems
  120922. * @param toRemove defines the particle system to remove
  120923. * @returns the index where the particle system was in the particle system list
  120924. */
  120925. removeParticleSystem(toRemove: IParticleSystem): number;
  120926. /**
  120927. * Remove a animation for the list of scene's animations
  120928. * @param toRemove defines the animation to remove
  120929. * @returns the index where the animation was in the animation list
  120930. */
  120931. removeAnimation(toRemove: Animation): number;
  120932. /**
  120933. * Will stop the animation of the given target
  120934. * @param target - the target
  120935. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120936. * @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)
  120937. */
  120938. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120939. /**
  120940. * Removes the given animation group from this scene.
  120941. * @param toRemove The animation group to remove
  120942. * @returns The index of the removed animation group
  120943. */
  120944. removeAnimationGroup(toRemove: AnimationGroup): number;
  120945. /**
  120946. * Removes the given multi-material from this scene.
  120947. * @param toRemove The multi-material to remove
  120948. * @returns The index of the removed multi-material
  120949. */
  120950. removeMultiMaterial(toRemove: MultiMaterial): number;
  120951. /**
  120952. * Removes the given material from this scene.
  120953. * @param toRemove The material to remove
  120954. * @returns The index of the removed material
  120955. */
  120956. removeMaterial(toRemove: Material): number;
  120957. /**
  120958. * Removes the given action manager from this scene.
  120959. * @param toRemove The action manager to remove
  120960. * @returns The index of the removed action manager
  120961. */
  120962. removeActionManager(toRemove: AbstractActionManager): number;
  120963. /**
  120964. * Removes the given texture from this scene.
  120965. * @param toRemove The texture to remove
  120966. * @returns The index of the removed texture
  120967. */
  120968. removeTexture(toRemove: BaseTexture): number;
  120969. /**
  120970. * Adds the given light to this scene
  120971. * @param newLight The light to add
  120972. */
  120973. addLight(newLight: Light): void;
  120974. /**
  120975. * Sorts the list list based on light priorities
  120976. */
  120977. sortLightsByPriority(): void;
  120978. /**
  120979. * Adds the given camera to this scene
  120980. * @param newCamera The camera to add
  120981. */
  120982. addCamera(newCamera: Camera): void;
  120983. /**
  120984. * Adds the given skeleton to this scene
  120985. * @param newSkeleton The skeleton to add
  120986. */
  120987. addSkeleton(newSkeleton: Skeleton): void;
  120988. /**
  120989. * Adds the given particle system to this scene
  120990. * @param newParticleSystem The particle system to add
  120991. */
  120992. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120993. /**
  120994. * Adds the given animation to this scene
  120995. * @param newAnimation The animation to add
  120996. */
  120997. addAnimation(newAnimation: Animation): void;
  120998. /**
  120999. * Adds the given animation group to this scene.
  121000. * @param newAnimationGroup The animation group to add
  121001. */
  121002. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  121003. /**
  121004. * Adds the given multi-material to this scene
  121005. * @param newMultiMaterial The multi-material to add
  121006. */
  121007. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  121008. /**
  121009. * Adds the given material to this scene
  121010. * @param newMaterial The material to add
  121011. */
  121012. addMaterial(newMaterial: Material): void;
  121013. /**
  121014. * Adds the given morph target to this scene
  121015. * @param newMorphTargetManager The morph target to add
  121016. */
  121017. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  121018. /**
  121019. * Adds the given geometry to this scene
  121020. * @param newGeometry The geometry to add
  121021. */
  121022. addGeometry(newGeometry: Geometry): void;
  121023. /**
  121024. * Adds the given action manager to this scene
  121025. * @param newActionManager The action manager to add
  121026. */
  121027. addActionManager(newActionManager: AbstractActionManager): void;
  121028. /**
  121029. * Adds the given texture to this scene.
  121030. * @param newTexture The texture to add
  121031. */
  121032. addTexture(newTexture: BaseTexture): void;
  121033. /**
  121034. * Switch active camera
  121035. * @param newCamera defines the new active camera
  121036. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  121037. */
  121038. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  121039. /**
  121040. * sets the active camera of the scene using its ID
  121041. * @param id defines the camera's ID
  121042. * @return the new active camera or null if none found.
  121043. */
  121044. setActiveCameraByID(id: string): Nullable<Camera>;
  121045. /**
  121046. * sets the active camera of the scene using its name
  121047. * @param name defines the camera's name
  121048. * @returns the new active camera or null if none found.
  121049. */
  121050. setActiveCameraByName(name: string): Nullable<Camera>;
  121051. /**
  121052. * get an animation group using its name
  121053. * @param name defines the material's name
  121054. * @return the animation group or null if none found.
  121055. */
  121056. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  121057. /**
  121058. * Get a material using its unique id
  121059. * @param uniqueId defines the material's unique id
  121060. * @return the material or null if none found.
  121061. */
  121062. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  121063. /**
  121064. * get a material using its id
  121065. * @param id defines the material's ID
  121066. * @return the material or null if none found.
  121067. */
  121068. getMaterialByID(id: string): Nullable<Material>;
  121069. /**
  121070. * Gets a the last added material using a given id
  121071. * @param id defines the material's ID
  121072. * @return the last material with the given id or null if none found.
  121073. */
  121074. getLastMaterialByID(id: string): Nullable<Material>;
  121075. /**
  121076. * Gets a material using its name
  121077. * @param name defines the material's name
  121078. * @return the material or null if none found.
  121079. */
  121080. getMaterialByName(name: string): Nullable<Material>;
  121081. /**
  121082. * Get a texture using its unique id
  121083. * @param uniqueId defines the texture's unique id
  121084. * @return the texture or null if none found.
  121085. */
  121086. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  121087. /**
  121088. * Gets a camera using its id
  121089. * @param id defines the id to look for
  121090. * @returns the camera or null if not found
  121091. */
  121092. getCameraByID(id: string): Nullable<Camera>;
  121093. /**
  121094. * Gets a camera using its unique id
  121095. * @param uniqueId defines the unique id to look for
  121096. * @returns the camera or null if not found
  121097. */
  121098. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  121099. /**
  121100. * Gets a camera using its name
  121101. * @param name defines the camera's name
  121102. * @return the camera or null if none found.
  121103. */
  121104. getCameraByName(name: string): Nullable<Camera>;
  121105. /**
  121106. * Gets a bone using its id
  121107. * @param id defines the bone's id
  121108. * @return the bone or null if not found
  121109. */
  121110. getBoneByID(id: string): Nullable<Bone>;
  121111. /**
  121112. * Gets a bone using its id
  121113. * @param name defines the bone's name
  121114. * @return the bone or null if not found
  121115. */
  121116. getBoneByName(name: string): Nullable<Bone>;
  121117. /**
  121118. * Gets a light node using its name
  121119. * @param name defines the the light's name
  121120. * @return the light or null if none found.
  121121. */
  121122. getLightByName(name: string): Nullable<Light>;
  121123. /**
  121124. * Gets a light node using its id
  121125. * @param id defines the light's id
  121126. * @return the light or null if none found.
  121127. */
  121128. getLightByID(id: string): Nullable<Light>;
  121129. /**
  121130. * Gets a light node using its scene-generated unique ID
  121131. * @param uniqueId defines the light's unique id
  121132. * @return the light or null if none found.
  121133. */
  121134. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  121135. /**
  121136. * Gets a particle system by id
  121137. * @param id defines the particle system id
  121138. * @return the corresponding system or null if none found
  121139. */
  121140. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  121141. /**
  121142. * Gets a geometry using its ID
  121143. * @param id defines the geometry's id
  121144. * @return the geometry or null if none found.
  121145. */
  121146. getGeometryByID(id: string): Nullable<Geometry>;
  121147. private _getGeometryByUniqueID;
  121148. /**
  121149. * Add a new geometry to this scene
  121150. * @param geometry defines the geometry to be added to the scene.
  121151. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  121152. * @return a boolean defining if the geometry was added or not
  121153. */
  121154. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  121155. /**
  121156. * Removes an existing geometry
  121157. * @param geometry defines the geometry to be removed from the scene
  121158. * @return a boolean defining if the geometry was removed or not
  121159. */
  121160. removeGeometry(geometry: Geometry): boolean;
  121161. /**
  121162. * Gets the list of geometries attached to the scene
  121163. * @returns an array of Geometry
  121164. */
  121165. getGeometries(): Geometry[];
  121166. /**
  121167. * Gets the first added mesh found of a given ID
  121168. * @param id defines the id to search for
  121169. * @return the mesh found or null if not found at all
  121170. */
  121171. getMeshByID(id: string): Nullable<AbstractMesh>;
  121172. /**
  121173. * Gets a list of meshes using their id
  121174. * @param id defines the id to search for
  121175. * @returns a list of meshes
  121176. */
  121177. getMeshesByID(id: string): Array<AbstractMesh>;
  121178. /**
  121179. * Gets the first added transform node found of a given ID
  121180. * @param id defines the id to search for
  121181. * @return the found transform node or null if not found at all.
  121182. */
  121183. getTransformNodeByID(id: string): Nullable<TransformNode>;
  121184. /**
  121185. * Gets a transform node with its auto-generated unique id
  121186. * @param uniqueId efines the unique id to search for
  121187. * @return the found transform node or null if not found at all.
  121188. */
  121189. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  121190. /**
  121191. * Gets a list of transform nodes using their id
  121192. * @param id defines the id to search for
  121193. * @returns a list of transform nodes
  121194. */
  121195. getTransformNodesByID(id: string): Array<TransformNode>;
  121196. /**
  121197. * Gets a mesh with its auto-generated unique id
  121198. * @param uniqueId defines the unique id to search for
  121199. * @return the found mesh or null if not found at all.
  121200. */
  121201. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  121202. /**
  121203. * Gets a the last added mesh using a given id
  121204. * @param id defines the id to search for
  121205. * @return the found mesh or null if not found at all.
  121206. */
  121207. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  121208. /**
  121209. * Gets a the last added node (Mesh, Camera, Light) using a given id
  121210. * @param id defines the id to search for
  121211. * @return the found node or null if not found at all
  121212. */
  121213. getLastEntryByID(id: string): Nullable<Node>;
  121214. /**
  121215. * Gets a node (Mesh, Camera, Light) using a given id
  121216. * @param id defines the id to search for
  121217. * @return the found node or null if not found at all
  121218. */
  121219. getNodeByID(id: string): Nullable<Node>;
  121220. /**
  121221. * Gets a node (Mesh, Camera, Light) using a given name
  121222. * @param name defines the name to search for
  121223. * @return the found node or null if not found at all.
  121224. */
  121225. getNodeByName(name: string): Nullable<Node>;
  121226. /**
  121227. * Gets a mesh using a given name
  121228. * @param name defines the name to search for
  121229. * @return the found mesh or null if not found at all.
  121230. */
  121231. getMeshByName(name: string): Nullable<AbstractMesh>;
  121232. /**
  121233. * Gets a transform node using a given name
  121234. * @param name defines the name to search for
  121235. * @return the found transform node or null if not found at all.
  121236. */
  121237. getTransformNodeByName(name: string): Nullable<TransformNode>;
  121238. /**
  121239. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  121240. * @param id defines the id to search for
  121241. * @return the found skeleton or null if not found at all.
  121242. */
  121243. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  121244. /**
  121245. * Gets a skeleton using a given auto generated unique id
  121246. * @param uniqueId defines the unique id to search for
  121247. * @return the found skeleton or null if not found at all.
  121248. */
  121249. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  121250. /**
  121251. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  121252. * @param id defines the id to search for
  121253. * @return the found skeleton or null if not found at all.
  121254. */
  121255. getSkeletonById(id: string): Nullable<Skeleton>;
  121256. /**
  121257. * Gets a skeleton using a given name
  121258. * @param name defines the name to search for
  121259. * @return the found skeleton or null if not found at all.
  121260. */
  121261. getSkeletonByName(name: string): Nullable<Skeleton>;
  121262. /**
  121263. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  121264. * @param id defines the id to search for
  121265. * @return the found morph target manager or null if not found at all.
  121266. */
  121267. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  121268. /**
  121269. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  121270. * @param id defines the id to search for
  121271. * @return the found morph target or null if not found at all.
  121272. */
  121273. getMorphTargetById(id: string): Nullable<MorphTarget>;
  121274. /**
  121275. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  121276. * @param name defines the name to search for
  121277. * @return the found morph target or null if not found at all.
  121278. */
  121279. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  121280. /**
  121281. * Gets a post process using a given name (if many are found, this function will pick the first one)
  121282. * @param name defines the name to search for
  121283. * @return the found post process or null if not found at all.
  121284. */
  121285. getPostProcessByName(name: string): Nullable<PostProcess>;
  121286. /**
  121287. * Gets a boolean indicating if the given mesh is active
  121288. * @param mesh defines the mesh to look for
  121289. * @returns true if the mesh is in the active list
  121290. */
  121291. isActiveMesh(mesh: AbstractMesh): boolean;
  121292. /**
  121293. * Return a unique id as a string which can serve as an identifier for the scene
  121294. */
  121295. get uid(): string;
  121296. /**
  121297. * Add an externaly attached data from its key.
  121298. * This method call will fail and return false, if such key already exists.
  121299. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  121300. * @param key the unique key that identifies the data
  121301. * @param data the data object to associate to the key for this Engine instance
  121302. * @return true if no such key were already present and the data was added successfully, false otherwise
  121303. */
  121304. addExternalData<T>(key: string, data: T): boolean;
  121305. /**
  121306. * Get an externaly attached data from its key
  121307. * @param key the unique key that identifies the data
  121308. * @return the associated data, if present (can be null), or undefined if not present
  121309. */
  121310. getExternalData<T>(key: string): Nullable<T>;
  121311. /**
  121312. * Get an externaly attached data from its key, create it using a factory if it's not already present
  121313. * @param key the unique key that identifies the data
  121314. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  121315. * @return the associated data, can be null if the factory returned null.
  121316. */
  121317. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  121318. /**
  121319. * Remove an externaly attached data from the Engine instance
  121320. * @param key the unique key that identifies the data
  121321. * @return true if the data was successfully removed, false if it doesn't exist
  121322. */
  121323. removeExternalData(key: string): boolean;
  121324. private _evaluateSubMesh;
  121325. /**
  121326. * Clear the processed materials smart array preventing retention point in material dispose.
  121327. */
  121328. freeProcessedMaterials(): void;
  121329. private _preventFreeActiveMeshesAndRenderingGroups;
  121330. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  121331. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  121332. * when disposing several meshes in a row or a hierarchy of meshes.
  121333. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  121334. */
  121335. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  121336. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  121337. /**
  121338. * Clear the active meshes smart array preventing retention point in mesh dispose.
  121339. */
  121340. freeActiveMeshes(): void;
  121341. /**
  121342. * Clear the info related to rendering groups preventing retention points during dispose.
  121343. */
  121344. freeRenderingGroups(): void;
  121345. /** @hidden */
  121346. _isInIntermediateRendering(): boolean;
  121347. /**
  121348. * Lambda returning the list of potentially active meshes.
  121349. */
  121350. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  121351. /**
  121352. * Lambda returning the list of potentially active sub meshes.
  121353. */
  121354. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  121355. /**
  121356. * Lambda returning the list of potentially intersecting sub meshes.
  121357. */
  121358. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  121359. /**
  121360. * Lambda returning the list of potentially colliding sub meshes.
  121361. */
  121362. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  121363. private _activeMeshesFrozen;
  121364. private _skipEvaluateActiveMeshesCompletely;
  121365. /**
  121366. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  121367. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  121368. * @returns the current scene
  121369. */
  121370. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  121371. /**
  121372. * Use this function to restart evaluating active meshes on every frame
  121373. * @returns the current scene
  121374. */
  121375. unfreezeActiveMeshes(): Scene;
  121376. private _evaluateActiveMeshes;
  121377. private _activeMesh;
  121378. /**
  121379. * Update the transform matrix to update from the current active camera
  121380. * @param force defines a boolean used to force the update even if cache is up to date
  121381. */
  121382. updateTransformMatrix(force?: boolean): void;
  121383. private _bindFrameBuffer;
  121384. /** @hidden */
  121385. _allowPostProcessClearColor: boolean;
  121386. /** @hidden */
  121387. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  121388. private _processSubCameras;
  121389. private _checkIntersections;
  121390. /** @hidden */
  121391. _advancePhysicsEngineStep(step: number): void;
  121392. /**
  121393. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  121394. */
  121395. getDeterministicFrameTime: () => number;
  121396. /** @hidden */
  121397. _animate(): void;
  121398. /** Execute all animations (for a frame) */
  121399. animate(): void;
  121400. /**
  121401. * Render the scene
  121402. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  121403. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  121404. */
  121405. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  121406. /**
  121407. * Freeze all materials
  121408. * A frozen material will not be updatable but should be faster to render
  121409. */
  121410. freezeMaterials(): void;
  121411. /**
  121412. * Unfreeze all materials
  121413. * A frozen material will not be updatable but should be faster to render
  121414. */
  121415. unfreezeMaterials(): void;
  121416. /**
  121417. * Releases all held ressources
  121418. */
  121419. dispose(): void;
  121420. /**
  121421. * Gets if the scene is already disposed
  121422. */
  121423. get isDisposed(): boolean;
  121424. /**
  121425. * Call this function to reduce memory footprint of the scene.
  121426. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  121427. */
  121428. clearCachedVertexData(): void;
  121429. /**
  121430. * This function will remove the local cached buffer data from texture.
  121431. * It will save memory but will prevent the texture from being rebuilt
  121432. */
  121433. cleanCachedTextureBuffer(): void;
  121434. /**
  121435. * Get the world extend vectors with an optional filter
  121436. *
  121437. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  121438. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  121439. */
  121440. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  121441. min: Vector3;
  121442. max: Vector3;
  121443. };
  121444. /**
  121445. * Creates a ray that can be used to pick in the scene
  121446. * @param x defines the x coordinate of the origin (on-screen)
  121447. * @param y defines the y coordinate of the origin (on-screen)
  121448. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121449. * @param camera defines the camera to use for the picking
  121450. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121451. * @returns a Ray
  121452. */
  121453. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  121454. /**
  121455. * Creates a ray that can be used to pick in the scene
  121456. * @param x defines the x coordinate of the origin (on-screen)
  121457. * @param y defines the y coordinate of the origin (on-screen)
  121458. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121459. * @param result defines the ray where to store the picking ray
  121460. * @param camera defines the camera to use for the picking
  121461. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121462. * @returns the current scene
  121463. */
  121464. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  121465. /**
  121466. * Creates a ray that can be used to pick in the scene
  121467. * @param x defines the x coordinate of the origin (on-screen)
  121468. * @param y defines the y coordinate of the origin (on-screen)
  121469. * @param camera defines the camera to use for the picking
  121470. * @returns a Ray
  121471. */
  121472. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  121473. /**
  121474. * Creates a ray that can be used to pick in the scene
  121475. * @param x defines the x coordinate of the origin (on-screen)
  121476. * @param y defines the y coordinate of the origin (on-screen)
  121477. * @param result defines the ray where to store the picking ray
  121478. * @param camera defines the camera to use for the picking
  121479. * @returns the current scene
  121480. */
  121481. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  121482. /** Launch a ray to try to pick a mesh in the scene
  121483. * @param x position on screen
  121484. * @param y position on screen
  121485. * @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
  121486. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121487. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121488. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121489. * @returns a PickingInfo
  121490. */
  121491. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121492. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121493. * @param x position on screen
  121494. * @param y position on screen
  121495. * @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
  121496. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121497. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121498. * @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)
  121499. */
  121500. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121501. /** Use the given ray to pick a mesh in the scene
  121502. * @param ray The ray to use to pick meshes
  121503. * @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
  121504. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121505. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121506. * @returns a PickingInfo
  121507. */
  121508. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121509. /**
  121510. * Launch a ray to try to pick a mesh in the scene
  121511. * @param x X position on screen
  121512. * @param y Y position on screen
  121513. * @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
  121514. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121515. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121516. * @returns an array of PickingInfo
  121517. */
  121518. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121519. /**
  121520. * Launch a ray to try to pick a mesh in the scene
  121521. * @param ray Ray to use
  121522. * @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
  121523. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121524. * @returns an array of PickingInfo
  121525. */
  121526. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121527. /**
  121528. * Force the value of meshUnderPointer
  121529. * @param mesh defines the mesh to use
  121530. * @param pointerId optional pointer id when using more than one pointer
  121531. */
  121532. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121533. /**
  121534. * Gets the mesh under the pointer
  121535. * @returns a Mesh or null if no mesh is under the pointer
  121536. */
  121537. getPointerOverMesh(): Nullable<AbstractMesh>;
  121538. /** @hidden */
  121539. _rebuildGeometries(): void;
  121540. /** @hidden */
  121541. _rebuildTextures(): void;
  121542. private _getByTags;
  121543. /**
  121544. * Get a list of meshes by tags
  121545. * @param tagsQuery defines the tags query to use
  121546. * @param forEach defines a predicate used to filter results
  121547. * @returns an array of Mesh
  121548. */
  121549. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121550. /**
  121551. * Get a list of cameras by tags
  121552. * @param tagsQuery defines the tags query to use
  121553. * @param forEach defines a predicate used to filter results
  121554. * @returns an array of Camera
  121555. */
  121556. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121557. /**
  121558. * Get a list of lights by tags
  121559. * @param tagsQuery defines the tags query to use
  121560. * @param forEach defines a predicate used to filter results
  121561. * @returns an array of Light
  121562. */
  121563. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121564. /**
  121565. * Get a list of materials by tags
  121566. * @param tagsQuery defines the tags query to use
  121567. * @param forEach defines a predicate used to filter results
  121568. * @returns an array of Material
  121569. */
  121570. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121571. /**
  121572. * Get a list of transform nodes by tags
  121573. * @param tagsQuery defines the tags query to use
  121574. * @param forEach defines a predicate used to filter results
  121575. * @returns an array of TransformNode
  121576. */
  121577. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121578. /**
  121579. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121580. * This allowed control for front to back rendering or reversly depending of the special needs.
  121581. *
  121582. * @param renderingGroupId The rendering group id corresponding to its index
  121583. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121584. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121585. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121586. */
  121587. 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;
  121588. /**
  121589. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121590. *
  121591. * @param renderingGroupId The rendering group id corresponding to its index
  121592. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121593. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121594. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121595. */
  121596. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121597. /**
  121598. * Gets the current auto clear configuration for one rendering group of the rendering
  121599. * manager.
  121600. * @param index the rendering group index to get the information for
  121601. * @returns The auto clear setup for the requested rendering group
  121602. */
  121603. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121604. private _blockMaterialDirtyMechanism;
  121605. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121606. get blockMaterialDirtyMechanism(): boolean;
  121607. set blockMaterialDirtyMechanism(value: boolean);
  121608. /**
  121609. * Will flag all materials as dirty to trigger new shader compilation
  121610. * @param flag defines the flag used to specify which material part must be marked as dirty
  121611. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121612. */
  121613. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121614. /** @hidden */
  121615. _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;
  121616. /** @hidden */
  121617. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121618. /** @hidden */
  121619. _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;
  121620. /** @hidden */
  121621. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121622. /** @hidden */
  121623. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121624. /** @hidden */
  121625. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121626. }
  121627. }
  121628. declare module BABYLON {
  121629. /**
  121630. * Set of assets to keep when moving a scene into an asset container.
  121631. */
  121632. export class KeepAssets extends AbstractScene {
  121633. }
  121634. /**
  121635. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121636. */
  121637. export class InstantiatedEntries {
  121638. /**
  121639. * List of new root nodes (eg. nodes with no parent)
  121640. */
  121641. rootNodes: TransformNode[];
  121642. /**
  121643. * List of new skeletons
  121644. */
  121645. skeletons: Skeleton[];
  121646. /**
  121647. * List of new animation groups
  121648. */
  121649. animationGroups: AnimationGroup[];
  121650. }
  121651. /**
  121652. * Container with a set of assets that can be added or removed from a scene.
  121653. */
  121654. export class AssetContainer extends AbstractScene {
  121655. private _wasAddedToScene;
  121656. /**
  121657. * The scene the AssetContainer belongs to.
  121658. */
  121659. scene: Scene;
  121660. /**
  121661. * Instantiates an AssetContainer.
  121662. * @param scene The scene the AssetContainer belongs to.
  121663. */
  121664. constructor(scene: Scene);
  121665. /**
  121666. * Instantiate or clone all meshes and add the new ones to the scene.
  121667. * Skeletons and animation groups will all be cloned
  121668. * @param nameFunction defines an optional function used to get new names for clones
  121669. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121670. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121671. */
  121672. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121673. /**
  121674. * Adds all the assets from the container to the scene.
  121675. */
  121676. addAllToScene(): void;
  121677. /**
  121678. * Removes all the assets in the container from the scene
  121679. */
  121680. removeAllFromScene(): void;
  121681. /**
  121682. * Disposes all the assets in the container
  121683. */
  121684. dispose(): void;
  121685. private _moveAssets;
  121686. /**
  121687. * Removes all the assets contained in the scene and adds them to the container.
  121688. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121689. */
  121690. moveAllFromScene(keepAssets?: KeepAssets): void;
  121691. /**
  121692. * 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.
  121693. * @returns the root mesh
  121694. */
  121695. createRootMesh(): Mesh;
  121696. /**
  121697. * Merge animations (direct and animation groups) from this asset container into a scene
  121698. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  121699. * @param animatables set of animatables to retarget to a node from the scene
  121700. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  121701. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  121702. */
  121703. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  121704. }
  121705. }
  121706. declare module BABYLON {
  121707. /**
  121708. * Defines how the parser contract is defined.
  121709. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  121710. */
  121711. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  121712. /**
  121713. * Defines how the individual parser contract is defined.
  121714. * These parser can parse an individual asset
  121715. */
  121716. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  121717. /**
  121718. * Base class of the scene acting as a container for the different elements composing a scene.
  121719. * This class is dynamically extended by the different components of the scene increasing
  121720. * flexibility and reducing coupling
  121721. */
  121722. export abstract class AbstractScene {
  121723. /**
  121724. * Stores the list of available parsers in the application.
  121725. */
  121726. private static _BabylonFileParsers;
  121727. /**
  121728. * Stores the list of available individual parsers in the application.
  121729. */
  121730. private static _IndividualBabylonFileParsers;
  121731. /**
  121732. * Adds a parser in the list of available ones
  121733. * @param name Defines the name of the parser
  121734. * @param parser Defines the parser to add
  121735. */
  121736. static AddParser(name: string, parser: BabylonFileParser): void;
  121737. /**
  121738. * Gets a general parser from the list of avaialble ones
  121739. * @param name Defines the name of the parser
  121740. * @returns the requested parser or null
  121741. */
  121742. static GetParser(name: string): Nullable<BabylonFileParser>;
  121743. /**
  121744. * Adds n individual parser in the list of available ones
  121745. * @param name Defines the name of the parser
  121746. * @param parser Defines the parser to add
  121747. */
  121748. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121749. /**
  121750. * Gets an individual parser from the list of avaialble ones
  121751. * @param name Defines the name of the parser
  121752. * @returns the requested parser or null
  121753. */
  121754. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121755. /**
  121756. * Parser json data and populate both a scene and its associated container object
  121757. * @param jsonData Defines the data to parse
  121758. * @param scene Defines the scene to parse the data for
  121759. * @param container Defines the container attached to the parsing sequence
  121760. * @param rootUrl Defines the root url of the data
  121761. */
  121762. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121763. /**
  121764. * Gets the list of root nodes (ie. nodes with no parent)
  121765. */
  121766. rootNodes: Node[];
  121767. /** All of the cameras added to this scene
  121768. * @see https://doc.babylonjs.com/babylon101/cameras
  121769. */
  121770. cameras: Camera[];
  121771. /**
  121772. * All of the lights added to this scene
  121773. * @see https://doc.babylonjs.com/babylon101/lights
  121774. */
  121775. lights: Light[];
  121776. /**
  121777. * All of the (abstract) meshes added to this scene
  121778. */
  121779. meshes: AbstractMesh[];
  121780. /**
  121781. * The list of skeletons added to the scene
  121782. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121783. */
  121784. skeletons: Skeleton[];
  121785. /**
  121786. * All of the particle systems added to this scene
  121787. * @see https://doc.babylonjs.com/babylon101/particles
  121788. */
  121789. particleSystems: IParticleSystem[];
  121790. /**
  121791. * Gets a list of Animations associated with the scene
  121792. */
  121793. animations: Animation[];
  121794. /**
  121795. * All of the animation groups added to this scene
  121796. * @see https://doc.babylonjs.com/how_to/group
  121797. */
  121798. animationGroups: AnimationGroup[];
  121799. /**
  121800. * All of the multi-materials added to this scene
  121801. * @see https://doc.babylonjs.com/how_to/multi_materials
  121802. */
  121803. multiMaterials: MultiMaterial[];
  121804. /**
  121805. * All of the materials added to this scene
  121806. * In the context of a Scene, it is not supposed to be modified manually.
  121807. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121808. * Note also that the order of the Material within the array is not significant and might change.
  121809. * @see https://doc.babylonjs.com/babylon101/materials
  121810. */
  121811. materials: Material[];
  121812. /**
  121813. * The list of morph target managers added to the scene
  121814. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121815. */
  121816. morphTargetManagers: MorphTargetManager[];
  121817. /**
  121818. * The list of geometries used in the scene.
  121819. */
  121820. geometries: Geometry[];
  121821. /**
  121822. * All of the tranform nodes added to this scene
  121823. * In the context of a Scene, it is not supposed to be modified manually.
  121824. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121825. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121826. * @see https://doc.babylonjs.com/how_to/transformnode
  121827. */
  121828. transformNodes: TransformNode[];
  121829. /**
  121830. * ActionManagers available on the scene.
  121831. */
  121832. actionManagers: AbstractActionManager[];
  121833. /**
  121834. * Textures to keep.
  121835. */
  121836. textures: BaseTexture[];
  121837. /** @hidden */
  121838. protected _environmentTexture: Nullable<BaseTexture>;
  121839. /**
  121840. * Texture used in all pbr material as the reflection texture.
  121841. * As in the majority of the scene they are the same (exception for multi room and so on),
  121842. * this is easier to reference from here than from all the materials.
  121843. */
  121844. get environmentTexture(): Nullable<BaseTexture>;
  121845. set environmentTexture(value: Nullable<BaseTexture>);
  121846. /**
  121847. * The list of postprocesses added to the scene
  121848. */
  121849. postProcesses: PostProcess[];
  121850. /**
  121851. * @returns all meshes, lights, cameras, transformNodes and bones
  121852. */
  121853. getNodes(): Array<Node>;
  121854. }
  121855. }
  121856. declare module BABYLON {
  121857. /**
  121858. * Interface used to define options for Sound class
  121859. */
  121860. export interface ISoundOptions {
  121861. /**
  121862. * Does the sound autoplay once loaded.
  121863. */
  121864. autoplay?: boolean;
  121865. /**
  121866. * Does the sound loop after it finishes playing once.
  121867. */
  121868. loop?: boolean;
  121869. /**
  121870. * Sound's volume
  121871. */
  121872. volume?: number;
  121873. /**
  121874. * Is it a spatial sound?
  121875. */
  121876. spatialSound?: boolean;
  121877. /**
  121878. * Maximum distance to hear that sound
  121879. */
  121880. maxDistance?: number;
  121881. /**
  121882. * Uses user defined attenuation function
  121883. */
  121884. useCustomAttenuation?: boolean;
  121885. /**
  121886. * Define the roll off factor of spatial sounds.
  121887. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121888. */
  121889. rolloffFactor?: number;
  121890. /**
  121891. * Define the reference distance the sound should be heard perfectly.
  121892. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121893. */
  121894. refDistance?: number;
  121895. /**
  121896. * Define the distance attenuation model the sound will follow.
  121897. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121898. */
  121899. distanceModel?: string;
  121900. /**
  121901. * Defines the playback speed (1 by default)
  121902. */
  121903. playbackRate?: number;
  121904. /**
  121905. * Defines if the sound is from a streaming source
  121906. */
  121907. streaming?: boolean;
  121908. /**
  121909. * Defines an optional length (in seconds) inside the sound file
  121910. */
  121911. length?: number;
  121912. /**
  121913. * Defines an optional offset (in seconds) inside the sound file
  121914. */
  121915. offset?: number;
  121916. /**
  121917. * If true, URLs will not be required to state the audio file codec to use.
  121918. */
  121919. skipCodecCheck?: boolean;
  121920. }
  121921. /**
  121922. * Defines a sound that can be played in the application.
  121923. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121924. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121925. */
  121926. export class Sound {
  121927. /**
  121928. * The name of the sound in the scene.
  121929. */
  121930. name: string;
  121931. /**
  121932. * Does the sound autoplay once loaded.
  121933. */
  121934. autoplay: boolean;
  121935. /**
  121936. * Does the sound loop after it finishes playing once.
  121937. */
  121938. loop: boolean;
  121939. /**
  121940. * Does the sound use a custom attenuation curve to simulate the falloff
  121941. * happening when the source gets further away from the camera.
  121942. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121943. */
  121944. useCustomAttenuation: boolean;
  121945. /**
  121946. * The sound track id this sound belongs to.
  121947. */
  121948. soundTrackId: number;
  121949. /**
  121950. * Is this sound currently played.
  121951. */
  121952. isPlaying: boolean;
  121953. /**
  121954. * Is this sound currently paused.
  121955. */
  121956. isPaused: boolean;
  121957. /**
  121958. * Does this sound enables spatial sound.
  121959. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121960. */
  121961. spatialSound: boolean;
  121962. /**
  121963. * Define the reference distance the sound should be heard perfectly.
  121964. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121965. */
  121966. refDistance: number;
  121967. /**
  121968. * Define the roll off factor of spatial sounds.
  121969. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121970. */
  121971. rolloffFactor: number;
  121972. /**
  121973. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121974. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121975. */
  121976. maxDistance: number;
  121977. /**
  121978. * Define the distance attenuation model the sound will follow.
  121979. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121980. */
  121981. distanceModel: string;
  121982. /**
  121983. * @hidden
  121984. * Back Compat
  121985. **/
  121986. onended: () => any;
  121987. /**
  121988. * Gets or sets an object used to store user defined information for the sound.
  121989. */
  121990. metadata: any;
  121991. /**
  121992. * Observable event when the current playing sound finishes.
  121993. */
  121994. onEndedObservable: Observable<Sound>;
  121995. private _panningModel;
  121996. private _playbackRate;
  121997. private _streaming;
  121998. private _startTime;
  121999. private _startOffset;
  122000. private _position;
  122001. /** @hidden */
  122002. _positionInEmitterSpace: boolean;
  122003. private _localDirection;
  122004. private _volume;
  122005. private _isReadyToPlay;
  122006. private _isDirectional;
  122007. private _readyToPlayCallback;
  122008. private _audioBuffer;
  122009. private _soundSource;
  122010. private _streamingSource;
  122011. private _soundPanner;
  122012. private _soundGain;
  122013. private _inputAudioNode;
  122014. private _outputAudioNode;
  122015. private _coneInnerAngle;
  122016. private _coneOuterAngle;
  122017. private _coneOuterGain;
  122018. private _scene;
  122019. private _connectedTransformNode;
  122020. private _customAttenuationFunction;
  122021. private _registerFunc;
  122022. private _isOutputConnected;
  122023. private _htmlAudioElement;
  122024. private _urlType;
  122025. private _length?;
  122026. private _offset?;
  122027. /** @hidden */
  122028. static _SceneComponentInitialization: (scene: Scene) => void;
  122029. /**
  122030. * Create a sound and attach it to a scene
  122031. * @param name Name of your sound
  122032. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  122033. * @param scene defines the scene the sound belongs to
  122034. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  122035. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  122036. */
  122037. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  122038. /**
  122039. * Release the sound and its associated resources
  122040. */
  122041. dispose(): void;
  122042. /**
  122043. * Gets if the sounds is ready to be played or not.
  122044. * @returns true if ready, otherwise false
  122045. */
  122046. isReady(): boolean;
  122047. private _soundLoaded;
  122048. /**
  122049. * Sets the data of the sound from an audiobuffer
  122050. * @param audioBuffer The audioBuffer containing the data
  122051. */
  122052. setAudioBuffer(audioBuffer: AudioBuffer): void;
  122053. /**
  122054. * Updates the current sounds options such as maxdistance, loop...
  122055. * @param options A JSON object containing values named as the object properties
  122056. */
  122057. updateOptions(options: ISoundOptions): void;
  122058. private _createSpatialParameters;
  122059. private _updateSpatialParameters;
  122060. /**
  122061. * Switch the panning model to HRTF:
  122062. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122063. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122064. */
  122065. switchPanningModelToHRTF(): void;
  122066. /**
  122067. * Switch the panning model to Equal Power:
  122068. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122069. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122070. */
  122071. switchPanningModelToEqualPower(): void;
  122072. private _switchPanningModel;
  122073. /**
  122074. * Connect this sound to a sound track audio node like gain...
  122075. * @param soundTrackAudioNode the sound track audio node to connect to
  122076. */
  122077. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  122078. /**
  122079. * Transform this sound into a directional source
  122080. * @param coneInnerAngle Size of the inner cone in degree
  122081. * @param coneOuterAngle Size of the outer cone in degree
  122082. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  122083. */
  122084. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  122085. /**
  122086. * Gets or sets the inner angle for the directional cone.
  122087. */
  122088. get directionalConeInnerAngle(): number;
  122089. /**
  122090. * Gets or sets the inner angle for the directional cone.
  122091. */
  122092. set directionalConeInnerAngle(value: number);
  122093. /**
  122094. * Gets or sets the outer angle for the directional cone.
  122095. */
  122096. get directionalConeOuterAngle(): number;
  122097. /**
  122098. * Gets or sets the outer angle for the directional cone.
  122099. */
  122100. set directionalConeOuterAngle(value: number);
  122101. /**
  122102. * Sets the position of the emitter if spatial sound is enabled
  122103. * @param newPosition Defines the new posisiton
  122104. */
  122105. setPosition(newPosition: Vector3): void;
  122106. /**
  122107. * Sets the local direction of the emitter if spatial sound is enabled
  122108. * @param newLocalDirection Defines the new local direction
  122109. */
  122110. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  122111. private _updateDirection;
  122112. /** @hidden */
  122113. updateDistanceFromListener(): void;
  122114. /**
  122115. * Sets a new custom attenuation function for the sound.
  122116. * @param callback Defines the function used for the attenuation
  122117. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122118. */
  122119. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  122120. /**
  122121. * Play the sound
  122122. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  122123. * @param offset (optional) Start the sound at a specific time in seconds
  122124. * @param length (optional) Sound duration (in seconds)
  122125. */
  122126. play(time?: number, offset?: number, length?: number): void;
  122127. private _onended;
  122128. /**
  122129. * Stop the sound
  122130. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  122131. */
  122132. stop(time?: number): void;
  122133. /**
  122134. * Put the sound in pause
  122135. */
  122136. pause(): void;
  122137. /**
  122138. * Sets a dedicated volume for this sounds
  122139. * @param newVolume Define the new volume of the sound
  122140. * @param time Define time for gradual change to new volume
  122141. */
  122142. setVolume(newVolume: number, time?: number): void;
  122143. /**
  122144. * Set the sound play back rate
  122145. * @param newPlaybackRate Define the playback rate the sound should be played at
  122146. */
  122147. setPlaybackRate(newPlaybackRate: number): void;
  122148. /**
  122149. * Gets the volume of the sound.
  122150. * @returns the volume of the sound
  122151. */
  122152. getVolume(): number;
  122153. /**
  122154. * Attach the sound to a dedicated mesh
  122155. * @param transformNode The transform node to connect the sound with
  122156. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122157. */
  122158. attachToMesh(transformNode: TransformNode): void;
  122159. /**
  122160. * Detach the sound from the previously attached mesh
  122161. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122162. */
  122163. detachFromMesh(): void;
  122164. private _onRegisterAfterWorldMatrixUpdate;
  122165. /**
  122166. * Clone the current sound in the scene.
  122167. * @returns the new sound clone
  122168. */
  122169. clone(): Nullable<Sound>;
  122170. /**
  122171. * Gets the current underlying audio buffer containing the data
  122172. * @returns the audio buffer
  122173. */
  122174. getAudioBuffer(): Nullable<AudioBuffer>;
  122175. /**
  122176. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  122177. * @returns the source node
  122178. */
  122179. getSoundSource(): Nullable<AudioBufferSourceNode>;
  122180. /**
  122181. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  122182. * @returns the gain node
  122183. */
  122184. getSoundGain(): Nullable<GainNode>;
  122185. /**
  122186. * Serializes the Sound in a JSON representation
  122187. * @returns the JSON representation of the sound
  122188. */
  122189. serialize(): any;
  122190. /**
  122191. * Parse a JSON representation of a sound to innstantiate in a given scene
  122192. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  122193. * @param scene Define the scene the new parsed sound should be created in
  122194. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  122195. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  122196. * @returns the newly parsed sound
  122197. */
  122198. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  122199. }
  122200. }
  122201. declare module BABYLON {
  122202. /**
  122203. * This defines an action helpful to play a defined sound on a triggered action.
  122204. */
  122205. export class PlaySoundAction extends Action {
  122206. private _sound;
  122207. /**
  122208. * Instantiate the action
  122209. * @param triggerOptions defines the trigger options
  122210. * @param sound defines the sound to play
  122211. * @param condition defines the trigger related conditions
  122212. */
  122213. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122214. /** @hidden */
  122215. _prepare(): void;
  122216. /**
  122217. * Execute the action and play the sound.
  122218. */
  122219. execute(): void;
  122220. /**
  122221. * Serializes the actions and its related information.
  122222. * @param parent defines the object to serialize in
  122223. * @returns the serialized object
  122224. */
  122225. serialize(parent: any): any;
  122226. }
  122227. /**
  122228. * This defines an action helpful to stop a defined sound on a triggered action.
  122229. */
  122230. export class StopSoundAction extends Action {
  122231. private _sound;
  122232. /**
  122233. * Instantiate the action
  122234. * @param triggerOptions defines the trigger options
  122235. * @param sound defines the sound to stop
  122236. * @param condition defines the trigger related conditions
  122237. */
  122238. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122239. /** @hidden */
  122240. _prepare(): void;
  122241. /**
  122242. * Execute the action and stop the sound.
  122243. */
  122244. execute(): void;
  122245. /**
  122246. * Serializes the actions and its related information.
  122247. * @param parent defines the object to serialize in
  122248. * @returns the serialized object
  122249. */
  122250. serialize(parent: any): any;
  122251. }
  122252. }
  122253. declare module BABYLON {
  122254. /**
  122255. * This defines an action responsible to change the value of a property
  122256. * by interpolating between its current value and the newly set one once triggered.
  122257. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  122258. */
  122259. export class InterpolateValueAction extends Action {
  122260. /**
  122261. * Defines the path of the property where the value should be interpolated
  122262. */
  122263. propertyPath: string;
  122264. /**
  122265. * Defines the target value at the end of the interpolation.
  122266. */
  122267. value: any;
  122268. /**
  122269. * Defines the time it will take for the property to interpolate to the value.
  122270. */
  122271. duration: number;
  122272. /**
  122273. * Defines if the other scene animations should be stopped when the action has been triggered
  122274. */
  122275. stopOtherAnimations?: boolean;
  122276. /**
  122277. * Defines a callback raised once the interpolation animation has been done.
  122278. */
  122279. onInterpolationDone?: () => void;
  122280. /**
  122281. * Observable triggered once the interpolation animation has been done.
  122282. */
  122283. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  122284. private _target;
  122285. private _effectiveTarget;
  122286. private _property;
  122287. /**
  122288. * Instantiate the action
  122289. * @param triggerOptions defines the trigger options
  122290. * @param target defines the object containing the value to interpolate
  122291. * @param propertyPath defines the path to the property in the target object
  122292. * @param value defines the target value at the end of the interpolation
  122293. * @param duration deines the time it will take for the property to interpolate to the value.
  122294. * @param condition defines the trigger related conditions
  122295. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  122296. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  122297. */
  122298. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  122299. /** @hidden */
  122300. _prepare(): void;
  122301. /**
  122302. * Execute the action starts the value interpolation.
  122303. */
  122304. execute(): void;
  122305. /**
  122306. * Serializes the actions and its related information.
  122307. * @param parent defines the object to serialize in
  122308. * @returns the serialized object
  122309. */
  122310. serialize(parent: any): any;
  122311. }
  122312. }
  122313. declare module BABYLON {
  122314. /**
  122315. * Options allowed during the creation of a sound track.
  122316. */
  122317. export interface ISoundTrackOptions {
  122318. /**
  122319. * The volume the sound track should take during creation
  122320. */
  122321. volume?: number;
  122322. /**
  122323. * Define if the sound track is the main sound track of the scene
  122324. */
  122325. mainTrack?: boolean;
  122326. }
  122327. /**
  122328. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  122329. * It will be also used in a future release to apply effects on a specific track.
  122330. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122331. */
  122332. export class SoundTrack {
  122333. /**
  122334. * The unique identifier of the sound track in the scene.
  122335. */
  122336. id: number;
  122337. /**
  122338. * The list of sounds included in the sound track.
  122339. */
  122340. soundCollection: Array<Sound>;
  122341. private _outputAudioNode;
  122342. private _scene;
  122343. private _connectedAnalyser;
  122344. private _options;
  122345. private _isInitialized;
  122346. /**
  122347. * Creates a new sound track.
  122348. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122349. * @param scene Define the scene the sound track belongs to
  122350. * @param options
  122351. */
  122352. constructor(scene: Scene, options?: ISoundTrackOptions);
  122353. private _initializeSoundTrackAudioGraph;
  122354. /**
  122355. * Release the sound track and its associated resources
  122356. */
  122357. dispose(): void;
  122358. /**
  122359. * Adds a sound to this sound track
  122360. * @param sound define the cound to add
  122361. * @ignoreNaming
  122362. */
  122363. AddSound(sound: Sound): void;
  122364. /**
  122365. * Removes a sound to this sound track
  122366. * @param sound define the cound to remove
  122367. * @ignoreNaming
  122368. */
  122369. RemoveSound(sound: Sound): void;
  122370. /**
  122371. * Set a global volume for the full sound track.
  122372. * @param newVolume Define the new volume of the sound track
  122373. */
  122374. setVolume(newVolume: number): void;
  122375. /**
  122376. * Switch the panning model to HRTF:
  122377. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122378. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122379. */
  122380. switchPanningModelToHRTF(): void;
  122381. /**
  122382. * Switch the panning model to Equal Power:
  122383. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122384. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122385. */
  122386. switchPanningModelToEqualPower(): void;
  122387. /**
  122388. * Connect the sound track to an audio analyser allowing some amazing
  122389. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122390. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122391. * @param analyser The analyser to connect to the engine
  122392. */
  122393. connectToAnalyser(analyser: Analyser): void;
  122394. }
  122395. }
  122396. declare module BABYLON {
  122397. interface AbstractScene {
  122398. /**
  122399. * The list of sounds used in the scene.
  122400. */
  122401. sounds: Nullable<Array<Sound>>;
  122402. }
  122403. interface Scene {
  122404. /**
  122405. * @hidden
  122406. * Backing field
  122407. */
  122408. _mainSoundTrack: SoundTrack;
  122409. /**
  122410. * The main sound track played by the scene.
  122411. * It cotains your primary collection of sounds.
  122412. */
  122413. mainSoundTrack: SoundTrack;
  122414. /**
  122415. * The list of sound tracks added to the scene
  122416. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122417. */
  122418. soundTracks: Nullable<Array<SoundTrack>>;
  122419. /**
  122420. * Gets a sound using a given name
  122421. * @param name defines the name to search for
  122422. * @return the found sound or null if not found at all.
  122423. */
  122424. getSoundByName(name: string): Nullable<Sound>;
  122425. /**
  122426. * Gets or sets if audio support is enabled
  122427. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122428. */
  122429. audioEnabled: boolean;
  122430. /**
  122431. * Gets or sets if audio will be output to headphones
  122432. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122433. */
  122434. headphone: boolean;
  122435. /**
  122436. * Gets or sets custom audio listener position provider
  122437. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122438. */
  122439. audioListenerPositionProvider: Nullable<() => Vector3>;
  122440. /**
  122441. * Gets or sets a refresh rate when using 3D audio positioning
  122442. */
  122443. audioPositioningRefreshRate: number;
  122444. }
  122445. /**
  122446. * Defines the sound scene component responsible to manage any sounds
  122447. * in a given scene.
  122448. */
  122449. export class AudioSceneComponent implements ISceneSerializableComponent {
  122450. private static _CameraDirectionLH;
  122451. private static _CameraDirectionRH;
  122452. /**
  122453. * The component name helpfull to identify the component in the list of scene components.
  122454. */
  122455. readonly name: string;
  122456. /**
  122457. * The scene the component belongs to.
  122458. */
  122459. scene: Scene;
  122460. private _audioEnabled;
  122461. /**
  122462. * Gets whether audio is enabled or not.
  122463. * Please use related enable/disable method to switch state.
  122464. */
  122465. get audioEnabled(): boolean;
  122466. private _headphone;
  122467. /**
  122468. * Gets whether audio is outputing to headphone or not.
  122469. * Please use the according Switch methods to change output.
  122470. */
  122471. get headphone(): boolean;
  122472. /**
  122473. * Gets or sets a refresh rate when using 3D audio positioning
  122474. */
  122475. audioPositioningRefreshRate: number;
  122476. private _audioListenerPositionProvider;
  122477. /**
  122478. * Gets the current audio listener position provider
  122479. */
  122480. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  122481. /**
  122482. * Sets a custom listener position for all sounds in the scene
  122483. * By default, this is the position of the first active camera
  122484. */
  122485. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122486. /**
  122487. * Creates a new instance of the component for the given scene
  122488. * @param scene Defines the scene to register the component in
  122489. */
  122490. constructor(scene: Scene);
  122491. /**
  122492. * Registers the component in a given scene
  122493. */
  122494. register(): void;
  122495. /**
  122496. * Rebuilds the elements related to this component in case of
  122497. * context lost for instance.
  122498. */
  122499. rebuild(): void;
  122500. /**
  122501. * Serializes the component data to the specified json object
  122502. * @param serializationObject The object to serialize to
  122503. */
  122504. serialize(serializationObject: any): void;
  122505. /**
  122506. * Adds all the elements from the container to the scene
  122507. * @param container the container holding the elements
  122508. */
  122509. addFromContainer(container: AbstractScene): void;
  122510. /**
  122511. * Removes all the elements in the container from the scene
  122512. * @param container contains the elements to remove
  122513. * @param dispose if the removed element should be disposed (default: false)
  122514. */
  122515. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122516. /**
  122517. * Disposes the component and the associated ressources.
  122518. */
  122519. dispose(): void;
  122520. /**
  122521. * Disables audio in the associated scene.
  122522. */
  122523. disableAudio(): void;
  122524. /**
  122525. * Enables audio in the associated scene.
  122526. */
  122527. enableAudio(): void;
  122528. /**
  122529. * Switch audio to headphone output.
  122530. */
  122531. switchAudioModeForHeadphones(): void;
  122532. /**
  122533. * Switch audio to normal speakers.
  122534. */
  122535. switchAudioModeForNormalSpeakers(): void;
  122536. private _cachedCameraDirection;
  122537. private _cachedCameraPosition;
  122538. private _lastCheck;
  122539. private _afterRender;
  122540. }
  122541. }
  122542. declare module BABYLON {
  122543. /**
  122544. * Wraps one or more Sound objects and selects one with random weight for playback.
  122545. */
  122546. export class WeightedSound {
  122547. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122548. loop: boolean;
  122549. private _coneInnerAngle;
  122550. private _coneOuterAngle;
  122551. private _volume;
  122552. /** A Sound is currently playing. */
  122553. isPlaying: boolean;
  122554. /** A Sound is currently paused. */
  122555. isPaused: boolean;
  122556. private _sounds;
  122557. private _weights;
  122558. private _currentIndex?;
  122559. /**
  122560. * Creates a new WeightedSound from the list of sounds given.
  122561. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122562. * @param sounds Array of Sounds that will be selected from.
  122563. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122564. */
  122565. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122566. /**
  122567. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122568. */
  122569. get directionalConeInnerAngle(): number;
  122570. /**
  122571. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122572. */
  122573. set directionalConeInnerAngle(value: number);
  122574. /**
  122575. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122576. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122577. */
  122578. get directionalConeOuterAngle(): number;
  122579. /**
  122580. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122581. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122582. */
  122583. set directionalConeOuterAngle(value: number);
  122584. /**
  122585. * Playback volume.
  122586. */
  122587. get volume(): number;
  122588. /**
  122589. * Playback volume.
  122590. */
  122591. set volume(value: number);
  122592. private _onended;
  122593. /**
  122594. * Suspend playback
  122595. */
  122596. pause(): void;
  122597. /**
  122598. * Stop playback
  122599. */
  122600. stop(): void;
  122601. /**
  122602. * Start playback.
  122603. * @param startOffset Position the clip head at a specific time in seconds.
  122604. */
  122605. play(startOffset?: number): void;
  122606. }
  122607. }
  122608. declare module BABYLON {
  122609. /**
  122610. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122611. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122612. */
  122613. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122614. /**
  122615. * Gets the name of the behavior.
  122616. */
  122617. get name(): string;
  122618. /**
  122619. * The easing function used by animations
  122620. */
  122621. static EasingFunction: BackEase;
  122622. /**
  122623. * The easing mode used by animations
  122624. */
  122625. static EasingMode: number;
  122626. /**
  122627. * The duration of the animation, in milliseconds
  122628. */
  122629. transitionDuration: number;
  122630. /**
  122631. * Length of the distance animated by the transition when lower radius is reached
  122632. */
  122633. lowerRadiusTransitionRange: number;
  122634. /**
  122635. * Length of the distance animated by the transition when upper radius is reached
  122636. */
  122637. upperRadiusTransitionRange: number;
  122638. private _autoTransitionRange;
  122639. /**
  122640. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122641. */
  122642. get autoTransitionRange(): boolean;
  122643. /**
  122644. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122645. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122646. */
  122647. set autoTransitionRange(value: boolean);
  122648. private _attachedCamera;
  122649. private _onAfterCheckInputsObserver;
  122650. private _onMeshTargetChangedObserver;
  122651. /**
  122652. * Initializes the behavior.
  122653. */
  122654. init(): void;
  122655. /**
  122656. * Attaches the behavior to its arc rotate camera.
  122657. * @param camera Defines the camera to attach the behavior to
  122658. */
  122659. attach(camera: ArcRotateCamera): void;
  122660. /**
  122661. * Detaches the behavior from its current arc rotate camera.
  122662. */
  122663. detach(): void;
  122664. private _radiusIsAnimating;
  122665. private _radiusBounceTransition;
  122666. private _animatables;
  122667. private _cachedWheelPrecision;
  122668. /**
  122669. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122670. * @param radiusLimit The limit to check against.
  122671. * @return Bool to indicate if at limit.
  122672. */
  122673. private _isRadiusAtLimit;
  122674. /**
  122675. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122676. * @param radiusDelta The delta by which to animate to. Can be negative.
  122677. */
  122678. private _applyBoundRadiusAnimation;
  122679. /**
  122680. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122681. */
  122682. protected _clearAnimationLocks(): void;
  122683. /**
  122684. * Stops and removes all animations that have been applied to the camera
  122685. */
  122686. stopAllAnimations(): void;
  122687. }
  122688. }
  122689. declare module BABYLON {
  122690. /**
  122691. * 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.
  122692. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122693. */
  122694. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122695. /**
  122696. * Gets the name of the behavior.
  122697. */
  122698. get name(): string;
  122699. private _mode;
  122700. private _radiusScale;
  122701. private _positionScale;
  122702. private _defaultElevation;
  122703. private _elevationReturnTime;
  122704. private _elevationReturnWaitTime;
  122705. private _zoomStopsAnimation;
  122706. private _framingTime;
  122707. /**
  122708. * The easing function used by animations
  122709. */
  122710. static EasingFunction: ExponentialEase;
  122711. /**
  122712. * The easing mode used by animations
  122713. */
  122714. static EasingMode: number;
  122715. /**
  122716. * Sets the current mode used by the behavior
  122717. */
  122718. set mode(mode: number);
  122719. /**
  122720. * Gets current mode used by the behavior.
  122721. */
  122722. get mode(): number;
  122723. /**
  122724. * Sets the scale applied to the radius (1 by default)
  122725. */
  122726. set radiusScale(radius: number);
  122727. /**
  122728. * Gets the scale applied to the radius
  122729. */
  122730. get radiusScale(): number;
  122731. /**
  122732. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122733. */
  122734. set positionScale(scale: number);
  122735. /**
  122736. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122737. */
  122738. get positionScale(): number;
  122739. /**
  122740. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122741. * behaviour is triggered, in radians.
  122742. */
  122743. set defaultElevation(elevation: number);
  122744. /**
  122745. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122746. * behaviour is triggered, in radians.
  122747. */
  122748. get defaultElevation(): number;
  122749. /**
  122750. * Sets the time (in milliseconds) taken to return to the default beta position.
  122751. * Negative value indicates camera should not return to default.
  122752. */
  122753. set elevationReturnTime(speed: number);
  122754. /**
  122755. * Gets the time (in milliseconds) taken to return to the default beta position.
  122756. * Negative value indicates camera should not return to default.
  122757. */
  122758. get elevationReturnTime(): number;
  122759. /**
  122760. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122761. */
  122762. set elevationReturnWaitTime(time: number);
  122763. /**
  122764. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122765. */
  122766. get elevationReturnWaitTime(): number;
  122767. /**
  122768. * Sets the flag that indicates if user zooming should stop animation.
  122769. */
  122770. set zoomStopsAnimation(flag: boolean);
  122771. /**
  122772. * Gets the flag that indicates if user zooming should stop animation.
  122773. */
  122774. get zoomStopsAnimation(): boolean;
  122775. /**
  122776. * Sets the transition time when framing the mesh, in milliseconds
  122777. */
  122778. set framingTime(time: number);
  122779. /**
  122780. * Gets the transition time when framing the mesh, in milliseconds
  122781. */
  122782. get framingTime(): number;
  122783. /**
  122784. * Define if the behavior should automatically change the configured
  122785. * camera limits and sensibilities.
  122786. */
  122787. autoCorrectCameraLimitsAndSensibility: boolean;
  122788. private _onPrePointerObservableObserver;
  122789. private _onAfterCheckInputsObserver;
  122790. private _onMeshTargetChangedObserver;
  122791. private _attachedCamera;
  122792. private _isPointerDown;
  122793. private _lastInteractionTime;
  122794. /**
  122795. * Initializes the behavior.
  122796. */
  122797. init(): void;
  122798. /**
  122799. * Attaches the behavior to its arc rotate camera.
  122800. * @param camera Defines the camera to attach the behavior to
  122801. */
  122802. attach(camera: ArcRotateCamera): void;
  122803. /**
  122804. * Detaches the behavior from its current arc rotate camera.
  122805. */
  122806. detach(): void;
  122807. private _animatables;
  122808. private _betaIsAnimating;
  122809. private _betaTransition;
  122810. private _radiusTransition;
  122811. private _vectorTransition;
  122812. /**
  122813. * Targets the given mesh and updates zoom level accordingly.
  122814. * @param mesh The mesh to target.
  122815. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122816. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122817. */
  122818. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122819. /**
  122820. * Targets the given mesh with its children and updates zoom level accordingly.
  122821. * @param mesh The mesh to target.
  122822. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122823. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122824. */
  122825. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122826. /**
  122827. * Targets the given meshes with their children and updates zoom level accordingly.
  122828. * @param meshes The mesh to target.
  122829. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122830. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122831. */
  122832. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122833. /**
  122834. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122835. * @param minimumWorld Determines the smaller position of the bounding box extend
  122836. * @param maximumWorld Determines the bigger position of the bounding box extend
  122837. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122838. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122839. */
  122840. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122841. /**
  122842. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122843. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122844. * frustum width.
  122845. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122846. * to fully enclose the mesh in the viewing frustum.
  122847. */
  122848. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122849. /**
  122850. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122851. * is automatically returned to its default position (expected to be above ground plane).
  122852. */
  122853. private _maintainCameraAboveGround;
  122854. /**
  122855. * Returns the frustum slope based on the canvas ratio and camera FOV
  122856. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122857. */
  122858. private _getFrustumSlope;
  122859. /**
  122860. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122861. */
  122862. private _clearAnimationLocks;
  122863. /**
  122864. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122865. */
  122866. private _applyUserInteraction;
  122867. /**
  122868. * Stops and removes all animations that have been applied to the camera
  122869. */
  122870. stopAllAnimations(): void;
  122871. /**
  122872. * Gets a value indicating if the user is moving the camera
  122873. */
  122874. get isUserIsMoving(): boolean;
  122875. /**
  122876. * The camera can move all the way towards the mesh.
  122877. */
  122878. static IgnoreBoundsSizeMode: number;
  122879. /**
  122880. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122881. */
  122882. static FitFrustumSidesMode: number;
  122883. }
  122884. }
  122885. declare module BABYLON {
  122886. /**
  122887. * Base class for Camera Pointer Inputs.
  122888. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122889. * for example usage.
  122890. */
  122891. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122892. /**
  122893. * Defines the camera the input is attached to.
  122894. */
  122895. abstract camera: Camera;
  122896. /**
  122897. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122898. */
  122899. protected _altKey: boolean;
  122900. protected _ctrlKey: boolean;
  122901. protected _metaKey: boolean;
  122902. protected _shiftKey: boolean;
  122903. /**
  122904. * Which mouse buttons were pressed at time of last mouse event.
  122905. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122906. */
  122907. protected _buttonsPressed: number;
  122908. /**
  122909. * Defines the buttons associated with the input to handle camera move.
  122910. */
  122911. buttons: number[];
  122912. /**
  122913. * Attach the input controls to a specific dom element to get the input from.
  122914. * @param element Defines the element the controls should be listened from
  122915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122916. */
  122917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122918. /**
  122919. * Detach the current controls from the specified dom element.
  122920. * @param element Defines the element to stop listening the inputs from
  122921. */
  122922. detachControl(element: Nullable<HTMLElement>): void;
  122923. /**
  122924. * Gets the class name of the current input.
  122925. * @returns the class name
  122926. */
  122927. getClassName(): string;
  122928. /**
  122929. * Get the friendly name associated with the input class.
  122930. * @returns the input friendly name
  122931. */
  122932. getSimpleName(): string;
  122933. /**
  122934. * Called on pointer POINTERDOUBLETAP event.
  122935. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122936. */
  122937. protected onDoubleTap(type: string): void;
  122938. /**
  122939. * Called on pointer POINTERMOVE event if only a single touch is active.
  122940. * Override this method to provide functionality.
  122941. */
  122942. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122943. /**
  122944. * Called on pointer POINTERMOVE event if multiple touches are active.
  122945. * Override this method to provide functionality.
  122946. */
  122947. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122948. /**
  122949. * Called on JS contextmenu event.
  122950. * Override this method to provide functionality.
  122951. */
  122952. protected onContextMenu(evt: PointerEvent): void;
  122953. /**
  122954. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122955. * press.
  122956. * Override this method to provide functionality.
  122957. */
  122958. protected onButtonDown(evt: PointerEvent): void;
  122959. /**
  122960. * Called each time a new POINTERUP event occurs. Ie, for each button
  122961. * release.
  122962. * Override this method to provide functionality.
  122963. */
  122964. protected onButtonUp(evt: PointerEvent): void;
  122965. /**
  122966. * Called when window becomes inactive.
  122967. * Override this method to provide functionality.
  122968. */
  122969. protected onLostFocus(): void;
  122970. private _pointerInput;
  122971. private _observer;
  122972. private _onLostFocus;
  122973. private pointA;
  122974. private pointB;
  122975. }
  122976. }
  122977. declare module BABYLON {
  122978. /**
  122979. * Manage the pointers inputs to control an arc rotate camera.
  122980. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122981. */
  122982. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122983. /**
  122984. * Defines the camera the input is attached to.
  122985. */
  122986. camera: ArcRotateCamera;
  122987. /**
  122988. * Gets the class name of the current input.
  122989. * @returns the class name
  122990. */
  122991. getClassName(): string;
  122992. /**
  122993. * Defines the buttons associated with the input to handle camera move.
  122994. */
  122995. buttons: number[];
  122996. /**
  122997. * Defines the pointer angular sensibility along the X axis or how fast is
  122998. * the camera rotating.
  122999. */
  123000. angularSensibilityX: number;
  123001. /**
  123002. * Defines the pointer angular sensibility along the Y axis or how fast is
  123003. * the camera rotating.
  123004. */
  123005. angularSensibilityY: number;
  123006. /**
  123007. * Defines the pointer pinch precision or how fast is the camera zooming.
  123008. */
  123009. pinchPrecision: number;
  123010. /**
  123011. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123012. * from 0.
  123013. * It defines the percentage of current camera.radius to use as delta when
  123014. * pinch zoom is used.
  123015. */
  123016. pinchDeltaPercentage: number;
  123017. /**
  123018. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123019. * that any object in the plane at the camera's target point will scale
  123020. * perfectly with finger motion.
  123021. * Overrides pinchDeltaPercentage and pinchPrecision.
  123022. */
  123023. useNaturalPinchZoom: boolean;
  123024. /**
  123025. * Defines the pointer panning sensibility or how fast is the camera moving.
  123026. */
  123027. panningSensibility: number;
  123028. /**
  123029. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  123030. */
  123031. multiTouchPanning: boolean;
  123032. /**
  123033. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  123034. * zoom (pinch) through multitouch.
  123035. */
  123036. multiTouchPanAndZoom: boolean;
  123037. /**
  123038. * Revers pinch action direction.
  123039. */
  123040. pinchInwards: boolean;
  123041. private _isPanClick;
  123042. private _twoFingerActivityCount;
  123043. private _isPinching;
  123044. /**
  123045. * Called on pointer POINTERMOVE event if only a single touch is active.
  123046. */
  123047. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123048. /**
  123049. * Called on pointer POINTERDOUBLETAP event.
  123050. */
  123051. protected onDoubleTap(type: string): void;
  123052. /**
  123053. * Called on pointer POINTERMOVE event if multiple touches are active.
  123054. */
  123055. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123056. /**
  123057. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123058. * press.
  123059. */
  123060. protected onButtonDown(evt: PointerEvent): void;
  123061. /**
  123062. * Called each time a new POINTERUP event occurs. Ie, for each button
  123063. * release.
  123064. */
  123065. protected onButtonUp(evt: PointerEvent): void;
  123066. /**
  123067. * Called when window becomes inactive.
  123068. */
  123069. protected onLostFocus(): void;
  123070. }
  123071. }
  123072. declare module BABYLON {
  123073. /**
  123074. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  123075. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123076. */
  123077. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  123078. /**
  123079. * Defines the camera the input is attached to.
  123080. */
  123081. camera: ArcRotateCamera;
  123082. /**
  123083. * Defines the list of key codes associated with the up action (increase alpha)
  123084. */
  123085. keysUp: number[];
  123086. /**
  123087. * Defines the list of key codes associated with the down action (decrease alpha)
  123088. */
  123089. keysDown: number[];
  123090. /**
  123091. * Defines the list of key codes associated with the left action (increase beta)
  123092. */
  123093. keysLeft: number[];
  123094. /**
  123095. * Defines the list of key codes associated with the right action (decrease beta)
  123096. */
  123097. keysRight: number[];
  123098. /**
  123099. * Defines the list of key codes associated with the reset action.
  123100. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  123101. */
  123102. keysReset: number[];
  123103. /**
  123104. * Defines the panning sensibility of the inputs.
  123105. * (How fast is the camera panning)
  123106. */
  123107. panningSensibility: number;
  123108. /**
  123109. * Defines the zooming sensibility of the inputs.
  123110. * (How fast is the camera zooming)
  123111. */
  123112. zoomingSensibility: number;
  123113. /**
  123114. * Defines whether maintaining the alt key down switch the movement mode from
  123115. * orientation to zoom.
  123116. */
  123117. useAltToZoom: boolean;
  123118. /**
  123119. * Rotation speed of the camera
  123120. */
  123121. angularSpeed: number;
  123122. private _keys;
  123123. private _ctrlPressed;
  123124. private _altPressed;
  123125. private _onCanvasBlurObserver;
  123126. private _onKeyboardObserver;
  123127. private _engine;
  123128. private _scene;
  123129. /**
  123130. * Attach the input controls to a specific dom element to get the input from.
  123131. * @param element Defines the element the controls should be listened from
  123132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123133. */
  123134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123135. /**
  123136. * Detach the current controls from the specified dom element.
  123137. * @param element Defines the element to stop listening the inputs from
  123138. */
  123139. detachControl(element: Nullable<HTMLElement>): void;
  123140. /**
  123141. * Update the current camera state depending on the inputs that have been used this frame.
  123142. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123143. */
  123144. checkInputs(): void;
  123145. /**
  123146. * Gets the class name of the current intput.
  123147. * @returns the class name
  123148. */
  123149. getClassName(): string;
  123150. /**
  123151. * Get the friendly name associated with the input class.
  123152. * @returns the input friendly name
  123153. */
  123154. getSimpleName(): string;
  123155. }
  123156. }
  123157. declare module BABYLON {
  123158. /**
  123159. * Manage the mouse wheel inputs to control an arc rotate camera.
  123160. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123161. */
  123162. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  123163. /**
  123164. * Defines the camera the input is attached to.
  123165. */
  123166. camera: ArcRotateCamera;
  123167. /**
  123168. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123169. */
  123170. wheelPrecision: number;
  123171. /**
  123172. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123173. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123174. */
  123175. wheelDeltaPercentage: number;
  123176. private _wheel;
  123177. private _observer;
  123178. private computeDeltaFromMouseWheelLegacyEvent;
  123179. /**
  123180. * Attach the input controls to a specific dom element to get the input from.
  123181. * @param element Defines the element the controls should be listened from
  123182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123183. */
  123184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123185. /**
  123186. * Detach the current controls from the specified dom element.
  123187. * @param element Defines the element to stop listening the inputs from
  123188. */
  123189. detachControl(element: Nullable<HTMLElement>): void;
  123190. /**
  123191. * Gets the class name of the current intput.
  123192. * @returns the class name
  123193. */
  123194. getClassName(): string;
  123195. /**
  123196. * Get the friendly name associated with the input class.
  123197. * @returns the input friendly name
  123198. */
  123199. getSimpleName(): string;
  123200. }
  123201. }
  123202. declare module BABYLON {
  123203. /**
  123204. * Default Inputs manager for the ArcRotateCamera.
  123205. * It groups all the default supported inputs for ease of use.
  123206. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123207. */
  123208. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  123209. /**
  123210. * Instantiates a new ArcRotateCameraInputsManager.
  123211. * @param camera Defines the camera the inputs belong to
  123212. */
  123213. constructor(camera: ArcRotateCamera);
  123214. /**
  123215. * Add mouse wheel input support to the input manager.
  123216. * @returns the current input manager
  123217. */
  123218. addMouseWheel(): ArcRotateCameraInputsManager;
  123219. /**
  123220. * Add pointers input support to the input manager.
  123221. * @returns the current input manager
  123222. */
  123223. addPointers(): ArcRotateCameraInputsManager;
  123224. /**
  123225. * Add keyboard input support to the input manager.
  123226. * @returns the current input manager
  123227. */
  123228. addKeyboard(): ArcRotateCameraInputsManager;
  123229. }
  123230. }
  123231. declare module BABYLON {
  123232. /**
  123233. * This represents an orbital type of camera.
  123234. *
  123235. * 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.
  123236. * 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.
  123237. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  123238. */
  123239. export class ArcRotateCamera extends TargetCamera {
  123240. /**
  123241. * Defines the rotation angle of the camera along the longitudinal axis.
  123242. */
  123243. alpha: number;
  123244. /**
  123245. * Defines the rotation angle of the camera along the latitudinal axis.
  123246. */
  123247. beta: number;
  123248. /**
  123249. * Defines the radius of the camera from it s target point.
  123250. */
  123251. radius: number;
  123252. protected _target: Vector3;
  123253. protected _targetHost: Nullable<AbstractMesh>;
  123254. /**
  123255. * Defines the target point of the camera.
  123256. * The camera looks towards it form the radius distance.
  123257. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  123258. */
  123259. get target(): Vector3;
  123260. set target(value: Vector3);
  123261. /**
  123262. * Define the current local position of the camera in the scene
  123263. */
  123264. get position(): Vector3;
  123265. set position(newPosition: Vector3);
  123266. protected _upToYMatrix: Matrix;
  123267. protected _YToUpMatrix: Matrix;
  123268. /**
  123269. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  123270. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  123271. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  123272. */
  123273. set upVector(vec: Vector3);
  123274. get upVector(): Vector3;
  123275. /**
  123276. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  123277. */
  123278. setMatUp(): void;
  123279. /**
  123280. * Current inertia value on the longitudinal axis.
  123281. * The bigger this number the longer it will take for the camera to stop.
  123282. */
  123283. inertialAlphaOffset: number;
  123284. /**
  123285. * Current inertia value on the latitudinal axis.
  123286. * The bigger this number the longer it will take for the camera to stop.
  123287. */
  123288. inertialBetaOffset: number;
  123289. /**
  123290. * Current inertia value on the radius axis.
  123291. * The bigger this number the longer it will take for the camera to stop.
  123292. */
  123293. inertialRadiusOffset: number;
  123294. /**
  123295. * Minimum allowed angle on the longitudinal axis.
  123296. * This can help limiting how the Camera is able to move in the scene.
  123297. */
  123298. lowerAlphaLimit: Nullable<number>;
  123299. /**
  123300. * Maximum allowed angle on the longitudinal axis.
  123301. * This can help limiting how the Camera is able to move in the scene.
  123302. */
  123303. upperAlphaLimit: Nullable<number>;
  123304. /**
  123305. * Minimum allowed angle on the latitudinal axis.
  123306. * This can help limiting how the Camera is able to move in the scene.
  123307. */
  123308. lowerBetaLimit: number;
  123309. /**
  123310. * Maximum allowed angle on the latitudinal axis.
  123311. * This can help limiting how the Camera is able to move in the scene.
  123312. */
  123313. upperBetaLimit: number;
  123314. /**
  123315. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  123316. * This can help limiting how the Camera is able to move in the scene.
  123317. */
  123318. lowerRadiusLimit: Nullable<number>;
  123319. /**
  123320. * Maximum allowed distance of the camera to the target (The camera can not get further).
  123321. * This can help limiting how the Camera is able to move in the scene.
  123322. */
  123323. upperRadiusLimit: Nullable<number>;
  123324. /**
  123325. * Defines the current inertia value used during panning of the camera along the X axis.
  123326. */
  123327. inertialPanningX: number;
  123328. /**
  123329. * Defines the current inertia value used during panning of the camera along the Y axis.
  123330. */
  123331. inertialPanningY: number;
  123332. /**
  123333. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  123334. * Basically if your fingers moves away from more than this distance you will be considered
  123335. * in pinch mode.
  123336. */
  123337. pinchToPanMaxDistance: number;
  123338. /**
  123339. * Defines the maximum distance the camera can pan.
  123340. * This could help keeping the cammera always in your scene.
  123341. */
  123342. panningDistanceLimit: Nullable<number>;
  123343. /**
  123344. * Defines the target of the camera before paning.
  123345. */
  123346. panningOriginTarget: Vector3;
  123347. /**
  123348. * Defines the value of the inertia used during panning.
  123349. * 0 would mean stop inertia and one would mean no decelleration at all.
  123350. */
  123351. panningInertia: number;
  123352. /**
  123353. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  123354. */
  123355. get angularSensibilityX(): number;
  123356. set angularSensibilityX(value: number);
  123357. /**
  123358. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  123359. */
  123360. get angularSensibilityY(): number;
  123361. set angularSensibilityY(value: number);
  123362. /**
  123363. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  123364. */
  123365. get pinchPrecision(): number;
  123366. set pinchPrecision(value: number);
  123367. /**
  123368. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  123369. * It will be used instead of pinchDeltaPrecision if different from 0.
  123370. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123371. */
  123372. get pinchDeltaPercentage(): number;
  123373. set pinchDeltaPercentage(value: number);
  123374. /**
  123375. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  123376. * and pinch delta percentage.
  123377. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123378. * that any object in the plane at the camera's target point will scale
  123379. * perfectly with finger motion.
  123380. */
  123381. get useNaturalPinchZoom(): boolean;
  123382. set useNaturalPinchZoom(value: boolean);
  123383. /**
  123384. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  123385. */
  123386. get panningSensibility(): number;
  123387. set panningSensibility(value: number);
  123388. /**
  123389. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  123390. */
  123391. get keysUp(): number[];
  123392. set keysUp(value: number[]);
  123393. /**
  123394. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  123395. */
  123396. get keysDown(): number[];
  123397. set keysDown(value: number[]);
  123398. /**
  123399. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  123400. */
  123401. get keysLeft(): number[];
  123402. set keysLeft(value: number[]);
  123403. /**
  123404. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  123405. */
  123406. get keysRight(): number[];
  123407. set keysRight(value: number[]);
  123408. /**
  123409. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123410. */
  123411. get wheelPrecision(): number;
  123412. set wheelPrecision(value: number);
  123413. /**
  123414. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  123415. * It will be used instead of pinchDeltaPrecision if different from 0.
  123416. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123417. */
  123418. get wheelDeltaPercentage(): number;
  123419. set wheelDeltaPercentage(value: number);
  123420. /**
  123421. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  123422. */
  123423. zoomOnFactor: number;
  123424. /**
  123425. * Defines a screen offset for the camera position.
  123426. */
  123427. targetScreenOffset: Vector2;
  123428. /**
  123429. * Allows the camera to be completely reversed.
  123430. * If false the camera can not arrive upside down.
  123431. */
  123432. allowUpsideDown: boolean;
  123433. /**
  123434. * Define if double tap/click is used to restore the previously saved state of the camera.
  123435. */
  123436. useInputToRestoreState: boolean;
  123437. /** @hidden */
  123438. _viewMatrix: Matrix;
  123439. /** @hidden */
  123440. _useCtrlForPanning: boolean;
  123441. /** @hidden */
  123442. _panningMouseButton: number;
  123443. /**
  123444. * Defines the input associated to the camera.
  123445. */
  123446. inputs: ArcRotateCameraInputsManager;
  123447. /** @hidden */
  123448. _reset: () => void;
  123449. /**
  123450. * Defines the allowed panning axis.
  123451. */
  123452. panningAxis: Vector3;
  123453. protected _localDirection: Vector3;
  123454. protected _transformedDirection: Vector3;
  123455. private _bouncingBehavior;
  123456. /**
  123457. * Gets the bouncing behavior of the camera if it has been enabled.
  123458. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123459. */
  123460. get bouncingBehavior(): Nullable<BouncingBehavior>;
  123461. /**
  123462. * Defines if the bouncing behavior of the camera is enabled on the camera.
  123463. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123464. */
  123465. get useBouncingBehavior(): boolean;
  123466. set useBouncingBehavior(value: boolean);
  123467. private _framingBehavior;
  123468. /**
  123469. * Gets the framing behavior of the camera if it has been enabled.
  123470. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123471. */
  123472. get framingBehavior(): Nullable<FramingBehavior>;
  123473. /**
  123474. * Defines if the framing behavior of the camera is enabled on the camera.
  123475. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123476. */
  123477. get useFramingBehavior(): boolean;
  123478. set useFramingBehavior(value: boolean);
  123479. private _autoRotationBehavior;
  123480. /**
  123481. * Gets the auto rotation behavior of the camera if it has been enabled.
  123482. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123483. */
  123484. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123485. /**
  123486. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123487. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123488. */
  123489. get useAutoRotationBehavior(): boolean;
  123490. set useAutoRotationBehavior(value: boolean);
  123491. /**
  123492. * Observable triggered when the mesh target has been changed on the camera.
  123493. */
  123494. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123495. /**
  123496. * Event raised when the camera is colliding with a mesh.
  123497. */
  123498. onCollide: (collidedMesh: AbstractMesh) => void;
  123499. /**
  123500. * Defines whether the camera should check collision with the objects oh the scene.
  123501. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123502. */
  123503. checkCollisions: boolean;
  123504. /**
  123505. * Defines the collision radius of the camera.
  123506. * This simulates a sphere around the camera.
  123507. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123508. */
  123509. collisionRadius: Vector3;
  123510. protected _collider: Collider;
  123511. protected _previousPosition: Vector3;
  123512. protected _collisionVelocity: Vector3;
  123513. protected _newPosition: Vector3;
  123514. protected _previousAlpha: number;
  123515. protected _previousBeta: number;
  123516. protected _previousRadius: number;
  123517. protected _collisionTriggered: boolean;
  123518. protected _targetBoundingCenter: Nullable<Vector3>;
  123519. private _computationVector;
  123520. /**
  123521. * Instantiates a new ArcRotateCamera in a given scene
  123522. * @param name Defines the name of the camera
  123523. * @param alpha Defines the camera rotation along the logitudinal axis
  123524. * @param beta Defines the camera rotation along the latitudinal axis
  123525. * @param radius Defines the camera distance from its target
  123526. * @param target Defines the camera target
  123527. * @param scene Defines the scene the camera belongs to
  123528. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123529. */
  123530. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123531. /** @hidden */
  123532. _initCache(): void;
  123533. /** @hidden */
  123534. _updateCache(ignoreParentClass?: boolean): void;
  123535. protected _getTargetPosition(): Vector3;
  123536. private _storedAlpha;
  123537. private _storedBeta;
  123538. private _storedRadius;
  123539. private _storedTarget;
  123540. private _storedTargetScreenOffset;
  123541. /**
  123542. * Stores the current state of the camera (alpha, beta, radius and target)
  123543. * @returns the camera itself
  123544. */
  123545. storeState(): Camera;
  123546. /**
  123547. * @hidden
  123548. * Restored camera state. You must call storeState() first
  123549. */
  123550. _restoreStateValues(): boolean;
  123551. /** @hidden */
  123552. _isSynchronizedViewMatrix(): boolean;
  123553. /**
  123554. * Attached controls to the current camera.
  123555. * @param element Defines the element the controls should be listened from
  123556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123557. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123558. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123559. */
  123560. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123561. /**
  123562. * Detach the current controls from the camera.
  123563. * The camera will stop reacting to inputs.
  123564. * @param element Defines the element to stop listening the inputs from
  123565. */
  123566. detachControl(element: HTMLElement): void;
  123567. /** @hidden */
  123568. _checkInputs(): void;
  123569. protected _checkLimits(): void;
  123570. /**
  123571. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123572. */
  123573. rebuildAnglesAndRadius(): void;
  123574. /**
  123575. * Use a position to define the current camera related information like alpha, beta and radius
  123576. * @param position Defines the position to set the camera at
  123577. */
  123578. setPosition(position: Vector3): void;
  123579. /**
  123580. * Defines the target the camera should look at.
  123581. * This will automatically adapt alpha beta and radius to fit within the new target.
  123582. * @param target Defines the new target as a Vector or a mesh
  123583. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123584. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123585. */
  123586. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123587. /** @hidden */
  123588. _getViewMatrix(): Matrix;
  123589. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123590. /**
  123591. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123592. * @param meshes Defines the mesh to zoom on
  123593. * @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)
  123594. */
  123595. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123596. /**
  123597. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123598. * The target will be changed but the radius
  123599. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123600. * @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)
  123601. */
  123602. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123603. min: Vector3;
  123604. max: Vector3;
  123605. distance: number;
  123606. }, doNotUpdateMaxZ?: boolean): void;
  123607. /**
  123608. * @override
  123609. * Override Camera.createRigCamera
  123610. */
  123611. createRigCamera(name: string, cameraIndex: number): Camera;
  123612. /**
  123613. * @hidden
  123614. * @override
  123615. * Override Camera._updateRigCameras
  123616. */
  123617. _updateRigCameras(): void;
  123618. /**
  123619. * Destroy the camera and release the current resources hold by it.
  123620. */
  123621. dispose(): void;
  123622. /**
  123623. * Gets the current object class name.
  123624. * @return the class name
  123625. */
  123626. getClassName(): string;
  123627. }
  123628. }
  123629. declare module BABYLON {
  123630. /**
  123631. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123632. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123633. */
  123634. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123635. /**
  123636. * Gets the name of the behavior.
  123637. */
  123638. get name(): string;
  123639. private _zoomStopsAnimation;
  123640. private _idleRotationSpeed;
  123641. private _idleRotationWaitTime;
  123642. private _idleRotationSpinupTime;
  123643. /**
  123644. * Sets the flag that indicates if user zooming should stop animation.
  123645. */
  123646. set zoomStopsAnimation(flag: boolean);
  123647. /**
  123648. * Gets the flag that indicates if user zooming should stop animation.
  123649. */
  123650. get zoomStopsAnimation(): boolean;
  123651. /**
  123652. * Sets the default speed at which the camera rotates around the model.
  123653. */
  123654. set idleRotationSpeed(speed: number);
  123655. /**
  123656. * Gets the default speed at which the camera rotates around the model.
  123657. */
  123658. get idleRotationSpeed(): number;
  123659. /**
  123660. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123661. */
  123662. set idleRotationWaitTime(time: number);
  123663. /**
  123664. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123665. */
  123666. get idleRotationWaitTime(): number;
  123667. /**
  123668. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123669. */
  123670. set idleRotationSpinupTime(time: number);
  123671. /**
  123672. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123673. */
  123674. get idleRotationSpinupTime(): number;
  123675. /**
  123676. * Gets a value indicating if the camera is currently rotating because of this behavior
  123677. */
  123678. get rotationInProgress(): boolean;
  123679. private _onPrePointerObservableObserver;
  123680. private _onAfterCheckInputsObserver;
  123681. private _attachedCamera;
  123682. private _isPointerDown;
  123683. private _lastFrameTime;
  123684. private _lastInteractionTime;
  123685. private _cameraRotationSpeed;
  123686. /**
  123687. * Initializes the behavior.
  123688. */
  123689. init(): void;
  123690. /**
  123691. * Attaches the behavior to its arc rotate camera.
  123692. * @param camera Defines the camera to attach the behavior to
  123693. */
  123694. attach(camera: ArcRotateCamera): void;
  123695. /**
  123696. * Detaches the behavior from its current arc rotate camera.
  123697. */
  123698. detach(): void;
  123699. /**
  123700. * Returns true if user is scrolling.
  123701. * @return true if user is scrolling.
  123702. */
  123703. private _userIsZooming;
  123704. private _lastFrameRadius;
  123705. private _shouldAnimationStopForInteraction;
  123706. /**
  123707. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123708. */
  123709. private _applyUserInteraction;
  123710. private _userIsMoving;
  123711. }
  123712. }
  123713. declare module BABYLON {
  123714. /**
  123715. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  123716. */
  123717. export class AttachToBoxBehavior implements Behavior<Mesh> {
  123718. private ui;
  123719. /**
  123720. * The name of the behavior
  123721. */
  123722. name: string;
  123723. /**
  123724. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  123725. */
  123726. distanceAwayFromFace: number;
  123727. /**
  123728. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  123729. */
  123730. distanceAwayFromBottomOfFace: number;
  123731. private _faceVectors;
  123732. private _target;
  123733. private _scene;
  123734. private _onRenderObserver;
  123735. private _tmpMatrix;
  123736. private _tmpVector;
  123737. /**
  123738. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123739. * @param ui The transform node that should be attched to the mesh
  123740. */
  123741. constructor(ui: TransformNode);
  123742. /**
  123743. * Initializes the behavior
  123744. */
  123745. init(): void;
  123746. private _closestFace;
  123747. private _zeroVector;
  123748. private _lookAtTmpMatrix;
  123749. private _lookAtToRef;
  123750. /**
  123751. * Attaches the AttachToBoxBehavior to the passed in mesh
  123752. * @param target The mesh that the specified node will be attached to
  123753. */
  123754. attach(target: Mesh): void;
  123755. /**
  123756. * Detaches the behavior from the mesh
  123757. */
  123758. detach(): void;
  123759. }
  123760. }
  123761. declare module BABYLON {
  123762. /**
  123763. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123764. */
  123765. export class FadeInOutBehavior implements Behavior<Mesh> {
  123766. /**
  123767. * Time in milliseconds to delay before fading in (Default: 0)
  123768. */
  123769. delay: number;
  123770. /**
  123771. * Time in milliseconds for the mesh to fade in (Default: 300)
  123772. */
  123773. fadeInTime: number;
  123774. private _millisecondsPerFrame;
  123775. private _hovered;
  123776. private _hoverValue;
  123777. private _ownerNode;
  123778. /**
  123779. * Instatiates the FadeInOutBehavior
  123780. */
  123781. constructor();
  123782. /**
  123783. * The name of the behavior
  123784. */
  123785. get name(): string;
  123786. /**
  123787. * Initializes the behavior
  123788. */
  123789. init(): void;
  123790. /**
  123791. * Attaches the fade behavior on the passed in mesh
  123792. * @param ownerNode The mesh that will be faded in/out once attached
  123793. */
  123794. attach(ownerNode: Mesh): void;
  123795. /**
  123796. * Detaches the behavior from the mesh
  123797. */
  123798. detach(): void;
  123799. /**
  123800. * Triggers the mesh to begin fading in or out
  123801. * @param value if the object should fade in or out (true to fade in)
  123802. */
  123803. fadeIn(value: boolean): void;
  123804. private _update;
  123805. private _setAllVisibility;
  123806. }
  123807. }
  123808. declare module BABYLON {
  123809. /**
  123810. * Class containing a set of static utilities functions for managing Pivots
  123811. * @hidden
  123812. */
  123813. export class PivotTools {
  123814. private static _PivotCached;
  123815. private static _OldPivotPoint;
  123816. private static _PivotTranslation;
  123817. private static _PivotTmpVector;
  123818. private static _PivotPostMultiplyPivotMatrix;
  123819. /** @hidden */
  123820. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123821. /** @hidden */
  123822. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123823. }
  123824. }
  123825. declare module BABYLON {
  123826. /**
  123827. * Class containing static functions to help procedurally build meshes
  123828. */
  123829. export class PlaneBuilder {
  123830. /**
  123831. * Creates a plane mesh
  123832. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123833. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123834. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123838. * @param name defines the name of the mesh
  123839. * @param options defines the options used to create the mesh
  123840. * @param scene defines the hosting scene
  123841. * @returns the plane mesh
  123842. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123843. */
  123844. static CreatePlane(name: string, options: {
  123845. size?: number;
  123846. width?: number;
  123847. height?: number;
  123848. sideOrientation?: number;
  123849. frontUVs?: Vector4;
  123850. backUVs?: Vector4;
  123851. updatable?: boolean;
  123852. sourcePlane?: Plane;
  123853. }, scene?: Nullable<Scene>): Mesh;
  123854. }
  123855. }
  123856. declare module BABYLON {
  123857. /**
  123858. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123859. */
  123860. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123861. private static _AnyMouseID;
  123862. /**
  123863. * Abstract mesh the behavior is set on
  123864. */
  123865. attachedNode: AbstractMesh;
  123866. private _dragPlane;
  123867. private _scene;
  123868. private _pointerObserver;
  123869. private _beforeRenderObserver;
  123870. private static _planeScene;
  123871. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123872. /**
  123873. * 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)
  123874. */
  123875. maxDragAngle: number;
  123876. /**
  123877. * @hidden
  123878. */
  123879. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123880. /**
  123881. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123882. */
  123883. currentDraggingPointerID: number;
  123884. /**
  123885. * The last position where the pointer hit the drag plane in world space
  123886. */
  123887. lastDragPosition: Vector3;
  123888. /**
  123889. * If the behavior is currently in a dragging state
  123890. */
  123891. dragging: boolean;
  123892. /**
  123893. * 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)
  123894. */
  123895. dragDeltaRatio: number;
  123896. /**
  123897. * If the drag plane orientation should be updated during the dragging (Default: true)
  123898. */
  123899. updateDragPlane: boolean;
  123900. private _debugMode;
  123901. private _moving;
  123902. /**
  123903. * Fires each time the attached mesh is dragged with the pointer
  123904. * * delta between last drag position and current drag position in world space
  123905. * * dragDistance along the drag axis
  123906. * * dragPlaneNormal normal of the current drag plane used during the drag
  123907. * * dragPlanePoint in world space where the drag intersects the drag plane
  123908. */
  123909. onDragObservable: Observable<{
  123910. delta: Vector3;
  123911. dragPlanePoint: Vector3;
  123912. dragPlaneNormal: Vector3;
  123913. dragDistance: number;
  123914. pointerId: number;
  123915. }>;
  123916. /**
  123917. * Fires each time a drag begins (eg. mouse down on mesh)
  123918. */
  123919. onDragStartObservable: Observable<{
  123920. dragPlanePoint: Vector3;
  123921. pointerId: number;
  123922. }>;
  123923. /**
  123924. * Fires each time a drag ends (eg. mouse release after drag)
  123925. */
  123926. onDragEndObservable: Observable<{
  123927. dragPlanePoint: Vector3;
  123928. pointerId: number;
  123929. }>;
  123930. /**
  123931. * If the attached mesh should be moved when dragged
  123932. */
  123933. moveAttached: boolean;
  123934. /**
  123935. * If the drag behavior will react to drag events (Default: true)
  123936. */
  123937. enabled: boolean;
  123938. /**
  123939. * If pointer events should start and release the drag (Default: true)
  123940. */
  123941. startAndReleaseDragOnPointerEvents: boolean;
  123942. /**
  123943. * If camera controls should be detached during the drag
  123944. */
  123945. detachCameraControls: boolean;
  123946. /**
  123947. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123948. */
  123949. useObjectOrientationForDragging: boolean;
  123950. private _options;
  123951. /**
  123952. * Gets the options used by the behavior
  123953. */
  123954. get options(): {
  123955. dragAxis?: Vector3;
  123956. dragPlaneNormal?: Vector3;
  123957. };
  123958. /**
  123959. * Sets the options used by the behavior
  123960. */
  123961. set options(options: {
  123962. dragAxis?: Vector3;
  123963. dragPlaneNormal?: Vector3;
  123964. });
  123965. /**
  123966. * Creates a pointer drag behavior that can be attached to a mesh
  123967. * @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)
  123968. */
  123969. constructor(options?: {
  123970. dragAxis?: Vector3;
  123971. dragPlaneNormal?: Vector3;
  123972. });
  123973. /**
  123974. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123975. */
  123976. validateDrag: (targetPosition: Vector3) => boolean;
  123977. /**
  123978. * The name of the behavior
  123979. */
  123980. get name(): string;
  123981. /**
  123982. * Initializes the behavior
  123983. */
  123984. init(): void;
  123985. private _tmpVector;
  123986. private _alternatePickedPoint;
  123987. private _worldDragAxis;
  123988. private _targetPosition;
  123989. private _attachedElement;
  123990. /**
  123991. * Attaches the drag behavior the passed in mesh
  123992. * @param ownerNode The mesh that will be dragged around once attached
  123993. * @param predicate Predicate to use for pick filtering
  123994. */
  123995. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123996. /**
  123997. * Force relase the drag action by code.
  123998. */
  123999. releaseDrag(): void;
  124000. private _startDragRay;
  124001. private _lastPointerRay;
  124002. /**
  124003. * Simulates the start of a pointer drag event on the behavior
  124004. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  124005. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  124006. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  124007. */
  124008. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124009. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124010. private _dragDelta;
  124011. protected _moveDrag(ray: Ray): void;
  124012. private _pickWithRayOnDragPlane;
  124013. private _pointA;
  124014. private _pointC;
  124015. private _localAxis;
  124016. private _lookAt;
  124017. private _updateDragPlanePosition;
  124018. /**
  124019. * Detaches the behavior from the mesh
  124020. */
  124021. detach(): void;
  124022. }
  124023. }
  124024. declare module BABYLON {
  124025. /**
  124026. * A behavior that when attached to a mesh will allow the mesh to be scaled
  124027. */
  124028. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  124029. private _dragBehaviorA;
  124030. private _dragBehaviorB;
  124031. private _startDistance;
  124032. private _initialScale;
  124033. private _targetScale;
  124034. private _ownerNode;
  124035. private _sceneRenderObserver;
  124036. /**
  124037. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  124038. */
  124039. constructor();
  124040. /**
  124041. * The name of the behavior
  124042. */
  124043. get name(): string;
  124044. /**
  124045. * Initializes the behavior
  124046. */
  124047. init(): void;
  124048. private _getCurrentDistance;
  124049. /**
  124050. * Attaches the scale behavior the passed in mesh
  124051. * @param ownerNode The mesh that will be scaled around once attached
  124052. */
  124053. attach(ownerNode: Mesh): void;
  124054. /**
  124055. * Detaches the behavior from the mesh
  124056. */
  124057. detach(): void;
  124058. }
  124059. }
  124060. declare module BABYLON {
  124061. /**
  124062. * 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
  124063. */
  124064. export class SixDofDragBehavior implements Behavior<Mesh> {
  124065. private static _virtualScene;
  124066. private _ownerNode;
  124067. private _sceneRenderObserver;
  124068. private _scene;
  124069. private _targetPosition;
  124070. private _virtualOriginMesh;
  124071. private _virtualDragMesh;
  124072. private _pointerObserver;
  124073. private _moving;
  124074. private _startingOrientation;
  124075. private _attachedElement;
  124076. /**
  124077. * 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)
  124078. */
  124079. private zDragFactor;
  124080. /**
  124081. * If the object should rotate to face the drag origin
  124082. */
  124083. rotateDraggedObject: boolean;
  124084. /**
  124085. * If the behavior is currently in a dragging state
  124086. */
  124087. dragging: boolean;
  124088. /**
  124089. * 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)
  124090. */
  124091. dragDeltaRatio: number;
  124092. /**
  124093. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124094. */
  124095. currentDraggingPointerID: number;
  124096. /**
  124097. * If camera controls should be detached during the drag
  124098. */
  124099. detachCameraControls: boolean;
  124100. /**
  124101. * Fires each time a drag starts
  124102. */
  124103. onDragStartObservable: Observable<{}>;
  124104. /**
  124105. * Fires each time a drag ends (eg. mouse release after drag)
  124106. */
  124107. onDragEndObservable: Observable<{}>;
  124108. /**
  124109. * 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
  124110. */
  124111. constructor();
  124112. /**
  124113. * The name of the behavior
  124114. */
  124115. get name(): string;
  124116. /**
  124117. * Initializes the behavior
  124118. */
  124119. init(): void;
  124120. /**
  124121. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  124122. */
  124123. private get _pointerCamera();
  124124. /**
  124125. * Attaches the scale behavior the passed in mesh
  124126. * @param ownerNode The mesh that will be scaled around once attached
  124127. */
  124128. attach(ownerNode: Mesh): void;
  124129. /**
  124130. * Detaches the behavior from the mesh
  124131. */
  124132. detach(): void;
  124133. }
  124134. }
  124135. declare module BABYLON {
  124136. /**
  124137. * Class used to apply inverse kinematics to bones
  124138. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  124139. */
  124140. export class BoneIKController {
  124141. private static _tmpVecs;
  124142. private static _tmpQuat;
  124143. private static _tmpMats;
  124144. /**
  124145. * Gets or sets the target mesh
  124146. */
  124147. targetMesh: AbstractMesh;
  124148. /** Gets or sets the mesh used as pole */
  124149. poleTargetMesh: AbstractMesh;
  124150. /**
  124151. * Gets or sets the bone used as pole
  124152. */
  124153. poleTargetBone: Nullable<Bone>;
  124154. /**
  124155. * Gets or sets the target position
  124156. */
  124157. targetPosition: Vector3;
  124158. /**
  124159. * Gets or sets the pole target position
  124160. */
  124161. poleTargetPosition: Vector3;
  124162. /**
  124163. * Gets or sets the pole target local offset
  124164. */
  124165. poleTargetLocalOffset: Vector3;
  124166. /**
  124167. * Gets or sets the pole angle
  124168. */
  124169. poleAngle: number;
  124170. /**
  124171. * Gets or sets the mesh associated with the controller
  124172. */
  124173. mesh: AbstractMesh;
  124174. /**
  124175. * 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)
  124176. */
  124177. slerpAmount: number;
  124178. private _bone1Quat;
  124179. private _bone1Mat;
  124180. private _bone2Ang;
  124181. private _bone1;
  124182. private _bone2;
  124183. private _bone1Length;
  124184. private _bone2Length;
  124185. private _maxAngle;
  124186. private _maxReach;
  124187. private _rightHandedSystem;
  124188. private _bendAxis;
  124189. private _slerping;
  124190. private _adjustRoll;
  124191. /**
  124192. * Gets or sets maximum allowed angle
  124193. */
  124194. get maxAngle(): number;
  124195. set maxAngle(value: number);
  124196. /**
  124197. * Creates a new BoneIKController
  124198. * @param mesh defines the mesh to control
  124199. * @param bone defines the bone to control
  124200. * @param options defines options to set up the controller
  124201. */
  124202. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  124203. targetMesh?: AbstractMesh;
  124204. poleTargetMesh?: AbstractMesh;
  124205. poleTargetBone?: Bone;
  124206. poleTargetLocalOffset?: Vector3;
  124207. poleAngle?: number;
  124208. bendAxis?: Vector3;
  124209. maxAngle?: number;
  124210. slerpAmount?: number;
  124211. });
  124212. private _setMaxAngle;
  124213. /**
  124214. * Force the controller to update the bones
  124215. */
  124216. update(): void;
  124217. }
  124218. }
  124219. declare module BABYLON {
  124220. /**
  124221. * Class used to make a bone look toward a point in space
  124222. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  124223. */
  124224. export class BoneLookController {
  124225. private static _tmpVecs;
  124226. private static _tmpQuat;
  124227. private static _tmpMats;
  124228. /**
  124229. * The target Vector3 that the bone will look at
  124230. */
  124231. target: Vector3;
  124232. /**
  124233. * The mesh that the bone is attached to
  124234. */
  124235. mesh: AbstractMesh;
  124236. /**
  124237. * The bone that will be looking to the target
  124238. */
  124239. bone: Bone;
  124240. /**
  124241. * The up axis of the coordinate system that is used when the bone is rotated
  124242. */
  124243. upAxis: Vector3;
  124244. /**
  124245. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  124246. */
  124247. upAxisSpace: Space;
  124248. /**
  124249. * Used to make an adjustment to the yaw of the bone
  124250. */
  124251. adjustYaw: number;
  124252. /**
  124253. * Used to make an adjustment to the pitch of the bone
  124254. */
  124255. adjustPitch: number;
  124256. /**
  124257. * Used to make an adjustment to the roll of the bone
  124258. */
  124259. adjustRoll: number;
  124260. /**
  124261. * 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)
  124262. */
  124263. slerpAmount: number;
  124264. private _minYaw;
  124265. private _maxYaw;
  124266. private _minPitch;
  124267. private _maxPitch;
  124268. private _minYawSin;
  124269. private _minYawCos;
  124270. private _maxYawSin;
  124271. private _maxYawCos;
  124272. private _midYawConstraint;
  124273. private _minPitchTan;
  124274. private _maxPitchTan;
  124275. private _boneQuat;
  124276. private _slerping;
  124277. private _transformYawPitch;
  124278. private _transformYawPitchInv;
  124279. private _firstFrameSkipped;
  124280. private _yawRange;
  124281. private _fowardAxis;
  124282. /**
  124283. * Gets or sets the minimum yaw angle that the bone can look to
  124284. */
  124285. get minYaw(): number;
  124286. set minYaw(value: number);
  124287. /**
  124288. * Gets or sets the maximum yaw angle that the bone can look to
  124289. */
  124290. get maxYaw(): number;
  124291. set maxYaw(value: number);
  124292. /**
  124293. * Gets or sets the minimum pitch angle that the bone can look to
  124294. */
  124295. get minPitch(): number;
  124296. set minPitch(value: number);
  124297. /**
  124298. * Gets or sets the maximum pitch angle that the bone can look to
  124299. */
  124300. get maxPitch(): number;
  124301. set maxPitch(value: number);
  124302. /**
  124303. * Create a BoneLookController
  124304. * @param mesh the mesh that the bone belongs to
  124305. * @param bone the bone that will be looking to the target
  124306. * @param target the target Vector3 to look at
  124307. * @param options optional settings:
  124308. * * maxYaw: the maximum angle the bone will yaw to
  124309. * * minYaw: the minimum angle the bone will yaw to
  124310. * * maxPitch: the maximum angle the bone will pitch to
  124311. * * minPitch: the minimum angle the bone will yaw to
  124312. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  124313. * * upAxis: the up axis of the coordinate system
  124314. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  124315. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  124316. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  124317. * * adjustYaw: used to make an adjustment to the yaw of the bone
  124318. * * adjustPitch: used to make an adjustment to the pitch of the bone
  124319. * * adjustRoll: used to make an adjustment to the roll of the bone
  124320. **/
  124321. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  124322. maxYaw?: number;
  124323. minYaw?: number;
  124324. maxPitch?: number;
  124325. minPitch?: number;
  124326. slerpAmount?: number;
  124327. upAxis?: Vector3;
  124328. upAxisSpace?: Space;
  124329. yawAxis?: Vector3;
  124330. pitchAxis?: Vector3;
  124331. adjustYaw?: number;
  124332. adjustPitch?: number;
  124333. adjustRoll?: number;
  124334. });
  124335. /**
  124336. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  124337. */
  124338. update(): void;
  124339. private _getAngleDiff;
  124340. private _getAngleBetween;
  124341. private _isAngleBetween;
  124342. }
  124343. }
  124344. declare module BABYLON {
  124345. /**
  124346. * Manage the gamepad inputs to control an arc rotate camera.
  124347. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124348. */
  124349. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  124350. /**
  124351. * Defines the camera the input is attached to.
  124352. */
  124353. camera: ArcRotateCamera;
  124354. /**
  124355. * Defines the gamepad the input is gathering event from.
  124356. */
  124357. gamepad: Nullable<Gamepad>;
  124358. /**
  124359. * Defines the gamepad rotation sensiblity.
  124360. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124361. */
  124362. gamepadRotationSensibility: number;
  124363. /**
  124364. * Defines the gamepad move sensiblity.
  124365. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124366. */
  124367. gamepadMoveSensibility: number;
  124368. private _yAxisScale;
  124369. /**
  124370. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124371. */
  124372. get invertYAxis(): boolean;
  124373. set invertYAxis(value: boolean);
  124374. private _onGamepadConnectedObserver;
  124375. private _onGamepadDisconnectedObserver;
  124376. /**
  124377. * Attach the input controls to a specific dom element to get the input from.
  124378. * @param element Defines the element the controls should be listened from
  124379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124380. */
  124381. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124382. /**
  124383. * Detach the current controls from the specified dom element.
  124384. * @param element Defines the element to stop listening the inputs from
  124385. */
  124386. detachControl(element: Nullable<HTMLElement>): void;
  124387. /**
  124388. * Update the current camera state depending on the inputs that have been used this frame.
  124389. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124390. */
  124391. checkInputs(): void;
  124392. /**
  124393. * Gets the class name of the current intput.
  124394. * @returns the class name
  124395. */
  124396. getClassName(): string;
  124397. /**
  124398. * Get the friendly name associated with the input class.
  124399. * @returns the input friendly name
  124400. */
  124401. getSimpleName(): string;
  124402. }
  124403. }
  124404. declare module BABYLON {
  124405. interface ArcRotateCameraInputsManager {
  124406. /**
  124407. * Add orientation input support to the input manager.
  124408. * @returns the current input manager
  124409. */
  124410. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  124411. }
  124412. /**
  124413. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  124414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124415. */
  124416. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  124417. /**
  124418. * Defines the camera the input is attached to.
  124419. */
  124420. camera: ArcRotateCamera;
  124421. /**
  124422. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  124423. */
  124424. alphaCorrection: number;
  124425. /**
  124426. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  124427. */
  124428. gammaCorrection: number;
  124429. private _alpha;
  124430. private _gamma;
  124431. private _dirty;
  124432. private _deviceOrientationHandler;
  124433. /**
  124434. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  124435. */
  124436. constructor();
  124437. /**
  124438. * Attach the input controls to a specific dom element to get the input from.
  124439. * @param element Defines the element the controls should be listened from
  124440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124441. */
  124442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124443. /** @hidden */
  124444. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  124445. /**
  124446. * Update the current camera state depending on the inputs that have been used this frame.
  124447. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124448. */
  124449. checkInputs(): void;
  124450. /**
  124451. * Detach the current controls from the specified dom element.
  124452. * @param element Defines the element to stop listening the inputs from
  124453. */
  124454. detachControl(element: Nullable<HTMLElement>): void;
  124455. /**
  124456. * Gets the class name of the current intput.
  124457. * @returns the class name
  124458. */
  124459. getClassName(): string;
  124460. /**
  124461. * Get the friendly name associated with the input class.
  124462. * @returns the input friendly name
  124463. */
  124464. getSimpleName(): string;
  124465. }
  124466. }
  124467. declare module BABYLON {
  124468. /**
  124469. * Listen to mouse events to control the camera.
  124470. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124471. */
  124472. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  124473. /**
  124474. * Defines the camera the input is attached to.
  124475. */
  124476. camera: FlyCamera;
  124477. /**
  124478. * Defines if touch is enabled. (Default is true.)
  124479. */
  124480. touchEnabled: boolean;
  124481. /**
  124482. * Defines the buttons associated with the input to handle camera rotation.
  124483. */
  124484. buttons: number[];
  124485. /**
  124486. * Assign buttons for Yaw control.
  124487. */
  124488. buttonsYaw: number[];
  124489. /**
  124490. * Assign buttons for Pitch control.
  124491. */
  124492. buttonsPitch: number[];
  124493. /**
  124494. * Assign buttons for Roll control.
  124495. */
  124496. buttonsRoll: number[];
  124497. /**
  124498. * Detect if any button is being pressed while mouse is moved.
  124499. * -1 = Mouse locked.
  124500. * 0 = Left button.
  124501. * 1 = Middle Button.
  124502. * 2 = Right Button.
  124503. */
  124504. activeButton: number;
  124505. /**
  124506. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124507. * Higher values reduce its sensitivity.
  124508. */
  124509. angularSensibility: number;
  124510. private _mousemoveCallback;
  124511. private _observer;
  124512. private _rollObserver;
  124513. private previousPosition;
  124514. private noPreventDefault;
  124515. private element;
  124516. /**
  124517. * Listen to mouse events to control the camera.
  124518. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124519. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124520. */
  124521. constructor(touchEnabled?: boolean);
  124522. /**
  124523. * Attach the mouse control to the HTML DOM element.
  124524. * @param element Defines the element that listens to the input events.
  124525. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124526. */
  124527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124528. /**
  124529. * Detach the current controls from the specified dom element.
  124530. * @param element Defines the element to stop listening the inputs from
  124531. */
  124532. detachControl(element: Nullable<HTMLElement>): void;
  124533. /**
  124534. * Gets the class name of the current input.
  124535. * @returns the class name.
  124536. */
  124537. getClassName(): string;
  124538. /**
  124539. * Get the friendly name associated with the input class.
  124540. * @returns the input's friendly name.
  124541. */
  124542. getSimpleName(): string;
  124543. private _pointerInput;
  124544. private _onMouseMove;
  124545. /**
  124546. * Rotate camera by mouse offset.
  124547. */
  124548. private rotateCamera;
  124549. }
  124550. }
  124551. declare module BABYLON {
  124552. /**
  124553. * Default Inputs manager for the FlyCamera.
  124554. * It groups all the default supported inputs for ease of use.
  124555. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124556. */
  124557. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124558. /**
  124559. * Instantiates a new FlyCameraInputsManager.
  124560. * @param camera Defines the camera the inputs belong to.
  124561. */
  124562. constructor(camera: FlyCamera);
  124563. /**
  124564. * Add keyboard input support to the input manager.
  124565. * @returns the new FlyCameraKeyboardMoveInput().
  124566. */
  124567. addKeyboard(): FlyCameraInputsManager;
  124568. /**
  124569. * Add mouse input support to the input manager.
  124570. * @param touchEnabled Enable touch screen support.
  124571. * @returns the new FlyCameraMouseInput().
  124572. */
  124573. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124574. }
  124575. }
  124576. declare module BABYLON {
  124577. /**
  124578. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124579. * such as in a 3D Space Shooter or a Flight Simulator.
  124580. */
  124581. export class FlyCamera extends TargetCamera {
  124582. /**
  124583. * Define the collision ellipsoid of the camera.
  124584. * This is helpful for simulating a camera body, like a player's body.
  124585. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124586. */
  124587. ellipsoid: Vector3;
  124588. /**
  124589. * Define an offset for the position of the ellipsoid around the camera.
  124590. * This can be helpful if the camera is attached away from the player's body center,
  124591. * such as at its head.
  124592. */
  124593. ellipsoidOffset: Vector3;
  124594. /**
  124595. * Enable or disable collisions of the camera with the rest of the scene objects.
  124596. */
  124597. checkCollisions: boolean;
  124598. /**
  124599. * Enable or disable gravity on the camera.
  124600. */
  124601. applyGravity: boolean;
  124602. /**
  124603. * Define the current direction the camera is moving to.
  124604. */
  124605. cameraDirection: Vector3;
  124606. /**
  124607. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124608. * This overrides and empties cameraRotation.
  124609. */
  124610. rotationQuaternion: Quaternion;
  124611. /**
  124612. * Track Roll to maintain the wanted Rolling when looking around.
  124613. */
  124614. _trackRoll: number;
  124615. /**
  124616. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124617. */
  124618. rollCorrect: number;
  124619. /**
  124620. * Mimic a banked turn, Rolling the camera when Yawing.
  124621. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124622. */
  124623. bankedTurn: boolean;
  124624. /**
  124625. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124626. */
  124627. bankedTurnLimit: number;
  124628. /**
  124629. * Value of 0 disables the banked Roll.
  124630. * Value of 1 is equal to the Yaw angle in radians.
  124631. */
  124632. bankedTurnMultiplier: number;
  124633. /**
  124634. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124635. */
  124636. inputs: FlyCameraInputsManager;
  124637. /**
  124638. * Gets the input sensibility for mouse input.
  124639. * Higher values reduce sensitivity.
  124640. */
  124641. get angularSensibility(): number;
  124642. /**
  124643. * Sets the input sensibility for a mouse input.
  124644. * Higher values reduce sensitivity.
  124645. */
  124646. set angularSensibility(value: number);
  124647. /**
  124648. * Get the keys for camera movement forward.
  124649. */
  124650. get keysForward(): number[];
  124651. /**
  124652. * Set the keys for camera movement forward.
  124653. */
  124654. set keysForward(value: number[]);
  124655. /**
  124656. * Get the keys for camera movement backward.
  124657. */
  124658. get keysBackward(): number[];
  124659. set keysBackward(value: number[]);
  124660. /**
  124661. * Get the keys for camera movement up.
  124662. */
  124663. get keysUp(): number[];
  124664. /**
  124665. * Set the keys for camera movement up.
  124666. */
  124667. set keysUp(value: number[]);
  124668. /**
  124669. * Get the keys for camera movement down.
  124670. */
  124671. get keysDown(): number[];
  124672. /**
  124673. * Set the keys for camera movement down.
  124674. */
  124675. set keysDown(value: number[]);
  124676. /**
  124677. * Get the keys for camera movement left.
  124678. */
  124679. get keysLeft(): number[];
  124680. /**
  124681. * Set the keys for camera movement left.
  124682. */
  124683. set keysLeft(value: number[]);
  124684. /**
  124685. * Set the keys for camera movement right.
  124686. */
  124687. get keysRight(): number[];
  124688. /**
  124689. * Set the keys for camera movement right.
  124690. */
  124691. set keysRight(value: number[]);
  124692. /**
  124693. * Event raised when the camera collides with a mesh in the scene.
  124694. */
  124695. onCollide: (collidedMesh: AbstractMesh) => void;
  124696. private _collider;
  124697. private _needMoveForGravity;
  124698. private _oldPosition;
  124699. private _diffPosition;
  124700. private _newPosition;
  124701. /** @hidden */
  124702. _localDirection: Vector3;
  124703. /** @hidden */
  124704. _transformedDirection: Vector3;
  124705. /**
  124706. * Instantiates a FlyCamera.
  124707. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124708. * such as in a 3D Space Shooter or a Flight Simulator.
  124709. * @param name Define the name of the camera in the scene.
  124710. * @param position Define the starting position of the camera in the scene.
  124711. * @param scene Define the scene the camera belongs to.
  124712. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  124713. */
  124714. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  124715. /**
  124716. * Attach a control to the HTML DOM element.
  124717. * @param element Defines the element that listens to the input events.
  124718. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  124719. */
  124720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124721. /**
  124722. * Detach a control from the HTML DOM element.
  124723. * The camera will stop reacting to that input.
  124724. * @param element Defines the element that listens to the input events.
  124725. */
  124726. detachControl(element: HTMLElement): void;
  124727. private _collisionMask;
  124728. /**
  124729. * Get the mask that the camera ignores in collision events.
  124730. */
  124731. get collisionMask(): number;
  124732. /**
  124733. * Set the mask that the camera ignores in collision events.
  124734. */
  124735. set collisionMask(mask: number);
  124736. /** @hidden */
  124737. _collideWithWorld(displacement: Vector3): void;
  124738. /** @hidden */
  124739. private _onCollisionPositionChange;
  124740. /** @hidden */
  124741. _checkInputs(): void;
  124742. /** @hidden */
  124743. _decideIfNeedsToMove(): boolean;
  124744. /** @hidden */
  124745. _updatePosition(): void;
  124746. /**
  124747. * Restore the Roll to its target value at the rate specified.
  124748. * @param rate - Higher means slower restoring.
  124749. * @hidden
  124750. */
  124751. restoreRoll(rate: number): void;
  124752. /**
  124753. * Destroy the camera and release the current resources held by it.
  124754. */
  124755. dispose(): void;
  124756. /**
  124757. * Get the current object class name.
  124758. * @returns the class name.
  124759. */
  124760. getClassName(): string;
  124761. }
  124762. }
  124763. declare module BABYLON {
  124764. /**
  124765. * Listen to keyboard events to control the camera.
  124766. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124767. */
  124768. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124769. /**
  124770. * Defines the camera the input is attached to.
  124771. */
  124772. camera: FlyCamera;
  124773. /**
  124774. * The list of keyboard keys used to control the forward move of the camera.
  124775. */
  124776. keysForward: number[];
  124777. /**
  124778. * The list of keyboard keys used to control the backward move of the camera.
  124779. */
  124780. keysBackward: number[];
  124781. /**
  124782. * The list of keyboard keys used to control the forward move of the camera.
  124783. */
  124784. keysUp: number[];
  124785. /**
  124786. * The list of keyboard keys used to control the backward move of the camera.
  124787. */
  124788. keysDown: number[];
  124789. /**
  124790. * The list of keyboard keys used to control the right strafe move of the camera.
  124791. */
  124792. keysRight: number[];
  124793. /**
  124794. * The list of keyboard keys used to control the left strafe move of the camera.
  124795. */
  124796. keysLeft: number[];
  124797. private _keys;
  124798. private _onCanvasBlurObserver;
  124799. private _onKeyboardObserver;
  124800. private _engine;
  124801. private _scene;
  124802. /**
  124803. * Attach the input controls to a specific dom element to get the input from.
  124804. * @param element Defines the element the controls should be listened from
  124805. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124806. */
  124807. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124808. /**
  124809. * Detach the current controls from the specified dom element.
  124810. * @param element Defines the element to stop listening the inputs from
  124811. */
  124812. detachControl(element: Nullable<HTMLElement>): void;
  124813. /**
  124814. * Gets the class name of the current intput.
  124815. * @returns the class name
  124816. */
  124817. getClassName(): string;
  124818. /** @hidden */
  124819. _onLostFocus(e: FocusEvent): void;
  124820. /**
  124821. * Get the friendly name associated with the input class.
  124822. * @returns the input friendly name
  124823. */
  124824. getSimpleName(): string;
  124825. /**
  124826. * Update the current camera state depending on the inputs that have been used this frame.
  124827. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124828. */
  124829. checkInputs(): void;
  124830. }
  124831. }
  124832. declare module BABYLON {
  124833. /**
  124834. * Manage the mouse wheel inputs to control a follow camera.
  124835. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124836. */
  124837. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124838. /**
  124839. * Defines the camera the input is attached to.
  124840. */
  124841. camera: FollowCamera;
  124842. /**
  124843. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124844. */
  124845. axisControlRadius: boolean;
  124846. /**
  124847. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124848. */
  124849. axisControlHeight: boolean;
  124850. /**
  124851. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124852. */
  124853. axisControlRotation: boolean;
  124854. /**
  124855. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124856. * relation to mouseWheel events.
  124857. */
  124858. wheelPrecision: number;
  124859. /**
  124860. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124861. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124862. */
  124863. wheelDeltaPercentage: number;
  124864. private _wheel;
  124865. private _observer;
  124866. /**
  124867. * Attach the input controls to a specific dom element to get the input from.
  124868. * @param element Defines the element the controls should be listened from
  124869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124870. */
  124871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124872. /**
  124873. * Detach the current controls from the specified dom element.
  124874. * @param element Defines the element to stop listening the inputs from
  124875. */
  124876. detachControl(element: Nullable<HTMLElement>): void;
  124877. /**
  124878. * Gets the class name of the current intput.
  124879. * @returns the class name
  124880. */
  124881. getClassName(): string;
  124882. /**
  124883. * Get the friendly name associated with the input class.
  124884. * @returns the input friendly name
  124885. */
  124886. getSimpleName(): string;
  124887. }
  124888. }
  124889. declare module BABYLON {
  124890. /**
  124891. * Manage the pointers inputs to control an follow camera.
  124892. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124893. */
  124894. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124895. /**
  124896. * Defines the camera the input is attached to.
  124897. */
  124898. camera: FollowCamera;
  124899. /**
  124900. * Gets the class name of the current input.
  124901. * @returns the class name
  124902. */
  124903. getClassName(): string;
  124904. /**
  124905. * Defines the pointer angular sensibility along the X axis or how fast is
  124906. * the camera rotating.
  124907. * A negative number will reverse the axis direction.
  124908. */
  124909. angularSensibilityX: number;
  124910. /**
  124911. * Defines the pointer angular sensibility along the Y axis or how fast is
  124912. * the camera rotating.
  124913. * A negative number will reverse the axis direction.
  124914. */
  124915. angularSensibilityY: number;
  124916. /**
  124917. * Defines the pointer pinch precision or how fast is the camera zooming.
  124918. * A negative number will reverse the axis direction.
  124919. */
  124920. pinchPrecision: number;
  124921. /**
  124922. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124923. * from 0.
  124924. * It defines the percentage of current camera.radius to use as delta when
  124925. * pinch zoom is used.
  124926. */
  124927. pinchDeltaPercentage: number;
  124928. /**
  124929. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124930. */
  124931. axisXControlRadius: boolean;
  124932. /**
  124933. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124934. */
  124935. axisXControlHeight: boolean;
  124936. /**
  124937. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124938. */
  124939. axisXControlRotation: boolean;
  124940. /**
  124941. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124942. */
  124943. axisYControlRadius: boolean;
  124944. /**
  124945. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124946. */
  124947. axisYControlHeight: boolean;
  124948. /**
  124949. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124950. */
  124951. axisYControlRotation: boolean;
  124952. /**
  124953. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124954. */
  124955. axisPinchControlRadius: boolean;
  124956. /**
  124957. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124958. */
  124959. axisPinchControlHeight: boolean;
  124960. /**
  124961. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124962. */
  124963. axisPinchControlRotation: boolean;
  124964. /**
  124965. * Log error messages if basic misconfiguration has occurred.
  124966. */
  124967. warningEnable: boolean;
  124968. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124969. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124970. private _warningCounter;
  124971. private _warning;
  124972. }
  124973. }
  124974. declare module BABYLON {
  124975. /**
  124976. * Default Inputs manager for the FollowCamera.
  124977. * It groups all the default supported inputs for ease of use.
  124978. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124979. */
  124980. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124981. /**
  124982. * Instantiates a new FollowCameraInputsManager.
  124983. * @param camera Defines the camera the inputs belong to
  124984. */
  124985. constructor(camera: FollowCamera);
  124986. /**
  124987. * Add keyboard input support to the input manager.
  124988. * @returns the current input manager
  124989. */
  124990. addKeyboard(): FollowCameraInputsManager;
  124991. /**
  124992. * Add mouse wheel input support to the input manager.
  124993. * @returns the current input manager
  124994. */
  124995. addMouseWheel(): FollowCameraInputsManager;
  124996. /**
  124997. * Add pointers input support to the input manager.
  124998. * @returns the current input manager
  124999. */
  125000. addPointers(): FollowCameraInputsManager;
  125001. /**
  125002. * Add orientation input support to the input manager.
  125003. * @returns the current input manager
  125004. */
  125005. addVRDeviceOrientation(): FollowCameraInputsManager;
  125006. }
  125007. }
  125008. declare module BABYLON {
  125009. /**
  125010. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  125011. * an arc rotate version arcFollowCamera are available.
  125012. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125013. */
  125014. export class FollowCamera extends TargetCamera {
  125015. /**
  125016. * Distance the follow camera should follow an object at
  125017. */
  125018. radius: number;
  125019. /**
  125020. * Minimum allowed distance of the camera to the axis of rotation
  125021. * (The camera can not get closer).
  125022. * This can help limiting how the Camera is able to move in the scene.
  125023. */
  125024. lowerRadiusLimit: Nullable<number>;
  125025. /**
  125026. * Maximum allowed distance of the camera to the axis of rotation
  125027. * (The camera can not get further).
  125028. * This can help limiting how the Camera is able to move in the scene.
  125029. */
  125030. upperRadiusLimit: Nullable<number>;
  125031. /**
  125032. * Define a rotation offset between the camera and the object it follows
  125033. */
  125034. rotationOffset: number;
  125035. /**
  125036. * Minimum allowed angle to camera position relative to target object.
  125037. * This can help limiting how the Camera is able to move in the scene.
  125038. */
  125039. lowerRotationOffsetLimit: Nullable<number>;
  125040. /**
  125041. * Maximum allowed angle to camera position relative to target object.
  125042. * This can help limiting how the Camera is able to move in the scene.
  125043. */
  125044. upperRotationOffsetLimit: Nullable<number>;
  125045. /**
  125046. * Define a height offset between the camera and the object it follows.
  125047. * It can help following an object from the top (like a car chaing a plane)
  125048. */
  125049. heightOffset: number;
  125050. /**
  125051. * Minimum allowed height of camera position relative to target object.
  125052. * This can help limiting how the Camera is able to move in the scene.
  125053. */
  125054. lowerHeightOffsetLimit: Nullable<number>;
  125055. /**
  125056. * Maximum allowed height of camera position relative to target object.
  125057. * This can help limiting how the Camera is able to move in the scene.
  125058. */
  125059. upperHeightOffsetLimit: Nullable<number>;
  125060. /**
  125061. * Define how fast the camera can accelerate to follow it s target.
  125062. */
  125063. cameraAcceleration: number;
  125064. /**
  125065. * Define the speed limit of the camera following an object.
  125066. */
  125067. maxCameraSpeed: number;
  125068. /**
  125069. * Define the target of the camera.
  125070. */
  125071. lockedTarget: Nullable<AbstractMesh>;
  125072. /**
  125073. * Defines the input associated with the camera.
  125074. */
  125075. inputs: FollowCameraInputsManager;
  125076. /**
  125077. * Instantiates the follow camera.
  125078. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125079. * @param name Define the name of the camera in the scene
  125080. * @param position Define the position of the camera
  125081. * @param scene Define the scene the camera belong to
  125082. * @param lockedTarget Define the target of the camera
  125083. */
  125084. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  125085. private _follow;
  125086. /**
  125087. * Attached controls to the current camera.
  125088. * @param element Defines the element the controls should be listened from
  125089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125090. */
  125091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125092. /**
  125093. * Detach the current controls from the camera.
  125094. * The camera will stop reacting to inputs.
  125095. * @param element Defines the element to stop listening the inputs from
  125096. */
  125097. detachControl(element: HTMLElement): void;
  125098. /** @hidden */
  125099. _checkInputs(): void;
  125100. private _checkLimits;
  125101. /**
  125102. * Gets the camera class name.
  125103. * @returns the class name
  125104. */
  125105. getClassName(): string;
  125106. }
  125107. /**
  125108. * Arc Rotate version of the follow camera.
  125109. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  125110. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125111. */
  125112. export class ArcFollowCamera extends TargetCamera {
  125113. /** The longitudinal angle of the camera */
  125114. alpha: number;
  125115. /** The latitudinal angle of the camera */
  125116. beta: number;
  125117. /** The radius of the camera from its target */
  125118. radius: number;
  125119. private _cartesianCoordinates;
  125120. /** Define the camera target (the mesh it should follow) */
  125121. private _meshTarget;
  125122. /**
  125123. * Instantiates a new ArcFollowCamera
  125124. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125125. * @param name Define the name of the camera
  125126. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  125127. * @param beta Define the rotation angle of the camera around the elevation axis
  125128. * @param radius Define the radius of the camera from its target point
  125129. * @param target Define the target of the camera
  125130. * @param scene Define the scene the camera belongs to
  125131. */
  125132. constructor(name: string,
  125133. /** The longitudinal angle of the camera */
  125134. alpha: number,
  125135. /** The latitudinal angle of the camera */
  125136. beta: number,
  125137. /** The radius of the camera from its target */
  125138. radius: number,
  125139. /** Define the camera target (the mesh it should follow) */
  125140. target: Nullable<AbstractMesh>, scene: Scene);
  125141. private _follow;
  125142. /** @hidden */
  125143. _checkInputs(): void;
  125144. /**
  125145. * Returns the class name of the object.
  125146. * It is mostly used internally for serialization purposes.
  125147. */
  125148. getClassName(): string;
  125149. }
  125150. }
  125151. declare module BABYLON {
  125152. /**
  125153. * Manage the keyboard inputs to control the movement of a follow camera.
  125154. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125155. */
  125156. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  125157. /**
  125158. * Defines the camera the input is attached to.
  125159. */
  125160. camera: FollowCamera;
  125161. /**
  125162. * Defines the list of key codes associated with the up action (increase heightOffset)
  125163. */
  125164. keysHeightOffsetIncr: number[];
  125165. /**
  125166. * Defines the list of key codes associated with the down action (decrease heightOffset)
  125167. */
  125168. keysHeightOffsetDecr: number[];
  125169. /**
  125170. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  125171. */
  125172. keysHeightOffsetModifierAlt: boolean;
  125173. /**
  125174. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  125175. */
  125176. keysHeightOffsetModifierCtrl: boolean;
  125177. /**
  125178. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  125179. */
  125180. keysHeightOffsetModifierShift: boolean;
  125181. /**
  125182. * Defines the list of key codes associated with the left action (increase rotationOffset)
  125183. */
  125184. keysRotationOffsetIncr: number[];
  125185. /**
  125186. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  125187. */
  125188. keysRotationOffsetDecr: number[];
  125189. /**
  125190. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  125191. */
  125192. keysRotationOffsetModifierAlt: boolean;
  125193. /**
  125194. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  125195. */
  125196. keysRotationOffsetModifierCtrl: boolean;
  125197. /**
  125198. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  125199. */
  125200. keysRotationOffsetModifierShift: boolean;
  125201. /**
  125202. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  125203. */
  125204. keysRadiusIncr: number[];
  125205. /**
  125206. * Defines the list of key codes associated with the zoom-out action (increase radius)
  125207. */
  125208. keysRadiusDecr: number[];
  125209. /**
  125210. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  125211. */
  125212. keysRadiusModifierAlt: boolean;
  125213. /**
  125214. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  125215. */
  125216. keysRadiusModifierCtrl: boolean;
  125217. /**
  125218. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  125219. */
  125220. keysRadiusModifierShift: boolean;
  125221. /**
  125222. * Defines the rate of change of heightOffset.
  125223. */
  125224. heightSensibility: number;
  125225. /**
  125226. * Defines the rate of change of rotationOffset.
  125227. */
  125228. rotationSensibility: number;
  125229. /**
  125230. * Defines the rate of change of radius.
  125231. */
  125232. radiusSensibility: number;
  125233. private _keys;
  125234. private _ctrlPressed;
  125235. private _altPressed;
  125236. private _shiftPressed;
  125237. private _onCanvasBlurObserver;
  125238. private _onKeyboardObserver;
  125239. private _engine;
  125240. private _scene;
  125241. /**
  125242. * Attach the input controls to a specific dom element to get the input from.
  125243. * @param element Defines the element the controls should be listened from
  125244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125245. */
  125246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125247. /**
  125248. * Detach the current controls from the specified dom element.
  125249. * @param element Defines the element to stop listening the inputs from
  125250. */
  125251. detachControl(element: Nullable<HTMLElement>): void;
  125252. /**
  125253. * Update the current camera state depending on the inputs that have been used this frame.
  125254. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125255. */
  125256. checkInputs(): void;
  125257. /**
  125258. * Gets the class name of the current input.
  125259. * @returns the class name
  125260. */
  125261. getClassName(): string;
  125262. /**
  125263. * Get the friendly name associated with the input class.
  125264. * @returns the input friendly name
  125265. */
  125266. getSimpleName(): string;
  125267. /**
  125268. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125269. * allow modification of the heightOffset value.
  125270. */
  125271. private _modifierHeightOffset;
  125272. /**
  125273. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125274. * allow modification of the rotationOffset value.
  125275. */
  125276. private _modifierRotationOffset;
  125277. /**
  125278. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125279. * allow modification of the radius value.
  125280. */
  125281. private _modifierRadius;
  125282. }
  125283. }
  125284. declare module BABYLON {
  125285. interface FreeCameraInputsManager {
  125286. /**
  125287. * @hidden
  125288. */
  125289. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  125290. /**
  125291. * Add orientation input support to the input manager.
  125292. * @returns the current input manager
  125293. */
  125294. addDeviceOrientation(): FreeCameraInputsManager;
  125295. }
  125296. /**
  125297. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  125298. * Screen rotation is taken into account.
  125299. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125300. */
  125301. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  125302. private _camera;
  125303. private _screenOrientationAngle;
  125304. private _constantTranform;
  125305. private _screenQuaternion;
  125306. private _alpha;
  125307. private _beta;
  125308. private _gamma;
  125309. /**
  125310. * Can be used to detect if a device orientation sensor is available on a device
  125311. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  125312. * @returns a promise that will resolve on orientation change
  125313. */
  125314. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  125315. /**
  125316. * @hidden
  125317. */
  125318. _onDeviceOrientationChangedObservable: Observable<void>;
  125319. /**
  125320. * Instantiates a new input
  125321. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125322. */
  125323. constructor();
  125324. /**
  125325. * Define the camera controlled by the input.
  125326. */
  125327. get camera(): FreeCamera;
  125328. set camera(camera: FreeCamera);
  125329. /**
  125330. * Attach the input controls to a specific dom element to get the input from.
  125331. * @param element Defines the element the controls should be listened from
  125332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125333. */
  125334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125335. private _orientationChanged;
  125336. private _deviceOrientation;
  125337. /**
  125338. * Detach the current controls from the specified dom element.
  125339. * @param element Defines the element to stop listening the inputs from
  125340. */
  125341. detachControl(element: Nullable<HTMLElement>): void;
  125342. /**
  125343. * Update the current camera state depending on the inputs that have been used this frame.
  125344. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125345. */
  125346. checkInputs(): void;
  125347. /**
  125348. * Gets the class name of the current intput.
  125349. * @returns the class name
  125350. */
  125351. getClassName(): string;
  125352. /**
  125353. * Get the friendly name associated with the input class.
  125354. * @returns the input friendly name
  125355. */
  125356. getSimpleName(): string;
  125357. }
  125358. }
  125359. declare module BABYLON {
  125360. /**
  125361. * Manage the gamepad inputs to control a free camera.
  125362. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125363. */
  125364. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  125365. /**
  125366. * Define the camera the input is attached to.
  125367. */
  125368. camera: FreeCamera;
  125369. /**
  125370. * Define the Gamepad controlling the input
  125371. */
  125372. gamepad: Nullable<Gamepad>;
  125373. /**
  125374. * Defines the gamepad rotation sensiblity.
  125375. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125376. */
  125377. gamepadAngularSensibility: number;
  125378. /**
  125379. * Defines the gamepad move sensiblity.
  125380. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125381. */
  125382. gamepadMoveSensibility: number;
  125383. private _yAxisScale;
  125384. /**
  125385. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  125386. */
  125387. get invertYAxis(): boolean;
  125388. set invertYAxis(value: boolean);
  125389. private _onGamepadConnectedObserver;
  125390. private _onGamepadDisconnectedObserver;
  125391. private _cameraTransform;
  125392. private _deltaTransform;
  125393. private _vector3;
  125394. private _vector2;
  125395. /**
  125396. * Attach the input controls to a specific dom element to get the input from.
  125397. * @param element Defines the element the controls should be listened from
  125398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125399. */
  125400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125401. /**
  125402. * Detach the current controls from the specified dom element.
  125403. * @param element Defines the element to stop listening the inputs from
  125404. */
  125405. detachControl(element: Nullable<HTMLElement>): void;
  125406. /**
  125407. * Update the current camera state depending on the inputs that have been used this frame.
  125408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125409. */
  125410. checkInputs(): void;
  125411. /**
  125412. * Gets the class name of the current intput.
  125413. * @returns the class name
  125414. */
  125415. getClassName(): string;
  125416. /**
  125417. * Get the friendly name associated with the input class.
  125418. * @returns the input friendly name
  125419. */
  125420. getSimpleName(): string;
  125421. }
  125422. }
  125423. declare module BABYLON {
  125424. /**
  125425. * Defines the potential axis of a Joystick
  125426. */
  125427. export enum JoystickAxis {
  125428. /** X axis */
  125429. X = 0,
  125430. /** Y axis */
  125431. Y = 1,
  125432. /** Z axis */
  125433. Z = 2
  125434. }
  125435. /**
  125436. * Represents the different customization options available
  125437. * for VirtualJoystick
  125438. */
  125439. interface VirtualJoystickCustomizations {
  125440. /**
  125441. * Size of the joystick's puck
  125442. */
  125443. puckSize: number;
  125444. /**
  125445. * Size of the joystick's container
  125446. */
  125447. containerSize: number;
  125448. /**
  125449. * Color of the joystick && puck
  125450. */
  125451. color: string;
  125452. /**
  125453. * Image URL for the joystick's puck
  125454. */
  125455. puckImage?: string;
  125456. /**
  125457. * Image URL for the joystick's container
  125458. */
  125459. containerImage?: string;
  125460. /**
  125461. * Defines the unmoving position of the joystick container
  125462. */
  125463. position?: {
  125464. x: number;
  125465. y: number;
  125466. };
  125467. /**
  125468. * Defines whether or not the joystick container is always visible
  125469. */
  125470. alwaysVisible: boolean;
  125471. /**
  125472. * Defines whether or not to limit the movement of the puck to the joystick's container
  125473. */
  125474. limitToContainer: boolean;
  125475. }
  125476. /**
  125477. * Class used to define virtual joystick (used in touch mode)
  125478. */
  125479. export class VirtualJoystick {
  125480. /**
  125481. * Gets or sets a boolean indicating that left and right values must be inverted
  125482. */
  125483. reverseLeftRight: boolean;
  125484. /**
  125485. * Gets or sets a boolean indicating that up and down values must be inverted
  125486. */
  125487. reverseUpDown: boolean;
  125488. /**
  125489. * Gets the offset value for the position (ie. the change of the position value)
  125490. */
  125491. deltaPosition: Vector3;
  125492. /**
  125493. * Gets a boolean indicating if the virtual joystick was pressed
  125494. */
  125495. pressed: boolean;
  125496. /**
  125497. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125498. */
  125499. static Canvas: Nullable<HTMLCanvasElement>;
  125500. /**
  125501. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125502. */
  125503. limitToContainer: boolean;
  125504. private static _globalJoystickIndex;
  125505. private static _alwaysVisibleSticks;
  125506. private static vjCanvasContext;
  125507. private static vjCanvasWidth;
  125508. private static vjCanvasHeight;
  125509. private static halfWidth;
  125510. private static _GetDefaultOptions;
  125511. private _action;
  125512. private _axisTargetedByLeftAndRight;
  125513. private _axisTargetedByUpAndDown;
  125514. private _joystickSensibility;
  125515. private _inversedSensibility;
  125516. private _joystickPointerID;
  125517. private _joystickColor;
  125518. private _joystickPointerPos;
  125519. private _joystickPreviousPointerPos;
  125520. private _joystickPointerStartPos;
  125521. private _deltaJoystickVector;
  125522. private _leftJoystick;
  125523. private _touches;
  125524. private _joystickPosition;
  125525. private _alwaysVisible;
  125526. private _puckImage;
  125527. private _containerImage;
  125528. private _joystickPuckSize;
  125529. private _joystickContainerSize;
  125530. private _clearPuckSize;
  125531. private _clearContainerSize;
  125532. private _clearPuckSizeOffset;
  125533. private _clearContainerSizeOffset;
  125534. private _onPointerDownHandlerRef;
  125535. private _onPointerMoveHandlerRef;
  125536. private _onPointerUpHandlerRef;
  125537. private _onResize;
  125538. /**
  125539. * Creates a new virtual joystick
  125540. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125541. * @param customizations Defines the options we want to customize the VirtualJoystick
  125542. */
  125543. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125544. /**
  125545. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125546. * @param newJoystickSensibility defines the new sensibility
  125547. */
  125548. setJoystickSensibility(newJoystickSensibility: number): void;
  125549. private _onPointerDown;
  125550. private _onPointerMove;
  125551. private _onPointerUp;
  125552. /**
  125553. * Change the color of the virtual joystick
  125554. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125555. */
  125556. setJoystickColor(newColor: string): void;
  125557. /**
  125558. * Size of the joystick's container
  125559. */
  125560. set containerSize(newSize: number);
  125561. get containerSize(): number;
  125562. /**
  125563. * Size of the joystick's puck
  125564. */
  125565. set puckSize(newSize: number);
  125566. get puckSize(): number;
  125567. /**
  125568. * Clears the set position of the joystick
  125569. */
  125570. clearPosition(): void;
  125571. /**
  125572. * Defines whether or not the joystick container is always visible
  125573. */
  125574. set alwaysVisible(value: boolean);
  125575. get alwaysVisible(): boolean;
  125576. /**
  125577. * Sets the constant position of the Joystick container
  125578. * @param x X axis coordinate
  125579. * @param y Y axis coordinate
  125580. */
  125581. setPosition(x: number, y: number): void;
  125582. /**
  125583. * Defines a callback to call when the joystick is touched
  125584. * @param action defines the callback
  125585. */
  125586. setActionOnTouch(action: () => any): void;
  125587. /**
  125588. * Defines which axis you'd like to control for left & right
  125589. * @param axis defines the axis to use
  125590. */
  125591. setAxisForLeftRight(axis: JoystickAxis): void;
  125592. /**
  125593. * Defines which axis you'd like to control for up & down
  125594. * @param axis defines the axis to use
  125595. */
  125596. setAxisForUpDown(axis: JoystickAxis): void;
  125597. /**
  125598. * Clears the canvas from the previous puck / container draw
  125599. */
  125600. private _clearPreviousDraw;
  125601. /**
  125602. * Loads `urlPath` to be used for the container's image
  125603. * @param urlPath defines the urlPath of an image to use
  125604. */
  125605. setContainerImage(urlPath: string): void;
  125606. /**
  125607. * Loads `urlPath` to be used for the puck's image
  125608. * @param urlPath defines the urlPath of an image to use
  125609. */
  125610. setPuckImage(urlPath: string): void;
  125611. /**
  125612. * Draws the Virtual Joystick's container
  125613. */
  125614. private _drawContainer;
  125615. /**
  125616. * Draws the Virtual Joystick's puck
  125617. */
  125618. private _drawPuck;
  125619. private _drawVirtualJoystick;
  125620. /**
  125621. * Release internal HTML canvas
  125622. */
  125623. releaseCanvas(): void;
  125624. }
  125625. }
  125626. declare module BABYLON {
  125627. interface FreeCameraInputsManager {
  125628. /**
  125629. * Add virtual joystick input support to the input manager.
  125630. * @returns the current input manager
  125631. */
  125632. addVirtualJoystick(): FreeCameraInputsManager;
  125633. }
  125634. /**
  125635. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125636. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125637. */
  125638. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125639. /**
  125640. * Defines the camera the input is attached to.
  125641. */
  125642. camera: FreeCamera;
  125643. private _leftjoystick;
  125644. private _rightjoystick;
  125645. /**
  125646. * Gets the left stick of the virtual joystick.
  125647. * @returns The virtual Joystick
  125648. */
  125649. getLeftJoystick(): VirtualJoystick;
  125650. /**
  125651. * Gets the right stick of the virtual joystick.
  125652. * @returns The virtual Joystick
  125653. */
  125654. getRightJoystick(): VirtualJoystick;
  125655. /**
  125656. * Update the current camera state depending on the inputs that have been used this frame.
  125657. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125658. */
  125659. checkInputs(): void;
  125660. /**
  125661. * Attach the input controls to a specific dom element to get the input from.
  125662. * @param element Defines the element the controls should be listened from
  125663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125664. */
  125665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125666. /**
  125667. * Detach the current controls from the specified dom element.
  125668. * @param element Defines the element to stop listening the inputs from
  125669. */
  125670. detachControl(element: Nullable<HTMLElement>): void;
  125671. /**
  125672. * Gets the class name of the current intput.
  125673. * @returns the class name
  125674. */
  125675. getClassName(): string;
  125676. /**
  125677. * Get the friendly name associated with the input class.
  125678. * @returns the input friendly name
  125679. */
  125680. getSimpleName(): string;
  125681. }
  125682. }
  125683. declare module BABYLON {
  125684. /**
  125685. * This represents a FPS type of camera controlled by touch.
  125686. * This is like a universal camera minus the Gamepad controls.
  125687. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125688. */
  125689. export class TouchCamera extends FreeCamera {
  125690. /**
  125691. * Defines the touch sensibility for rotation.
  125692. * The higher the faster.
  125693. */
  125694. get touchAngularSensibility(): number;
  125695. set touchAngularSensibility(value: number);
  125696. /**
  125697. * Defines the touch sensibility for move.
  125698. * The higher the faster.
  125699. */
  125700. get touchMoveSensibility(): number;
  125701. set touchMoveSensibility(value: number);
  125702. /**
  125703. * Instantiates a new touch camera.
  125704. * This represents a FPS type of camera controlled by touch.
  125705. * This is like a universal camera minus the Gamepad controls.
  125706. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125707. * @param name Define the name of the camera in the scene
  125708. * @param position Define the start position of the camera in the scene
  125709. * @param scene Define the scene the camera belongs to
  125710. */
  125711. constructor(name: string, position: Vector3, scene: Scene);
  125712. /**
  125713. * Gets the current object class name.
  125714. * @return the class name
  125715. */
  125716. getClassName(): string;
  125717. /** @hidden */
  125718. _setupInputs(): void;
  125719. }
  125720. }
  125721. declare module BABYLON {
  125722. /**
  125723. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  125724. * being tilted forward or back and left or right.
  125725. */
  125726. export class DeviceOrientationCamera extends FreeCamera {
  125727. private _initialQuaternion;
  125728. private _quaternionCache;
  125729. private _tmpDragQuaternion;
  125730. private _disablePointerInputWhenUsingDeviceOrientation;
  125731. /**
  125732. * Creates a new device orientation camera
  125733. * @param name The name of the camera
  125734. * @param position The start position camera
  125735. * @param scene The scene the camera belongs to
  125736. */
  125737. constructor(name: string, position: Vector3, scene: Scene);
  125738. /**
  125739. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125740. */
  125741. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125742. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125743. private _dragFactor;
  125744. /**
  125745. * Enabled turning on the y axis when the orientation sensor is active
  125746. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125747. */
  125748. enableHorizontalDragging(dragFactor?: number): void;
  125749. /**
  125750. * Gets the current instance class name ("DeviceOrientationCamera").
  125751. * This helps avoiding instanceof at run time.
  125752. * @returns the class name
  125753. */
  125754. getClassName(): string;
  125755. /**
  125756. * @hidden
  125757. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125758. */
  125759. _checkInputs(): void;
  125760. /**
  125761. * Reset the camera to its default orientation on the specified axis only.
  125762. * @param axis The axis to reset
  125763. */
  125764. resetToCurrentRotation(axis?: Axis): void;
  125765. }
  125766. }
  125767. declare module BABYLON {
  125768. /**
  125769. * Defines supported buttons for XBox360 compatible gamepads
  125770. */
  125771. export enum Xbox360Button {
  125772. /** A */
  125773. A = 0,
  125774. /** B */
  125775. B = 1,
  125776. /** X */
  125777. X = 2,
  125778. /** Y */
  125779. Y = 3,
  125780. /** Left button */
  125781. LB = 4,
  125782. /** Right button */
  125783. RB = 5,
  125784. /** Back */
  125785. Back = 8,
  125786. /** Start */
  125787. Start = 9,
  125788. /** Left stick */
  125789. LeftStick = 10,
  125790. /** Right stick */
  125791. RightStick = 11
  125792. }
  125793. /** Defines values for XBox360 DPad */
  125794. export enum Xbox360Dpad {
  125795. /** Up */
  125796. Up = 12,
  125797. /** Down */
  125798. Down = 13,
  125799. /** Left */
  125800. Left = 14,
  125801. /** Right */
  125802. Right = 15
  125803. }
  125804. /**
  125805. * Defines a XBox360 gamepad
  125806. */
  125807. export class Xbox360Pad extends Gamepad {
  125808. private _leftTrigger;
  125809. private _rightTrigger;
  125810. private _onlefttriggerchanged;
  125811. private _onrighttriggerchanged;
  125812. private _onbuttondown;
  125813. private _onbuttonup;
  125814. private _ondpaddown;
  125815. private _ondpadup;
  125816. /** Observable raised when a button is pressed */
  125817. onButtonDownObservable: Observable<Xbox360Button>;
  125818. /** Observable raised when a button is released */
  125819. onButtonUpObservable: Observable<Xbox360Button>;
  125820. /** Observable raised when a pad is pressed */
  125821. onPadDownObservable: Observable<Xbox360Dpad>;
  125822. /** Observable raised when a pad is released */
  125823. onPadUpObservable: Observable<Xbox360Dpad>;
  125824. private _buttonA;
  125825. private _buttonB;
  125826. private _buttonX;
  125827. private _buttonY;
  125828. private _buttonBack;
  125829. private _buttonStart;
  125830. private _buttonLB;
  125831. private _buttonRB;
  125832. private _buttonLeftStick;
  125833. private _buttonRightStick;
  125834. private _dPadUp;
  125835. private _dPadDown;
  125836. private _dPadLeft;
  125837. private _dPadRight;
  125838. private _isXboxOnePad;
  125839. /**
  125840. * Creates a new XBox360 gamepad object
  125841. * @param id defines the id of this gamepad
  125842. * @param index defines its index
  125843. * @param gamepad defines the internal HTML gamepad object
  125844. * @param xboxOne defines if it is a XBox One gamepad
  125845. */
  125846. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125847. /**
  125848. * Defines the callback to call when left trigger is pressed
  125849. * @param callback defines the callback to use
  125850. */
  125851. onlefttriggerchanged(callback: (value: number) => void): void;
  125852. /**
  125853. * Defines the callback to call when right trigger is pressed
  125854. * @param callback defines the callback to use
  125855. */
  125856. onrighttriggerchanged(callback: (value: number) => void): void;
  125857. /**
  125858. * Gets the left trigger value
  125859. */
  125860. get leftTrigger(): number;
  125861. /**
  125862. * Sets the left trigger value
  125863. */
  125864. set leftTrigger(newValue: number);
  125865. /**
  125866. * Gets the right trigger value
  125867. */
  125868. get rightTrigger(): number;
  125869. /**
  125870. * Sets the right trigger value
  125871. */
  125872. set rightTrigger(newValue: number);
  125873. /**
  125874. * Defines the callback to call when a button is pressed
  125875. * @param callback defines the callback to use
  125876. */
  125877. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125878. /**
  125879. * Defines the callback to call when a button is released
  125880. * @param callback defines the callback to use
  125881. */
  125882. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125883. /**
  125884. * Defines the callback to call when a pad is pressed
  125885. * @param callback defines the callback to use
  125886. */
  125887. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125888. /**
  125889. * Defines the callback to call when a pad is released
  125890. * @param callback defines the callback to use
  125891. */
  125892. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125893. private _setButtonValue;
  125894. private _setDPadValue;
  125895. /**
  125896. * Gets the value of the `A` button
  125897. */
  125898. get buttonA(): number;
  125899. /**
  125900. * Sets the value of the `A` button
  125901. */
  125902. set buttonA(value: number);
  125903. /**
  125904. * Gets the value of the `B` button
  125905. */
  125906. get buttonB(): number;
  125907. /**
  125908. * Sets the value of the `B` button
  125909. */
  125910. set buttonB(value: number);
  125911. /**
  125912. * Gets the value of the `X` button
  125913. */
  125914. get buttonX(): number;
  125915. /**
  125916. * Sets the value of the `X` button
  125917. */
  125918. set buttonX(value: number);
  125919. /**
  125920. * Gets the value of the `Y` button
  125921. */
  125922. get buttonY(): number;
  125923. /**
  125924. * Sets the value of the `Y` button
  125925. */
  125926. set buttonY(value: number);
  125927. /**
  125928. * Gets the value of the `Start` button
  125929. */
  125930. get buttonStart(): number;
  125931. /**
  125932. * Sets the value of the `Start` button
  125933. */
  125934. set buttonStart(value: number);
  125935. /**
  125936. * Gets the value of the `Back` button
  125937. */
  125938. get buttonBack(): number;
  125939. /**
  125940. * Sets the value of the `Back` button
  125941. */
  125942. set buttonBack(value: number);
  125943. /**
  125944. * Gets the value of the `Left` button
  125945. */
  125946. get buttonLB(): number;
  125947. /**
  125948. * Sets the value of the `Left` button
  125949. */
  125950. set buttonLB(value: number);
  125951. /**
  125952. * Gets the value of the `Right` button
  125953. */
  125954. get buttonRB(): number;
  125955. /**
  125956. * Sets the value of the `Right` button
  125957. */
  125958. set buttonRB(value: number);
  125959. /**
  125960. * Gets the value of the Left joystick
  125961. */
  125962. get buttonLeftStick(): number;
  125963. /**
  125964. * Sets the value of the Left joystick
  125965. */
  125966. set buttonLeftStick(value: number);
  125967. /**
  125968. * Gets the value of the Right joystick
  125969. */
  125970. get buttonRightStick(): number;
  125971. /**
  125972. * Sets the value of the Right joystick
  125973. */
  125974. set buttonRightStick(value: number);
  125975. /**
  125976. * Gets the value of D-pad up
  125977. */
  125978. get dPadUp(): number;
  125979. /**
  125980. * Sets the value of D-pad up
  125981. */
  125982. set dPadUp(value: number);
  125983. /**
  125984. * Gets the value of D-pad down
  125985. */
  125986. get dPadDown(): number;
  125987. /**
  125988. * Sets the value of D-pad down
  125989. */
  125990. set dPadDown(value: number);
  125991. /**
  125992. * Gets the value of D-pad left
  125993. */
  125994. get dPadLeft(): number;
  125995. /**
  125996. * Sets the value of D-pad left
  125997. */
  125998. set dPadLeft(value: number);
  125999. /**
  126000. * Gets the value of D-pad right
  126001. */
  126002. get dPadRight(): number;
  126003. /**
  126004. * Sets the value of D-pad right
  126005. */
  126006. set dPadRight(value: number);
  126007. /**
  126008. * Force the gamepad to synchronize with device values
  126009. */
  126010. update(): void;
  126011. /**
  126012. * Disposes the gamepad
  126013. */
  126014. dispose(): void;
  126015. }
  126016. }
  126017. declare module BABYLON {
  126018. /**
  126019. * Defines supported buttons for DualShock compatible gamepads
  126020. */
  126021. export enum DualShockButton {
  126022. /** Cross */
  126023. Cross = 0,
  126024. /** Circle */
  126025. Circle = 1,
  126026. /** Square */
  126027. Square = 2,
  126028. /** Triangle */
  126029. Triangle = 3,
  126030. /** L1 */
  126031. L1 = 4,
  126032. /** R1 */
  126033. R1 = 5,
  126034. /** Share */
  126035. Share = 8,
  126036. /** Options */
  126037. Options = 9,
  126038. /** Left stick */
  126039. LeftStick = 10,
  126040. /** Right stick */
  126041. RightStick = 11
  126042. }
  126043. /** Defines values for DualShock DPad */
  126044. export enum DualShockDpad {
  126045. /** Up */
  126046. Up = 12,
  126047. /** Down */
  126048. Down = 13,
  126049. /** Left */
  126050. Left = 14,
  126051. /** Right */
  126052. Right = 15
  126053. }
  126054. /**
  126055. * Defines a DualShock gamepad
  126056. */
  126057. export class DualShockPad extends Gamepad {
  126058. private _leftTrigger;
  126059. private _rightTrigger;
  126060. private _onlefttriggerchanged;
  126061. private _onrighttriggerchanged;
  126062. private _onbuttondown;
  126063. private _onbuttonup;
  126064. private _ondpaddown;
  126065. private _ondpadup;
  126066. /** Observable raised when a button is pressed */
  126067. onButtonDownObservable: Observable<DualShockButton>;
  126068. /** Observable raised when a button is released */
  126069. onButtonUpObservable: Observable<DualShockButton>;
  126070. /** Observable raised when a pad is pressed */
  126071. onPadDownObservable: Observable<DualShockDpad>;
  126072. /** Observable raised when a pad is released */
  126073. onPadUpObservable: Observable<DualShockDpad>;
  126074. private _buttonCross;
  126075. private _buttonCircle;
  126076. private _buttonSquare;
  126077. private _buttonTriangle;
  126078. private _buttonShare;
  126079. private _buttonOptions;
  126080. private _buttonL1;
  126081. private _buttonR1;
  126082. private _buttonLeftStick;
  126083. private _buttonRightStick;
  126084. private _dPadUp;
  126085. private _dPadDown;
  126086. private _dPadLeft;
  126087. private _dPadRight;
  126088. /**
  126089. * Creates a new DualShock gamepad object
  126090. * @param id defines the id of this gamepad
  126091. * @param index defines its index
  126092. * @param gamepad defines the internal HTML gamepad object
  126093. */
  126094. constructor(id: string, index: number, gamepad: any);
  126095. /**
  126096. * Defines the callback to call when left trigger is pressed
  126097. * @param callback defines the callback to use
  126098. */
  126099. onlefttriggerchanged(callback: (value: number) => void): void;
  126100. /**
  126101. * Defines the callback to call when right trigger is pressed
  126102. * @param callback defines the callback to use
  126103. */
  126104. onrighttriggerchanged(callback: (value: number) => void): void;
  126105. /**
  126106. * Gets the left trigger value
  126107. */
  126108. get leftTrigger(): number;
  126109. /**
  126110. * Sets the left trigger value
  126111. */
  126112. set leftTrigger(newValue: number);
  126113. /**
  126114. * Gets the right trigger value
  126115. */
  126116. get rightTrigger(): number;
  126117. /**
  126118. * Sets the right trigger value
  126119. */
  126120. set rightTrigger(newValue: number);
  126121. /**
  126122. * Defines the callback to call when a button is pressed
  126123. * @param callback defines the callback to use
  126124. */
  126125. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  126126. /**
  126127. * Defines the callback to call when a button is released
  126128. * @param callback defines the callback to use
  126129. */
  126130. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  126131. /**
  126132. * Defines the callback to call when a pad is pressed
  126133. * @param callback defines the callback to use
  126134. */
  126135. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  126136. /**
  126137. * Defines the callback to call when a pad is released
  126138. * @param callback defines the callback to use
  126139. */
  126140. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  126141. private _setButtonValue;
  126142. private _setDPadValue;
  126143. /**
  126144. * Gets the value of the `Cross` button
  126145. */
  126146. get buttonCross(): number;
  126147. /**
  126148. * Sets the value of the `Cross` button
  126149. */
  126150. set buttonCross(value: number);
  126151. /**
  126152. * Gets the value of the `Circle` button
  126153. */
  126154. get buttonCircle(): number;
  126155. /**
  126156. * Sets the value of the `Circle` button
  126157. */
  126158. set buttonCircle(value: number);
  126159. /**
  126160. * Gets the value of the `Square` button
  126161. */
  126162. get buttonSquare(): number;
  126163. /**
  126164. * Sets the value of the `Square` button
  126165. */
  126166. set buttonSquare(value: number);
  126167. /**
  126168. * Gets the value of the `Triangle` button
  126169. */
  126170. get buttonTriangle(): number;
  126171. /**
  126172. * Sets the value of the `Triangle` button
  126173. */
  126174. set buttonTriangle(value: number);
  126175. /**
  126176. * Gets the value of the `Options` button
  126177. */
  126178. get buttonOptions(): number;
  126179. /**
  126180. * Sets the value of the `Options` button
  126181. */
  126182. set buttonOptions(value: number);
  126183. /**
  126184. * Gets the value of the `Share` button
  126185. */
  126186. get buttonShare(): number;
  126187. /**
  126188. * Sets the value of the `Share` button
  126189. */
  126190. set buttonShare(value: number);
  126191. /**
  126192. * Gets the value of the `L1` button
  126193. */
  126194. get buttonL1(): number;
  126195. /**
  126196. * Sets the value of the `L1` button
  126197. */
  126198. set buttonL1(value: number);
  126199. /**
  126200. * Gets the value of the `R1` button
  126201. */
  126202. get buttonR1(): number;
  126203. /**
  126204. * Sets the value of the `R1` button
  126205. */
  126206. set buttonR1(value: number);
  126207. /**
  126208. * Gets the value of the Left joystick
  126209. */
  126210. get buttonLeftStick(): number;
  126211. /**
  126212. * Sets the value of the Left joystick
  126213. */
  126214. set buttonLeftStick(value: number);
  126215. /**
  126216. * Gets the value of the Right joystick
  126217. */
  126218. get buttonRightStick(): number;
  126219. /**
  126220. * Sets the value of the Right joystick
  126221. */
  126222. set buttonRightStick(value: number);
  126223. /**
  126224. * Gets the value of D-pad up
  126225. */
  126226. get dPadUp(): number;
  126227. /**
  126228. * Sets the value of D-pad up
  126229. */
  126230. set dPadUp(value: number);
  126231. /**
  126232. * Gets the value of D-pad down
  126233. */
  126234. get dPadDown(): number;
  126235. /**
  126236. * Sets the value of D-pad down
  126237. */
  126238. set dPadDown(value: number);
  126239. /**
  126240. * Gets the value of D-pad left
  126241. */
  126242. get dPadLeft(): number;
  126243. /**
  126244. * Sets the value of D-pad left
  126245. */
  126246. set dPadLeft(value: number);
  126247. /**
  126248. * Gets the value of D-pad right
  126249. */
  126250. get dPadRight(): number;
  126251. /**
  126252. * Sets the value of D-pad right
  126253. */
  126254. set dPadRight(value: number);
  126255. /**
  126256. * Force the gamepad to synchronize with device values
  126257. */
  126258. update(): void;
  126259. /**
  126260. * Disposes the gamepad
  126261. */
  126262. dispose(): void;
  126263. }
  126264. }
  126265. declare module BABYLON {
  126266. /**
  126267. * Manager for handling gamepads
  126268. */
  126269. export class GamepadManager {
  126270. private _scene?;
  126271. private _babylonGamepads;
  126272. private _oneGamepadConnected;
  126273. /** @hidden */
  126274. _isMonitoring: boolean;
  126275. private _gamepadEventSupported;
  126276. private _gamepadSupport?;
  126277. /**
  126278. * observable to be triggered when the gamepad controller has been connected
  126279. */
  126280. onGamepadConnectedObservable: Observable<Gamepad>;
  126281. /**
  126282. * observable to be triggered when the gamepad controller has been disconnected
  126283. */
  126284. onGamepadDisconnectedObservable: Observable<Gamepad>;
  126285. private _onGamepadConnectedEvent;
  126286. private _onGamepadDisconnectedEvent;
  126287. /**
  126288. * Initializes the gamepad manager
  126289. * @param _scene BabylonJS scene
  126290. */
  126291. constructor(_scene?: Scene | undefined);
  126292. /**
  126293. * The gamepads in the game pad manager
  126294. */
  126295. get gamepads(): Gamepad[];
  126296. /**
  126297. * Get the gamepad controllers based on type
  126298. * @param type The type of gamepad controller
  126299. * @returns Nullable gamepad
  126300. */
  126301. getGamepadByType(type?: number): Nullable<Gamepad>;
  126302. /**
  126303. * Disposes the gamepad manager
  126304. */
  126305. dispose(): void;
  126306. private _addNewGamepad;
  126307. private _startMonitoringGamepads;
  126308. private _stopMonitoringGamepads;
  126309. /** @hidden */
  126310. _checkGamepadsStatus(): void;
  126311. private _updateGamepadObjects;
  126312. }
  126313. }
  126314. declare module BABYLON {
  126315. interface Scene {
  126316. /** @hidden */
  126317. _gamepadManager: Nullable<GamepadManager>;
  126318. /**
  126319. * Gets the gamepad manager associated with the scene
  126320. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  126321. */
  126322. gamepadManager: GamepadManager;
  126323. }
  126324. /**
  126325. * Interface representing a free camera inputs manager
  126326. */
  126327. interface FreeCameraInputsManager {
  126328. /**
  126329. * Adds gamepad input support to the FreeCameraInputsManager.
  126330. * @returns the FreeCameraInputsManager
  126331. */
  126332. addGamepad(): FreeCameraInputsManager;
  126333. }
  126334. /**
  126335. * Interface representing an arc rotate camera inputs manager
  126336. */
  126337. interface ArcRotateCameraInputsManager {
  126338. /**
  126339. * Adds gamepad input support to the ArcRotateCamera InputManager.
  126340. * @returns the camera inputs manager
  126341. */
  126342. addGamepad(): ArcRotateCameraInputsManager;
  126343. }
  126344. /**
  126345. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  126346. */
  126347. export class GamepadSystemSceneComponent implements ISceneComponent {
  126348. /**
  126349. * The component name helpfull to identify the component in the list of scene components.
  126350. */
  126351. readonly name: string;
  126352. /**
  126353. * The scene the component belongs to.
  126354. */
  126355. scene: Scene;
  126356. /**
  126357. * Creates a new instance of the component for the given scene
  126358. * @param scene Defines the scene to register the component in
  126359. */
  126360. constructor(scene: Scene);
  126361. /**
  126362. * Registers the component in a given scene
  126363. */
  126364. register(): void;
  126365. /**
  126366. * Rebuilds the elements related to this component in case of
  126367. * context lost for instance.
  126368. */
  126369. rebuild(): void;
  126370. /**
  126371. * Disposes the component and the associated ressources
  126372. */
  126373. dispose(): void;
  126374. private _beforeCameraUpdate;
  126375. }
  126376. }
  126377. declare module BABYLON {
  126378. /**
  126379. * 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,
  126380. * which still works and will still be found in many Playgrounds.
  126381. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126382. */
  126383. export class UniversalCamera extends TouchCamera {
  126384. /**
  126385. * Defines the gamepad rotation sensiblity.
  126386. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  126387. */
  126388. get gamepadAngularSensibility(): number;
  126389. set gamepadAngularSensibility(value: number);
  126390. /**
  126391. * Defines the gamepad move sensiblity.
  126392. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  126393. */
  126394. get gamepadMoveSensibility(): number;
  126395. set gamepadMoveSensibility(value: number);
  126396. /**
  126397. * 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,
  126398. * which still works and will still be found in many Playgrounds.
  126399. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126400. * @param name Define the name of the camera in the scene
  126401. * @param position Define the start position of the camera in the scene
  126402. * @param scene Define the scene the camera belongs to
  126403. */
  126404. constructor(name: string, position: Vector3, scene: Scene);
  126405. /**
  126406. * Gets the current object class name.
  126407. * @return the class name
  126408. */
  126409. getClassName(): string;
  126410. }
  126411. }
  126412. declare module BABYLON {
  126413. /**
  126414. * This represents a FPS type of camera. This is only here for back compat purpose.
  126415. * Please use the UniversalCamera instead as both are identical.
  126416. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126417. */
  126418. export class GamepadCamera extends UniversalCamera {
  126419. /**
  126420. * Instantiates a new Gamepad Camera
  126421. * This represents a FPS type of camera. This is only here for back compat purpose.
  126422. * Please use the UniversalCamera instead as both are identical.
  126423. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126424. * @param name Define the name of the camera in the scene
  126425. * @param position Define the start position of the camera in the scene
  126426. * @param scene Define the scene the camera belongs to
  126427. */
  126428. constructor(name: string, position: Vector3, scene: Scene);
  126429. /**
  126430. * Gets the current object class name.
  126431. * @return the class name
  126432. */
  126433. getClassName(): string;
  126434. }
  126435. }
  126436. declare module BABYLON {
  126437. /** @hidden */
  126438. export var passPixelShader: {
  126439. name: string;
  126440. shader: string;
  126441. };
  126442. }
  126443. declare module BABYLON {
  126444. /** @hidden */
  126445. export var passCubePixelShader: {
  126446. name: string;
  126447. shader: string;
  126448. };
  126449. }
  126450. declare module BABYLON {
  126451. /**
  126452. * PassPostProcess which produces an output the same as it's input
  126453. */
  126454. export class PassPostProcess extends PostProcess {
  126455. /**
  126456. * Gets a string identifying the name of the class
  126457. * @returns "PassPostProcess" string
  126458. */
  126459. getClassName(): string;
  126460. /**
  126461. * Creates the PassPostProcess
  126462. * @param name The name of the effect.
  126463. * @param options The required width/height ratio to downsize to before computing the render pass.
  126464. * @param camera The camera to apply the render pass to.
  126465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126466. * @param engine The engine which the post process will be applied. (default: current engine)
  126467. * @param reusable If the post process can be reused on the same frame. (default: false)
  126468. * @param textureType The type of texture to be used when performing the post processing.
  126469. * @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)
  126470. */
  126471. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126472. /** @hidden */
  126473. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  126474. }
  126475. /**
  126476. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126477. */
  126478. export class PassCubePostProcess extends PostProcess {
  126479. private _face;
  126480. /**
  126481. * Gets or sets the cube face to display.
  126482. * * 0 is +X
  126483. * * 1 is -X
  126484. * * 2 is +Y
  126485. * * 3 is -Y
  126486. * * 4 is +Z
  126487. * * 5 is -Z
  126488. */
  126489. get face(): number;
  126490. set face(value: number);
  126491. /**
  126492. * Gets a string identifying the name of the class
  126493. * @returns "PassCubePostProcess" string
  126494. */
  126495. getClassName(): string;
  126496. /**
  126497. * Creates the PassCubePostProcess
  126498. * @param name The name of the effect.
  126499. * @param options The required width/height ratio to downsize to before computing the render pass.
  126500. * @param camera The camera to apply the render pass to.
  126501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126502. * @param engine The engine which the post process will be applied. (default: current engine)
  126503. * @param reusable If the post process can be reused on the same frame. (default: false)
  126504. * @param textureType The type of texture to be used when performing the post processing.
  126505. * @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)
  126506. */
  126507. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126508. /** @hidden */
  126509. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126510. }
  126511. }
  126512. declare module BABYLON {
  126513. /** @hidden */
  126514. export var anaglyphPixelShader: {
  126515. name: string;
  126516. shader: string;
  126517. };
  126518. }
  126519. declare module BABYLON {
  126520. /**
  126521. * Postprocess used to generate anaglyphic rendering
  126522. */
  126523. export class AnaglyphPostProcess extends PostProcess {
  126524. private _passedProcess;
  126525. /**
  126526. * Gets a string identifying the name of the class
  126527. * @returns "AnaglyphPostProcess" string
  126528. */
  126529. getClassName(): string;
  126530. /**
  126531. * Creates a new AnaglyphPostProcess
  126532. * @param name defines postprocess name
  126533. * @param options defines creation options or target ratio scale
  126534. * @param rigCameras defines cameras using this postprocess
  126535. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126536. * @param engine defines hosting engine
  126537. * @param reusable defines if the postprocess will be reused multiple times per frame
  126538. */
  126539. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126540. }
  126541. }
  126542. declare module BABYLON {
  126543. /**
  126544. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126545. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126546. */
  126547. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126548. /**
  126549. * Creates a new AnaglyphArcRotateCamera
  126550. * @param name defines camera name
  126551. * @param alpha defines alpha angle (in radians)
  126552. * @param beta defines beta angle (in radians)
  126553. * @param radius defines radius
  126554. * @param target defines camera target
  126555. * @param interaxialDistance defines distance between each color axis
  126556. * @param scene defines the hosting scene
  126557. */
  126558. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126559. /**
  126560. * Gets camera class name
  126561. * @returns AnaglyphArcRotateCamera
  126562. */
  126563. getClassName(): string;
  126564. }
  126565. }
  126566. declare module BABYLON {
  126567. /**
  126568. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126569. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126570. */
  126571. export class AnaglyphFreeCamera extends FreeCamera {
  126572. /**
  126573. * Creates a new AnaglyphFreeCamera
  126574. * @param name defines camera name
  126575. * @param position defines initial position
  126576. * @param interaxialDistance defines distance between each color axis
  126577. * @param scene defines the hosting scene
  126578. */
  126579. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126580. /**
  126581. * Gets camera class name
  126582. * @returns AnaglyphFreeCamera
  126583. */
  126584. getClassName(): string;
  126585. }
  126586. }
  126587. declare module BABYLON {
  126588. /**
  126589. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126590. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126591. */
  126592. export class AnaglyphGamepadCamera extends GamepadCamera {
  126593. /**
  126594. * Creates a new AnaglyphGamepadCamera
  126595. * @param name defines camera name
  126596. * @param position defines initial position
  126597. * @param interaxialDistance defines distance between each color axis
  126598. * @param scene defines the hosting scene
  126599. */
  126600. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126601. /**
  126602. * Gets camera class name
  126603. * @returns AnaglyphGamepadCamera
  126604. */
  126605. getClassName(): string;
  126606. }
  126607. }
  126608. declare module BABYLON {
  126609. /**
  126610. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126611. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126612. */
  126613. export class AnaglyphUniversalCamera extends UniversalCamera {
  126614. /**
  126615. * Creates a new AnaglyphUniversalCamera
  126616. * @param name defines camera name
  126617. * @param position defines initial position
  126618. * @param interaxialDistance defines distance between each color axis
  126619. * @param scene defines the hosting scene
  126620. */
  126621. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126622. /**
  126623. * Gets camera class name
  126624. * @returns AnaglyphUniversalCamera
  126625. */
  126626. getClassName(): string;
  126627. }
  126628. }
  126629. declare module BABYLON {
  126630. /**
  126631. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126632. * @see https://doc.babylonjs.com/features/cameras
  126633. */
  126634. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126635. /**
  126636. * Creates a new StereoscopicArcRotateCamera
  126637. * @param name defines camera name
  126638. * @param alpha defines alpha angle (in radians)
  126639. * @param beta defines beta angle (in radians)
  126640. * @param radius defines radius
  126641. * @param target defines camera target
  126642. * @param interaxialDistance defines distance between each color axis
  126643. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126644. * @param scene defines the hosting scene
  126645. */
  126646. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126647. /**
  126648. * Gets camera class name
  126649. * @returns StereoscopicArcRotateCamera
  126650. */
  126651. getClassName(): string;
  126652. }
  126653. }
  126654. declare module BABYLON {
  126655. /**
  126656. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126657. * @see https://doc.babylonjs.com/features/cameras
  126658. */
  126659. export class StereoscopicFreeCamera extends FreeCamera {
  126660. /**
  126661. * Creates a new StereoscopicFreeCamera
  126662. * @param name defines camera name
  126663. * @param position defines initial position
  126664. * @param interaxialDistance defines distance between each color axis
  126665. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126666. * @param scene defines the hosting scene
  126667. */
  126668. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126669. /**
  126670. * Gets camera class name
  126671. * @returns StereoscopicFreeCamera
  126672. */
  126673. getClassName(): string;
  126674. }
  126675. }
  126676. declare module BABYLON {
  126677. /**
  126678. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126679. * @see https://doc.babylonjs.com/features/cameras
  126680. */
  126681. export class StereoscopicGamepadCamera extends GamepadCamera {
  126682. /**
  126683. * Creates a new StereoscopicGamepadCamera
  126684. * @param name defines camera name
  126685. * @param position defines initial position
  126686. * @param interaxialDistance defines distance between each color axis
  126687. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126688. * @param scene defines the hosting scene
  126689. */
  126690. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126691. /**
  126692. * Gets camera class name
  126693. * @returns StereoscopicGamepadCamera
  126694. */
  126695. getClassName(): string;
  126696. }
  126697. }
  126698. declare module BABYLON {
  126699. /**
  126700. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  126701. * @see https://doc.babylonjs.com/features/cameras
  126702. */
  126703. export class StereoscopicUniversalCamera extends UniversalCamera {
  126704. /**
  126705. * Creates a new StereoscopicUniversalCamera
  126706. * @param name defines camera name
  126707. * @param position defines initial position
  126708. * @param interaxialDistance defines distance between each color axis
  126709. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126710. * @param scene defines the hosting scene
  126711. */
  126712. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126713. /**
  126714. * Gets camera class name
  126715. * @returns StereoscopicUniversalCamera
  126716. */
  126717. getClassName(): string;
  126718. }
  126719. }
  126720. declare module BABYLON {
  126721. /**
  126722. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  126723. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126724. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126725. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126726. */
  126727. export class VirtualJoysticksCamera extends FreeCamera {
  126728. /**
  126729. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  126730. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126731. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126732. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126733. * @param name Define the name of the camera in the scene
  126734. * @param position Define the start position of the camera in the scene
  126735. * @param scene Define the scene the camera belongs to
  126736. */
  126737. constructor(name: string, position: Vector3, scene: Scene);
  126738. /**
  126739. * Gets the current object class name.
  126740. * @return the class name
  126741. */
  126742. getClassName(): string;
  126743. }
  126744. }
  126745. declare module BABYLON {
  126746. /**
  126747. * This represents all the required metrics to create a VR camera.
  126748. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126749. */
  126750. export class VRCameraMetrics {
  126751. /**
  126752. * Define the horizontal resolution off the screen.
  126753. */
  126754. hResolution: number;
  126755. /**
  126756. * Define the vertical resolution off the screen.
  126757. */
  126758. vResolution: number;
  126759. /**
  126760. * Define the horizontal screen size.
  126761. */
  126762. hScreenSize: number;
  126763. /**
  126764. * Define the vertical screen size.
  126765. */
  126766. vScreenSize: number;
  126767. /**
  126768. * Define the vertical screen center position.
  126769. */
  126770. vScreenCenter: number;
  126771. /**
  126772. * Define the distance of the eyes to the screen.
  126773. */
  126774. eyeToScreenDistance: number;
  126775. /**
  126776. * Define the distance between both lenses
  126777. */
  126778. lensSeparationDistance: number;
  126779. /**
  126780. * Define the distance between both viewer's eyes.
  126781. */
  126782. interpupillaryDistance: number;
  126783. /**
  126784. * Define the distortion factor of the VR postprocess.
  126785. * Please, touch with care.
  126786. */
  126787. distortionK: number[];
  126788. /**
  126789. * Define the chromatic aberration correction factors for the VR post process.
  126790. */
  126791. chromaAbCorrection: number[];
  126792. /**
  126793. * Define the scale factor of the post process.
  126794. * The smaller the better but the slower.
  126795. */
  126796. postProcessScaleFactor: number;
  126797. /**
  126798. * Define an offset for the lens center.
  126799. */
  126800. lensCenterOffset: number;
  126801. /**
  126802. * Define if the current vr camera should compensate the distortion of the lense or not.
  126803. */
  126804. compensateDistortion: boolean;
  126805. /**
  126806. * Defines if multiview should be enabled when rendering (Default: false)
  126807. */
  126808. multiviewEnabled: boolean;
  126809. /**
  126810. * Gets the rendering aspect ratio based on the provided resolutions.
  126811. */
  126812. get aspectRatio(): number;
  126813. /**
  126814. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126815. */
  126816. get aspectRatioFov(): number;
  126817. /**
  126818. * @hidden
  126819. */
  126820. get leftHMatrix(): Matrix;
  126821. /**
  126822. * @hidden
  126823. */
  126824. get rightHMatrix(): Matrix;
  126825. /**
  126826. * @hidden
  126827. */
  126828. get leftPreViewMatrix(): Matrix;
  126829. /**
  126830. * @hidden
  126831. */
  126832. get rightPreViewMatrix(): Matrix;
  126833. /**
  126834. * Get the default VRMetrics based on the most generic setup.
  126835. * @returns the default vr metrics
  126836. */
  126837. static GetDefault(): VRCameraMetrics;
  126838. }
  126839. }
  126840. declare module BABYLON {
  126841. /** @hidden */
  126842. export var vrDistortionCorrectionPixelShader: {
  126843. name: string;
  126844. shader: string;
  126845. };
  126846. }
  126847. declare module BABYLON {
  126848. /**
  126849. * VRDistortionCorrectionPostProcess used for mobile VR
  126850. */
  126851. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126852. private _isRightEye;
  126853. private _distortionFactors;
  126854. private _postProcessScaleFactor;
  126855. private _lensCenterOffset;
  126856. private _scaleIn;
  126857. private _scaleFactor;
  126858. private _lensCenter;
  126859. /**
  126860. * Gets a string identifying the name of the class
  126861. * @returns "VRDistortionCorrectionPostProcess" string
  126862. */
  126863. getClassName(): string;
  126864. /**
  126865. * Initializes the VRDistortionCorrectionPostProcess
  126866. * @param name The name of the effect.
  126867. * @param camera The camera to apply the render pass to.
  126868. * @param isRightEye If this is for the right eye distortion
  126869. * @param vrMetrics All the required metrics for the VR camera
  126870. */
  126871. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126872. }
  126873. }
  126874. declare module BABYLON {
  126875. /**
  126876. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126877. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126878. */
  126879. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126880. /**
  126881. * Creates a new VRDeviceOrientationArcRotateCamera
  126882. * @param name defines camera name
  126883. * @param alpha defines the camera rotation along the logitudinal axis
  126884. * @param beta defines the camera rotation along the latitudinal axis
  126885. * @param radius defines the camera distance from its target
  126886. * @param target defines the camera target
  126887. * @param scene defines the scene the camera belongs to
  126888. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126889. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126890. */
  126891. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126892. /**
  126893. * Gets camera class name
  126894. * @returns VRDeviceOrientationArcRotateCamera
  126895. */
  126896. getClassName(): string;
  126897. }
  126898. }
  126899. declare module BABYLON {
  126900. /**
  126901. * Camera used to simulate VR rendering (based on FreeCamera)
  126902. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126903. */
  126904. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126905. /**
  126906. * Creates a new VRDeviceOrientationFreeCamera
  126907. * @param name defines camera name
  126908. * @param position defines the start position of the camera
  126909. * @param scene defines the scene the camera belongs to
  126910. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126911. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126912. */
  126913. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126914. /**
  126915. * Gets camera class name
  126916. * @returns VRDeviceOrientationFreeCamera
  126917. */
  126918. getClassName(): string;
  126919. }
  126920. }
  126921. declare module BABYLON {
  126922. /**
  126923. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126924. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126925. */
  126926. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126927. /**
  126928. * Creates a new VRDeviceOrientationGamepadCamera
  126929. * @param name defines camera name
  126930. * @param position defines the start position of the camera
  126931. * @param scene defines the scene the camera belongs to
  126932. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126933. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126934. */
  126935. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126936. /**
  126937. * Gets camera class name
  126938. * @returns VRDeviceOrientationGamepadCamera
  126939. */
  126940. getClassName(): string;
  126941. }
  126942. }
  126943. declare module BABYLON {
  126944. /**
  126945. * A class extending Texture allowing drawing on a texture
  126946. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126947. */
  126948. export class DynamicTexture extends Texture {
  126949. private _generateMipMaps;
  126950. private _canvas;
  126951. private _context;
  126952. /**
  126953. * Creates a DynamicTexture
  126954. * @param name defines the name of the texture
  126955. * @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
  126956. * @param scene defines the scene where you want the texture
  126957. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126958. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126959. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126960. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  126961. */
  126962. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  126963. /**
  126964. * Get the current class name of the texture useful for serialization or dynamic coding.
  126965. * @returns "DynamicTexture"
  126966. */
  126967. getClassName(): string;
  126968. /**
  126969. * Gets the current state of canRescale
  126970. */
  126971. get canRescale(): boolean;
  126972. private _recreate;
  126973. /**
  126974. * Scales the texture
  126975. * @param ratio the scale factor to apply to both width and height
  126976. */
  126977. scale(ratio: number): void;
  126978. /**
  126979. * Resizes the texture
  126980. * @param width the new width
  126981. * @param height the new height
  126982. */
  126983. scaleTo(width: number, height: number): void;
  126984. /**
  126985. * Gets the context of the canvas used by the texture
  126986. * @returns the canvas context of the dynamic texture
  126987. */
  126988. getContext(): CanvasRenderingContext2D;
  126989. /**
  126990. * Clears the texture
  126991. */
  126992. clear(): void;
  126993. /**
  126994. * Updates the texture
  126995. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126996. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126997. */
  126998. update(invertY?: boolean, premulAlpha?: boolean): void;
  126999. /**
  127000. * Draws text onto the texture
  127001. * @param text defines the text to be drawn
  127002. * @param x defines the placement of the text from the left
  127003. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  127004. * @param font defines the font to be used with font-style, font-size, font-name
  127005. * @param color defines the color used for the text
  127006. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  127007. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  127008. * @param update defines whether texture is immediately update (default is true)
  127009. */
  127010. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  127011. /**
  127012. * Clones the texture
  127013. * @returns the clone of the texture.
  127014. */
  127015. clone(): DynamicTexture;
  127016. /**
  127017. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  127018. * @returns a serialized dynamic texture object
  127019. */
  127020. serialize(): any;
  127021. private _IsCanvasElement;
  127022. /** @hidden */
  127023. _rebuild(): void;
  127024. }
  127025. }
  127026. declare module BABYLON {
  127027. /**
  127028. * Class containing static functions to help procedurally build meshes
  127029. */
  127030. export class GroundBuilder {
  127031. /**
  127032. * Creates a ground mesh
  127033. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127034. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127036. * @param name defines the name of the mesh
  127037. * @param options defines the options used to create the mesh
  127038. * @param scene defines the hosting scene
  127039. * @returns the ground mesh
  127040. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127041. */
  127042. static CreateGround(name: string, options: {
  127043. width?: number;
  127044. height?: number;
  127045. subdivisions?: number;
  127046. subdivisionsX?: number;
  127047. subdivisionsY?: number;
  127048. updatable?: boolean;
  127049. }, scene: any): Mesh;
  127050. /**
  127051. * Creates a tiled ground mesh
  127052. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127053. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127054. * * 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
  127055. * * 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
  127056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127057. * @param name defines the name of the mesh
  127058. * @param options defines the options used to create the mesh
  127059. * @param scene defines the hosting scene
  127060. * @returns the tiled ground mesh
  127061. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127062. */
  127063. static CreateTiledGround(name: string, options: {
  127064. xmin: number;
  127065. zmin: number;
  127066. xmax: number;
  127067. zmax: number;
  127068. subdivisions?: {
  127069. w: number;
  127070. h: number;
  127071. };
  127072. precision?: {
  127073. w: number;
  127074. h: number;
  127075. };
  127076. updatable?: boolean;
  127077. }, scene?: Nullable<Scene>): Mesh;
  127078. /**
  127079. * Creates a ground mesh from a height map
  127080. * * The parameter `url` sets the URL of the height map image resource.
  127081. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127082. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127083. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127084. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127085. * * 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.
  127086. * * 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).
  127087. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127089. * @param name defines the name of the mesh
  127090. * @param url defines the url to the height map
  127091. * @param options defines the options used to create the mesh
  127092. * @param scene defines the hosting scene
  127093. * @returns the ground mesh
  127094. * @see https://doc.babylonjs.com/babylon101/height_map
  127095. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127096. */
  127097. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127098. width?: number;
  127099. height?: number;
  127100. subdivisions?: number;
  127101. minHeight?: number;
  127102. maxHeight?: number;
  127103. colorFilter?: Color3;
  127104. alphaFilter?: number;
  127105. updatable?: boolean;
  127106. onReady?: (mesh: GroundMesh) => void;
  127107. }, scene?: Nullable<Scene>): GroundMesh;
  127108. }
  127109. }
  127110. declare module BABYLON {
  127111. /**
  127112. * Class containing static functions to help procedurally build meshes
  127113. */
  127114. export class TorusBuilder {
  127115. /**
  127116. * Creates a torus mesh
  127117. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127118. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127119. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127123. * @param name defines the name of the mesh
  127124. * @param options defines the options used to create the mesh
  127125. * @param scene defines the hosting scene
  127126. * @returns the torus mesh
  127127. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127128. */
  127129. static CreateTorus(name: string, options: {
  127130. diameter?: number;
  127131. thickness?: number;
  127132. tessellation?: number;
  127133. updatable?: boolean;
  127134. sideOrientation?: number;
  127135. frontUVs?: Vector4;
  127136. backUVs?: Vector4;
  127137. }, scene: any): Mesh;
  127138. }
  127139. }
  127140. declare module BABYLON {
  127141. /**
  127142. * Class containing static functions to help procedurally build meshes
  127143. */
  127144. export class CylinderBuilder {
  127145. /**
  127146. * Creates a cylinder or a cone mesh
  127147. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127148. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127149. * * 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.
  127150. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127151. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127152. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127153. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127154. * * 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).
  127155. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127156. * * 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).
  127157. * * 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
  127158. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127159. * * 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
  127160. * * 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.
  127161. * * If `enclose` is false, a ring surface is one element.
  127162. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127163. * * 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
  127164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127167. * @param name defines the name of the mesh
  127168. * @param options defines the options used to create the mesh
  127169. * @param scene defines the hosting scene
  127170. * @returns the cylinder mesh
  127171. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127172. */
  127173. static CreateCylinder(name: string, options: {
  127174. height?: number;
  127175. diameterTop?: number;
  127176. diameterBottom?: number;
  127177. diameter?: number;
  127178. tessellation?: number;
  127179. subdivisions?: number;
  127180. arc?: number;
  127181. faceColors?: Color4[];
  127182. faceUV?: Vector4[];
  127183. updatable?: boolean;
  127184. hasRings?: boolean;
  127185. enclose?: boolean;
  127186. cap?: number;
  127187. sideOrientation?: number;
  127188. frontUVs?: Vector4;
  127189. backUVs?: Vector4;
  127190. }, scene: any): Mesh;
  127191. }
  127192. }
  127193. declare module BABYLON {
  127194. /**
  127195. * States of the webXR experience
  127196. */
  127197. export enum WebXRState {
  127198. /**
  127199. * Transitioning to being in XR mode
  127200. */
  127201. ENTERING_XR = 0,
  127202. /**
  127203. * Transitioning to non XR mode
  127204. */
  127205. EXITING_XR = 1,
  127206. /**
  127207. * In XR mode and presenting
  127208. */
  127209. IN_XR = 2,
  127210. /**
  127211. * Not entered XR mode
  127212. */
  127213. NOT_IN_XR = 3
  127214. }
  127215. /**
  127216. * Abstraction of the XR render target
  127217. */
  127218. export interface WebXRRenderTarget extends IDisposable {
  127219. /**
  127220. * xrpresent context of the canvas which can be used to display/mirror xr content
  127221. */
  127222. canvasContext: WebGLRenderingContext;
  127223. /**
  127224. * xr layer for the canvas
  127225. */
  127226. xrLayer: Nullable<XRWebGLLayer>;
  127227. /**
  127228. * Initializes the xr layer for the session
  127229. * @param xrSession xr session
  127230. * @returns a promise that will resolve once the XR Layer has been created
  127231. */
  127232. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127233. }
  127234. }
  127235. declare module BABYLON {
  127236. /**
  127237. * COnfiguration object for WebXR output canvas
  127238. */
  127239. export class WebXRManagedOutputCanvasOptions {
  127240. /**
  127241. * An optional canvas in case you wish to create it yourself and provide it here.
  127242. * If not provided, a new canvas will be created
  127243. */
  127244. canvasElement?: HTMLCanvasElement;
  127245. /**
  127246. * Options for this XR Layer output
  127247. */
  127248. canvasOptions?: XRWebGLLayerOptions;
  127249. /**
  127250. * CSS styling for a newly created canvas (if not provided)
  127251. */
  127252. newCanvasCssStyle?: string;
  127253. /**
  127254. * Get the default values of the configuration object
  127255. * @param engine defines the engine to use (can be null)
  127256. * @returns default values of this configuration object
  127257. */
  127258. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  127259. }
  127260. /**
  127261. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  127262. */
  127263. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  127264. private _options;
  127265. private _canvas;
  127266. private _engine;
  127267. private _originalCanvasSize;
  127268. /**
  127269. * Rendering context of the canvas which can be used to display/mirror xr content
  127270. */
  127271. canvasContext: WebGLRenderingContext;
  127272. /**
  127273. * xr layer for the canvas
  127274. */
  127275. xrLayer: Nullable<XRWebGLLayer>;
  127276. /**
  127277. * Obseervers registered here will be triggered when the xr layer was initialized
  127278. */
  127279. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  127280. /**
  127281. * Initializes the canvas to be added/removed upon entering/exiting xr
  127282. * @param _xrSessionManager The XR Session manager
  127283. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  127284. */
  127285. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  127286. /**
  127287. * Disposes of the object
  127288. */
  127289. dispose(): void;
  127290. /**
  127291. * Initializes the xr layer for the session
  127292. * @param xrSession xr session
  127293. * @returns a promise that will resolve once the XR Layer has been created
  127294. */
  127295. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127296. private _addCanvas;
  127297. private _removeCanvas;
  127298. private _setCanvasSize;
  127299. private _setManagedOutputCanvas;
  127300. }
  127301. }
  127302. declare module BABYLON {
  127303. /**
  127304. * Manages an XRSession to work with Babylon's engine
  127305. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  127306. */
  127307. export class WebXRSessionManager implements IDisposable {
  127308. /** The scene which the session should be created for */
  127309. scene: Scene;
  127310. private _referenceSpace;
  127311. private _rttProvider;
  127312. private _sessionEnded;
  127313. private _xrNavigator;
  127314. private baseLayer;
  127315. /**
  127316. * The base reference space from which the session started. good if you want to reset your
  127317. * reference space
  127318. */
  127319. baseReferenceSpace: XRReferenceSpace;
  127320. /**
  127321. * Current XR frame
  127322. */
  127323. currentFrame: Nullable<XRFrame>;
  127324. /** WebXR timestamp updated every frame */
  127325. currentTimestamp: number;
  127326. /**
  127327. * Used just in case of a failure to initialize an immersive session.
  127328. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  127329. */
  127330. defaultHeightCompensation: number;
  127331. /**
  127332. * Fires every time a new xrFrame arrives which can be used to update the camera
  127333. */
  127334. onXRFrameObservable: Observable<XRFrame>;
  127335. /**
  127336. * Fires when the reference space changed
  127337. */
  127338. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  127339. /**
  127340. * Fires when the xr session is ended either by the device or manually done
  127341. */
  127342. onXRSessionEnded: Observable<any>;
  127343. /**
  127344. * Fires when the xr session is ended either by the device or manually done
  127345. */
  127346. onXRSessionInit: Observable<XRSession>;
  127347. /**
  127348. * Underlying xr session
  127349. */
  127350. session: XRSession;
  127351. /**
  127352. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  127353. * or get the offset the player is currently at.
  127354. */
  127355. viewerReferenceSpace: XRReferenceSpace;
  127356. /**
  127357. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  127358. * @param scene The scene which the session should be created for
  127359. */
  127360. constructor(
  127361. /** The scene which the session should be created for */
  127362. scene: Scene);
  127363. /**
  127364. * The current reference space used in this session. This reference space can constantly change!
  127365. * It is mainly used to offset the camera's position.
  127366. */
  127367. get referenceSpace(): XRReferenceSpace;
  127368. /**
  127369. * Set a new reference space and triggers the observable
  127370. */
  127371. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  127372. /**
  127373. * Disposes of the session manager
  127374. */
  127375. dispose(): void;
  127376. /**
  127377. * Stops the xrSession and restores the render loop
  127378. * @returns Promise which resolves after it exits XR
  127379. */
  127380. exitXRAsync(): Promise<void>;
  127381. /**
  127382. * Gets the correct render target texture to be rendered this frame for this eye
  127383. * @param eye the eye for which to get the render target
  127384. * @returns the render target for the specified eye
  127385. */
  127386. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  127387. /**
  127388. * Creates a WebXRRenderTarget object for the XR session
  127389. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  127390. * @param options optional options to provide when creating a new render target
  127391. * @returns a WebXR render target to which the session can render
  127392. */
  127393. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  127394. /**
  127395. * Initializes the manager
  127396. * After initialization enterXR can be called to start an XR session
  127397. * @returns Promise which resolves after it is initialized
  127398. */
  127399. initializeAsync(): Promise<void>;
  127400. /**
  127401. * Initializes an xr session
  127402. * @param xrSessionMode mode to initialize
  127403. * @param xrSessionInit defines optional and required values to pass to the session builder
  127404. * @returns a promise which will resolve once the session has been initialized
  127405. */
  127406. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  127407. /**
  127408. * Checks if a session would be supported for the creation options specified
  127409. * @param sessionMode session mode to check if supported eg. immersive-vr
  127410. * @returns A Promise that resolves to true if supported and false if not
  127411. */
  127412. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127413. /**
  127414. * Resets the reference space to the one started the session
  127415. */
  127416. resetReferenceSpace(): void;
  127417. /**
  127418. * Starts rendering to the xr layer
  127419. */
  127420. runXRRenderLoop(): void;
  127421. /**
  127422. * Sets the reference space on the xr session
  127423. * @param referenceSpaceType space to set
  127424. * @returns a promise that will resolve once the reference space has been set
  127425. */
  127426. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127427. /**
  127428. * Updates the render state of the session
  127429. * @param state state to set
  127430. * @returns a promise that resolves once the render state has been updated
  127431. */
  127432. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  127433. /**
  127434. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  127435. * @param sessionMode defines the session to test
  127436. * @returns a promise with boolean as final value
  127437. */
  127438. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127439. private _createRenderTargetTexture;
  127440. }
  127441. }
  127442. declare module BABYLON {
  127443. /**
  127444. * WebXR Camera which holds the views for the xrSession
  127445. * @see https://doc.babylonjs.com/how_to/webxr_camera
  127446. */
  127447. export class WebXRCamera extends FreeCamera {
  127448. private _xrSessionManager;
  127449. private _firstFrame;
  127450. private _referenceQuaternion;
  127451. private _referencedPosition;
  127452. private _xrInvPositionCache;
  127453. private _xrInvQuaternionCache;
  127454. /**
  127455. * Observable raised before camera teleportation
  127456. */
  127457. onBeforeCameraTeleport: Observable<Vector3>;
  127458. /**
  127459. * Observable raised after camera teleportation
  127460. */
  127461. onAfterCameraTeleport: Observable<Vector3>;
  127462. /**
  127463. * Should position compensation execute on first frame.
  127464. * This is used when copying the position from a native (non XR) camera
  127465. */
  127466. compensateOnFirstFrame: boolean;
  127467. /**
  127468. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  127469. * @param name the name of the camera
  127470. * @param scene the scene to add the camera to
  127471. * @param _xrSessionManager a constructed xr session manager
  127472. */
  127473. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  127474. /**
  127475. * Return the user's height, unrelated to the current ground.
  127476. * This will be the y position of this camera, when ground level is 0.
  127477. */
  127478. get realWorldHeight(): number;
  127479. /** @hidden */
  127480. _updateForDualEyeDebugging(): void;
  127481. /**
  127482. * Sets this camera's transformation based on a non-vr camera
  127483. * @param otherCamera the non-vr camera to copy the transformation from
  127484. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  127485. */
  127486. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127487. /**
  127488. * Gets the current instance class name ("WebXRCamera").
  127489. * @returns the class name
  127490. */
  127491. getClassName(): string;
  127492. private _rotate180;
  127493. private _updateFromXRSession;
  127494. private _updateNumberOfRigCameras;
  127495. private _updateReferenceSpace;
  127496. private _updateReferenceSpaceOffset;
  127497. }
  127498. }
  127499. declare module BABYLON {
  127500. /**
  127501. * Defining the interface required for a (webxr) feature
  127502. */
  127503. export interface IWebXRFeature extends IDisposable {
  127504. /**
  127505. * Is this feature attached
  127506. */
  127507. attached: boolean;
  127508. /**
  127509. * Should auto-attach be disabled?
  127510. */
  127511. disableAutoAttach: boolean;
  127512. /**
  127513. * Attach the feature to the session
  127514. * Will usually be called by the features manager
  127515. *
  127516. * @param force should attachment be forced (even when already attached)
  127517. * @returns true if successful.
  127518. */
  127519. attach(force?: boolean): boolean;
  127520. /**
  127521. * Detach the feature from the session
  127522. * Will usually be called by the features manager
  127523. *
  127524. * @returns true if successful.
  127525. */
  127526. detach(): boolean;
  127527. /**
  127528. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127529. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127530. *
  127531. * @returns whether or not the feature is compatible in this environment
  127532. */
  127533. isCompatible(): boolean;
  127534. /**
  127535. * Was this feature disposed;
  127536. */
  127537. isDisposed: boolean;
  127538. /**
  127539. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127540. */
  127541. xrNativeFeatureName?: string;
  127542. /**
  127543. * A list of (Babylon WebXR) features this feature depends on
  127544. */
  127545. dependsOn?: string[];
  127546. }
  127547. /**
  127548. * A list of the currently available features without referencing them
  127549. */
  127550. export class WebXRFeatureName {
  127551. /**
  127552. * The name of the anchor system feature
  127553. */
  127554. static readonly ANCHOR_SYSTEM: string;
  127555. /**
  127556. * The name of the background remover feature
  127557. */
  127558. static readonly BACKGROUND_REMOVER: string;
  127559. /**
  127560. * The name of the hit test feature
  127561. */
  127562. static readonly HIT_TEST: string;
  127563. /**
  127564. * physics impostors for xr controllers feature
  127565. */
  127566. static readonly PHYSICS_CONTROLLERS: string;
  127567. /**
  127568. * The name of the plane detection feature
  127569. */
  127570. static readonly PLANE_DETECTION: string;
  127571. /**
  127572. * The name of the pointer selection feature
  127573. */
  127574. static readonly POINTER_SELECTION: string;
  127575. /**
  127576. * The name of the teleportation feature
  127577. */
  127578. static readonly TELEPORTATION: string;
  127579. /**
  127580. * The name of the feature points feature.
  127581. */
  127582. static readonly FEATURE_POINTS: string;
  127583. /**
  127584. * The name of the hand tracking feature.
  127585. */
  127586. static readonly HAND_TRACKING: string;
  127587. }
  127588. /**
  127589. * Defining the constructor of a feature. Used to register the modules.
  127590. */
  127591. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127592. /**
  127593. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127594. * It is mainly used in AR sessions.
  127595. *
  127596. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127597. */
  127598. export class WebXRFeaturesManager implements IDisposable {
  127599. private _xrSessionManager;
  127600. private static readonly _AvailableFeatures;
  127601. private _features;
  127602. /**
  127603. * constructs a new features manages.
  127604. *
  127605. * @param _xrSessionManager an instance of WebXRSessionManager
  127606. */
  127607. constructor(_xrSessionManager: WebXRSessionManager);
  127608. /**
  127609. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127610. * Mainly used internally.
  127611. *
  127612. * @param featureName the name of the feature to register
  127613. * @param constructorFunction the function used to construct the module
  127614. * @param version the (babylon) version of the module
  127615. * @param stable is that a stable version of this module
  127616. */
  127617. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127618. /**
  127619. * Returns a constructor of a specific feature.
  127620. *
  127621. * @param featureName the name of the feature to construct
  127622. * @param version the version of the feature to load
  127623. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127624. * @param options optional options provided to the module.
  127625. * @returns a function that, when called, will return a new instance of this feature
  127626. */
  127627. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127628. /**
  127629. * Can be used to return the list of features currently registered
  127630. *
  127631. * @returns an Array of available features
  127632. */
  127633. static GetAvailableFeatures(): string[];
  127634. /**
  127635. * Gets the versions available for a specific feature
  127636. * @param featureName the name of the feature
  127637. * @returns an array with the available versions
  127638. */
  127639. static GetAvailableVersions(featureName: string): string[];
  127640. /**
  127641. * Return the latest unstable version of this feature
  127642. * @param featureName the name of the feature to search
  127643. * @returns the version number. if not found will return -1
  127644. */
  127645. static GetLatestVersionOfFeature(featureName: string): number;
  127646. /**
  127647. * Return the latest stable version of this feature
  127648. * @param featureName the name of the feature to search
  127649. * @returns the version number. if not found will return -1
  127650. */
  127651. static GetStableVersionOfFeature(featureName: string): number;
  127652. /**
  127653. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127654. * Can be used during a session to start a feature
  127655. * @param featureName the name of feature to attach
  127656. */
  127657. attachFeature(featureName: string): void;
  127658. /**
  127659. * Can be used inside a session or when the session ends to detach a specific feature
  127660. * @param featureName the name of the feature to detach
  127661. */
  127662. detachFeature(featureName: string): void;
  127663. /**
  127664. * Used to disable an already-enabled feature
  127665. * The feature will be disposed and will be recreated once enabled.
  127666. * @param featureName the feature to disable
  127667. * @returns true if disable was successful
  127668. */
  127669. disableFeature(featureName: string | {
  127670. Name: string;
  127671. }): boolean;
  127672. /**
  127673. * dispose this features manager
  127674. */
  127675. dispose(): void;
  127676. /**
  127677. * 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.
  127678. * 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.
  127679. *
  127680. * @param featureName the name of the feature to load or the class of the feature
  127681. * @param version optional version to load. if not provided the latest version will be enabled
  127682. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127683. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127684. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127685. * @returns a new constructed feature or throws an error if feature not found.
  127686. */
  127687. enableFeature(featureName: string | {
  127688. Name: string;
  127689. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127690. /**
  127691. * get the implementation of an enabled feature.
  127692. * @param featureName the name of the feature to load
  127693. * @returns the feature class, if found
  127694. */
  127695. getEnabledFeature(featureName: string): IWebXRFeature;
  127696. /**
  127697. * Get the list of enabled features
  127698. * @returns an array of enabled features
  127699. */
  127700. getEnabledFeatures(): string[];
  127701. /**
  127702. * This function will exten the session creation configuration object with enabled features.
  127703. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  127704. * according to the defined "required" variable, provided during enableFeature call
  127705. * @param xrSessionInit the xr Session init object to extend
  127706. *
  127707. * @returns an extended XRSessionInit object
  127708. */
  127709. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  127710. }
  127711. }
  127712. declare module BABYLON {
  127713. /**
  127714. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  127715. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  127716. */
  127717. export class WebXRExperienceHelper implements IDisposable {
  127718. private scene;
  127719. private _nonVRCamera;
  127720. private _originalSceneAutoClear;
  127721. private _supported;
  127722. /**
  127723. * Camera used to render xr content
  127724. */
  127725. camera: WebXRCamera;
  127726. /** A features manager for this xr session */
  127727. featuresManager: WebXRFeaturesManager;
  127728. /**
  127729. * Observers registered here will be triggered after the camera's initial transformation is set
  127730. * This can be used to set a different ground level or an extra rotation.
  127731. *
  127732. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  127733. * to the position set after this observable is done executing.
  127734. */
  127735. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  127736. /**
  127737. * Fires when the state of the experience helper has changed
  127738. */
  127739. onStateChangedObservable: Observable<WebXRState>;
  127740. /** Session manager used to keep track of xr session */
  127741. sessionManager: WebXRSessionManager;
  127742. /**
  127743. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127744. */
  127745. state: WebXRState;
  127746. /**
  127747. * Creates a WebXRExperienceHelper
  127748. * @param scene The scene the helper should be created in
  127749. */
  127750. private constructor();
  127751. /**
  127752. * Creates the experience helper
  127753. * @param scene the scene to attach the experience helper to
  127754. * @returns a promise for the experience helper
  127755. */
  127756. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127757. /**
  127758. * Disposes of the experience helper
  127759. */
  127760. dispose(): void;
  127761. /**
  127762. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127763. * @param sessionMode options for the XR session
  127764. * @param referenceSpaceType frame of reference of the XR session
  127765. * @param renderTarget the output canvas that will be used to enter XR mode
  127766. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127767. * @returns promise that resolves after xr mode has entered
  127768. */
  127769. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127770. /**
  127771. * Exits XR mode and returns the scene to its original state
  127772. * @returns promise that resolves after xr mode has exited
  127773. */
  127774. exitXRAsync(): Promise<void>;
  127775. private _nonXRToXRCamera;
  127776. private _setState;
  127777. }
  127778. }
  127779. declare module BABYLON {
  127780. /**
  127781. * X-Y values for axes in WebXR
  127782. */
  127783. export interface IWebXRMotionControllerAxesValue {
  127784. /**
  127785. * The value of the x axis
  127786. */
  127787. x: number;
  127788. /**
  127789. * The value of the y-axis
  127790. */
  127791. y: number;
  127792. }
  127793. /**
  127794. * changed / previous values for the values of this component
  127795. */
  127796. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127797. /**
  127798. * current (this frame) value
  127799. */
  127800. current: T;
  127801. /**
  127802. * previous (last change) value
  127803. */
  127804. previous: T;
  127805. }
  127806. /**
  127807. * Represents changes in the component between current frame and last values recorded
  127808. */
  127809. export interface IWebXRMotionControllerComponentChanges {
  127810. /**
  127811. * will be populated with previous and current values if axes changed
  127812. */
  127813. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127814. /**
  127815. * will be populated with previous and current values if pressed changed
  127816. */
  127817. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127818. /**
  127819. * will be populated with previous and current values if touched changed
  127820. */
  127821. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127822. /**
  127823. * will be populated with previous and current values if value changed
  127824. */
  127825. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127826. }
  127827. /**
  127828. * This class represents a single component (for example button or thumbstick) of a motion controller
  127829. */
  127830. export class WebXRControllerComponent implements IDisposable {
  127831. /**
  127832. * the id of this component
  127833. */
  127834. id: string;
  127835. /**
  127836. * the type of the component
  127837. */
  127838. type: MotionControllerComponentType;
  127839. private _buttonIndex;
  127840. private _axesIndices;
  127841. private _axes;
  127842. private _changes;
  127843. private _currentValue;
  127844. private _hasChanges;
  127845. private _pressed;
  127846. private _touched;
  127847. /**
  127848. * button component type
  127849. */
  127850. static BUTTON_TYPE: MotionControllerComponentType;
  127851. /**
  127852. * squeeze component type
  127853. */
  127854. static SQUEEZE_TYPE: MotionControllerComponentType;
  127855. /**
  127856. * Thumbstick component type
  127857. */
  127858. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127859. /**
  127860. * Touchpad component type
  127861. */
  127862. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127863. /**
  127864. * trigger component type
  127865. */
  127866. static TRIGGER_TYPE: MotionControllerComponentType;
  127867. /**
  127868. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127869. * the axes data changes
  127870. */
  127871. onAxisValueChangedObservable: Observable<{
  127872. x: number;
  127873. y: number;
  127874. }>;
  127875. /**
  127876. * Observers registered here will be triggered when the state of a button changes
  127877. * State change is either pressed / touched / value
  127878. */
  127879. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127880. /**
  127881. * Creates a new component for a motion controller.
  127882. * It is created by the motion controller itself
  127883. *
  127884. * @param id the id of this component
  127885. * @param type the type of the component
  127886. * @param _buttonIndex index in the buttons array of the gamepad
  127887. * @param _axesIndices indices of the values in the axes array of the gamepad
  127888. */
  127889. constructor(
  127890. /**
  127891. * the id of this component
  127892. */
  127893. id: string,
  127894. /**
  127895. * the type of the component
  127896. */
  127897. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127898. /**
  127899. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127900. */
  127901. get axes(): IWebXRMotionControllerAxesValue;
  127902. /**
  127903. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127904. */
  127905. get changes(): IWebXRMotionControllerComponentChanges;
  127906. /**
  127907. * Return whether or not the component changed the last frame
  127908. */
  127909. get hasChanges(): boolean;
  127910. /**
  127911. * is the button currently pressed
  127912. */
  127913. get pressed(): boolean;
  127914. /**
  127915. * is the button currently touched
  127916. */
  127917. get touched(): boolean;
  127918. /**
  127919. * Get the current value of this component
  127920. */
  127921. get value(): number;
  127922. /**
  127923. * Dispose this component
  127924. */
  127925. dispose(): void;
  127926. /**
  127927. * Are there axes correlating to this component
  127928. * @return true is axes data is available
  127929. */
  127930. isAxes(): boolean;
  127931. /**
  127932. * Is this component a button (hence - pressable)
  127933. * @returns true if can be pressed
  127934. */
  127935. isButton(): boolean;
  127936. /**
  127937. * update this component using the gamepad object it is in. Called on every frame
  127938. * @param nativeController the native gamepad controller object
  127939. */
  127940. update(nativeController: IMinimalMotionControllerObject): void;
  127941. }
  127942. }
  127943. declare module BABYLON {
  127944. /**
  127945. * Interface used to represent data loading progression
  127946. */
  127947. export interface ISceneLoaderProgressEvent {
  127948. /**
  127949. * Defines if data length to load can be evaluated
  127950. */
  127951. readonly lengthComputable: boolean;
  127952. /**
  127953. * Defines the loaded data length
  127954. */
  127955. readonly loaded: number;
  127956. /**
  127957. * Defines the data length to load
  127958. */
  127959. readonly total: number;
  127960. }
  127961. /**
  127962. * Interface used by SceneLoader plugins to define supported file extensions
  127963. */
  127964. export interface ISceneLoaderPluginExtensions {
  127965. /**
  127966. * Defines the list of supported extensions
  127967. */
  127968. [extension: string]: {
  127969. isBinary: boolean;
  127970. };
  127971. }
  127972. /**
  127973. * Interface used by SceneLoader plugin factory
  127974. */
  127975. export interface ISceneLoaderPluginFactory {
  127976. /**
  127977. * Defines the name of the factory
  127978. */
  127979. name: string;
  127980. /**
  127981. * Function called to create a new plugin
  127982. * @return the new plugin
  127983. */
  127984. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127985. /**
  127986. * The callback that returns true if the data can be directly loaded.
  127987. * @param data string containing the file data
  127988. * @returns if the data can be loaded directly
  127989. */
  127990. canDirectLoad?(data: string): boolean;
  127991. }
  127992. /**
  127993. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127994. */
  127995. export interface ISceneLoaderPluginBase {
  127996. /**
  127997. * The friendly name of this plugin.
  127998. */
  127999. name: string;
  128000. /**
  128001. * The file extensions supported by this plugin.
  128002. */
  128003. extensions: string | ISceneLoaderPluginExtensions;
  128004. /**
  128005. * The callback called when loading from a url.
  128006. * @param scene scene loading this url
  128007. * @param url url to load
  128008. * @param onSuccess callback called when the file successfully loads
  128009. * @param onProgress callback called while file is loading (if the server supports this mode)
  128010. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  128011. * @param onError callback called when the file fails to load
  128012. * @returns a file request object
  128013. */
  128014. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128015. /**
  128016. * The callback called when loading from a file object.
  128017. * @param scene scene loading this file
  128018. * @param file defines the file to load
  128019. * @param onSuccess defines the callback to call when data is loaded
  128020. * @param onProgress defines the callback to call during loading process
  128021. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  128022. * @param onError defines the callback to call when an error occurs
  128023. * @returns a file request object
  128024. */
  128025. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128026. /**
  128027. * The callback that returns true if the data can be directly loaded.
  128028. * @param data string containing the file data
  128029. * @returns if the data can be loaded directly
  128030. */
  128031. canDirectLoad?(data: string): boolean;
  128032. /**
  128033. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  128034. * @param scene scene loading this data
  128035. * @param data string containing the data
  128036. * @returns data to pass to the plugin
  128037. */
  128038. directLoad?(scene: Scene, data: string): any;
  128039. /**
  128040. * The callback that allows custom handling of the root url based on the response url.
  128041. * @param rootUrl the original root url
  128042. * @param responseURL the response url if available
  128043. * @returns the new root url
  128044. */
  128045. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  128046. }
  128047. /**
  128048. * Interface used to define a SceneLoader plugin
  128049. */
  128050. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  128051. /**
  128052. * Import meshes into a scene.
  128053. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128054. * @param scene The scene to import into
  128055. * @param data The data to import
  128056. * @param rootUrl The root url for scene and resources
  128057. * @param meshes The meshes array to import into
  128058. * @param particleSystems The particle systems array to import into
  128059. * @param skeletons The skeletons array to import into
  128060. * @param onError The callback when import fails
  128061. * @returns True if successful or false otherwise
  128062. */
  128063. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  128064. /**
  128065. * Load into a scene.
  128066. * @param scene The scene to load into
  128067. * @param data The data to import
  128068. * @param rootUrl The root url for scene and resources
  128069. * @param onError The callback when import fails
  128070. * @returns True if successful or false otherwise
  128071. */
  128072. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  128073. /**
  128074. * Load into an asset container.
  128075. * @param scene The scene to load into
  128076. * @param data The data to import
  128077. * @param rootUrl The root url for scene and resources
  128078. * @param onError The callback when import fails
  128079. * @returns The loaded asset container
  128080. */
  128081. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  128082. }
  128083. /**
  128084. * Interface used to define an async SceneLoader plugin
  128085. */
  128086. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  128087. /**
  128088. * Import meshes into a scene.
  128089. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128090. * @param scene The scene to import into
  128091. * @param data The data to import
  128092. * @param rootUrl The root url for scene and resources
  128093. * @param onProgress The callback when the load progresses
  128094. * @param fileName Defines the name of the file to load
  128095. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  128096. */
  128097. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  128098. meshes: AbstractMesh[];
  128099. particleSystems: IParticleSystem[];
  128100. skeletons: Skeleton[];
  128101. animationGroups: AnimationGroup[];
  128102. }>;
  128103. /**
  128104. * Load into a scene.
  128105. * @param scene The scene to load into
  128106. * @param data The data to import
  128107. * @param rootUrl The root url for scene and resources
  128108. * @param onProgress The callback when the load progresses
  128109. * @param fileName Defines the name of the file to load
  128110. * @returns Nothing
  128111. */
  128112. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  128113. /**
  128114. * Load into an asset container.
  128115. * @param scene The scene to load into
  128116. * @param data The data to import
  128117. * @param rootUrl The root url for scene and resources
  128118. * @param onProgress The callback when the load progresses
  128119. * @param fileName Defines the name of the file to load
  128120. * @returns The loaded asset container
  128121. */
  128122. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  128123. }
  128124. /**
  128125. * Mode that determines how to handle old animation groups before loading new ones.
  128126. */
  128127. export enum SceneLoaderAnimationGroupLoadingMode {
  128128. /**
  128129. * Reset all old animations to initial state then dispose them.
  128130. */
  128131. Clean = 0,
  128132. /**
  128133. * Stop all old animations.
  128134. */
  128135. Stop = 1,
  128136. /**
  128137. * Restart old animations from first frame.
  128138. */
  128139. Sync = 2,
  128140. /**
  128141. * Old animations remains untouched.
  128142. */
  128143. NoSync = 3
  128144. }
  128145. /**
  128146. * Defines a plugin registered by the SceneLoader
  128147. */
  128148. interface IRegisteredPlugin {
  128149. /**
  128150. * Defines the plugin to use
  128151. */
  128152. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128153. /**
  128154. * Defines if the plugin supports binary data
  128155. */
  128156. isBinary: boolean;
  128157. }
  128158. /**
  128159. * Class used to load scene from various file formats using registered plugins
  128160. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  128161. */
  128162. export class SceneLoader {
  128163. /**
  128164. * No logging while loading
  128165. */
  128166. static readonly NO_LOGGING: number;
  128167. /**
  128168. * Minimal logging while loading
  128169. */
  128170. static readonly MINIMAL_LOGGING: number;
  128171. /**
  128172. * Summary logging while loading
  128173. */
  128174. static readonly SUMMARY_LOGGING: number;
  128175. /**
  128176. * Detailled logging while loading
  128177. */
  128178. static readonly DETAILED_LOGGING: number;
  128179. /**
  128180. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  128181. */
  128182. static get ForceFullSceneLoadingForIncremental(): boolean;
  128183. static set ForceFullSceneLoadingForIncremental(value: boolean);
  128184. /**
  128185. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  128186. */
  128187. static get ShowLoadingScreen(): boolean;
  128188. static set ShowLoadingScreen(value: boolean);
  128189. /**
  128190. * Defines the current logging level (while loading the scene)
  128191. * @ignorenaming
  128192. */
  128193. static get loggingLevel(): number;
  128194. static set loggingLevel(value: number);
  128195. /**
  128196. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  128197. */
  128198. static get CleanBoneMatrixWeights(): boolean;
  128199. static set CleanBoneMatrixWeights(value: boolean);
  128200. /**
  128201. * Event raised when a plugin is used to load a scene
  128202. */
  128203. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  128204. private static _registeredPlugins;
  128205. private static _showingLoadingScreen;
  128206. /**
  128207. * Gets the default plugin (used to load Babylon files)
  128208. * @returns the .babylon plugin
  128209. */
  128210. static GetDefaultPlugin(): IRegisteredPlugin;
  128211. private static _GetPluginForExtension;
  128212. private static _GetPluginForDirectLoad;
  128213. private static _GetPluginForFilename;
  128214. private static _GetDirectLoad;
  128215. private static _LoadData;
  128216. private static _GetFileInfo;
  128217. /**
  128218. * Gets a plugin that can load the given extension
  128219. * @param extension defines the extension to load
  128220. * @returns a plugin or null if none works
  128221. */
  128222. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128223. /**
  128224. * Gets a boolean indicating that the given extension can be loaded
  128225. * @param extension defines the extension to load
  128226. * @returns true if the extension is supported
  128227. */
  128228. static IsPluginForExtensionAvailable(extension: string): boolean;
  128229. /**
  128230. * Adds a new plugin to the list of registered plugins
  128231. * @param plugin defines the plugin to add
  128232. */
  128233. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  128234. /**
  128235. * Import meshes into a scene
  128236. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128237. * @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)
  128238. * @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)
  128239. * @param scene the instance of BABYLON.Scene to append to
  128240. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  128241. * @param onProgress a callback with a progress event for each file being loaded
  128242. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128243. * @param pluginExtension the extension used to determine the plugin
  128244. * @returns The loaded plugin
  128245. */
  128246. 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>;
  128247. /**
  128248. * Import meshes into a scene
  128249. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128250. * @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)
  128251. * @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)
  128252. * @param scene the instance of BABYLON.Scene to append to
  128253. * @param onProgress a callback with a progress event for each file being loaded
  128254. * @param pluginExtension the extension used to determine the plugin
  128255. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  128256. */
  128257. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  128258. meshes: AbstractMesh[];
  128259. particleSystems: IParticleSystem[];
  128260. skeletons: Skeleton[];
  128261. animationGroups: AnimationGroup[];
  128262. }>;
  128263. /**
  128264. * Load a scene
  128265. * @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)
  128266. * @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)
  128267. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128268. * @param onSuccess a callback with the scene when import succeeds
  128269. * @param onProgress a callback with a progress event for each file being loaded
  128270. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128271. * @param pluginExtension the extension used to determine the plugin
  128272. * @returns The loaded plugin
  128273. */
  128274. 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>;
  128275. /**
  128276. * Load a scene
  128277. * @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)
  128278. * @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)
  128279. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128280. * @param onProgress a callback with a progress event for each file being loaded
  128281. * @param pluginExtension the extension used to determine the plugin
  128282. * @returns The loaded scene
  128283. */
  128284. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128285. /**
  128286. * Append a scene
  128287. * @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)
  128288. * @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)
  128289. * @param scene is the instance of BABYLON.Scene to append to
  128290. * @param onSuccess a callback with the scene when import succeeds
  128291. * @param onProgress a callback with a progress event for each file being loaded
  128292. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128293. * @param pluginExtension the extension used to determine the plugin
  128294. * @returns The loaded plugin
  128295. */
  128296. 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>;
  128297. /**
  128298. * Append a scene
  128299. * @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)
  128300. * @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)
  128301. * @param scene is the instance of BABYLON.Scene to append to
  128302. * @param onProgress a callback with a progress event for each file being loaded
  128303. * @param pluginExtension the extension used to determine the plugin
  128304. * @returns The given scene
  128305. */
  128306. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128307. /**
  128308. * Load a scene into an asset container
  128309. * @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)
  128310. * @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)
  128311. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128312. * @param onSuccess a callback with the scene when import succeeds
  128313. * @param onProgress a callback with a progress event for each file being loaded
  128314. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128315. * @param pluginExtension the extension used to determine the plugin
  128316. * @returns The loaded plugin
  128317. */
  128318. 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>;
  128319. /**
  128320. * Load a scene into an asset container
  128321. * @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)
  128322. * @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)
  128323. * @param scene is the instance of Scene to append to
  128324. * @param onProgress a callback with a progress event for each file being loaded
  128325. * @param pluginExtension the extension used to determine the plugin
  128326. * @returns The loaded asset container
  128327. */
  128328. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  128329. /**
  128330. * Import animations from a file into a scene
  128331. * @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)
  128332. * @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)
  128333. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128334. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128335. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128336. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128337. * @param onSuccess a callback with the scene when import succeeds
  128338. * @param onProgress a callback with a progress event for each file being loaded
  128339. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128340. * @param pluginExtension the extension used to determine the plugin
  128341. */
  128342. 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;
  128343. /**
  128344. * Import animations from a file into a scene
  128345. * @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)
  128346. * @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)
  128347. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128348. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128349. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128350. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128351. * @param onSuccess a callback with the scene when import succeeds
  128352. * @param onProgress a callback with a progress event for each file being loaded
  128353. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128354. * @param pluginExtension the extension used to determine the plugin
  128355. * @returns the updated scene with imported animations
  128356. */
  128357. 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>;
  128358. }
  128359. }
  128360. declare module BABYLON {
  128361. /**
  128362. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  128363. */
  128364. export type MotionControllerHandedness = "none" | "left" | "right";
  128365. /**
  128366. * The type of components available in motion controllers.
  128367. * This is not the name of the component.
  128368. */
  128369. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  128370. /**
  128371. * The state of a controller component
  128372. */
  128373. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  128374. /**
  128375. * The schema of motion controller layout.
  128376. * No object will be initialized using this interface
  128377. * This is used just to define the profile.
  128378. */
  128379. export interface IMotionControllerLayout {
  128380. /**
  128381. * Path to load the assets. Usually relative to the base path
  128382. */
  128383. assetPath: string;
  128384. /**
  128385. * Available components (unsorted)
  128386. */
  128387. components: {
  128388. /**
  128389. * A map of component Ids
  128390. */
  128391. [componentId: string]: {
  128392. /**
  128393. * The type of input the component outputs
  128394. */
  128395. type: MotionControllerComponentType;
  128396. /**
  128397. * The indices of this component in the gamepad object
  128398. */
  128399. gamepadIndices: {
  128400. /**
  128401. * Index of button
  128402. */
  128403. button?: number;
  128404. /**
  128405. * If available, index of x-axis
  128406. */
  128407. xAxis?: number;
  128408. /**
  128409. * If available, index of y-axis
  128410. */
  128411. yAxis?: number;
  128412. };
  128413. /**
  128414. * The mesh's root node name
  128415. */
  128416. rootNodeName: string;
  128417. /**
  128418. * Animation definitions for this model
  128419. */
  128420. visualResponses: {
  128421. [stateKey: string]: {
  128422. /**
  128423. * What property will be animated
  128424. */
  128425. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  128426. /**
  128427. * What states influence this visual response
  128428. */
  128429. states: MotionControllerComponentStateType[];
  128430. /**
  128431. * Type of animation - movement or visibility
  128432. */
  128433. valueNodeProperty: "transform" | "visibility";
  128434. /**
  128435. * Base node name to move. Its position will be calculated according to the min and max nodes
  128436. */
  128437. valueNodeName?: string;
  128438. /**
  128439. * Minimum movement node
  128440. */
  128441. minNodeName?: string;
  128442. /**
  128443. * Max movement node
  128444. */
  128445. maxNodeName?: string;
  128446. };
  128447. };
  128448. /**
  128449. * If touch enabled, what is the name of node to display user feedback
  128450. */
  128451. touchPointNodeName?: string;
  128452. };
  128453. };
  128454. /**
  128455. * Is it xr standard mapping or not
  128456. */
  128457. gamepadMapping: "" | "xr-standard";
  128458. /**
  128459. * Base root node of this entire model
  128460. */
  128461. rootNodeName: string;
  128462. /**
  128463. * Defines the main button component id
  128464. */
  128465. selectComponentId: string;
  128466. }
  128467. /**
  128468. * A definition for the layout map in the input profile
  128469. */
  128470. export interface IMotionControllerLayoutMap {
  128471. /**
  128472. * Layouts with handedness type as a key
  128473. */
  128474. [handedness: string]: IMotionControllerLayout;
  128475. }
  128476. /**
  128477. * The XR Input profile schema
  128478. * Profiles can be found here:
  128479. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  128480. */
  128481. export interface IMotionControllerProfile {
  128482. /**
  128483. * fallback profiles for this profileId
  128484. */
  128485. fallbackProfileIds: string[];
  128486. /**
  128487. * The layout map, with handedness as key
  128488. */
  128489. layouts: IMotionControllerLayoutMap;
  128490. /**
  128491. * The id of this profile
  128492. * correlates to the profile(s) in the xrInput.profiles array
  128493. */
  128494. profileId: string;
  128495. }
  128496. /**
  128497. * A helper-interface for the 3 meshes needed for controller button animation
  128498. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128499. */
  128500. export interface IMotionControllerButtonMeshMap {
  128501. /**
  128502. * the mesh that defines the pressed value mesh position.
  128503. * This is used to find the max-position of this button
  128504. */
  128505. pressedMesh: AbstractMesh;
  128506. /**
  128507. * the mesh that defines the unpressed value mesh position.
  128508. * This is used to find the min (or initial) position of this button
  128509. */
  128510. unpressedMesh: AbstractMesh;
  128511. /**
  128512. * The mesh that will be changed when value changes
  128513. */
  128514. valueMesh: AbstractMesh;
  128515. }
  128516. /**
  128517. * A helper-interface for the 3 meshes needed for controller axis animation.
  128518. * This will be expanded when touchpad animations are fully supported
  128519. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128520. */
  128521. export interface IMotionControllerMeshMap {
  128522. /**
  128523. * the mesh that defines the maximum value mesh position.
  128524. */
  128525. maxMesh?: AbstractMesh;
  128526. /**
  128527. * the mesh that defines the minimum value mesh position.
  128528. */
  128529. minMesh?: AbstractMesh;
  128530. /**
  128531. * The mesh that will be changed when axis value changes
  128532. */
  128533. valueMesh?: AbstractMesh;
  128534. }
  128535. /**
  128536. * The elements needed for change-detection of the gamepad objects in motion controllers
  128537. */
  128538. export interface IMinimalMotionControllerObject {
  128539. /**
  128540. * Available axes of this controller
  128541. */
  128542. axes: number[];
  128543. /**
  128544. * An array of available buttons
  128545. */
  128546. buttons: Array<{
  128547. /**
  128548. * Value of the button/trigger
  128549. */
  128550. value: number;
  128551. /**
  128552. * If the button/trigger is currently touched
  128553. */
  128554. touched: boolean;
  128555. /**
  128556. * If the button/trigger is currently pressed
  128557. */
  128558. pressed: boolean;
  128559. }>;
  128560. /**
  128561. * EXPERIMENTAL haptic support.
  128562. */
  128563. hapticActuators?: Array<{
  128564. pulse: (value: number, duration: number) => Promise<boolean>;
  128565. }>;
  128566. }
  128567. /**
  128568. * An Abstract Motion controller
  128569. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128570. * Each component has an observable to check for changes in value and state
  128571. */
  128572. export abstract class WebXRAbstractMotionController implements IDisposable {
  128573. protected scene: Scene;
  128574. protected layout: IMotionControllerLayout;
  128575. /**
  128576. * The gamepad object correlating to this controller
  128577. */
  128578. gamepadObject: IMinimalMotionControllerObject;
  128579. /**
  128580. * handedness (left/right/none) of this controller
  128581. */
  128582. handedness: MotionControllerHandedness;
  128583. private _initComponent;
  128584. private _modelReady;
  128585. /**
  128586. * A map of components (WebXRControllerComponent) in this motion controller
  128587. * Components have a ComponentType and can also have both button and axis definitions
  128588. */
  128589. readonly components: {
  128590. [id: string]: WebXRControllerComponent;
  128591. };
  128592. /**
  128593. * Disable the model's animation. Can be set at any time.
  128594. */
  128595. disableAnimation: boolean;
  128596. /**
  128597. * Observers registered here will be triggered when the model of this controller is done loading
  128598. */
  128599. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128600. /**
  128601. * The profile id of this motion controller
  128602. */
  128603. abstract profileId: string;
  128604. /**
  128605. * The root mesh of the model. It is null if the model was not yet initialized
  128606. */
  128607. rootMesh: Nullable<AbstractMesh>;
  128608. /**
  128609. * constructs a new abstract motion controller
  128610. * @param scene the scene to which the model of the controller will be added
  128611. * @param layout The profile layout to load
  128612. * @param gamepadObject The gamepad object correlating to this controller
  128613. * @param handedness handedness (left/right/none) of this controller
  128614. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128615. */
  128616. constructor(scene: Scene, layout: IMotionControllerLayout,
  128617. /**
  128618. * The gamepad object correlating to this controller
  128619. */
  128620. gamepadObject: IMinimalMotionControllerObject,
  128621. /**
  128622. * handedness (left/right/none) of this controller
  128623. */
  128624. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128625. /**
  128626. * Dispose this controller, the model mesh and all its components
  128627. */
  128628. dispose(): void;
  128629. /**
  128630. * Returns all components of specific type
  128631. * @param type the type to search for
  128632. * @return an array of components with this type
  128633. */
  128634. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128635. /**
  128636. * get a component based an its component id as defined in layout.components
  128637. * @param id the id of the component
  128638. * @returns the component correlates to the id or undefined if not found
  128639. */
  128640. getComponent(id: string): WebXRControllerComponent;
  128641. /**
  128642. * Get the list of components available in this motion controller
  128643. * @returns an array of strings correlating to available components
  128644. */
  128645. getComponentIds(): string[];
  128646. /**
  128647. * Get the first component of specific type
  128648. * @param type type of component to find
  128649. * @return a controller component or null if not found
  128650. */
  128651. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128652. /**
  128653. * Get the main (Select) component of this controller as defined in the layout
  128654. * @returns the main component of this controller
  128655. */
  128656. getMainComponent(): WebXRControllerComponent;
  128657. /**
  128658. * Loads the model correlating to this controller
  128659. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128660. * @returns A promise fulfilled with the result of the model loading
  128661. */
  128662. loadModel(): Promise<boolean>;
  128663. /**
  128664. * Update this model using the current XRFrame
  128665. * @param xrFrame the current xr frame to use and update the model
  128666. */
  128667. updateFromXRFrame(xrFrame: XRFrame): void;
  128668. /**
  128669. * Backwards compatibility due to a deeply-integrated typo
  128670. */
  128671. get handness(): XREye;
  128672. /**
  128673. * Pulse (vibrate) this controller
  128674. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128675. * Consecutive calls to this function will cancel the last pulse call
  128676. *
  128677. * @param value the strength of the pulse in 0.0...1.0 range
  128678. * @param duration Duration of the pulse in milliseconds
  128679. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128680. * @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
  128681. */
  128682. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128683. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128684. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128685. /**
  128686. * Moves the axis on the controller mesh based on its current state
  128687. * @param axis the index of the axis
  128688. * @param axisValue the value of the axis which determines the meshes new position
  128689. * @hidden
  128690. */
  128691. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128692. /**
  128693. * Update the model itself with the current frame data
  128694. * @param xrFrame the frame to use for updating the model mesh
  128695. */
  128696. protected updateModel(xrFrame: XRFrame): void;
  128697. /**
  128698. * Get the filename and path for this controller's model
  128699. * @returns a map of filename and path
  128700. */
  128701. protected abstract _getFilenameAndPath(): {
  128702. filename: string;
  128703. path: string;
  128704. };
  128705. /**
  128706. * This function is called before the mesh is loaded. It checks for loading constraints.
  128707. * For example, this function can check if the GLB loader is available
  128708. * If this function returns false, the generic controller will be loaded instead
  128709. * @returns Is the client ready to load the mesh
  128710. */
  128711. protected abstract _getModelLoadingConstraints(): boolean;
  128712. /**
  128713. * This function will be called after the model was successfully loaded and can be used
  128714. * for mesh transformations before it is available for the user
  128715. * @param meshes the loaded meshes
  128716. */
  128717. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  128718. /**
  128719. * Set the root mesh for this controller. Important for the WebXR controller class
  128720. * @param meshes the loaded meshes
  128721. */
  128722. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  128723. /**
  128724. * A function executed each frame that updates the mesh (if needed)
  128725. * @param xrFrame the current xrFrame
  128726. */
  128727. protected abstract _updateModel(xrFrame: XRFrame): void;
  128728. private _getGenericFilenameAndPath;
  128729. private _getGenericParentMesh;
  128730. }
  128731. }
  128732. declare module BABYLON {
  128733. /**
  128734. * A generic trigger-only motion controller for WebXR
  128735. */
  128736. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  128737. /**
  128738. * Static version of the profile id of this controller
  128739. */
  128740. static ProfileId: string;
  128741. profileId: string;
  128742. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128743. protected _getFilenameAndPath(): {
  128744. filename: string;
  128745. path: string;
  128746. };
  128747. protected _getModelLoadingConstraints(): boolean;
  128748. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128749. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128750. protected _updateModel(): void;
  128751. }
  128752. }
  128753. declare module BABYLON {
  128754. /**
  128755. * Class containing static functions to help procedurally build meshes
  128756. */
  128757. export class SphereBuilder {
  128758. /**
  128759. * Creates a sphere mesh
  128760. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128761. * * 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`)
  128762. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128763. * * 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
  128764. * * 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)
  128765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128768. * @param name defines the name of the mesh
  128769. * @param options defines the options used to create the mesh
  128770. * @param scene defines the hosting scene
  128771. * @returns the sphere mesh
  128772. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128773. */
  128774. static CreateSphere(name: string, options: {
  128775. segments?: number;
  128776. diameter?: number;
  128777. diameterX?: number;
  128778. diameterY?: number;
  128779. diameterZ?: number;
  128780. arc?: number;
  128781. slice?: number;
  128782. sideOrientation?: number;
  128783. frontUVs?: Vector4;
  128784. backUVs?: Vector4;
  128785. updatable?: boolean;
  128786. }, scene?: Nullable<Scene>): Mesh;
  128787. }
  128788. }
  128789. declare module BABYLON {
  128790. /**
  128791. * A profiled motion controller has its profile loaded from an online repository.
  128792. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128793. */
  128794. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128795. private _repositoryUrl;
  128796. private _buttonMeshMapping;
  128797. private _touchDots;
  128798. /**
  128799. * The profile ID of this controller. Will be populated when the controller initializes.
  128800. */
  128801. profileId: string;
  128802. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128803. dispose(): void;
  128804. protected _getFilenameAndPath(): {
  128805. filename: string;
  128806. path: string;
  128807. };
  128808. protected _getModelLoadingConstraints(): boolean;
  128809. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128810. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128811. protected _updateModel(_xrFrame: XRFrame): void;
  128812. }
  128813. }
  128814. declare module BABYLON {
  128815. /**
  128816. * A construction function type to create a new controller based on an xrInput object
  128817. */
  128818. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128819. /**
  128820. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128821. *
  128822. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128823. * it should be replaced with auto-loaded controllers.
  128824. *
  128825. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128826. */
  128827. export class WebXRMotionControllerManager {
  128828. private static _AvailableControllers;
  128829. private static _Fallbacks;
  128830. private static _ProfileLoadingPromises;
  128831. private static _ProfilesList;
  128832. /**
  128833. * The base URL of the online controller repository. Can be changed at any time.
  128834. */
  128835. static BaseRepositoryUrl: string;
  128836. /**
  128837. * Which repository gets priority - local or online
  128838. */
  128839. static PrioritizeOnlineRepository: boolean;
  128840. /**
  128841. * Use the online repository, or use only locally-defined controllers
  128842. */
  128843. static UseOnlineRepository: boolean;
  128844. /**
  128845. * Clear the cache used for profile loading and reload when requested again
  128846. */
  128847. static ClearProfilesCache(): void;
  128848. /**
  128849. * Register the default fallbacks.
  128850. * This function is called automatically when this file is imported.
  128851. */
  128852. static DefaultFallbacks(): void;
  128853. /**
  128854. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128855. * @param profileId the profile to which a fallback needs to be found
  128856. * @return an array with corresponding fallback profiles
  128857. */
  128858. static FindFallbackWithProfileId(profileId: string): string[];
  128859. /**
  128860. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128861. * The order of search:
  128862. *
  128863. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128864. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128865. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128866. * 4) return the generic trigger controller if none were found
  128867. *
  128868. * @param xrInput the xrInput to which a new controller is initialized
  128869. * @param scene the scene to which the model will be added
  128870. * @param forceProfile force a certain profile for this controller
  128871. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128872. */
  128873. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128874. /**
  128875. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128876. *
  128877. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128878. *
  128879. * @param type the profile type to register
  128880. * @param constructFunction the function to be called when loading this profile
  128881. */
  128882. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128883. /**
  128884. * Register a fallback to a specific profile.
  128885. * @param profileId the profileId that will receive the fallbacks
  128886. * @param fallbacks A list of fallback profiles
  128887. */
  128888. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128889. /**
  128890. * Will update the list of profiles available in the repository
  128891. * @return a promise that resolves to a map of profiles available online
  128892. */
  128893. static UpdateProfilesList(): Promise<{
  128894. [profile: string]: string;
  128895. }>;
  128896. private static _LoadProfileFromRepository;
  128897. private static _LoadProfilesFromAvailableControllers;
  128898. }
  128899. }
  128900. declare module BABYLON {
  128901. /**
  128902. * Configuration options for the WebXR controller creation
  128903. */
  128904. export interface IWebXRControllerOptions {
  128905. /**
  128906. * Should the controller mesh be animated when a user interacts with it
  128907. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128908. */
  128909. disableMotionControllerAnimation?: boolean;
  128910. /**
  128911. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128912. */
  128913. doNotLoadControllerMesh?: boolean;
  128914. /**
  128915. * Force a specific controller type for this controller.
  128916. * This can be used when creating your own profile or when testing different controllers
  128917. */
  128918. forceControllerProfile?: string;
  128919. /**
  128920. * Defines a rendering group ID for meshes that will be loaded.
  128921. * This is for the default controllers only.
  128922. */
  128923. renderingGroupId?: number;
  128924. }
  128925. /**
  128926. * Represents an XR controller
  128927. */
  128928. export class WebXRInputSource {
  128929. private _scene;
  128930. /** The underlying input source for the controller */
  128931. inputSource: XRInputSource;
  128932. private _options;
  128933. private _tmpVector;
  128934. private _uniqueId;
  128935. private _disposed;
  128936. /**
  128937. * 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
  128938. */
  128939. grip?: AbstractMesh;
  128940. /**
  128941. * If available, this is the gamepad object related to this controller.
  128942. * Using this object it is possible to get click events and trackpad changes of the
  128943. * webxr controller that is currently being used.
  128944. */
  128945. motionController?: WebXRAbstractMotionController;
  128946. /**
  128947. * Event that fires when the controller is removed/disposed.
  128948. * The object provided as event data is this controller, after associated assets were disposed.
  128949. * uniqueId is still available.
  128950. */
  128951. onDisposeObservable: Observable<WebXRInputSource>;
  128952. /**
  128953. * Will be triggered when the mesh associated with the motion controller is done loading.
  128954. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128955. * A shortened version of controller -> motion controller -> on mesh loaded.
  128956. */
  128957. onMeshLoadedObservable: Observable<AbstractMesh>;
  128958. /**
  128959. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128960. */
  128961. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128962. /**
  128963. * Pointer which can be used to select objects or attach a visible laser to
  128964. */
  128965. pointer: AbstractMesh;
  128966. /**
  128967. * Creates the input source object
  128968. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128969. * @param _scene the scene which the controller should be associated to
  128970. * @param inputSource the underlying input source for the controller
  128971. * @param _options options for this controller creation
  128972. */
  128973. constructor(_scene: Scene,
  128974. /** The underlying input source for the controller */
  128975. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128976. /**
  128977. * Get this controllers unique id
  128978. */
  128979. get uniqueId(): string;
  128980. /**
  128981. * Disposes of the object
  128982. */
  128983. dispose(): void;
  128984. /**
  128985. * Gets a world space ray coming from the pointer or grip
  128986. * @param result the resulting ray
  128987. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128988. */
  128989. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128990. /**
  128991. * Updates the controller pose based on the given XRFrame
  128992. * @param xrFrame xr frame to update the pose with
  128993. * @param referenceSpace reference space to use
  128994. */
  128995. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128996. }
  128997. }
  128998. declare module BABYLON {
  128999. /**
  129000. * The schema for initialization options of the XR Input class
  129001. */
  129002. export interface IWebXRInputOptions {
  129003. /**
  129004. * If set to true no model will be automatically loaded
  129005. */
  129006. doNotLoadControllerMeshes?: boolean;
  129007. /**
  129008. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  129009. * If not found, the xr input profile data will be used.
  129010. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  129011. */
  129012. forceInputProfile?: string;
  129013. /**
  129014. * Do not send a request to the controller repository to load the profile.
  129015. *
  129016. * Instead, use the controllers available in babylon itself.
  129017. */
  129018. disableOnlineControllerRepository?: boolean;
  129019. /**
  129020. * A custom URL for the controllers repository
  129021. */
  129022. customControllersRepositoryURL?: string;
  129023. /**
  129024. * Should the controller model's components not move according to the user input
  129025. */
  129026. disableControllerAnimation?: boolean;
  129027. /**
  129028. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  129029. */
  129030. controllerOptions?: IWebXRControllerOptions;
  129031. }
  129032. /**
  129033. * XR input used to track XR inputs such as controllers/rays
  129034. */
  129035. export class WebXRInput implements IDisposable {
  129036. /**
  129037. * the xr session manager for this session
  129038. */
  129039. xrSessionManager: WebXRSessionManager;
  129040. /**
  129041. * the WebXR camera for this session. Mainly used for teleportation
  129042. */
  129043. xrCamera: WebXRCamera;
  129044. private readonly options;
  129045. /**
  129046. * XR controllers being tracked
  129047. */
  129048. controllers: Array<WebXRInputSource>;
  129049. private _frameObserver;
  129050. private _sessionEndedObserver;
  129051. private _sessionInitObserver;
  129052. /**
  129053. * Event when a controller has been connected/added
  129054. */
  129055. onControllerAddedObservable: Observable<WebXRInputSource>;
  129056. /**
  129057. * Event when a controller has been removed/disconnected
  129058. */
  129059. onControllerRemovedObservable: Observable<WebXRInputSource>;
  129060. /**
  129061. * Initializes the WebXRInput
  129062. * @param xrSessionManager the xr session manager for this session
  129063. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  129064. * @param options = initialization options for this xr input
  129065. */
  129066. constructor(
  129067. /**
  129068. * the xr session manager for this session
  129069. */
  129070. xrSessionManager: WebXRSessionManager,
  129071. /**
  129072. * the WebXR camera for this session. Mainly used for teleportation
  129073. */
  129074. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  129075. private _onInputSourcesChange;
  129076. private _addAndRemoveControllers;
  129077. /**
  129078. * Disposes of the object
  129079. */
  129080. dispose(): void;
  129081. }
  129082. }
  129083. declare module BABYLON {
  129084. /**
  129085. * This is the base class for all WebXR features.
  129086. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  129087. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  129088. */
  129089. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  129090. protected _xrSessionManager: WebXRSessionManager;
  129091. private _attached;
  129092. private _removeOnDetach;
  129093. /**
  129094. * Is this feature disposed?
  129095. */
  129096. isDisposed: boolean;
  129097. /**
  129098. * Should auto-attach be disabled?
  129099. */
  129100. disableAutoAttach: boolean;
  129101. /**
  129102. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  129103. */
  129104. xrNativeFeatureName: string;
  129105. /**
  129106. * Construct a new (abstract) WebXR feature
  129107. * @param _xrSessionManager the xr session manager for this feature
  129108. */
  129109. constructor(_xrSessionManager: WebXRSessionManager);
  129110. /**
  129111. * Is this feature attached
  129112. */
  129113. get attached(): boolean;
  129114. /**
  129115. * attach this feature
  129116. *
  129117. * @param force should attachment be forced (even when already attached)
  129118. * @returns true if successful, false is failed or already attached
  129119. */
  129120. attach(force?: boolean): boolean;
  129121. /**
  129122. * detach this feature.
  129123. *
  129124. * @returns true if successful, false if failed or already detached
  129125. */
  129126. detach(): boolean;
  129127. /**
  129128. * Dispose this feature and all of the resources attached
  129129. */
  129130. dispose(): void;
  129131. /**
  129132. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  129133. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  129134. *
  129135. * @returns whether or not the feature is compatible in this environment
  129136. */
  129137. isCompatible(): boolean;
  129138. /**
  129139. * This is used to register callbacks that will automatically be removed when detach is called.
  129140. * @param observable the observable to which the observer will be attached
  129141. * @param callback the callback to register
  129142. */
  129143. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  129144. /**
  129145. * Code in this function will be executed on each xrFrame received from the browser.
  129146. * This function will not execute after the feature is detached.
  129147. * @param _xrFrame the current frame
  129148. */
  129149. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  129150. }
  129151. }
  129152. declare module BABYLON {
  129153. /**
  129154. * Renders a layer on top of an existing scene
  129155. */
  129156. export class UtilityLayerRenderer implements IDisposable {
  129157. /** the original scene that will be rendered on top of */
  129158. originalScene: Scene;
  129159. private _pointerCaptures;
  129160. private _lastPointerEvents;
  129161. private static _DefaultUtilityLayer;
  129162. private static _DefaultKeepDepthUtilityLayer;
  129163. private _sharedGizmoLight;
  129164. private _renderCamera;
  129165. /**
  129166. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  129167. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  129168. * @returns the camera that is used when rendering the utility layer
  129169. */
  129170. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  129171. /**
  129172. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  129173. * @param cam the camera that should be used when rendering the utility layer
  129174. */
  129175. setRenderCamera(cam: Nullable<Camera>): void;
  129176. /**
  129177. * @hidden
  129178. * Light which used by gizmos to get light shading
  129179. */
  129180. _getSharedGizmoLight(): HemisphericLight;
  129181. /**
  129182. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  129183. */
  129184. pickUtilitySceneFirst: boolean;
  129185. /**
  129186. * 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)
  129187. */
  129188. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  129189. /**
  129190. * 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)
  129191. */
  129192. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  129193. /**
  129194. * The scene that is rendered on top of the original scene
  129195. */
  129196. utilityLayerScene: Scene;
  129197. /**
  129198. * If the utility layer should automatically be rendered on top of existing scene
  129199. */
  129200. shouldRender: boolean;
  129201. /**
  129202. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  129203. */
  129204. onlyCheckPointerDownEvents: boolean;
  129205. /**
  129206. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  129207. */
  129208. processAllEvents: boolean;
  129209. /**
  129210. * Observable raised when the pointer move from the utility layer scene to the main scene
  129211. */
  129212. onPointerOutObservable: Observable<number>;
  129213. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  129214. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  129215. private _afterRenderObserver;
  129216. private _sceneDisposeObserver;
  129217. private _originalPointerObserver;
  129218. /**
  129219. * Instantiates a UtilityLayerRenderer
  129220. * @param originalScene the original scene that will be rendered on top of
  129221. * @param handleEvents boolean indicating if the utility layer should handle events
  129222. */
  129223. constructor(
  129224. /** the original scene that will be rendered on top of */
  129225. originalScene: Scene, handleEvents?: boolean);
  129226. private _notifyObservers;
  129227. /**
  129228. * Renders the utility layers scene on top of the original scene
  129229. */
  129230. render(): void;
  129231. /**
  129232. * Disposes of the renderer
  129233. */
  129234. dispose(): void;
  129235. private _updateCamera;
  129236. }
  129237. }
  129238. declare module BABYLON {
  129239. /**
  129240. * Options interface for the pointer selection module
  129241. */
  129242. export interface IWebXRControllerPointerSelectionOptions {
  129243. /**
  129244. * if provided, this scene will be used to render meshes.
  129245. */
  129246. customUtilityLayerScene?: Scene;
  129247. /**
  129248. * 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)
  129249. * If not disabled, the last picked point will be used to execute a pointer up event
  129250. * If disabled, pointer up event will be triggered right after the pointer down event.
  129251. * Used in screen and gaze target ray mode only
  129252. */
  129253. disablePointerUpOnTouchOut: boolean;
  129254. /**
  129255. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  129256. */
  129257. forceGazeMode: boolean;
  129258. /**
  129259. * 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
  129260. * to start a new countdown to the pointer down event.
  129261. * Defaults to 1.
  129262. */
  129263. gazeModePointerMovedFactor?: number;
  129264. /**
  129265. * Different button type to use instead of the main component
  129266. */
  129267. overrideButtonId?: string;
  129268. /**
  129269. * use this rendering group id for the meshes (optional)
  129270. */
  129271. renderingGroupId?: number;
  129272. /**
  129273. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  129274. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  129275. * 3000 means 3 seconds between pointing at something and selecting it
  129276. */
  129277. timeToSelect?: number;
  129278. /**
  129279. * Should meshes created here be added to a utility layer or the main scene
  129280. */
  129281. useUtilityLayer?: boolean;
  129282. /**
  129283. * Optional WebXR camera to be used for gaze selection
  129284. */
  129285. gazeCamera?: WebXRCamera;
  129286. /**
  129287. * the xr input to use with this pointer selection
  129288. */
  129289. xrInput: WebXRInput;
  129290. }
  129291. /**
  129292. * A module that will enable pointer selection for motion controllers of XR Input Sources
  129293. */
  129294. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  129295. private readonly _options;
  129296. private static _idCounter;
  129297. private _attachController;
  129298. private _controllers;
  129299. private _scene;
  129300. private _tmpVectorForPickCompare;
  129301. /**
  129302. * The module's name
  129303. */
  129304. static readonly Name: string;
  129305. /**
  129306. * The (Babylon) version of this module.
  129307. * This is an integer representing the implementation version.
  129308. * This number does not correspond to the WebXR specs version
  129309. */
  129310. static readonly Version: number;
  129311. /**
  129312. * Disable lighting on the laser pointer (so it will always be visible)
  129313. */
  129314. disablePointerLighting: boolean;
  129315. /**
  129316. * Disable lighting on the selection mesh (so it will always be visible)
  129317. */
  129318. disableSelectionMeshLighting: boolean;
  129319. /**
  129320. * Should the laser pointer be displayed
  129321. */
  129322. displayLaserPointer: boolean;
  129323. /**
  129324. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  129325. */
  129326. displaySelectionMesh: boolean;
  129327. /**
  129328. * This color will be set to the laser pointer when selection is triggered
  129329. */
  129330. laserPointerPickedColor: Color3;
  129331. /**
  129332. * Default color of the laser pointer
  129333. */
  129334. laserPointerDefaultColor: Color3;
  129335. /**
  129336. * default color of the selection ring
  129337. */
  129338. selectionMeshDefaultColor: Color3;
  129339. /**
  129340. * This color will be applied to the selection ring when selection is triggered
  129341. */
  129342. selectionMeshPickedColor: Color3;
  129343. /**
  129344. * Optional filter to be used for ray selection. This predicate shares behavior with
  129345. * scene.pointerMovePredicate which takes priority if it is also assigned.
  129346. */
  129347. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129348. /**
  129349. * constructs a new background remover module
  129350. * @param _xrSessionManager the session manager for this module
  129351. * @param _options read-only options to be used in this module
  129352. */
  129353. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  129354. /**
  129355. * attach this feature
  129356. * Will usually be called by the features manager
  129357. *
  129358. * @returns true if successful.
  129359. */
  129360. attach(): boolean;
  129361. /**
  129362. * detach this feature.
  129363. * Will usually be called by the features manager
  129364. *
  129365. * @returns true if successful.
  129366. */
  129367. detach(): boolean;
  129368. /**
  129369. * Will get the mesh under a specific pointer.
  129370. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  129371. * @param controllerId the controllerId to check
  129372. * @returns The mesh under pointer or null if no mesh is under the pointer
  129373. */
  129374. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  129375. /**
  129376. * Get the xr controller that correlates to the pointer id in the pointer event
  129377. *
  129378. * @param id the pointer id to search for
  129379. * @returns the controller that correlates to this id or null if not found
  129380. */
  129381. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  129382. protected _onXRFrame(_xrFrame: XRFrame): void;
  129383. private _attachGazeMode;
  129384. private _attachScreenRayMode;
  129385. private _attachTrackedPointerRayMode;
  129386. private _convertNormalToDirectionOfRay;
  129387. private _detachController;
  129388. private _generateNewMeshPair;
  129389. private _pickingMoved;
  129390. private _updatePointerDistance;
  129391. /** @hidden */
  129392. get lasterPointerDefaultColor(): Color3;
  129393. }
  129394. }
  129395. declare module BABYLON {
  129396. /**
  129397. * Button which can be used to enter a different mode of XR
  129398. */
  129399. export class WebXREnterExitUIButton {
  129400. /** button element */
  129401. element: HTMLElement;
  129402. /** XR initialization options for the button */
  129403. sessionMode: XRSessionMode;
  129404. /** Reference space type */
  129405. referenceSpaceType: XRReferenceSpaceType;
  129406. /**
  129407. * Creates a WebXREnterExitUIButton
  129408. * @param element button element
  129409. * @param sessionMode XR initialization session mode
  129410. * @param referenceSpaceType the type of reference space to be used
  129411. */
  129412. constructor(
  129413. /** button element */
  129414. element: HTMLElement,
  129415. /** XR initialization options for the button */
  129416. sessionMode: XRSessionMode,
  129417. /** Reference space type */
  129418. referenceSpaceType: XRReferenceSpaceType);
  129419. /**
  129420. * Extendable function which can be used to update the button's visuals when the state changes
  129421. * @param activeButton the current active button in the UI
  129422. */
  129423. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  129424. }
  129425. /**
  129426. * Options to create the webXR UI
  129427. */
  129428. export class WebXREnterExitUIOptions {
  129429. /**
  129430. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  129431. */
  129432. customButtons?: Array<WebXREnterExitUIButton>;
  129433. /**
  129434. * A reference space type to use when creating the default button.
  129435. * Default is local-floor
  129436. */
  129437. referenceSpaceType?: XRReferenceSpaceType;
  129438. /**
  129439. * Context to enter xr with
  129440. */
  129441. renderTarget?: Nullable<WebXRRenderTarget>;
  129442. /**
  129443. * A session mode to use when creating the default button.
  129444. * Default is immersive-vr
  129445. */
  129446. sessionMode?: XRSessionMode;
  129447. /**
  129448. * A list of optional features to init the session with
  129449. */
  129450. optionalFeatures?: string[];
  129451. /**
  129452. * A list of optional features to init the session with
  129453. */
  129454. requiredFeatures?: string[];
  129455. }
  129456. /**
  129457. * UI to allow the user to enter/exit XR mode
  129458. */
  129459. export class WebXREnterExitUI implements IDisposable {
  129460. private scene;
  129461. /** version of the options passed to this UI */
  129462. options: WebXREnterExitUIOptions;
  129463. private _activeButton;
  129464. private _buttons;
  129465. /**
  129466. * The HTML Div Element to which buttons are added.
  129467. */
  129468. readonly overlay: HTMLDivElement;
  129469. /**
  129470. * Fired every time the active button is changed.
  129471. *
  129472. * When xr is entered via a button that launches xr that button will be the callback parameter
  129473. *
  129474. * When exiting xr the callback parameter will be null)
  129475. */
  129476. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  129477. /**
  129478. *
  129479. * @param scene babylon scene object to use
  129480. * @param options (read-only) version of the options passed to this UI
  129481. */
  129482. private constructor();
  129483. /**
  129484. * Creates UI to allow the user to enter/exit XR mode
  129485. * @param scene the scene to add the ui to
  129486. * @param helper the xr experience helper to enter/exit xr with
  129487. * @param options options to configure the UI
  129488. * @returns the created ui
  129489. */
  129490. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129491. /**
  129492. * Disposes of the XR UI component
  129493. */
  129494. dispose(): void;
  129495. private _updateButtons;
  129496. }
  129497. }
  129498. declare module BABYLON {
  129499. /**
  129500. * Class containing static functions to help procedurally build meshes
  129501. */
  129502. export class LinesBuilder {
  129503. /**
  129504. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129505. * * 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
  129506. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129507. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129508. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129509. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129510. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129511. * * 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
  129512. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129515. * @param name defines the name of the new line system
  129516. * @param options defines the options used to create the line system
  129517. * @param scene defines the hosting scene
  129518. * @returns a new line system mesh
  129519. */
  129520. static CreateLineSystem(name: string, options: {
  129521. lines: Vector3[][];
  129522. updatable?: boolean;
  129523. instance?: Nullable<LinesMesh>;
  129524. colors?: Nullable<Color4[][]>;
  129525. useVertexAlpha?: boolean;
  129526. }, scene: Nullable<Scene>): LinesMesh;
  129527. /**
  129528. * Creates a line mesh
  129529. * 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
  129530. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129531. * * The parameter `points` is an array successive Vector3
  129532. * * 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
  129533. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129534. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129535. * * When updating an instance, remember that only point positions can change, not the number of points
  129536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129538. * @param name defines the name of the new line system
  129539. * @param options defines the options used to create the line system
  129540. * @param scene defines the hosting scene
  129541. * @returns a new line mesh
  129542. */
  129543. static CreateLines(name: string, options: {
  129544. points: Vector3[];
  129545. updatable?: boolean;
  129546. instance?: Nullable<LinesMesh>;
  129547. colors?: Color4[];
  129548. useVertexAlpha?: boolean;
  129549. }, scene?: Nullable<Scene>): LinesMesh;
  129550. /**
  129551. * Creates a dashed line mesh
  129552. * * 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
  129553. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129554. * * The parameter `points` is an array successive Vector3
  129555. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129556. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129557. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129558. * * 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
  129559. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129560. * * When updating an instance, remember that only point positions can change, not the number of points
  129561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129562. * @param name defines the name of the mesh
  129563. * @param options defines the options used to create the mesh
  129564. * @param scene defines the hosting scene
  129565. * @returns the dashed line mesh
  129566. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129567. */
  129568. static CreateDashedLines(name: string, options: {
  129569. points: Vector3[];
  129570. dashSize?: number;
  129571. gapSize?: number;
  129572. dashNb?: number;
  129573. updatable?: boolean;
  129574. instance?: LinesMesh;
  129575. useVertexAlpha?: boolean;
  129576. }, scene?: Nullable<Scene>): LinesMesh;
  129577. }
  129578. }
  129579. declare module BABYLON {
  129580. /**
  129581. * Construction options for a timer
  129582. */
  129583. export interface ITimerOptions<T> {
  129584. /**
  129585. * Time-to-end
  129586. */
  129587. timeout: number;
  129588. /**
  129589. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129590. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129591. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129592. */
  129593. contextObservable: Observable<T>;
  129594. /**
  129595. * Optional parameters when adding an observer to the observable
  129596. */
  129597. observableParameters?: {
  129598. mask?: number;
  129599. insertFirst?: boolean;
  129600. scope?: any;
  129601. };
  129602. /**
  129603. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129604. */
  129605. breakCondition?: (data?: ITimerData<T>) => boolean;
  129606. /**
  129607. * Will be triggered when the time condition has met
  129608. */
  129609. onEnded?: (data: ITimerData<any>) => void;
  129610. /**
  129611. * Will be triggered when the break condition has met (prematurely ended)
  129612. */
  129613. onAborted?: (data: ITimerData<any>) => void;
  129614. /**
  129615. * Optional function to execute on each tick (or count)
  129616. */
  129617. onTick?: (data: ITimerData<any>) => void;
  129618. }
  129619. /**
  129620. * An interface defining the data sent by the timer
  129621. */
  129622. export interface ITimerData<T> {
  129623. /**
  129624. * When did it start
  129625. */
  129626. startTime: number;
  129627. /**
  129628. * Time now
  129629. */
  129630. currentTime: number;
  129631. /**
  129632. * Time passed since started
  129633. */
  129634. deltaTime: number;
  129635. /**
  129636. * How much is completed, in [0.0...1.0].
  129637. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129638. */
  129639. completeRate: number;
  129640. /**
  129641. * What the registered observable sent in the last count
  129642. */
  129643. payload: T;
  129644. }
  129645. /**
  129646. * The current state of the timer
  129647. */
  129648. export enum TimerState {
  129649. /**
  129650. * Timer initialized, not yet started
  129651. */
  129652. INIT = 0,
  129653. /**
  129654. * Timer started and counting
  129655. */
  129656. STARTED = 1,
  129657. /**
  129658. * Timer ended (whether aborted or time reached)
  129659. */
  129660. ENDED = 2
  129661. }
  129662. /**
  129663. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129664. *
  129665. * @param options options with which to initialize this timer
  129666. */
  129667. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129668. /**
  129669. * An advanced implementation of a timer class
  129670. */
  129671. export class AdvancedTimer<T = any> implements IDisposable {
  129672. /**
  129673. * Will notify each time the timer calculates the remaining time
  129674. */
  129675. onEachCountObservable: Observable<ITimerData<T>>;
  129676. /**
  129677. * Will trigger when the timer was aborted due to the break condition
  129678. */
  129679. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129680. /**
  129681. * Will trigger when the timer ended successfully
  129682. */
  129683. onTimerEndedObservable: Observable<ITimerData<T>>;
  129684. /**
  129685. * Will trigger when the timer state has changed
  129686. */
  129687. onStateChangedObservable: Observable<TimerState>;
  129688. private _observer;
  129689. private _contextObservable;
  129690. private _observableParameters;
  129691. private _startTime;
  129692. private _timer;
  129693. private _state;
  129694. private _breakCondition;
  129695. private _timeToEnd;
  129696. private _breakOnNextTick;
  129697. /**
  129698. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  129699. * @param options construction options for this advanced timer
  129700. */
  129701. constructor(options: ITimerOptions<T>);
  129702. /**
  129703. * set a breaking condition for this timer. Default is to never break during count
  129704. * @param predicate the new break condition. Returns true to break, false otherwise
  129705. */
  129706. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  129707. /**
  129708. * Reset ALL associated observables in this advanced timer
  129709. */
  129710. clearObservables(): void;
  129711. /**
  129712. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  129713. *
  129714. * @param timeToEnd how much time to measure until timer ended
  129715. */
  129716. start(timeToEnd?: number): void;
  129717. /**
  129718. * Will force a stop on the next tick.
  129719. */
  129720. stop(): void;
  129721. /**
  129722. * Dispose this timer, clearing all resources
  129723. */
  129724. dispose(): void;
  129725. private _setState;
  129726. private _tick;
  129727. private _stop;
  129728. }
  129729. }
  129730. declare module BABYLON {
  129731. /**
  129732. * The options container for the teleportation module
  129733. */
  129734. export interface IWebXRTeleportationOptions {
  129735. /**
  129736. * if provided, this scene will be used to render meshes.
  129737. */
  129738. customUtilityLayerScene?: Scene;
  129739. /**
  129740. * Values to configure the default target mesh
  129741. */
  129742. defaultTargetMeshOptions?: {
  129743. /**
  129744. * Fill color of the teleportation area
  129745. */
  129746. teleportationFillColor?: string;
  129747. /**
  129748. * Border color for the teleportation area
  129749. */
  129750. teleportationBorderColor?: string;
  129751. /**
  129752. * Disable the mesh's animation sequence
  129753. */
  129754. disableAnimation?: boolean;
  129755. /**
  129756. * Disable lighting on the material or the ring and arrow
  129757. */
  129758. disableLighting?: boolean;
  129759. /**
  129760. * Override the default material of the torus and arrow
  129761. */
  129762. torusArrowMaterial?: Material;
  129763. };
  129764. /**
  129765. * A list of meshes to use as floor meshes.
  129766. * Meshes can be added and removed after initializing the feature using the
  129767. * addFloorMesh and removeFloorMesh functions
  129768. * If empty, rotation will still work
  129769. */
  129770. floorMeshes?: AbstractMesh[];
  129771. /**
  129772. * use this rendering group id for the meshes (optional)
  129773. */
  129774. renderingGroupId?: number;
  129775. /**
  129776. * Should teleportation move only to snap points
  129777. */
  129778. snapPointsOnly?: boolean;
  129779. /**
  129780. * An array of points to which the teleportation will snap to.
  129781. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129782. */
  129783. snapPositions?: Vector3[];
  129784. /**
  129785. * How close should the teleportation ray be in order to snap to position.
  129786. * Default to 0.8 units (meters)
  129787. */
  129788. snapToPositionRadius?: number;
  129789. /**
  129790. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129791. * If you want to support rotation, make sure your mesh has a direction indicator.
  129792. *
  129793. * When left untouched, the default mesh will be initialized.
  129794. */
  129795. teleportationTargetMesh?: AbstractMesh;
  129796. /**
  129797. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129798. */
  129799. timeToTeleport?: number;
  129800. /**
  129801. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129802. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129803. */
  129804. useMainComponentOnly?: boolean;
  129805. /**
  129806. * Should meshes created here be added to a utility layer or the main scene
  129807. */
  129808. useUtilityLayer?: boolean;
  129809. /**
  129810. * Babylon XR Input class for controller
  129811. */
  129812. xrInput: WebXRInput;
  129813. /**
  129814. * Meshes that the teleportation ray cannot go through
  129815. */
  129816. pickBlockerMeshes?: AbstractMesh[];
  129817. }
  129818. /**
  129819. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129820. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129821. * the input of the attached controllers.
  129822. */
  129823. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129824. private _options;
  129825. private _controllers;
  129826. private _currentTeleportationControllerId;
  129827. private _floorMeshes;
  129828. private _quadraticBezierCurve;
  129829. private _selectionFeature;
  129830. private _snapToPositions;
  129831. private _snappedToPoint;
  129832. private _teleportationRingMaterial?;
  129833. private _tmpRay;
  129834. private _tmpVector;
  129835. private _tmpQuaternion;
  129836. /**
  129837. * The module's name
  129838. */
  129839. static readonly Name: string;
  129840. /**
  129841. * The (Babylon) version of this module.
  129842. * This is an integer representing the implementation version.
  129843. * This number does not correspond to the webxr specs version
  129844. */
  129845. static readonly Version: number;
  129846. /**
  129847. * Is movement backwards enabled
  129848. */
  129849. backwardsMovementEnabled: boolean;
  129850. /**
  129851. * Distance to travel when moving backwards
  129852. */
  129853. backwardsTeleportationDistance: number;
  129854. /**
  129855. * The distance from the user to the inspection point in the direction of the controller
  129856. * A higher number will allow the user to move further
  129857. * defaults to 5 (meters, in xr units)
  129858. */
  129859. parabolicCheckRadius: number;
  129860. /**
  129861. * Should the module support parabolic ray on top of direct ray
  129862. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129863. * Very helpful when moving between floors / different heights
  129864. */
  129865. parabolicRayEnabled: boolean;
  129866. /**
  129867. * How much rotation should be applied when rotating right and left
  129868. */
  129869. rotationAngle: number;
  129870. /**
  129871. * Is rotation enabled when moving forward?
  129872. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129873. */
  129874. rotationEnabled: boolean;
  129875. /**
  129876. * constructs a new anchor system
  129877. * @param _xrSessionManager an instance of WebXRSessionManager
  129878. * @param _options configuration object for this feature
  129879. */
  129880. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129881. /**
  129882. * Get the snapPointsOnly flag
  129883. */
  129884. get snapPointsOnly(): boolean;
  129885. /**
  129886. * Sets the snapPointsOnly flag
  129887. * @param snapToPoints should teleportation be exclusively to snap points
  129888. */
  129889. set snapPointsOnly(snapToPoints: boolean);
  129890. /**
  129891. * Add a new mesh to the floor meshes array
  129892. * @param mesh the mesh to use as floor mesh
  129893. */
  129894. addFloorMesh(mesh: AbstractMesh): void;
  129895. /**
  129896. * Add a new snap-to point to fix teleportation to this position
  129897. * @param newSnapPoint The new Snap-To point
  129898. */
  129899. addSnapPoint(newSnapPoint: Vector3): void;
  129900. attach(): boolean;
  129901. detach(): boolean;
  129902. dispose(): void;
  129903. /**
  129904. * Remove a mesh from the floor meshes array
  129905. * @param mesh the mesh to remove
  129906. */
  129907. removeFloorMesh(mesh: AbstractMesh): void;
  129908. /**
  129909. * Remove a mesh from the floor meshes array using its name
  129910. * @param name the mesh name to remove
  129911. */
  129912. removeFloorMeshByName(name: string): void;
  129913. /**
  129914. * 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
  129915. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129916. * @returns was the point found and removed or not
  129917. */
  129918. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129919. /**
  129920. * This function sets a selection feature that will be disabled when
  129921. * the forward ray is shown and will be reattached when hidden.
  129922. * This is used to remove the selection rays when moving.
  129923. * @param selectionFeature the feature to disable when forward movement is enabled
  129924. */
  129925. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  129926. protected _onXRFrame(_xrFrame: XRFrame): void;
  129927. private _attachController;
  129928. private _createDefaultTargetMesh;
  129929. private _detachController;
  129930. private _findClosestSnapPointWithRadius;
  129931. private _setTargetMeshPosition;
  129932. private _setTargetMeshVisibility;
  129933. private _showParabolicPath;
  129934. private _teleportForward;
  129935. }
  129936. }
  129937. declare module BABYLON {
  129938. /**
  129939. * Options for the default xr helper
  129940. */
  129941. export class WebXRDefaultExperienceOptions {
  129942. /**
  129943. * Enable or disable default UI to enter XR
  129944. */
  129945. disableDefaultUI?: boolean;
  129946. /**
  129947. * Should teleportation not initialize. defaults to false.
  129948. */
  129949. disableTeleportation?: boolean;
  129950. /**
  129951. * Floor meshes that will be used for teleport
  129952. */
  129953. floorMeshes?: Array<AbstractMesh>;
  129954. /**
  129955. * If set to true, the first frame will not be used to reset position
  129956. * The first frame is mainly used when copying transformation from the old camera
  129957. * Mainly used in AR
  129958. */
  129959. ignoreNativeCameraTransformation?: boolean;
  129960. /**
  129961. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129962. */
  129963. inputOptions?: IWebXRInputOptions;
  129964. /**
  129965. * optional configuration for the output canvas
  129966. */
  129967. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129968. /**
  129969. * optional UI options. This can be used among other to change session mode and reference space type
  129970. */
  129971. uiOptions?: WebXREnterExitUIOptions;
  129972. /**
  129973. * When loading teleportation and pointer select, use stable versions instead of latest.
  129974. */
  129975. useStablePlugins?: boolean;
  129976. /**
  129977. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129978. */
  129979. renderingGroupId?: number;
  129980. /**
  129981. * A list of optional features to init the session with
  129982. * If set to true, all features we support will be added
  129983. */
  129984. optionalFeatures?: boolean | string[];
  129985. }
  129986. /**
  129987. * Default experience which provides a similar setup to the previous webVRExperience
  129988. */
  129989. export class WebXRDefaultExperience {
  129990. /**
  129991. * Base experience
  129992. */
  129993. baseExperience: WebXRExperienceHelper;
  129994. /**
  129995. * Enables ui for entering/exiting xr
  129996. */
  129997. enterExitUI: WebXREnterExitUI;
  129998. /**
  129999. * Input experience extension
  130000. */
  130001. input: WebXRInput;
  130002. /**
  130003. * Enables laser pointer and selection
  130004. */
  130005. pointerSelection: WebXRControllerPointerSelection;
  130006. /**
  130007. * Default target xr should render to
  130008. */
  130009. renderTarget: WebXRRenderTarget;
  130010. /**
  130011. * Enables teleportation
  130012. */
  130013. teleportation: WebXRMotionControllerTeleportation;
  130014. private constructor();
  130015. /**
  130016. * Creates the default xr experience
  130017. * @param scene scene
  130018. * @param options options for basic configuration
  130019. * @returns resulting WebXRDefaultExperience
  130020. */
  130021. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  130022. /**
  130023. * DIsposes of the experience helper
  130024. */
  130025. dispose(): void;
  130026. }
  130027. }
  130028. declare module BABYLON {
  130029. /**
  130030. * Options to modify the vr teleportation behavior.
  130031. */
  130032. export interface VRTeleportationOptions {
  130033. /**
  130034. * The name of the mesh which should be used as the teleportation floor. (default: null)
  130035. */
  130036. floorMeshName?: string;
  130037. /**
  130038. * A list of meshes to be used as the teleportation floor. (default: empty)
  130039. */
  130040. floorMeshes?: Mesh[];
  130041. /**
  130042. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  130043. */
  130044. teleportationMode?: number;
  130045. /**
  130046. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  130047. */
  130048. teleportationTime?: number;
  130049. /**
  130050. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  130051. */
  130052. teleportationSpeed?: number;
  130053. /**
  130054. * The easing function used in the animation or null for Linear. (default CircleEase)
  130055. */
  130056. easingFunction?: EasingFunction;
  130057. }
  130058. /**
  130059. * Options to modify the vr experience helper's behavior.
  130060. */
  130061. export interface VRExperienceHelperOptions extends WebVROptions {
  130062. /**
  130063. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  130064. */
  130065. createDeviceOrientationCamera?: boolean;
  130066. /**
  130067. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  130068. */
  130069. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  130070. /**
  130071. * Uses the main button on the controller to toggle the laser casted. (default: true)
  130072. */
  130073. laserToggle?: boolean;
  130074. /**
  130075. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  130076. */
  130077. floorMeshes?: Mesh[];
  130078. /**
  130079. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  130080. */
  130081. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  130082. /**
  130083. * Defines if WebXR should be used instead of WebVR (if available)
  130084. */
  130085. useXR?: boolean;
  130086. }
  130087. /**
  130088. * Event containing information after VR has been entered
  130089. */
  130090. export class OnAfterEnteringVRObservableEvent {
  130091. /**
  130092. * If entering vr was successful
  130093. */
  130094. success: boolean;
  130095. }
  130096. /**
  130097. * Helps to quickly add VR support to an existing scene.
  130098. * See https://doc.babylonjs.com/how_to/webvr_helper
  130099. */
  130100. export class VRExperienceHelper {
  130101. /** Options to modify the vr experience helper's behavior. */
  130102. webVROptions: VRExperienceHelperOptions;
  130103. private _scene;
  130104. private _position;
  130105. private _btnVR;
  130106. private _btnVRDisplayed;
  130107. private _webVRsupported;
  130108. private _webVRready;
  130109. private _webVRrequesting;
  130110. private _webVRpresenting;
  130111. private _hasEnteredVR;
  130112. private _fullscreenVRpresenting;
  130113. private _inputElement;
  130114. private _webVRCamera;
  130115. private _vrDeviceOrientationCamera;
  130116. private _deviceOrientationCamera;
  130117. private _existingCamera;
  130118. private _onKeyDown;
  130119. private _onVrDisplayPresentChange;
  130120. private _onVRDisplayChanged;
  130121. private _onVRRequestPresentStart;
  130122. private _onVRRequestPresentComplete;
  130123. /**
  130124. * 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)
  130125. */
  130126. enableGazeEvenWhenNoPointerLock: boolean;
  130127. /**
  130128. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  130129. */
  130130. exitVROnDoubleTap: boolean;
  130131. /**
  130132. * Observable raised right before entering VR.
  130133. */
  130134. onEnteringVRObservable: Observable<VRExperienceHelper>;
  130135. /**
  130136. * Observable raised when entering VR has completed.
  130137. */
  130138. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  130139. /**
  130140. * Observable raised when exiting VR.
  130141. */
  130142. onExitingVRObservable: Observable<VRExperienceHelper>;
  130143. /**
  130144. * Observable raised when controller mesh is loaded.
  130145. */
  130146. onControllerMeshLoadedObservable: Observable<WebVRController>;
  130147. /** Return this.onEnteringVRObservable
  130148. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  130149. */
  130150. get onEnteringVR(): Observable<VRExperienceHelper>;
  130151. /** Return this.onExitingVRObservable
  130152. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  130153. */
  130154. get onExitingVR(): Observable<VRExperienceHelper>;
  130155. /** Return this.onControllerMeshLoadedObservable
  130156. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  130157. */
  130158. get onControllerMeshLoaded(): Observable<WebVRController>;
  130159. private _rayLength;
  130160. private _useCustomVRButton;
  130161. private _teleportationRequested;
  130162. private _teleportActive;
  130163. private _floorMeshName;
  130164. private _floorMeshesCollection;
  130165. private _teleportationMode;
  130166. private _teleportationTime;
  130167. private _teleportationSpeed;
  130168. private _teleportationEasing;
  130169. private _rotationAllowed;
  130170. private _teleportBackwardsVector;
  130171. private _teleportationTarget;
  130172. private _isDefaultTeleportationTarget;
  130173. private _postProcessMove;
  130174. private _teleportationFillColor;
  130175. private _teleportationBorderColor;
  130176. private _rotationAngle;
  130177. private _haloCenter;
  130178. private _cameraGazer;
  130179. private _padSensibilityUp;
  130180. private _padSensibilityDown;
  130181. private _leftController;
  130182. private _rightController;
  130183. private _gazeColor;
  130184. private _laserColor;
  130185. private _pickedLaserColor;
  130186. private _pickedGazeColor;
  130187. /**
  130188. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  130189. */
  130190. onNewMeshSelected: Observable<AbstractMesh>;
  130191. /**
  130192. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  130193. * This observable will provide the mesh and the controller used to select the mesh
  130194. */
  130195. onMeshSelectedWithController: Observable<{
  130196. mesh: AbstractMesh;
  130197. controller: WebVRController;
  130198. }>;
  130199. /**
  130200. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  130201. */
  130202. onNewMeshPicked: Observable<PickingInfo>;
  130203. private _circleEase;
  130204. /**
  130205. * Observable raised before camera teleportation
  130206. */
  130207. onBeforeCameraTeleport: Observable<Vector3>;
  130208. /**
  130209. * Observable raised after camera teleportation
  130210. */
  130211. onAfterCameraTeleport: Observable<Vector3>;
  130212. /**
  130213. * Observable raised when current selected mesh gets unselected
  130214. */
  130215. onSelectedMeshUnselected: Observable<AbstractMesh>;
  130216. private _raySelectionPredicate;
  130217. /**
  130218. * To be optionaly changed by user to define custom ray selection
  130219. */
  130220. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  130221. /**
  130222. * To be optionaly changed by user to define custom selection logic (after ray selection)
  130223. */
  130224. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130225. /**
  130226. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  130227. */
  130228. teleportationEnabled: boolean;
  130229. private _defaultHeight;
  130230. private _teleportationInitialized;
  130231. private _interactionsEnabled;
  130232. private _interactionsRequested;
  130233. private _displayGaze;
  130234. private _displayLaserPointer;
  130235. /**
  130236. * The mesh used to display where the user is going to teleport.
  130237. */
  130238. get teleportationTarget(): Mesh;
  130239. /**
  130240. * Sets the mesh to be used to display where the user is going to teleport.
  130241. */
  130242. set teleportationTarget(value: Mesh);
  130243. /**
  130244. * 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
  130245. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  130246. * See https://doc.babylonjs.com/resources/baking_transformations
  130247. */
  130248. get gazeTrackerMesh(): Mesh;
  130249. set gazeTrackerMesh(value: Mesh);
  130250. /**
  130251. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  130252. */
  130253. updateGazeTrackerScale: boolean;
  130254. /**
  130255. * If the gaze trackers color should be updated when selecting meshes
  130256. */
  130257. updateGazeTrackerColor: boolean;
  130258. /**
  130259. * If the controller laser color should be updated when selecting meshes
  130260. */
  130261. updateControllerLaserColor: boolean;
  130262. /**
  130263. * The gaze tracking mesh corresponding to the left controller
  130264. */
  130265. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  130266. /**
  130267. * The gaze tracking mesh corresponding to the right controller
  130268. */
  130269. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  130270. /**
  130271. * If the ray of the gaze should be displayed.
  130272. */
  130273. get displayGaze(): boolean;
  130274. /**
  130275. * Sets if the ray of the gaze should be displayed.
  130276. */
  130277. set displayGaze(value: boolean);
  130278. /**
  130279. * If the ray of the LaserPointer should be displayed.
  130280. */
  130281. get displayLaserPointer(): boolean;
  130282. /**
  130283. * Sets if the ray of the LaserPointer should be displayed.
  130284. */
  130285. set displayLaserPointer(value: boolean);
  130286. /**
  130287. * The deviceOrientationCamera used as the camera when not in VR.
  130288. */
  130289. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  130290. /**
  130291. * Based on the current WebVR support, returns the current VR camera used.
  130292. */
  130293. get currentVRCamera(): Nullable<Camera>;
  130294. /**
  130295. * The webVRCamera which is used when in VR.
  130296. */
  130297. get webVRCamera(): WebVRFreeCamera;
  130298. /**
  130299. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  130300. */
  130301. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  130302. /**
  130303. * The html button that is used to trigger entering into VR.
  130304. */
  130305. get vrButton(): Nullable<HTMLButtonElement>;
  130306. private get _teleportationRequestInitiated();
  130307. /**
  130308. * Defines whether or not Pointer lock should be requested when switching to
  130309. * full screen.
  130310. */
  130311. requestPointerLockOnFullScreen: boolean;
  130312. /**
  130313. * If asking to force XR, this will be populated with the default xr experience
  130314. */
  130315. xr: WebXRDefaultExperience;
  130316. /**
  130317. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  130318. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  130319. */
  130320. xrTestDone: boolean;
  130321. /**
  130322. * Instantiates a VRExperienceHelper.
  130323. * Helps to quickly add VR support to an existing scene.
  130324. * @param scene The scene the VRExperienceHelper belongs to.
  130325. * @param webVROptions Options to modify the vr experience helper's behavior.
  130326. */
  130327. constructor(scene: Scene,
  130328. /** Options to modify the vr experience helper's behavior. */
  130329. webVROptions?: VRExperienceHelperOptions);
  130330. private completeVRInit;
  130331. private _onDefaultMeshLoaded;
  130332. private _onResize;
  130333. private _onFullscreenChange;
  130334. /**
  130335. * Gets a value indicating if we are currently in VR mode.
  130336. */
  130337. get isInVRMode(): boolean;
  130338. private onVrDisplayPresentChange;
  130339. private onVRDisplayChanged;
  130340. private moveButtonToBottomRight;
  130341. private displayVRButton;
  130342. private updateButtonVisibility;
  130343. private _cachedAngularSensibility;
  130344. /**
  130345. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  130346. * Otherwise, will use the fullscreen API.
  130347. */
  130348. enterVR(): void;
  130349. /**
  130350. * Attempt to exit VR, or fullscreen.
  130351. */
  130352. exitVR(): void;
  130353. /**
  130354. * The position of the vr experience helper.
  130355. */
  130356. get position(): Vector3;
  130357. /**
  130358. * Sets the position of the vr experience helper.
  130359. */
  130360. set position(value: Vector3);
  130361. /**
  130362. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  130363. */
  130364. enableInteractions(): void;
  130365. private get _noControllerIsActive();
  130366. private beforeRender;
  130367. private _isTeleportationFloor;
  130368. /**
  130369. * Adds a floor mesh to be used for teleportation.
  130370. * @param floorMesh the mesh to be used for teleportation.
  130371. */
  130372. addFloorMesh(floorMesh: Mesh): void;
  130373. /**
  130374. * Removes a floor mesh from being used for teleportation.
  130375. * @param floorMesh the mesh to be removed.
  130376. */
  130377. removeFloorMesh(floorMesh: Mesh): void;
  130378. /**
  130379. * Enables interactions and teleportation using the VR controllers and gaze.
  130380. * @param vrTeleportationOptions options to modify teleportation behavior.
  130381. */
  130382. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  130383. private _onNewGamepadConnected;
  130384. private _tryEnableInteractionOnController;
  130385. private _onNewGamepadDisconnected;
  130386. private _enableInteractionOnController;
  130387. private _checkTeleportWithRay;
  130388. private _checkRotate;
  130389. private _checkTeleportBackwards;
  130390. private _enableTeleportationOnController;
  130391. private _createTeleportationCircles;
  130392. private _displayTeleportationTarget;
  130393. private _hideTeleportationTarget;
  130394. private _rotateCamera;
  130395. private _moveTeleportationSelectorTo;
  130396. private _workingVector;
  130397. private _workingQuaternion;
  130398. private _workingMatrix;
  130399. /**
  130400. * Time Constant Teleportation Mode
  130401. */
  130402. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  130403. /**
  130404. * Speed Constant Teleportation Mode
  130405. */
  130406. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  130407. /**
  130408. * Teleports the users feet to the desired location
  130409. * @param location The location where the user's feet should be placed
  130410. */
  130411. teleportCamera(location: Vector3): void;
  130412. private _convertNormalToDirectionOfRay;
  130413. private _castRayAndSelectObject;
  130414. private _notifySelectedMeshUnselected;
  130415. /**
  130416. * Permanently set new colors for the laser pointer
  130417. * @param color the new laser color
  130418. * @param pickedColor the new laser color when picked mesh detected
  130419. */
  130420. setLaserColor(color: Color3, pickedColor?: Color3): void;
  130421. /**
  130422. * Set lighting enabled / disabled on the laser pointer of both controllers
  130423. * @param enabled should the lighting be enabled on the laser pointer
  130424. */
  130425. setLaserLightingState(enabled?: boolean): void;
  130426. /**
  130427. * Permanently set new colors for the gaze pointer
  130428. * @param color the new gaze color
  130429. * @param pickedColor the new gaze color when picked mesh detected
  130430. */
  130431. setGazeColor(color: Color3, pickedColor?: Color3): void;
  130432. /**
  130433. * Sets the color of the laser ray from the vr controllers.
  130434. * @param color new color for the ray.
  130435. */
  130436. changeLaserColor(color: Color3): void;
  130437. /**
  130438. * Sets the color of the ray from the vr headsets gaze.
  130439. * @param color new color for the ray.
  130440. */
  130441. changeGazeColor(color: Color3): void;
  130442. /**
  130443. * Exits VR and disposes of the vr experience helper
  130444. */
  130445. dispose(): void;
  130446. /**
  130447. * Gets the name of the VRExperienceHelper class
  130448. * @returns "VRExperienceHelper"
  130449. */
  130450. getClassName(): string;
  130451. }
  130452. }
  130453. declare module BABYLON {
  130454. /**
  130455. * Contains an array of blocks representing the octree
  130456. */
  130457. export interface IOctreeContainer<T> {
  130458. /**
  130459. * Blocks within the octree
  130460. */
  130461. blocks: Array<OctreeBlock<T>>;
  130462. }
  130463. /**
  130464. * Class used to store a cell in an octree
  130465. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130466. */
  130467. export class OctreeBlock<T> {
  130468. /**
  130469. * Gets the content of the current block
  130470. */
  130471. entries: T[];
  130472. /**
  130473. * Gets the list of block children
  130474. */
  130475. blocks: Array<OctreeBlock<T>>;
  130476. private _depth;
  130477. private _maxDepth;
  130478. private _capacity;
  130479. private _minPoint;
  130480. private _maxPoint;
  130481. private _boundingVectors;
  130482. private _creationFunc;
  130483. /**
  130484. * Creates a new block
  130485. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130486. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130487. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130488. * @param depth defines the current depth of this block in the octree
  130489. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130490. * @param creationFunc defines a callback to call when an element is added to the block
  130491. */
  130492. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130493. /**
  130494. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130495. */
  130496. get capacity(): number;
  130497. /**
  130498. * Gets the minimum vector (in world space) of the block's bounding box
  130499. */
  130500. get minPoint(): Vector3;
  130501. /**
  130502. * Gets the maximum vector (in world space) of the block's bounding box
  130503. */
  130504. get maxPoint(): Vector3;
  130505. /**
  130506. * Add a new element to this block
  130507. * @param entry defines the element to add
  130508. */
  130509. addEntry(entry: T): void;
  130510. /**
  130511. * Remove an element from this block
  130512. * @param entry defines the element to remove
  130513. */
  130514. removeEntry(entry: T): void;
  130515. /**
  130516. * Add an array of elements to this block
  130517. * @param entries defines the array of elements to add
  130518. */
  130519. addEntries(entries: T[]): void;
  130520. /**
  130521. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130522. * @param frustumPlanes defines the frustum planes to test
  130523. * @param selection defines the array to store current content if selection is positive
  130524. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130525. */
  130526. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130527. /**
  130528. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130529. * @param sphereCenter defines the bounding sphere center
  130530. * @param sphereRadius defines the bounding sphere radius
  130531. * @param selection defines the array to store current content if selection is positive
  130532. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130533. */
  130534. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130535. /**
  130536. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130537. * @param ray defines the ray to test with
  130538. * @param selection defines the array to store current content if selection is positive
  130539. */
  130540. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130541. /**
  130542. * Subdivide the content into child blocks (this block will then be empty)
  130543. */
  130544. createInnerBlocks(): void;
  130545. /**
  130546. * @hidden
  130547. */
  130548. 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;
  130549. }
  130550. }
  130551. declare module BABYLON {
  130552. /**
  130553. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130554. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130555. */
  130556. export class Octree<T> {
  130557. /** 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.) */
  130558. maxDepth: number;
  130559. /**
  130560. * Blocks within the octree containing objects
  130561. */
  130562. blocks: Array<OctreeBlock<T>>;
  130563. /**
  130564. * Content stored in the octree
  130565. */
  130566. dynamicContent: T[];
  130567. private _maxBlockCapacity;
  130568. private _selectionContent;
  130569. private _creationFunc;
  130570. /**
  130571. * Creates a octree
  130572. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130573. * @param creationFunc function to be used to instatiate the octree
  130574. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130575. * @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.)
  130576. */
  130577. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130578. /** 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.) */
  130579. maxDepth?: number);
  130580. /**
  130581. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130582. * @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);
  130583. * @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);
  130584. * @param entries meshes to be added to the octree blocks
  130585. */
  130586. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130587. /**
  130588. * Adds a mesh to the octree
  130589. * @param entry Mesh to add to the octree
  130590. */
  130591. addMesh(entry: T): void;
  130592. /**
  130593. * Remove an element from the octree
  130594. * @param entry defines the element to remove
  130595. */
  130596. removeMesh(entry: T): void;
  130597. /**
  130598. * Selects an array of meshes within the frustum
  130599. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130600. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130601. * @returns array of meshes within the frustum
  130602. */
  130603. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130604. /**
  130605. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130606. * @param sphereCenter defines the bounding sphere center
  130607. * @param sphereRadius defines the bounding sphere radius
  130608. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130609. * @returns an array of objects that intersect the sphere
  130610. */
  130611. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130612. /**
  130613. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130614. * @param ray defines the ray to test with
  130615. * @returns array of intersected objects
  130616. */
  130617. intersectsRay(ray: Ray): SmartArray<T>;
  130618. /**
  130619. * Adds a mesh into the octree block if it intersects the block
  130620. */
  130621. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130622. /**
  130623. * Adds a submesh into the octree block if it intersects the block
  130624. */
  130625. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130626. }
  130627. }
  130628. declare module BABYLON {
  130629. interface Scene {
  130630. /**
  130631. * @hidden
  130632. * Backing Filed
  130633. */
  130634. _selectionOctree: Octree<AbstractMesh>;
  130635. /**
  130636. * Gets the octree used to boost mesh selection (picking)
  130637. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130638. */
  130639. selectionOctree: Octree<AbstractMesh>;
  130640. /**
  130641. * Creates or updates the octree used to boost selection (picking)
  130642. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130643. * @param maxCapacity defines the maximum capacity per leaf
  130644. * @param maxDepth defines the maximum depth of the octree
  130645. * @returns an octree of AbstractMesh
  130646. */
  130647. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130648. }
  130649. interface AbstractMesh {
  130650. /**
  130651. * @hidden
  130652. * Backing Field
  130653. */
  130654. _submeshesOctree: Octree<SubMesh>;
  130655. /**
  130656. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130657. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130658. * @param maxCapacity defines the maximum size of each block (64 by default)
  130659. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130660. * @returns the new octree
  130661. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130662. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130663. */
  130664. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130665. }
  130666. /**
  130667. * Defines the octree scene component responsible to manage any octrees
  130668. * in a given scene.
  130669. */
  130670. export class OctreeSceneComponent {
  130671. /**
  130672. * The component name help to identify the component in the list of scene components.
  130673. */
  130674. readonly name: string;
  130675. /**
  130676. * The scene the component belongs to.
  130677. */
  130678. scene: Scene;
  130679. /**
  130680. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130681. */
  130682. readonly checksIsEnabled: boolean;
  130683. /**
  130684. * Creates a new instance of the component for the given scene
  130685. * @param scene Defines the scene to register the component in
  130686. */
  130687. constructor(scene: Scene);
  130688. /**
  130689. * Registers the component in a given scene
  130690. */
  130691. register(): void;
  130692. /**
  130693. * Return the list of active meshes
  130694. * @returns the list of active meshes
  130695. */
  130696. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130697. /**
  130698. * Return the list of active sub meshes
  130699. * @param mesh The mesh to get the candidates sub meshes from
  130700. * @returns the list of active sub meshes
  130701. */
  130702. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130703. private _tempRay;
  130704. /**
  130705. * Return the list of sub meshes intersecting with a given local ray
  130706. * @param mesh defines the mesh to find the submesh for
  130707. * @param localRay defines the ray in local space
  130708. * @returns the list of intersecting sub meshes
  130709. */
  130710. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  130711. /**
  130712. * Return the list of sub meshes colliding with a collider
  130713. * @param mesh defines the mesh to find the submesh for
  130714. * @param collider defines the collider to evaluate the collision against
  130715. * @returns the list of colliding sub meshes
  130716. */
  130717. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  130718. /**
  130719. * Rebuilds the elements related to this component in case of
  130720. * context lost for instance.
  130721. */
  130722. rebuild(): void;
  130723. /**
  130724. * Disposes the component and the associated ressources.
  130725. */
  130726. dispose(): void;
  130727. }
  130728. }
  130729. declare module BABYLON {
  130730. /**
  130731. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  130732. */
  130733. export class Gizmo implements IDisposable {
  130734. /** The utility layer the gizmo will be added to */
  130735. gizmoLayer: UtilityLayerRenderer;
  130736. /**
  130737. * The root mesh of the gizmo
  130738. */
  130739. _rootMesh: Mesh;
  130740. private _attachedMesh;
  130741. private _attachedNode;
  130742. /**
  130743. * Ratio for the scale of the gizmo (Default: 1)
  130744. */
  130745. protected _scaleRatio: number;
  130746. /**
  130747. * boolean updated by pointermove when a gizmo mesh is hovered
  130748. */
  130749. protected _isHovered: boolean;
  130750. /**
  130751. * Ratio for the scale of the gizmo (Default: 1)
  130752. */
  130753. set scaleRatio(value: number);
  130754. get scaleRatio(): number;
  130755. /**
  130756. * True when the mouse pointer is hovered a gizmo mesh
  130757. */
  130758. get isHovered(): boolean;
  130759. /**
  130760. * If a custom mesh has been set (Default: false)
  130761. */
  130762. protected _customMeshSet: boolean;
  130763. /**
  130764. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130765. * * When set, interactions will be enabled
  130766. */
  130767. get attachedMesh(): Nullable<AbstractMesh>;
  130768. set attachedMesh(value: Nullable<AbstractMesh>);
  130769. /**
  130770. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130771. * * When set, interactions will be enabled
  130772. */
  130773. get attachedNode(): Nullable<Node>;
  130774. set attachedNode(value: Nullable<Node>);
  130775. /**
  130776. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130777. * @param mesh The mesh to replace the default mesh of the gizmo
  130778. */
  130779. setCustomMesh(mesh: Mesh): void;
  130780. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130781. /**
  130782. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130783. */
  130784. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130785. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130786. /**
  130787. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130788. */
  130789. updateGizmoPositionToMatchAttachedMesh: boolean;
  130790. /**
  130791. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130792. */
  130793. updateScale: boolean;
  130794. protected _interactionsEnabled: boolean;
  130795. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130796. private _beforeRenderObserver;
  130797. private _tempQuaternion;
  130798. private _tempVector;
  130799. private _tempVector2;
  130800. private _tempMatrix1;
  130801. private _tempMatrix2;
  130802. private _rightHandtoLeftHandMatrix;
  130803. /**
  130804. * Creates a gizmo
  130805. * @param gizmoLayer The utility layer the gizmo will be added to
  130806. */
  130807. constructor(
  130808. /** The utility layer the gizmo will be added to */
  130809. gizmoLayer?: UtilityLayerRenderer);
  130810. /**
  130811. * Updates the gizmo to match the attached mesh's position/rotation
  130812. */
  130813. protected _update(): void;
  130814. /**
  130815. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130816. * @param value Node, TransformNode or mesh
  130817. */
  130818. protected _matrixChanged(): void;
  130819. /**
  130820. * Disposes of the gizmo
  130821. */
  130822. dispose(): void;
  130823. }
  130824. }
  130825. declare module BABYLON {
  130826. /**
  130827. * Single plane drag gizmo
  130828. */
  130829. export class PlaneDragGizmo extends Gizmo {
  130830. /**
  130831. * Drag behavior responsible for the gizmos dragging interactions
  130832. */
  130833. dragBehavior: PointerDragBehavior;
  130834. private _pointerObserver;
  130835. /**
  130836. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130837. */
  130838. snapDistance: number;
  130839. /**
  130840. * Event that fires each time the gizmo snaps to a new location.
  130841. * * snapDistance is the the change in distance
  130842. */
  130843. onSnapObservable: Observable<{
  130844. snapDistance: number;
  130845. }>;
  130846. private _plane;
  130847. private _coloredMaterial;
  130848. private _hoverMaterial;
  130849. private _isEnabled;
  130850. private _parent;
  130851. /** @hidden */
  130852. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130853. /** @hidden */
  130854. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130855. /**
  130856. * Creates a PlaneDragGizmo
  130857. * @param gizmoLayer The utility layer the gizmo will be added to
  130858. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130859. * @param color The color of the gizmo
  130860. */
  130861. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130862. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130863. /**
  130864. * If the gizmo is enabled
  130865. */
  130866. set isEnabled(value: boolean);
  130867. get isEnabled(): boolean;
  130868. /**
  130869. * Disposes of the gizmo
  130870. */
  130871. dispose(): void;
  130872. }
  130873. }
  130874. declare module BABYLON {
  130875. /**
  130876. * Gizmo that enables dragging a mesh along 3 axis
  130877. */
  130878. export class PositionGizmo extends Gizmo {
  130879. /**
  130880. * Internal gizmo used for interactions on the x axis
  130881. */
  130882. xGizmo: AxisDragGizmo;
  130883. /**
  130884. * Internal gizmo used for interactions on the y axis
  130885. */
  130886. yGizmo: AxisDragGizmo;
  130887. /**
  130888. * Internal gizmo used for interactions on the z axis
  130889. */
  130890. zGizmo: AxisDragGizmo;
  130891. /**
  130892. * Internal gizmo used for interactions on the yz plane
  130893. */
  130894. xPlaneGizmo: PlaneDragGizmo;
  130895. /**
  130896. * Internal gizmo used for interactions on the xz plane
  130897. */
  130898. yPlaneGizmo: PlaneDragGizmo;
  130899. /**
  130900. * Internal gizmo used for interactions on the xy plane
  130901. */
  130902. zPlaneGizmo: PlaneDragGizmo;
  130903. /**
  130904. * private variables
  130905. */
  130906. private _meshAttached;
  130907. private _nodeAttached;
  130908. private _snapDistance;
  130909. /** Fires an event when any of it's sub gizmos are dragged */
  130910. onDragStartObservable: Observable<unknown>;
  130911. /** Fires an event when any of it's sub gizmos are released from dragging */
  130912. onDragEndObservable: Observable<unknown>;
  130913. /**
  130914. * If set to true, planar drag is enabled
  130915. */
  130916. private _planarGizmoEnabled;
  130917. get attachedMesh(): Nullable<AbstractMesh>;
  130918. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130919. get attachedNode(): Nullable<Node>;
  130920. set attachedNode(node: Nullable<Node>);
  130921. /**
  130922. * True when the mouse pointer is hovering a gizmo mesh
  130923. */
  130924. get isHovered(): boolean;
  130925. /**
  130926. * Creates a PositionGizmo
  130927. * @param gizmoLayer The utility layer the gizmo will be added to
  130928. @param thickness display gizmo axis thickness
  130929. */
  130930. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130931. /**
  130932. * If the planar drag gizmo is enabled
  130933. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130934. */
  130935. set planarGizmoEnabled(value: boolean);
  130936. get planarGizmoEnabled(): boolean;
  130937. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130938. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130939. /**
  130940. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130941. */
  130942. set snapDistance(value: number);
  130943. get snapDistance(): number;
  130944. /**
  130945. * Ratio for the scale of the gizmo (Default: 1)
  130946. */
  130947. set scaleRatio(value: number);
  130948. get scaleRatio(): number;
  130949. /**
  130950. * Disposes of the gizmo
  130951. */
  130952. dispose(): void;
  130953. /**
  130954. * CustomMeshes are not supported by this gizmo
  130955. * @param mesh The mesh to replace the default mesh of the gizmo
  130956. */
  130957. setCustomMesh(mesh: Mesh): void;
  130958. }
  130959. }
  130960. declare module BABYLON {
  130961. /**
  130962. * Single axis drag gizmo
  130963. */
  130964. export class AxisDragGizmo extends Gizmo {
  130965. /**
  130966. * Drag behavior responsible for the gizmos dragging interactions
  130967. */
  130968. dragBehavior: PointerDragBehavior;
  130969. private _pointerObserver;
  130970. /**
  130971. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130972. */
  130973. snapDistance: number;
  130974. /**
  130975. * Event that fires each time the gizmo snaps to a new location.
  130976. * * snapDistance is the the change in distance
  130977. */
  130978. onSnapObservable: Observable<{
  130979. snapDistance: number;
  130980. }>;
  130981. private _isEnabled;
  130982. private _parent;
  130983. private _arrow;
  130984. private _coloredMaterial;
  130985. private _hoverMaterial;
  130986. /** @hidden */
  130987. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130988. /** @hidden */
  130989. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130990. /**
  130991. * Creates an AxisDragGizmo
  130992. * @param gizmoLayer The utility layer the gizmo will be added to
  130993. * @param dragAxis The axis which the gizmo will be able to drag on
  130994. * @param color The color of the gizmo
  130995. * @param thickness display gizmo axis thickness
  130996. */
  130997. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130998. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130999. /**
  131000. * If the gizmo is enabled
  131001. */
  131002. set isEnabled(value: boolean);
  131003. get isEnabled(): boolean;
  131004. /**
  131005. * Disposes of the gizmo
  131006. */
  131007. dispose(): void;
  131008. }
  131009. }
  131010. declare module BABYLON.Debug {
  131011. /**
  131012. * The Axes viewer will show 3 axes in a specific point in space
  131013. */
  131014. export class AxesViewer {
  131015. private _xAxis;
  131016. private _yAxis;
  131017. private _zAxis;
  131018. private _scaleLinesFactor;
  131019. private _instanced;
  131020. /**
  131021. * Gets the hosting scene
  131022. */
  131023. scene: Nullable<Scene>;
  131024. /**
  131025. * Gets or sets a number used to scale line length
  131026. */
  131027. scaleLines: number;
  131028. /** Gets the node hierarchy used to render x-axis */
  131029. get xAxis(): TransformNode;
  131030. /** Gets the node hierarchy used to render y-axis */
  131031. get yAxis(): TransformNode;
  131032. /** Gets the node hierarchy used to render z-axis */
  131033. get zAxis(): TransformNode;
  131034. /**
  131035. * Creates a new AxesViewer
  131036. * @param scene defines the hosting scene
  131037. * @param scaleLines defines a number used to scale line length (1 by default)
  131038. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  131039. * @param xAxis defines the node hierarchy used to render the x-axis
  131040. * @param yAxis defines the node hierarchy used to render the y-axis
  131041. * @param zAxis defines the node hierarchy used to render the z-axis
  131042. */
  131043. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  131044. /**
  131045. * Force the viewer to update
  131046. * @param position defines the position of the viewer
  131047. * @param xaxis defines the x axis of the viewer
  131048. * @param yaxis defines the y axis of the viewer
  131049. * @param zaxis defines the z axis of the viewer
  131050. */
  131051. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  131052. /**
  131053. * Creates an instance of this axes viewer.
  131054. * @returns a new axes viewer with instanced meshes
  131055. */
  131056. createInstance(): AxesViewer;
  131057. /** Releases resources */
  131058. dispose(): void;
  131059. private static _SetRenderingGroupId;
  131060. }
  131061. }
  131062. declare module BABYLON.Debug {
  131063. /**
  131064. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  131065. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  131066. */
  131067. export class BoneAxesViewer extends AxesViewer {
  131068. /**
  131069. * Gets or sets the target mesh where to display the axes viewer
  131070. */
  131071. mesh: Nullable<Mesh>;
  131072. /**
  131073. * Gets or sets the target bone where to display the axes viewer
  131074. */
  131075. bone: Nullable<Bone>;
  131076. /** Gets current position */
  131077. pos: Vector3;
  131078. /** Gets direction of X axis */
  131079. xaxis: Vector3;
  131080. /** Gets direction of Y axis */
  131081. yaxis: Vector3;
  131082. /** Gets direction of Z axis */
  131083. zaxis: Vector3;
  131084. /**
  131085. * Creates a new BoneAxesViewer
  131086. * @param scene defines the hosting scene
  131087. * @param bone defines the target bone
  131088. * @param mesh defines the target mesh
  131089. * @param scaleLines defines a scaling factor for line length (1 by default)
  131090. */
  131091. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  131092. /**
  131093. * Force the viewer to update
  131094. */
  131095. update(): void;
  131096. /** Releases resources */
  131097. dispose(): void;
  131098. }
  131099. }
  131100. declare module BABYLON {
  131101. /**
  131102. * Interface used to define scene explorer extensibility option
  131103. */
  131104. export interface IExplorerExtensibilityOption {
  131105. /**
  131106. * Define the option label
  131107. */
  131108. label: string;
  131109. /**
  131110. * Defines the action to execute on click
  131111. */
  131112. action: (entity: any) => void;
  131113. }
  131114. /**
  131115. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  131116. */
  131117. export interface IExplorerExtensibilityGroup {
  131118. /**
  131119. * Defines a predicate to test if a given type mut be extended
  131120. */
  131121. predicate: (entity: any) => boolean;
  131122. /**
  131123. * Gets the list of options added to a type
  131124. */
  131125. entries: IExplorerExtensibilityOption[];
  131126. }
  131127. /**
  131128. * Interface used to define the options to use to create the Inspector
  131129. */
  131130. export interface IInspectorOptions {
  131131. /**
  131132. * Display in overlay mode (default: false)
  131133. */
  131134. overlay?: boolean;
  131135. /**
  131136. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  131137. */
  131138. globalRoot?: HTMLElement;
  131139. /**
  131140. * Display the Scene explorer
  131141. */
  131142. showExplorer?: boolean;
  131143. /**
  131144. * Display the property inspector
  131145. */
  131146. showInspector?: boolean;
  131147. /**
  131148. * Display in embed mode (both panes on the right)
  131149. */
  131150. embedMode?: boolean;
  131151. /**
  131152. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  131153. */
  131154. handleResize?: boolean;
  131155. /**
  131156. * Allow the panes to popup (default: true)
  131157. */
  131158. enablePopup?: boolean;
  131159. /**
  131160. * Allow the panes to be closed by users (default: true)
  131161. */
  131162. enableClose?: boolean;
  131163. /**
  131164. * Optional list of extensibility entries
  131165. */
  131166. explorerExtensibility?: IExplorerExtensibilityGroup[];
  131167. /**
  131168. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  131169. */
  131170. inspectorURL?: string;
  131171. /**
  131172. * Optional initial tab (default to DebugLayerTab.Properties)
  131173. */
  131174. initialTab?: DebugLayerTab;
  131175. }
  131176. interface Scene {
  131177. /**
  131178. * @hidden
  131179. * Backing field
  131180. */
  131181. _debugLayer: DebugLayer;
  131182. /**
  131183. * Gets the debug layer (aka Inspector) associated with the scene
  131184. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131185. */
  131186. debugLayer: DebugLayer;
  131187. }
  131188. /**
  131189. * Enum of inspector action tab
  131190. */
  131191. export enum DebugLayerTab {
  131192. /**
  131193. * Properties tag (default)
  131194. */
  131195. Properties = 0,
  131196. /**
  131197. * Debug tab
  131198. */
  131199. Debug = 1,
  131200. /**
  131201. * Statistics tab
  131202. */
  131203. Statistics = 2,
  131204. /**
  131205. * Tools tab
  131206. */
  131207. Tools = 3,
  131208. /**
  131209. * Settings tab
  131210. */
  131211. Settings = 4
  131212. }
  131213. /**
  131214. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131215. * what is happening in your scene
  131216. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131217. */
  131218. export class DebugLayer {
  131219. /**
  131220. * Define the url to get the inspector script from.
  131221. * By default it uses the babylonjs CDN.
  131222. * @ignoreNaming
  131223. */
  131224. static InspectorURL: string;
  131225. private _scene;
  131226. private BJSINSPECTOR;
  131227. private _onPropertyChangedObservable?;
  131228. /**
  131229. * Observable triggered when a property is changed through the inspector.
  131230. */
  131231. get onPropertyChangedObservable(): any;
  131232. /**
  131233. * Instantiates a new debug layer.
  131234. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131235. * what is happening in your scene
  131236. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131237. * @param scene Defines the scene to inspect
  131238. */
  131239. constructor(scene: Scene);
  131240. /** Creates the inspector window. */
  131241. private _createInspector;
  131242. /**
  131243. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  131244. * @param entity defines the entity to select
  131245. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  131246. */
  131247. select(entity: any, lineContainerTitles?: string | string[]): void;
  131248. /** Get the inspector from bundle or global */
  131249. private _getGlobalInspector;
  131250. /**
  131251. * Get if the inspector is visible or not.
  131252. * @returns true if visible otherwise, false
  131253. */
  131254. isVisible(): boolean;
  131255. /**
  131256. * Hide the inspector and close its window.
  131257. */
  131258. hide(): void;
  131259. /**
  131260. * Update the scene in the inspector
  131261. */
  131262. setAsActiveScene(): void;
  131263. /**
  131264. * Launch the debugLayer.
  131265. * @param config Define the configuration of the inspector
  131266. * @return a promise fulfilled when the debug layer is visible
  131267. */
  131268. show(config?: IInspectorOptions): Promise<DebugLayer>;
  131269. }
  131270. }
  131271. declare module BABYLON {
  131272. /**
  131273. * Class containing static functions to help procedurally build meshes
  131274. */
  131275. export class BoxBuilder {
  131276. /**
  131277. * Creates a box mesh
  131278. * * The parameter `size` sets the size (float) of each box side (default 1)
  131279. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131280. * * 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)
  131281. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131285. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131286. * @param name defines the name of the mesh
  131287. * @param options defines the options used to create the mesh
  131288. * @param scene defines the hosting scene
  131289. * @returns the box mesh
  131290. */
  131291. static CreateBox(name: string, options: {
  131292. size?: number;
  131293. width?: number;
  131294. height?: number;
  131295. depth?: number;
  131296. faceUV?: Vector4[];
  131297. faceColors?: Color4[];
  131298. sideOrientation?: number;
  131299. frontUVs?: Vector4;
  131300. backUVs?: Vector4;
  131301. wrap?: boolean;
  131302. topBaseAt?: number;
  131303. bottomBaseAt?: number;
  131304. updatable?: boolean;
  131305. }, scene?: Nullable<Scene>): Mesh;
  131306. }
  131307. }
  131308. declare module BABYLON.Debug {
  131309. /**
  131310. * Used to show the physics impostor around the specific mesh
  131311. */
  131312. export class PhysicsViewer {
  131313. /** @hidden */
  131314. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  131315. /** @hidden */
  131316. protected _meshes: Array<Nullable<AbstractMesh>>;
  131317. /** @hidden */
  131318. protected _scene: Nullable<Scene>;
  131319. /** @hidden */
  131320. protected _numMeshes: number;
  131321. /** @hidden */
  131322. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  131323. private _renderFunction;
  131324. private _utilityLayer;
  131325. private _debugBoxMesh;
  131326. private _debugSphereMesh;
  131327. private _debugCylinderMesh;
  131328. private _debugMaterial;
  131329. private _debugMeshMeshes;
  131330. /**
  131331. * Creates a new PhysicsViewer
  131332. * @param scene defines the hosting scene
  131333. */
  131334. constructor(scene: Scene);
  131335. /** @hidden */
  131336. protected _updateDebugMeshes(): void;
  131337. /**
  131338. * Renders a specified physic impostor
  131339. * @param impostor defines the impostor to render
  131340. * @param targetMesh defines the mesh represented by the impostor
  131341. * @returns the new debug mesh used to render the impostor
  131342. */
  131343. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  131344. /**
  131345. * Hides a specified physic impostor
  131346. * @param impostor defines the impostor to hide
  131347. */
  131348. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  131349. private _getDebugMaterial;
  131350. private _getDebugBoxMesh;
  131351. private _getDebugSphereMesh;
  131352. private _getDebugCylinderMesh;
  131353. private _getDebugMeshMesh;
  131354. private _getDebugMesh;
  131355. /** Releases all resources */
  131356. dispose(): void;
  131357. }
  131358. }
  131359. declare module BABYLON {
  131360. /**
  131361. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131362. * in order to better appreciate the issue one might have.
  131363. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131364. */
  131365. export class RayHelper {
  131366. /**
  131367. * Defines the ray we are currently tryin to visualize.
  131368. */
  131369. ray: Nullable<Ray>;
  131370. private _renderPoints;
  131371. private _renderLine;
  131372. private _renderFunction;
  131373. private _scene;
  131374. private _onAfterRenderObserver;
  131375. private _onAfterStepObserver;
  131376. private _attachedToMesh;
  131377. private _meshSpaceDirection;
  131378. private _meshSpaceOrigin;
  131379. /**
  131380. * Helper function to create a colored helper in a scene in one line.
  131381. * @param ray Defines the ray we are currently tryin to visualize
  131382. * @param scene Defines the scene the ray is used in
  131383. * @param color Defines the color we want to see the ray in
  131384. * @returns The newly created ray helper.
  131385. */
  131386. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  131387. /**
  131388. * Instantiate a new ray helper.
  131389. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131390. * in order to better appreciate the issue one might have.
  131391. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131392. * @param ray Defines the ray we are currently tryin to visualize
  131393. */
  131394. constructor(ray: Ray);
  131395. /**
  131396. * Shows the ray we are willing to debug.
  131397. * @param scene Defines the scene the ray needs to be rendered in
  131398. * @param color Defines the color the ray needs to be rendered in
  131399. */
  131400. show(scene: Scene, color?: Color3): void;
  131401. /**
  131402. * Hides the ray we are debugging.
  131403. */
  131404. hide(): void;
  131405. private _render;
  131406. /**
  131407. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  131408. * @param mesh Defines the mesh we want the helper attached to
  131409. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  131410. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  131411. * @param length Defines the length of the ray
  131412. */
  131413. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  131414. /**
  131415. * Detach the ray helper from the mesh it has previously been attached to.
  131416. */
  131417. detachFromMesh(): void;
  131418. private _updateToMesh;
  131419. /**
  131420. * Dispose the helper and release its associated resources.
  131421. */
  131422. dispose(): void;
  131423. }
  131424. }
  131425. declare module BABYLON {
  131426. /**
  131427. * Defines the options associated with the creation of a SkeletonViewer.
  131428. */
  131429. export interface ISkeletonViewerOptions {
  131430. /** Should the system pause animations before building the Viewer? */
  131431. pauseAnimations: boolean;
  131432. /** Should the system return the skeleton to rest before building? */
  131433. returnToRest: boolean;
  131434. /** public Display Mode of the Viewer */
  131435. displayMode: number;
  131436. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131437. displayOptions: ISkeletonViewerDisplayOptions;
  131438. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131439. computeBonesUsingShaders: boolean;
  131440. /** Flag ignore non weighted bones */
  131441. useAllBones: boolean;
  131442. }
  131443. /**
  131444. * Defines how to display the various bone meshes for the viewer.
  131445. */
  131446. export interface ISkeletonViewerDisplayOptions {
  131447. /** How far down to start tapering the bone spurs */
  131448. midStep?: number;
  131449. /** How big is the midStep? */
  131450. midStepFactor?: number;
  131451. /** Base for the Sphere Size */
  131452. sphereBaseSize?: number;
  131453. /** The ratio of the sphere to the longest bone in units */
  131454. sphereScaleUnit?: number;
  131455. /** Ratio for the Sphere Size */
  131456. sphereFactor?: number;
  131457. /** Whether to show local axes or not */
  131458. showLocalAxes?: boolean;
  131459. /** Length of each local axis */
  131460. localAxesSize?: number;
  131461. }
  131462. /**
  131463. * Defines the constructor options for the BoneWeight Shader.
  131464. */
  131465. export interface IBoneWeightShaderOptions {
  131466. /** Skeleton to Map */
  131467. skeleton: Skeleton;
  131468. /** Colors for Uninfluenced bones */
  131469. colorBase?: Color3;
  131470. /** Colors for 0.0-0.25 Weight bones */
  131471. colorZero?: Color3;
  131472. /** Color for 0.25-0.5 Weight Influence */
  131473. colorQuarter?: Color3;
  131474. /** Color for 0.5-0.75 Weight Influence */
  131475. colorHalf?: Color3;
  131476. /** Color for 0.75-1 Weight Influence */
  131477. colorFull?: Color3;
  131478. /** Color for Zero Weight Influence */
  131479. targetBoneIndex?: number;
  131480. }
  131481. /**
  131482. * Simple structure of the gradient steps for the Color Map.
  131483. */
  131484. export interface ISkeletonMapShaderColorMapKnot {
  131485. /** Color of the Knot */
  131486. color: Color3;
  131487. /** Location of the Knot */
  131488. location: number;
  131489. }
  131490. /**
  131491. * Defines the constructor options for the SkeletonMap Shader.
  131492. */
  131493. export interface ISkeletonMapShaderOptions {
  131494. /** Skeleton to Map */
  131495. skeleton: Skeleton;
  131496. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  131497. colorMap?: ISkeletonMapShaderColorMapKnot[];
  131498. }
  131499. }
  131500. declare module BABYLON {
  131501. /**
  131502. * Class containing static functions to help procedurally build meshes
  131503. */
  131504. export class RibbonBuilder {
  131505. /**
  131506. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131507. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131508. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131509. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131510. * * 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
  131511. * * 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
  131512. * * 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
  131513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131516. * * 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
  131517. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131518. * * 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
  131519. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131521. * @param name defines the name of the mesh
  131522. * @param options defines the options used to create the mesh
  131523. * @param scene defines the hosting scene
  131524. * @returns the ribbon mesh
  131525. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131526. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131527. */
  131528. static CreateRibbon(name: string, options: {
  131529. pathArray: Vector3[][];
  131530. closeArray?: boolean;
  131531. closePath?: boolean;
  131532. offset?: number;
  131533. updatable?: boolean;
  131534. sideOrientation?: number;
  131535. frontUVs?: Vector4;
  131536. backUVs?: Vector4;
  131537. instance?: Mesh;
  131538. invertUV?: boolean;
  131539. uvs?: Vector2[];
  131540. colors?: Color4[];
  131541. }, scene?: Nullable<Scene>): Mesh;
  131542. }
  131543. }
  131544. declare module BABYLON {
  131545. /**
  131546. * Class containing static functions to help procedurally build meshes
  131547. */
  131548. export class ShapeBuilder {
  131549. /**
  131550. * 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.
  131551. * * 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.
  131552. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131553. * * 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.
  131554. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131555. * * 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
  131556. * * 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
  131557. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131560. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131562. * @param name defines the name of the mesh
  131563. * @param options defines the options used to create the mesh
  131564. * @param scene defines the hosting scene
  131565. * @returns the extruded shape mesh
  131566. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131568. */
  131569. static ExtrudeShape(name: string, options: {
  131570. shape: Vector3[];
  131571. path: Vector3[];
  131572. scale?: number;
  131573. rotation?: number;
  131574. cap?: number;
  131575. updatable?: boolean;
  131576. sideOrientation?: number;
  131577. frontUVs?: Vector4;
  131578. backUVs?: Vector4;
  131579. instance?: Mesh;
  131580. invertUV?: boolean;
  131581. }, scene?: Nullable<Scene>): Mesh;
  131582. /**
  131583. * Creates an custom extruded shape mesh.
  131584. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131585. * * 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.
  131586. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131587. * * 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
  131588. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131589. * * 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
  131590. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131591. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131592. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131593. * * 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
  131594. * * 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
  131595. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131598. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131600. * @param name defines the name of the mesh
  131601. * @param options defines the options used to create the mesh
  131602. * @param scene defines the hosting scene
  131603. * @returns the custom extruded shape mesh
  131604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131605. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131606. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131607. */
  131608. static ExtrudeShapeCustom(name: string, options: {
  131609. shape: Vector3[];
  131610. path: Vector3[];
  131611. scaleFunction?: any;
  131612. rotationFunction?: any;
  131613. ribbonCloseArray?: boolean;
  131614. ribbonClosePath?: boolean;
  131615. cap?: number;
  131616. updatable?: boolean;
  131617. sideOrientation?: number;
  131618. frontUVs?: Vector4;
  131619. backUVs?: Vector4;
  131620. instance?: Mesh;
  131621. invertUV?: boolean;
  131622. }, scene?: Nullable<Scene>): Mesh;
  131623. private static _ExtrudeShapeGeneric;
  131624. }
  131625. }
  131626. declare module BABYLON.Debug {
  131627. /**
  131628. * Class used to render a debug view of a given skeleton
  131629. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131630. */
  131631. export class SkeletonViewer {
  131632. /** defines the skeleton to render */
  131633. skeleton: Skeleton;
  131634. /** defines the mesh attached to the skeleton */
  131635. mesh: AbstractMesh;
  131636. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131637. autoUpdateBonesMatrices: boolean;
  131638. /** defines the rendering group id to use with the viewer */
  131639. renderingGroupId: number;
  131640. /** is the options for the viewer */
  131641. options: Partial<ISkeletonViewerOptions>;
  131642. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131643. static readonly DISPLAY_LINES: number;
  131644. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131645. static readonly DISPLAY_SPHERES: number;
  131646. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131647. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131648. /** public static method to create a BoneWeight Shader
  131649. * @param options The constructor options
  131650. * @param scene The scene that the shader is scoped to
  131651. * @returns The created ShaderMaterial
  131652. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131653. */
  131654. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131655. /** public static method to create a BoneWeight Shader
  131656. * @param options The constructor options
  131657. * @param scene The scene that the shader is scoped to
  131658. * @returns The created ShaderMaterial
  131659. */
  131660. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131661. /** private static method to create a BoneWeight Shader
  131662. * @param size The size of the buffer to create (usually the bone count)
  131663. * @param colorMap The gradient data to generate
  131664. * @param scene The scene that the shader is scoped to
  131665. * @returns an Array of floats from the color gradient values
  131666. */
  131667. private static _CreateBoneMapColorBuffer;
  131668. /** If SkeletonViewer scene scope. */
  131669. private _scene;
  131670. /** Gets or sets the color used to render the skeleton */
  131671. color: Color3;
  131672. /** Array of the points of the skeleton fo the line view. */
  131673. private _debugLines;
  131674. /** The SkeletonViewers Mesh. */
  131675. private _debugMesh;
  131676. /** The local axes Meshes. */
  131677. private _localAxes;
  131678. /** If SkeletonViewer is enabled. */
  131679. private _isEnabled;
  131680. /** If SkeletonViewer is ready. */
  131681. private _ready;
  131682. /** SkeletonViewer render observable. */
  131683. private _obs;
  131684. /** The Utility Layer to render the gizmos in. */
  131685. private _utilityLayer;
  131686. private _boneIndices;
  131687. /** Gets the Scene. */
  131688. get scene(): Scene;
  131689. /** Gets the utilityLayer. */
  131690. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131691. /** Checks Ready Status. */
  131692. get isReady(): Boolean;
  131693. /** Sets Ready Status. */
  131694. set ready(value: boolean);
  131695. /** Gets the debugMesh */
  131696. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  131697. /** Sets the debugMesh */
  131698. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  131699. /** Gets the displayMode */
  131700. get displayMode(): number;
  131701. /** Sets the displayMode */
  131702. set displayMode(value: number);
  131703. /**
  131704. * Creates a new SkeletonViewer
  131705. * @param skeleton defines the skeleton to render
  131706. * @param mesh defines the mesh attached to the skeleton
  131707. * @param scene defines the hosting scene
  131708. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  131709. * @param renderingGroupId defines the rendering group id to use with the viewer
  131710. * @param options All of the extra constructor options for the SkeletonViewer
  131711. */
  131712. constructor(
  131713. /** defines the skeleton to render */
  131714. skeleton: Skeleton,
  131715. /** defines the mesh attached to the skeleton */
  131716. mesh: AbstractMesh,
  131717. /** The Scene scope*/
  131718. scene: Scene,
  131719. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131720. autoUpdateBonesMatrices?: boolean,
  131721. /** defines the rendering group id to use with the viewer */
  131722. renderingGroupId?: number,
  131723. /** is the options for the viewer */
  131724. options?: Partial<ISkeletonViewerOptions>);
  131725. /** The Dynamic bindings for the update functions */
  131726. private _bindObs;
  131727. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  131728. update(): void;
  131729. /** Gets or sets a boolean indicating if the viewer is enabled */
  131730. set isEnabled(value: boolean);
  131731. get isEnabled(): boolean;
  131732. private _getBonePosition;
  131733. private _getLinesForBonesWithLength;
  131734. private _getLinesForBonesNoLength;
  131735. /** function to revert the mesh and scene back to the initial state. */
  131736. private _revert;
  131737. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  131738. private _getAbsoluteBindPoseToRef;
  131739. /** function to build and bind sphere joint points and spur bone representations. */
  131740. private _buildSpheresAndSpurs;
  131741. private _buildLocalAxes;
  131742. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  131743. private _displayLinesUpdate;
  131744. /** Changes the displayMode of the skeleton viewer
  131745. * @param mode The displayMode numerical value
  131746. */
  131747. changeDisplayMode(mode: number): void;
  131748. /** Sets a display option of the skeleton viewer
  131749. *
  131750. * | Option | Type | Default | Description |
  131751. * | --------------- | ------- | ------- | ----------- |
  131752. * | 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`. |
  131753. * | 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`. |
  131754. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131755. * | 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`. |
  131756. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  131757. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  131758. *
  131759. * @param option String of the option name
  131760. * @param value The numerical option value
  131761. */
  131762. changeDisplayOptions(option: string, value: number): void;
  131763. /** Release associated resources */
  131764. dispose(): void;
  131765. }
  131766. }
  131767. declare module BABYLON {
  131768. /**
  131769. * Enum for Device Types
  131770. */
  131771. export enum DeviceType {
  131772. /** Generic */
  131773. Generic = 0,
  131774. /** Keyboard */
  131775. Keyboard = 1,
  131776. /** Mouse */
  131777. Mouse = 2,
  131778. /** Touch Pointers */
  131779. Touch = 3,
  131780. /** PS4 Dual Shock */
  131781. DualShock = 4,
  131782. /** Xbox */
  131783. Xbox = 5,
  131784. /** Switch Controller */
  131785. Switch = 6
  131786. }
  131787. /**
  131788. * Enum for All Pointers (Touch/Mouse)
  131789. */
  131790. export enum PointerInput {
  131791. /** Horizontal Axis */
  131792. Horizontal = 0,
  131793. /** Vertical Axis */
  131794. Vertical = 1,
  131795. /** Left Click or Touch */
  131796. LeftClick = 2,
  131797. /** Middle Click */
  131798. MiddleClick = 3,
  131799. /** Right Click */
  131800. RightClick = 4,
  131801. /** Browser Back */
  131802. BrowserBack = 5,
  131803. /** Browser Forward */
  131804. BrowserForward = 6
  131805. }
  131806. /**
  131807. * Enum for Dual Shock Gamepad
  131808. */
  131809. export enum DualShockInput {
  131810. /** Cross */
  131811. Cross = 0,
  131812. /** Circle */
  131813. Circle = 1,
  131814. /** Square */
  131815. Square = 2,
  131816. /** Triangle */
  131817. Triangle = 3,
  131818. /** L1 */
  131819. L1 = 4,
  131820. /** R1 */
  131821. R1 = 5,
  131822. /** L2 */
  131823. L2 = 6,
  131824. /** R2 */
  131825. R2 = 7,
  131826. /** Share */
  131827. Share = 8,
  131828. /** Options */
  131829. Options = 9,
  131830. /** L3 */
  131831. L3 = 10,
  131832. /** R3 */
  131833. R3 = 11,
  131834. /** DPadUp */
  131835. DPadUp = 12,
  131836. /** DPadDown */
  131837. DPadDown = 13,
  131838. /** DPadLeft */
  131839. DPadLeft = 14,
  131840. /** DRight */
  131841. DPadRight = 15,
  131842. /** Home */
  131843. Home = 16,
  131844. /** TouchPad */
  131845. TouchPad = 17,
  131846. /** LStickXAxis */
  131847. LStickXAxis = 18,
  131848. /** LStickYAxis */
  131849. LStickYAxis = 19,
  131850. /** RStickXAxis */
  131851. RStickXAxis = 20,
  131852. /** RStickYAxis */
  131853. RStickYAxis = 21
  131854. }
  131855. /**
  131856. * Enum for Xbox Gamepad
  131857. */
  131858. export enum XboxInput {
  131859. /** A */
  131860. A = 0,
  131861. /** B */
  131862. B = 1,
  131863. /** X */
  131864. X = 2,
  131865. /** Y */
  131866. Y = 3,
  131867. /** LB */
  131868. LB = 4,
  131869. /** RB */
  131870. RB = 5,
  131871. /** LT */
  131872. LT = 6,
  131873. /** RT */
  131874. RT = 7,
  131875. /** Back */
  131876. Back = 8,
  131877. /** Start */
  131878. Start = 9,
  131879. /** LS */
  131880. LS = 10,
  131881. /** RS */
  131882. RS = 11,
  131883. /** DPadUp */
  131884. DPadUp = 12,
  131885. /** DPadDown */
  131886. DPadDown = 13,
  131887. /** DPadLeft */
  131888. DPadLeft = 14,
  131889. /** DRight */
  131890. DPadRight = 15,
  131891. /** Home */
  131892. Home = 16,
  131893. /** LStickXAxis */
  131894. LStickXAxis = 17,
  131895. /** LStickYAxis */
  131896. LStickYAxis = 18,
  131897. /** RStickXAxis */
  131898. RStickXAxis = 19,
  131899. /** RStickYAxis */
  131900. RStickYAxis = 20
  131901. }
  131902. /**
  131903. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131904. */
  131905. export enum SwitchInput {
  131906. /** B */
  131907. B = 0,
  131908. /** A */
  131909. A = 1,
  131910. /** Y */
  131911. Y = 2,
  131912. /** X */
  131913. X = 3,
  131914. /** L */
  131915. L = 4,
  131916. /** R */
  131917. R = 5,
  131918. /** ZL */
  131919. ZL = 6,
  131920. /** ZR */
  131921. ZR = 7,
  131922. /** Minus */
  131923. Minus = 8,
  131924. /** Plus */
  131925. Plus = 9,
  131926. /** LS */
  131927. LS = 10,
  131928. /** RS */
  131929. RS = 11,
  131930. /** DPadUp */
  131931. DPadUp = 12,
  131932. /** DPadDown */
  131933. DPadDown = 13,
  131934. /** DPadLeft */
  131935. DPadLeft = 14,
  131936. /** DRight */
  131937. DPadRight = 15,
  131938. /** Home */
  131939. Home = 16,
  131940. /** Capture */
  131941. Capture = 17,
  131942. /** LStickXAxis */
  131943. LStickXAxis = 18,
  131944. /** LStickYAxis */
  131945. LStickYAxis = 19,
  131946. /** RStickXAxis */
  131947. RStickXAxis = 20,
  131948. /** RStickYAxis */
  131949. RStickYAxis = 21
  131950. }
  131951. }
  131952. declare module BABYLON {
  131953. /**
  131954. * This class will take all inputs from Keyboard, Pointer, and
  131955. * any Gamepads and provide a polling system that all devices
  131956. * will use. This class assumes that there will only be one
  131957. * pointer device and one keyboard.
  131958. */
  131959. export class DeviceInputSystem implements IDisposable {
  131960. /**
  131961. * Callback to be triggered when a device is connected
  131962. */
  131963. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131964. /**
  131965. * Callback to be triggered when a device is disconnected
  131966. */
  131967. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131968. /**
  131969. * Callback to be triggered when event driven input is updated
  131970. */
  131971. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131972. private _inputs;
  131973. private _gamepads;
  131974. private _keyboardActive;
  131975. private _pointerActive;
  131976. private _elementToAttachTo;
  131977. private _keyboardDownEvent;
  131978. private _keyboardUpEvent;
  131979. private _pointerMoveEvent;
  131980. private _pointerDownEvent;
  131981. private _pointerUpEvent;
  131982. private _gamepadConnectedEvent;
  131983. private _gamepadDisconnectedEvent;
  131984. private static _MAX_KEYCODES;
  131985. private static _MAX_POINTER_INPUTS;
  131986. private constructor();
  131987. /**
  131988. * Creates a new DeviceInputSystem instance
  131989. * @param engine Engine to pull input element from
  131990. * @returns The new instance
  131991. */
  131992. static Create(engine: Engine): DeviceInputSystem;
  131993. /**
  131994. * Checks for current device input value, given an id and input index
  131995. * @param deviceName Id of connected device
  131996. * @param inputIndex Index of device input
  131997. * @returns Current value of input
  131998. */
  131999. /**
  132000. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  132001. * @param deviceType Enum specifiying device type
  132002. * @param deviceSlot "Slot" or index that device is referenced in
  132003. * @param inputIndex Id of input to be checked
  132004. * @returns Current value of input
  132005. */
  132006. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  132007. /**
  132008. * Dispose of all the eventlisteners
  132009. */
  132010. dispose(): void;
  132011. /**
  132012. * Add device and inputs to device array
  132013. * @param deviceType Enum specifiying device type
  132014. * @param deviceSlot "Slot" or index that device is referenced in
  132015. * @param numberOfInputs Number of input entries to create for given device
  132016. */
  132017. private _registerDevice;
  132018. /**
  132019. * Given a specific device name, remove that device from the device map
  132020. * @param deviceType Enum specifiying device type
  132021. * @param deviceSlot "Slot" or index that device is referenced in
  132022. */
  132023. private _unregisterDevice;
  132024. /**
  132025. * Handle all actions that come from keyboard interaction
  132026. */
  132027. private _handleKeyActions;
  132028. /**
  132029. * Handle all actions that come from pointer interaction
  132030. */
  132031. private _handlePointerActions;
  132032. /**
  132033. * Handle all actions that come from gamepad interaction
  132034. */
  132035. private _handleGamepadActions;
  132036. /**
  132037. * Update all non-event based devices with each frame
  132038. * @param deviceType Enum specifiying device type
  132039. * @param deviceSlot "Slot" or index that device is referenced in
  132040. * @param inputIndex Id of input to be checked
  132041. */
  132042. private _updateDevice;
  132043. /**
  132044. * Gets DeviceType from the device name
  132045. * @param deviceName Name of Device from DeviceInputSystem
  132046. * @returns DeviceType enum value
  132047. */
  132048. private _getGamepadDeviceType;
  132049. }
  132050. }
  132051. declare module BABYLON {
  132052. /**
  132053. * Type to handle enforcement of inputs
  132054. */
  132055. 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;
  132056. }
  132057. declare module BABYLON {
  132058. /**
  132059. * Class that handles all input for a specific device
  132060. */
  132061. export class DeviceSource<T extends DeviceType> {
  132062. /** Type of device */
  132063. readonly deviceType: DeviceType;
  132064. /** "Slot" or index that device is referenced in */
  132065. readonly deviceSlot: number;
  132066. /**
  132067. * Observable to handle device input changes per device
  132068. */
  132069. readonly onInputChangedObservable: Observable<{
  132070. inputIndex: DeviceInput<T>;
  132071. previousState: Nullable<number>;
  132072. currentState: Nullable<number>;
  132073. }>;
  132074. private readonly _deviceInputSystem;
  132075. /**
  132076. * Default Constructor
  132077. * @param deviceInputSystem Reference to DeviceInputSystem
  132078. * @param deviceType Type of device
  132079. * @param deviceSlot "Slot" or index that device is referenced in
  132080. */
  132081. constructor(deviceInputSystem: DeviceInputSystem,
  132082. /** Type of device */
  132083. deviceType: DeviceType,
  132084. /** "Slot" or index that device is referenced in */
  132085. deviceSlot?: number);
  132086. /**
  132087. * Get input for specific input
  132088. * @param inputIndex index of specific input on device
  132089. * @returns Input value from DeviceInputSystem
  132090. */
  132091. getInput(inputIndex: DeviceInput<T>): number;
  132092. }
  132093. /**
  132094. * Class to keep track of devices
  132095. */
  132096. export class DeviceSourceManager implements IDisposable {
  132097. /**
  132098. * Observable to be triggered when before a device is connected
  132099. */
  132100. readonly onBeforeDeviceConnectedObservable: Observable<{
  132101. deviceType: DeviceType;
  132102. deviceSlot: number;
  132103. }>;
  132104. /**
  132105. * Observable to be triggered when before a device is disconnected
  132106. */
  132107. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  132108. deviceType: DeviceType;
  132109. deviceSlot: number;
  132110. }>;
  132111. /**
  132112. * Observable to be triggered when after a device is connected
  132113. */
  132114. readonly onAfterDeviceConnectedObservable: Observable<{
  132115. deviceType: DeviceType;
  132116. deviceSlot: number;
  132117. }>;
  132118. /**
  132119. * Observable to be triggered when after a device is disconnected
  132120. */
  132121. readonly onAfterDeviceDisconnectedObservable: Observable<{
  132122. deviceType: DeviceType;
  132123. deviceSlot: number;
  132124. }>;
  132125. private readonly _devices;
  132126. private readonly _firstDevice;
  132127. private readonly _deviceInputSystem;
  132128. /**
  132129. * Default Constructor
  132130. * @param engine engine to pull input element from
  132131. */
  132132. constructor(engine: Engine);
  132133. /**
  132134. * Gets a DeviceSource, given a type and slot
  132135. * @param deviceType Enum specifying device type
  132136. * @param deviceSlot "Slot" or index that device is referenced in
  132137. * @returns DeviceSource object
  132138. */
  132139. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  132140. /**
  132141. * Gets an array of DeviceSource objects for a given device type
  132142. * @param deviceType Enum specifying device type
  132143. * @returns Array of DeviceSource objects
  132144. */
  132145. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  132146. /**
  132147. * Dispose of DeviceInputSystem and other parts
  132148. */
  132149. dispose(): void;
  132150. /**
  132151. * Function to add device name to device list
  132152. * @param deviceType Enum specifying device type
  132153. * @param deviceSlot "Slot" or index that device is referenced in
  132154. */
  132155. private _addDevice;
  132156. /**
  132157. * Function to remove device name to device list
  132158. * @param deviceType Enum specifying device type
  132159. * @param deviceSlot "Slot" or index that device is referenced in
  132160. */
  132161. private _removeDevice;
  132162. /**
  132163. * Updates array storing first connected device of each type
  132164. * @param type Type of Device
  132165. */
  132166. private _updateFirstDevices;
  132167. }
  132168. }
  132169. declare module BABYLON {
  132170. /**
  132171. * Options to create the null engine
  132172. */
  132173. export class NullEngineOptions {
  132174. /**
  132175. * Render width (Default: 512)
  132176. */
  132177. renderWidth: number;
  132178. /**
  132179. * Render height (Default: 256)
  132180. */
  132181. renderHeight: number;
  132182. /**
  132183. * Texture size (Default: 512)
  132184. */
  132185. textureSize: number;
  132186. /**
  132187. * If delta time between frames should be constant
  132188. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132189. */
  132190. deterministicLockstep: boolean;
  132191. /**
  132192. * Maximum about of steps between frames (Default: 4)
  132193. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132194. */
  132195. lockstepMaxSteps: number;
  132196. /**
  132197. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  132198. */
  132199. useHighPrecisionMatrix?: boolean;
  132200. }
  132201. /**
  132202. * The null engine class provides support for headless version of babylon.js.
  132203. * This can be used in server side scenario or for testing purposes
  132204. */
  132205. export class NullEngine extends Engine {
  132206. private _options;
  132207. /**
  132208. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  132209. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132210. * @returns true if engine is in deterministic lock step mode
  132211. */
  132212. isDeterministicLockStep(): boolean;
  132213. /**
  132214. * Gets the max steps when engine is running in deterministic lock step
  132215. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132216. * @returns the max steps
  132217. */
  132218. getLockstepMaxSteps(): number;
  132219. /**
  132220. * Gets the current hardware scaling level.
  132221. * By default the hardware scaling level is computed from the window device ratio.
  132222. * 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.
  132223. * @returns a number indicating the current hardware scaling level
  132224. */
  132225. getHardwareScalingLevel(): number;
  132226. constructor(options?: NullEngineOptions);
  132227. /**
  132228. * Creates a vertex buffer
  132229. * @param vertices the data for the vertex buffer
  132230. * @returns the new WebGL static buffer
  132231. */
  132232. createVertexBuffer(vertices: FloatArray): DataBuffer;
  132233. /**
  132234. * Creates a new index buffer
  132235. * @param indices defines the content of the index buffer
  132236. * @param updatable defines if the index buffer must be updatable
  132237. * @returns a new webGL buffer
  132238. */
  132239. createIndexBuffer(indices: IndicesArray): DataBuffer;
  132240. /**
  132241. * Clear the current render buffer or the current render target (if any is set up)
  132242. * @param color defines the color to use
  132243. * @param backBuffer defines if the back buffer must be cleared
  132244. * @param depth defines if the depth buffer must be cleared
  132245. * @param stencil defines if the stencil buffer must be cleared
  132246. */
  132247. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132248. /**
  132249. * Gets the current render width
  132250. * @param useScreen defines if screen size must be used (or the current render target if any)
  132251. * @returns a number defining the current render width
  132252. */
  132253. getRenderWidth(useScreen?: boolean): number;
  132254. /**
  132255. * Gets the current render height
  132256. * @param useScreen defines if screen size must be used (or the current render target if any)
  132257. * @returns a number defining the current render height
  132258. */
  132259. getRenderHeight(useScreen?: boolean): number;
  132260. /**
  132261. * Set the WebGL's viewport
  132262. * @param viewport defines the viewport element to be used
  132263. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  132264. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  132265. */
  132266. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  132267. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  132268. /**
  132269. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  132270. * @param pipelineContext defines the pipeline context to use
  132271. * @param uniformsNames defines the list of uniform names
  132272. * @returns an array of webGL uniform locations
  132273. */
  132274. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  132275. /**
  132276. * Gets the lsit of active attributes for a given webGL program
  132277. * @param pipelineContext defines the pipeline context to use
  132278. * @param attributesNames defines the list of attribute names to get
  132279. * @returns an array of indices indicating the offset of each attribute
  132280. */
  132281. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132282. /**
  132283. * Binds an effect to the webGL context
  132284. * @param effect defines the effect to bind
  132285. */
  132286. bindSamplers(effect: Effect): void;
  132287. /**
  132288. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  132289. * @param effect defines the effect to activate
  132290. */
  132291. enableEffect(effect: Effect): void;
  132292. /**
  132293. * Set various states to the webGL context
  132294. * @param culling defines backface culling state
  132295. * @param zOffset defines the value to apply to zOffset (0 by default)
  132296. * @param force defines if states must be applied even if cache is up to date
  132297. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  132298. */
  132299. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132300. /**
  132301. * Set the value of an uniform to an array of int32
  132302. * @param uniform defines the webGL uniform location where to store the value
  132303. * @param array defines the array of int32 to store
  132304. * @returns true if value was set
  132305. */
  132306. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132307. /**
  132308. * Set the value of an uniform to an array of int32 (stored as vec2)
  132309. * @param uniform defines the webGL uniform location where to store the value
  132310. * @param array defines the array of int32 to store
  132311. * @returns true if value was set
  132312. */
  132313. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132314. /**
  132315. * Set the value of an uniform to an array of int32 (stored as vec3)
  132316. * @param uniform defines the webGL uniform location where to store the value
  132317. * @param array defines the array of int32 to store
  132318. * @returns true if value was set
  132319. */
  132320. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132321. /**
  132322. * Set the value of an uniform to an array of int32 (stored as vec4)
  132323. * @param uniform defines the webGL uniform location where to store the value
  132324. * @param array defines the array of int32 to store
  132325. * @returns true if value was set
  132326. */
  132327. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132328. /**
  132329. * Set the value of an uniform to an array of float32
  132330. * @param uniform defines the webGL uniform location where to store the value
  132331. * @param array defines the array of float32 to store
  132332. * @returns true if value was set
  132333. */
  132334. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132335. /**
  132336. * Set the value of an uniform to an array of float32 (stored as vec2)
  132337. * @param uniform defines the webGL uniform location where to store the value
  132338. * @param array defines the array of float32 to store
  132339. * @returns true if value was set
  132340. */
  132341. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132342. /**
  132343. * Set the value of an uniform to an array of float32 (stored as vec3)
  132344. * @param uniform defines the webGL uniform location where to store the value
  132345. * @param array defines the array of float32 to store
  132346. * @returns true if value was set
  132347. */
  132348. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132349. /**
  132350. * Set the value of an uniform to an array of float32 (stored as vec4)
  132351. * @param uniform defines the webGL uniform location where to store the value
  132352. * @param array defines the array of float32 to store
  132353. * @returns true if value was set
  132354. */
  132355. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132356. /**
  132357. * Set the value of an uniform to an array of number
  132358. * @param uniform defines the webGL uniform location where to store the value
  132359. * @param array defines the array of number to store
  132360. * @returns true if value was set
  132361. */
  132362. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  132363. /**
  132364. * Set the value of an uniform to an array of number (stored as vec2)
  132365. * @param uniform defines the webGL uniform location where to store the value
  132366. * @param array defines the array of number to store
  132367. * @returns true if value was set
  132368. */
  132369. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  132370. /**
  132371. * Set the value of an uniform to an array of number (stored as vec3)
  132372. * @param uniform defines the webGL uniform location where to store the value
  132373. * @param array defines the array of number to store
  132374. * @returns true if value was set
  132375. */
  132376. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  132377. /**
  132378. * Set the value of an uniform to an array of number (stored as vec4)
  132379. * @param uniform defines the webGL uniform location where to store the value
  132380. * @param array defines the array of number to store
  132381. * @returns true if value was set
  132382. */
  132383. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  132384. /**
  132385. * Set the value of an uniform to an array of float32 (stored as matrices)
  132386. * @param uniform defines the webGL uniform location where to store the value
  132387. * @param matrices defines the array of float32 to store
  132388. * @returns true if value was set
  132389. */
  132390. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  132391. /**
  132392. * Set the value of an uniform to a matrix (3x3)
  132393. * @param uniform defines the webGL uniform location where to store the value
  132394. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  132395. * @returns true if value was set
  132396. */
  132397. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132398. /**
  132399. * Set the value of an uniform to a matrix (2x2)
  132400. * @param uniform defines the webGL uniform location where to store the value
  132401. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  132402. * @returns true if value was set
  132403. */
  132404. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132405. /**
  132406. * Set the value of an uniform to a number (float)
  132407. * @param uniform defines the webGL uniform location where to store the value
  132408. * @param value defines the float number to store
  132409. * @returns true if value was set
  132410. */
  132411. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  132412. /**
  132413. * Set the value of an uniform to a vec2
  132414. * @param uniform defines the webGL uniform location where to store the value
  132415. * @param x defines the 1st component of the value
  132416. * @param y defines the 2nd component of the value
  132417. * @returns true if value was set
  132418. */
  132419. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  132420. /**
  132421. * Set the value of an uniform to a vec3
  132422. * @param uniform defines the webGL uniform location where to store the value
  132423. * @param x defines the 1st component of the value
  132424. * @param y defines the 2nd component of the value
  132425. * @param z defines the 3rd component of the value
  132426. * @returns true if value was set
  132427. */
  132428. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  132429. /**
  132430. * Set the value of an uniform to a boolean
  132431. * @param uniform defines the webGL uniform location where to store the value
  132432. * @param bool defines the boolean to store
  132433. * @returns true if value was set
  132434. */
  132435. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  132436. /**
  132437. * Set the value of an uniform to a vec4
  132438. * @param uniform defines the webGL uniform location where to store the value
  132439. * @param x defines the 1st component of the value
  132440. * @param y defines the 2nd component of the value
  132441. * @param z defines the 3rd component of the value
  132442. * @param w defines the 4th component of the value
  132443. * @returns true if value was set
  132444. */
  132445. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  132446. /**
  132447. * Sets the current alpha mode
  132448. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  132449. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132450. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132451. */
  132452. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132453. /**
  132454. * Bind webGl buffers directly to the webGL context
  132455. * @param vertexBuffers defines the vertex buffer to bind
  132456. * @param indexBuffer defines the index buffer to bind
  132457. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  132458. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  132459. * @param effect defines the effect associated with the vertex buffer
  132460. */
  132461. bindBuffers(vertexBuffers: {
  132462. [key: string]: VertexBuffer;
  132463. }, indexBuffer: DataBuffer, effect: Effect): void;
  132464. /**
  132465. * Force the entire cache to be cleared
  132466. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  132467. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  132468. */
  132469. wipeCaches(bruteForce?: boolean): void;
  132470. /**
  132471. * Send a draw order
  132472. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  132473. * @param indexStart defines the starting index
  132474. * @param indexCount defines the number of index to draw
  132475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132476. */
  132477. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  132478. /**
  132479. * Draw a list of indexed primitives
  132480. * @param fillMode defines the primitive to use
  132481. * @param indexStart defines the starting index
  132482. * @param indexCount defines the number of index to draw
  132483. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132484. */
  132485. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132486. /**
  132487. * Draw a list of unindexed primitives
  132488. * @param fillMode defines the primitive to use
  132489. * @param verticesStart defines the index of first vertex to draw
  132490. * @param verticesCount defines the count of vertices to draw
  132491. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132492. */
  132493. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132494. /** @hidden */
  132495. _createTexture(): WebGLTexture;
  132496. /** @hidden */
  132497. _releaseTexture(texture: InternalTexture): void;
  132498. /**
  132499. * Usually called from Texture.ts.
  132500. * Passed information to create a WebGLTexture
  132501. * @param urlArg defines a value which contains one of the following:
  132502. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132503. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132504. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132505. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132506. * @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)
  132507. * @param scene needed for loading to the correct scene
  132508. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132509. * @param onLoad optional callback to be called upon successful completion
  132510. * @param onError optional callback to be called upon failure
  132511. * @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
  132512. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132513. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132514. * @param forcedExtension defines the extension to use to pick the right loader
  132515. * @param mimeType defines an optional mime type
  132516. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132517. */
  132518. 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;
  132519. /**
  132520. * Creates a new render target texture
  132521. * @param size defines the size of the texture
  132522. * @param options defines the options used to create the texture
  132523. * @returns a new render target texture stored in an InternalTexture
  132524. */
  132525. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  132526. /**
  132527. * Update the sampling mode of a given texture
  132528. * @param samplingMode defines the required sampling mode
  132529. * @param texture defines the texture to update
  132530. */
  132531. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132532. /**
  132533. * Binds the frame buffer to the specified texture.
  132534. * @param texture The texture to render to or null for the default canvas
  132535. * @param faceIndex The face of the texture to render to in case of cube texture
  132536. * @param requiredWidth The width of the target to render to
  132537. * @param requiredHeight The height of the target to render to
  132538. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132539. * @param lodLevel defines le lod level to bind to the frame buffer
  132540. */
  132541. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132542. /**
  132543. * Unbind the current render target texture from the webGL context
  132544. * @param texture defines the render target texture to unbind
  132545. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132546. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132547. */
  132548. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132549. /**
  132550. * Creates a dynamic vertex buffer
  132551. * @param vertices the data for the dynamic vertex buffer
  132552. * @returns the new WebGL dynamic buffer
  132553. */
  132554. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132555. /**
  132556. * Update the content of a dynamic texture
  132557. * @param texture defines the texture to update
  132558. * @param canvas defines the canvas containing the source
  132559. * @param invertY defines if data must be stored with Y axis inverted
  132560. * @param premulAlpha defines if alpha is stored as premultiplied
  132561. * @param format defines the format of the data
  132562. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132563. */
  132564. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132565. /**
  132566. * Gets a boolean indicating if all created effects are ready
  132567. * @returns true if all effects are ready
  132568. */
  132569. areAllEffectsReady(): boolean;
  132570. /**
  132571. * @hidden
  132572. * Get the current error code of the webGL context
  132573. * @returns the error code
  132574. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132575. */
  132576. getError(): number;
  132577. /** @hidden */
  132578. _getUnpackAlignement(): number;
  132579. /** @hidden */
  132580. _unpackFlipY(value: boolean): void;
  132581. /**
  132582. * Update a dynamic index buffer
  132583. * @param indexBuffer defines the target index buffer
  132584. * @param indices defines the data to update
  132585. * @param offset defines the offset in the target index buffer where update should start
  132586. */
  132587. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132588. /**
  132589. * Updates a dynamic vertex buffer.
  132590. * @param vertexBuffer the vertex buffer to update
  132591. * @param vertices the data used to update the vertex buffer
  132592. * @param byteOffset the byte offset of the data (optional)
  132593. * @param byteLength the byte length of the data (optional)
  132594. */
  132595. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132596. /** @hidden */
  132597. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132598. /** @hidden */
  132599. _bindTexture(channel: number, texture: InternalTexture): void;
  132600. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132601. /**
  132602. * 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
  132603. */
  132604. releaseEffects(): void;
  132605. displayLoadingUI(): void;
  132606. hideLoadingUI(): void;
  132607. /** @hidden */
  132608. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132609. /** @hidden */
  132610. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132611. /** @hidden */
  132612. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132613. /** @hidden */
  132614. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132615. }
  132616. }
  132617. declare module BABYLON {
  132618. /**
  132619. * @hidden
  132620. **/
  132621. export class _TimeToken {
  132622. _startTimeQuery: Nullable<WebGLQuery>;
  132623. _endTimeQuery: Nullable<WebGLQuery>;
  132624. _timeElapsedQuery: Nullable<WebGLQuery>;
  132625. _timeElapsedQueryEnded: boolean;
  132626. }
  132627. }
  132628. declare module BABYLON {
  132629. /** @hidden */
  132630. export class _OcclusionDataStorage {
  132631. /** @hidden */
  132632. occlusionInternalRetryCounter: number;
  132633. /** @hidden */
  132634. isOcclusionQueryInProgress: boolean;
  132635. /** @hidden */
  132636. isOccluded: boolean;
  132637. /** @hidden */
  132638. occlusionRetryCount: number;
  132639. /** @hidden */
  132640. occlusionType: number;
  132641. /** @hidden */
  132642. occlusionQueryAlgorithmType: number;
  132643. }
  132644. interface Engine {
  132645. /**
  132646. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132647. * @return the new query
  132648. */
  132649. createQuery(): WebGLQuery;
  132650. /**
  132651. * Delete and release a webGL query
  132652. * @param query defines the query to delete
  132653. * @return the current engine
  132654. */
  132655. deleteQuery(query: WebGLQuery): Engine;
  132656. /**
  132657. * Check if a given query has resolved and got its value
  132658. * @param query defines the query to check
  132659. * @returns true if the query got its value
  132660. */
  132661. isQueryResultAvailable(query: WebGLQuery): boolean;
  132662. /**
  132663. * Gets the value of a given query
  132664. * @param query defines the query to check
  132665. * @returns the value of the query
  132666. */
  132667. getQueryResult(query: WebGLQuery): number;
  132668. /**
  132669. * Initiates an occlusion query
  132670. * @param algorithmType defines the algorithm to use
  132671. * @param query defines the query to use
  132672. * @returns the current engine
  132673. * @see https://doc.babylonjs.com/features/occlusionquery
  132674. */
  132675. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132676. /**
  132677. * Ends an occlusion query
  132678. * @see https://doc.babylonjs.com/features/occlusionquery
  132679. * @param algorithmType defines the algorithm to use
  132680. * @returns the current engine
  132681. */
  132682. endOcclusionQuery(algorithmType: number): Engine;
  132683. /**
  132684. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132685. * Please note that only one query can be issued at a time
  132686. * @returns a time token used to track the time span
  132687. */
  132688. startTimeQuery(): Nullable<_TimeToken>;
  132689. /**
  132690. * Ends a time query
  132691. * @param token defines the token used to measure the time span
  132692. * @returns the time spent (in ns)
  132693. */
  132694. endTimeQuery(token: _TimeToken): int;
  132695. /** @hidden */
  132696. _currentNonTimestampToken: Nullable<_TimeToken>;
  132697. /** @hidden */
  132698. _createTimeQuery(): WebGLQuery;
  132699. /** @hidden */
  132700. _deleteTimeQuery(query: WebGLQuery): void;
  132701. /** @hidden */
  132702. _getGlAlgorithmType(algorithmType: number): number;
  132703. /** @hidden */
  132704. _getTimeQueryResult(query: WebGLQuery): any;
  132705. /** @hidden */
  132706. _getTimeQueryAvailability(query: WebGLQuery): any;
  132707. }
  132708. interface AbstractMesh {
  132709. /**
  132710. * Backing filed
  132711. * @hidden
  132712. */
  132713. __occlusionDataStorage: _OcclusionDataStorage;
  132714. /**
  132715. * Access property
  132716. * @hidden
  132717. */
  132718. _occlusionDataStorage: _OcclusionDataStorage;
  132719. /**
  132720. * 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.
  132721. * The default value is -1 which means don't break the query and wait till the result
  132722. * @see https://doc.babylonjs.com/features/occlusionquery
  132723. */
  132724. occlusionRetryCount: number;
  132725. /**
  132726. * 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:
  132727. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  132728. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  132729. * * 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.
  132730. * @see https://doc.babylonjs.com/features/occlusionquery
  132731. */
  132732. occlusionType: number;
  132733. /**
  132734. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  132735. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  132736. * * 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.
  132737. * @see https://doc.babylonjs.com/features/occlusionquery
  132738. */
  132739. occlusionQueryAlgorithmType: number;
  132740. /**
  132741. * 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
  132742. * @see https://doc.babylonjs.com/features/occlusionquery
  132743. */
  132744. isOccluded: boolean;
  132745. /**
  132746. * Flag to check the progress status of the query
  132747. * @see https://doc.babylonjs.com/features/occlusionquery
  132748. */
  132749. isOcclusionQueryInProgress: boolean;
  132750. }
  132751. }
  132752. declare module BABYLON {
  132753. /** @hidden */
  132754. export var _forceTransformFeedbackToBundle: boolean;
  132755. interface Engine {
  132756. /**
  132757. * Creates a webGL transform feedback object
  132758. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  132759. * @returns the webGL transform feedback object
  132760. */
  132761. createTransformFeedback(): WebGLTransformFeedback;
  132762. /**
  132763. * Delete a webGL transform feedback object
  132764. * @param value defines the webGL transform feedback object to delete
  132765. */
  132766. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  132767. /**
  132768. * Bind a webGL transform feedback object to the webgl context
  132769. * @param value defines the webGL transform feedback object to bind
  132770. */
  132771. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  132772. /**
  132773. * Begins a transform feedback operation
  132774. * @param usePoints defines if points or triangles must be used
  132775. */
  132776. beginTransformFeedback(usePoints: boolean): void;
  132777. /**
  132778. * Ends a transform feedback operation
  132779. */
  132780. endTransformFeedback(): void;
  132781. /**
  132782. * Specify the varyings to use with transform feedback
  132783. * @param program defines the associated webGL program
  132784. * @param value defines the list of strings representing the varying names
  132785. */
  132786. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  132787. /**
  132788. * Bind a webGL buffer for a transform feedback operation
  132789. * @param value defines the webGL buffer to bind
  132790. */
  132791. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  132792. }
  132793. }
  132794. declare module BABYLON {
  132795. /**
  132796. * Class used to define an additional view for the engine
  132797. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132798. */
  132799. export class EngineView {
  132800. /** Defines the canvas where to render the view */
  132801. target: HTMLCanvasElement;
  132802. /** Defines an optional camera used to render the view (will use active camera else) */
  132803. camera?: Camera;
  132804. }
  132805. interface Engine {
  132806. /**
  132807. * Gets or sets the HTML element to use for attaching events
  132808. */
  132809. inputElement: Nullable<HTMLElement>;
  132810. /**
  132811. * Gets the current engine view
  132812. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132813. */
  132814. activeView: Nullable<EngineView>;
  132815. /** Gets or sets the list of views */
  132816. views: EngineView[];
  132817. /**
  132818. * Register a new child canvas
  132819. * @param canvas defines the canvas to register
  132820. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  132821. * @returns the associated view
  132822. */
  132823. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  132824. /**
  132825. * Remove a registered child canvas
  132826. * @param canvas defines the canvas to remove
  132827. * @returns the current engine
  132828. */
  132829. unRegisterView(canvas: HTMLCanvasElement): Engine;
  132830. }
  132831. }
  132832. declare module BABYLON {
  132833. interface Engine {
  132834. /** @hidden */
  132835. _excludedCompressedTextures: string[];
  132836. /** @hidden */
  132837. _textureFormatInUse: string;
  132838. /**
  132839. * Gets the list of texture formats supported
  132840. */
  132841. readonly texturesSupported: Array<string>;
  132842. /**
  132843. * Gets the texture format in use
  132844. */
  132845. readonly textureFormatInUse: Nullable<string>;
  132846. /**
  132847. * Set the compressed texture extensions or file names to skip.
  132848. *
  132849. * @param skippedFiles defines the list of those texture files you want to skip
  132850. * Example: [".dds", ".env", "myfile.png"]
  132851. */
  132852. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132853. /**
  132854. * Set the compressed texture format to use, based on the formats you have, and the formats
  132855. * supported by the hardware / browser.
  132856. *
  132857. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132858. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132859. * to API arguments needed to compressed textures. This puts the burden on the container
  132860. * generator to house the arcane code for determining these for current & future formats.
  132861. *
  132862. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132863. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132864. *
  132865. * Note: The result of this call is not taken into account when a texture is base64.
  132866. *
  132867. * @param formatsAvailable defines the list of those format families you have created
  132868. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132869. *
  132870. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132871. * @returns The extension selected.
  132872. */
  132873. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132874. }
  132875. }
  132876. declare module BABYLON {
  132877. /**
  132878. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132879. */
  132880. export interface CubeMapInfo {
  132881. /**
  132882. * The pixel array for the front face.
  132883. * This is stored in format, left to right, up to down format.
  132884. */
  132885. front: Nullable<ArrayBufferView>;
  132886. /**
  132887. * The pixel array for the back face.
  132888. * This is stored in format, left to right, up to down format.
  132889. */
  132890. back: Nullable<ArrayBufferView>;
  132891. /**
  132892. * The pixel array for the left face.
  132893. * This is stored in format, left to right, up to down format.
  132894. */
  132895. left: Nullable<ArrayBufferView>;
  132896. /**
  132897. * The pixel array for the right face.
  132898. * This is stored in format, left to right, up to down format.
  132899. */
  132900. right: Nullable<ArrayBufferView>;
  132901. /**
  132902. * The pixel array for the up face.
  132903. * This is stored in format, left to right, up to down format.
  132904. */
  132905. up: Nullable<ArrayBufferView>;
  132906. /**
  132907. * The pixel array for the down face.
  132908. * This is stored in format, left to right, up to down format.
  132909. */
  132910. down: Nullable<ArrayBufferView>;
  132911. /**
  132912. * The size of the cubemap stored.
  132913. *
  132914. * Each faces will be size * size pixels.
  132915. */
  132916. size: number;
  132917. /**
  132918. * The format of the texture.
  132919. *
  132920. * RGBA, RGB.
  132921. */
  132922. format: number;
  132923. /**
  132924. * The type of the texture data.
  132925. *
  132926. * UNSIGNED_INT, FLOAT.
  132927. */
  132928. type: number;
  132929. /**
  132930. * Specifies whether the texture is in gamma space.
  132931. */
  132932. gammaSpace: boolean;
  132933. }
  132934. /**
  132935. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132936. */
  132937. export class PanoramaToCubeMapTools {
  132938. private static FACE_LEFT;
  132939. private static FACE_RIGHT;
  132940. private static FACE_FRONT;
  132941. private static FACE_BACK;
  132942. private static FACE_DOWN;
  132943. private static FACE_UP;
  132944. /**
  132945. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  132946. *
  132947. * @param float32Array The source data.
  132948. * @param inputWidth The width of the input panorama.
  132949. * @param inputHeight The height of the input panorama.
  132950. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  132951. * @return The cubemap data
  132952. */
  132953. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  132954. private static CreateCubemapTexture;
  132955. private static CalcProjectionSpherical;
  132956. }
  132957. }
  132958. declare module BABYLON {
  132959. /**
  132960. * Helper class dealing with the extraction of spherical polynomial dataArray
  132961. * from a cube map.
  132962. */
  132963. export class CubeMapToSphericalPolynomialTools {
  132964. private static FileFaces;
  132965. /**
  132966. * Converts a texture to the according Spherical Polynomial data.
  132967. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132968. *
  132969. * @param texture The texture to extract the information from.
  132970. * @return The Spherical Polynomial data.
  132971. */
  132972. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132973. /**
  132974. * Converts a cubemap to the according Spherical Polynomial data.
  132975. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132976. *
  132977. * @param cubeInfo The Cube map to extract the information from.
  132978. * @return The Spherical Polynomial data.
  132979. */
  132980. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132981. }
  132982. }
  132983. declare module BABYLON {
  132984. interface BaseTexture {
  132985. /**
  132986. * Get the polynomial representation of the texture data.
  132987. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132988. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132989. */
  132990. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132991. }
  132992. }
  132993. declare module BABYLON {
  132994. /** @hidden */
  132995. export var rgbdEncodePixelShader: {
  132996. name: string;
  132997. shader: string;
  132998. };
  132999. }
  133000. declare module BABYLON {
  133001. /** @hidden */
  133002. export var rgbdDecodePixelShader: {
  133003. name: string;
  133004. shader: string;
  133005. };
  133006. }
  133007. declare module BABYLON {
  133008. /**
  133009. * Raw texture data and descriptor sufficient for WebGL texture upload
  133010. */
  133011. export interface EnvironmentTextureInfo {
  133012. /**
  133013. * Version of the environment map
  133014. */
  133015. version: number;
  133016. /**
  133017. * Width of image
  133018. */
  133019. width: number;
  133020. /**
  133021. * Irradiance information stored in the file.
  133022. */
  133023. irradiance: any;
  133024. /**
  133025. * Specular information stored in the file.
  133026. */
  133027. specular: any;
  133028. }
  133029. /**
  133030. * Defines One Image in the file. It requires only the position in the file
  133031. * as well as the length.
  133032. */
  133033. interface BufferImageData {
  133034. /**
  133035. * Length of the image data.
  133036. */
  133037. length: number;
  133038. /**
  133039. * Position of the data from the null terminator delimiting the end of the JSON.
  133040. */
  133041. position: number;
  133042. }
  133043. /**
  133044. * Defines the specular data enclosed in the file.
  133045. * This corresponds to the version 1 of the data.
  133046. */
  133047. export interface EnvironmentTextureSpecularInfoV1 {
  133048. /**
  133049. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  133050. */
  133051. specularDataPosition?: number;
  133052. /**
  133053. * This contains all the images data needed to reconstruct the cubemap.
  133054. */
  133055. mipmaps: Array<BufferImageData>;
  133056. /**
  133057. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  133058. */
  133059. lodGenerationScale: number;
  133060. }
  133061. /**
  133062. * Sets of helpers addressing the serialization and deserialization of environment texture
  133063. * stored in a BabylonJS env file.
  133064. * Those files are usually stored as .env files.
  133065. */
  133066. export class EnvironmentTextureTools {
  133067. /**
  133068. * Magic number identifying the env file.
  133069. */
  133070. private static _MagicBytes;
  133071. /**
  133072. * Gets the environment info from an env file.
  133073. * @param data The array buffer containing the .env bytes.
  133074. * @returns the environment file info (the json header) if successfully parsed.
  133075. */
  133076. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  133077. /**
  133078. * Creates an environment texture from a loaded cube texture.
  133079. * @param texture defines the cube texture to convert in env file
  133080. * @return a promise containing the environment data if succesfull.
  133081. */
  133082. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  133083. /**
  133084. * Creates a JSON representation of the spherical data.
  133085. * @param texture defines the texture containing the polynomials
  133086. * @return the JSON representation of the spherical info
  133087. */
  133088. private static _CreateEnvTextureIrradiance;
  133089. /**
  133090. * Creates the ArrayBufferViews used for initializing environment texture image data.
  133091. * @param data the image data
  133092. * @param info parameters that determine what views will be created for accessing the underlying buffer
  133093. * @return the views described by info providing access to the underlying buffer
  133094. */
  133095. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  133096. /**
  133097. * Uploads the texture info contained in the env file to the GPU.
  133098. * @param texture defines the internal texture to upload to
  133099. * @param data defines the data to load
  133100. * @param info defines the texture info retrieved through the GetEnvInfo method
  133101. * @returns a promise
  133102. */
  133103. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  133104. private static _OnImageReadyAsync;
  133105. /**
  133106. * Uploads the levels of image data to the GPU.
  133107. * @param texture defines the internal texture to upload to
  133108. * @param imageData defines the array buffer views of image data [mipmap][face]
  133109. * @returns a promise
  133110. */
  133111. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  133112. /**
  133113. * Uploads spherical polynomials information to the texture.
  133114. * @param texture defines the texture we are trying to upload the information to
  133115. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  133116. */
  133117. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  133118. /** @hidden */
  133119. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133120. }
  133121. }
  133122. declare module BABYLON {
  133123. /**
  133124. * Class used to inline functions in shader code
  133125. */
  133126. export class ShaderCodeInliner {
  133127. private static readonly _RegexpFindFunctionNameAndType;
  133128. private _sourceCode;
  133129. private _functionDescr;
  133130. private _numMaxIterations;
  133131. /** Gets or sets the token used to mark the functions to inline */
  133132. inlineToken: string;
  133133. /** Gets or sets the debug mode */
  133134. debug: boolean;
  133135. /** Gets the code after the inlining process */
  133136. get code(): string;
  133137. /**
  133138. * Initializes the inliner
  133139. * @param sourceCode shader code source to inline
  133140. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  133141. */
  133142. constructor(sourceCode: string, numMaxIterations?: number);
  133143. /**
  133144. * Start the processing of the shader code
  133145. */
  133146. processCode(): void;
  133147. private _collectFunctions;
  133148. private _processInlining;
  133149. private _extractBetweenMarkers;
  133150. private _skipWhitespaces;
  133151. private _removeComments;
  133152. private _replaceFunctionCallsByCode;
  133153. private _findBackward;
  133154. private _escapeRegExp;
  133155. private _replaceNames;
  133156. }
  133157. }
  133158. declare module BABYLON {
  133159. /**
  133160. * Container for accessors for natively-stored mesh data buffers.
  133161. */
  133162. class NativeDataBuffer extends DataBuffer {
  133163. /**
  133164. * Accessor value used to identify/retrieve a natively-stored index buffer.
  133165. */
  133166. nativeIndexBuffer?: any;
  133167. /**
  133168. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  133169. */
  133170. nativeVertexBuffer?: any;
  133171. }
  133172. /** @hidden */
  133173. class NativeTexture extends InternalTexture {
  133174. getInternalTexture(): InternalTexture;
  133175. getViewCount(): number;
  133176. }
  133177. /** @hidden */
  133178. export class NativeEngine extends Engine {
  133179. private readonly _native;
  133180. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  133181. private readonly INVALID_HANDLE;
  133182. private _boundBuffersVertexArray;
  133183. private _currentDepthTest;
  133184. getHardwareScalingLevel(): number;
  133185. constructor();
  133186. dispose(): void;
  133187. /**
  133188. * Can be used to override the current requestAnimationFrame requester.
  133189. * @hidden
  133190. */
  133191. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  133192. /**
  133193. * Override default engine behavior.
  133194. * @param color
  133195. * @param backBuffer
  133196. * @param depth
  133197. * @param stencil
  133198. */
  133199. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  133200. /**
  133201. * Gets host document
  133202. * @returns the host document object
  133203. */
  133204. getHostDocument(): Nullable<Document>;
  133205. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  133206. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  133207. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  133208. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  133209. [key: string]: VertexBuffer;
  133210. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133211. bindBuffers(vertexBuffers: {
  133212. [key: string]: VertexBuffer;
  133213. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133214. recordVertexArrayObject(vertexBuffers: {
  133215. [key: string]: VertexBuffer;
  133216. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  133217. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133218. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133219. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  133220. /**
  133221. * Draw a list of indexed primitives
  133222. * @param fillMode defines the primitive to use
  133223. * @param indexStart defines the starting index
  133224. * @param indexCount defines the number of index to draw
  133225. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133226. */
  133227. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  133228. /**
  133229. * Draw a list of unindexed primitives
  133230. * @param fillMode defines the primitive to use
  133231. * @param verticesStart defines the index of first vertex to draw
  133232. * @param verticesCount defines the count of vertices to draw
  133233. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133234. */
  133235. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  133236. createPipelineContext(): IPipelineContext;
  133237. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  133238. /** @hidden */
  133239. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  133240. /** @hidden */
  133241. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  133242. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133243. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133244. protected _setProgram(program: WebGLProgram): void;
  133245. _releaseEffect(effect: Effect): void;
  133246. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  133247. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  133248. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  133249. bindSamplers(effect: Effect): void;
  133250. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  133251. getRenderWidth(useScreen?: boolean): number;
  133252. getRenderHeight(useScreen?: boolean): number;
  133253. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  133254. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  133255. /**
  133256. * Set the z offset to apply to current rendering
  133257. * @param value defines the offset to apply
  133258. */
  133259. setZOffset(value: number): void;
  133260. /**
  133261. * Gets the current value of the zOffset
  133262. * @returns the current zOffset state
  133263. */
  133264. getZOffset(): number;
  133265. /**
  133266. * Enable or disable depth buffering
  133267. * @param enable defines the state to set
  133268. */
  133269. setDepthBuffer(enable: boolean): void;
  133270. /**
  133271. * Gets a boolean indicating if depth writing is enabled
  133272. * @returns the current depth writing state
  133273. */
  133274. getDepthWrite(): boolean;
  133275. setDepthFunctionToGreater(): void;
  133276. setDepthFunctionToGreaterOrEqual(): void;
  133277. setDepthFunctionToLess(): void;
  133278. setDepthFunctionToLessOrEqual(): void;
  133279. /**
  133280. * Enable or disable depth writing
  133281. * @param enable defines the state to set
  133282. */
  133283. setDepthWrite(enable: boolean): void;
  133284. /**
  133285. * Enable or disable color writing
  133286. * @param enable defines the state to set
  133287. */
  133288. setColorWrite(enable: boolean): void;
  133289. /**
  133290. * Gets a boolean indicating if color writing is enabled
  133291. * @returns the current color writing state
  133292. */
  133293. getColorWrite(): boolean;
  133294. /**
  133295. * Sets alpha constants used by some alpha blending modes
  133296. * @param r defines the red component
  133297. * @param g defines the green component
  133298. * @param b defines the blue component
  133299. * @param a defines the alpha component
  133300. */
  133301. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  133302. /**
  133303. * Sets the current alpha mode
  133304. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  133305. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  133306. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133307. */
  133308. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  133309. /**
  133310. * Gets the current alpha mode
  133311. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133312. * @returns the current alpha mode
  133313. */
  133314. getAlphaMode(): number;
  133315. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  133316. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133317. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133318. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133319. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133320. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133321. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133322. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133323. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133324. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  133325. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  133326. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  133327. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  133328. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  133329. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133330. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133331. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  133332. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  133333. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  133334. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  133335. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  133336. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  133337. wipeCaches(bruteForce?: boolean): void;
  133338. _createTexture(): WebGLTexture;
  133339. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  133340. /**
  133341. * Usually called from Texture.ts.
  133342. * Passed information to create a WebGLTexture
  133343. * @param url defines a value which contains one of the following:
  133344. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  133345. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  133346. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  133347. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  133348. * @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)
  133349. * @param scene needed for loading to the correct scene
  133350. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  133351. * @param onLoad optional callback to be called upon successful completion
  133352. * @param onError optional callback to be called upon failure
  133353. * @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
  133354. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  133355. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  133356. * @param forcedExtension defines the extension to use to pick the right loader
  133357. * @param mimeType defines an optional mime type
  133358. * @returns a InternalTexture for assignment back into BABYLON.Texture
  133359. */
  133360. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  133361. /**
  133362. * Creates a cube texture
  133363. * @param rootUrl defines the url where the files to load is located
  133364. * @param scene defines the current scene
  133365. * @param files defines the list of files to load (1 per face)
  133366. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  133367. * @param onLoad defines an optional callback raised when the texture is loaded
  133368. * @param onError defines an optional callback raised if there is an issue to load the texture
  133369. * @param format defines the format of the data
  133370. * @param forcedExtension defines the extension to use to pick the right loader
  133371. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  133372. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133373. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133374. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  133375. * @returns the cube texture as an InternalTexture
  133376. */
  133377. 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;
  133378. private _getSamplingFilter;
  133379. private static _GetNativeTextureFormat;
  133380. createRenderTargetTexture(size: number | {
  133381. width: number;
  133382. height: number;
  133383. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  133384. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  133385. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  133386. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  133387. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  133388. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  133389. /**
  133390. * Updates a dynamic vertex buffer.
  133391. * @param vertexBuffer the vertex buffer to update
  133392. * @param data the data used to update the vertex buffer
  133393. * @param byteOffset the byte offset of the data (optional)
  133394. * @param byteLength the byte length of the data (optional)
  133395. */
  133396. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  133397. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  133398. private _updateAnisotropicLevel;
  133399. private _getAddressMode;
  133400. /** @hidden */
  133401. _bindTexture(channel: number, texture: InternalTexture): void;
  133402. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  133403. releaseEffects(): void;
  133404. /** @hidden */
  133405. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133406. /** @hidden */
  133407. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133408. /** @hidden */
  133409. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133410. /** @hidden */
  133411. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  133412. }
  133413. }
  133414. declare module BABYLON {
  133415. /**
  133416. * Gather the list of clipboard event types as constants.
  133417. */
  133418. export class ClipboardEventTypes {
  133419. /**
  133420. * The clipboard event is fired when a copy command is active (pressed).
  133421. */
  133422. static readonly COPY: number;
  133423. /**
  133424. * The clipboard event is fired when a cut command is active (pressed).
  133425. */
  133426. static readonly CUT: number;
  133427. /**
  133428. * The clipboard event is fired when a paste command is active (pressed).
  133429. */
  133430. static readonly PASTE: number;
  133431. }
  133432. /**
  133433. * This class is used to store clipboard related info for the onClipboardObservable event.
  133434. */
  133435. export class ClipboardInfo {
  133436. /**
  133437. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133438. */
  133439. type: number;
  133440. /**
  133441. * Defines the related dom event
  133442. */
  133443. event: ClipboardEvent;
  133444. /**
  133445. *Creates an instance of ClipboardInfo.
  133446. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  133447. * @param event Defines the related dom event
  133448. */
  133449. constructor(
  133450. /**
  133451. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133452. */
  133453. type: number,
  133454. /**
  133455. * Defines the related dom event
  133456. */
  133457. event: ClipboardEvent);
  133458. /**
  133459. * Get the clipboard event's type from the keycode.
  133460. * @param keyCode Defines the keyCode for the current keyboard event.
  133461. * @return {number}
  133462. */
  133463. static GetTypeFromCharacter(keyCode: number): number;
  133464. }
  133465. }
  133466. declare module BABYLON {
  133467. /**
  133468. * Google Daydream controller
  133469. */
  133470. export class DaydreamController extends WebVRController {
  133471. /**
  133472. * Base Url for the controller model.
  133473. */
  133474. static MODEL_BASE_URL: string;
  133475. /**
  133476. * File name for the controller model.
  133477. */
  133478. static MODEL_FILENAME: string;
  133479. /**
  133480. * Gamepad Id prefix used to identify Daydream Controller.
  133481. */
  133482. static readonly GAMEPAD_ID_PREFIX: string;
  133483. /**
  133484. * Creates a new DaydreamController from a gamepad
  133485. * @param vrGamepad the gamepad that the controller should be created from
  133486. */
  133487. constructor(vrGamepad: any);
  133488. /**
  133489. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133490. * @param scene scene in which to add meshes
  133491. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133492. */
  133493. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133494. /**
  133495. * Called once for each button that changed state since the last frame
  133496. * @param buttonIdx Which button index changed
  133497. * @param state New state of the button
  133498. * @param changes Which properties on the state changed since last frame
  133499. */
  133500. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133501. }
  133502. }
  133503. declare module BABYLON {
  133504. /**
  133505. * Gear VR Controller
  133506. */
  133507. export class GearVRController extends WebVRController {
  133508. /**
  133509. * Base Url for the controller model.
  133510. */
  133511. static MODEL_BASE_URL: string;
  133512. /**
  133513. * File name for the controller model.
  133514. */
  133515. static MODEL_FILENAME: string;
  133516. /**
  133517. * Gamepad Id prefix used to identify this controller.
  133518. */
  133519. static readonly GAMEPAD_ID_PREFIX: string;
  133520. private readonly _buttonIndexToObservableNameMap;
  133521. /**
  133522. * Creates a new GearVRController from a gamepad
  133523. * @param vrGamepad the gamepad that the controller should be created from
  133524. */
  133525. constructor(vrGamepad: any);
  133526. /**
  133527. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133528. * @param scene scene in which to add meshes
  133529. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133530. */
  133531. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133532. /**
  133533. * Called once for each button that changed state since the last frame
  133534. * @param buttonIdx Which button index changed
  133535. * @param state New state of the button
  133536. * @param changes Which properties on the state changed since last frame
  133537. */
  133538. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133539. }
  133540. }
  133541. declare module BABYLON {
  133542. /**
  133543. * Generic Controller
  133544. */
  133545. export class GenericController extends WebVRController {
  133546. /**
  133547. * Base Url for the controller model.
  133548. */
  133549. static readonly MODEL_BASE_URL: string;
  133550. /**
  133551. * File name for the controller model.
  133552. */
  133553. static readonly MODEL_FILENAME: string;
  133554. /**
  133555. * Creates a new GenericController from a gamepad
  133556. * @param vrGamepad the gamepad that the controller should be created from
  133557. */
  133558. constructor(vrGamepad: any);
  133559. /**
  133560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133561. * @param scene scene in which to add meshes
  133562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133563. */
  133564. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133565. /**
  133566. * Called once for each button that changed state since the last frame
  133567. * @param buttonIdx Which button index changed
  133568. * @param state New state of the button
  133569. * @param changes Which properties on the state changed since last frame
  133570. */
  133571. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133572. }
  133573. }
  133574. declare module BABYLON {
  133575. /**
  133576. * Oculus Touch Controller
  133577. */
  133578. export class OculusTouchController extends WebVRController {
  133579. /**
  133580. * Base Url for the controller model.
  133581. */
  133582. static MODEL_BASE_URL: string;
  133583. /**
  133584. * File name for the left controller model.
  133585. */
  133586. static MODEL_LEFT_FILENAME: string;
  133587. /**
  133588. * File name for the right controller model.
  133589. */
  133590. static MODEL_RIGHT_FILENAME: string;
  133591. /**
  133592. * Base Url for the Quest controller model.
  133593. */
  133594. static QUEST_MODEL_BASE_URL: string;
  133595. /**
  133596. * @hidden
  133597. * If the controllers are running on a device that needs the updated Quest controller models
  133598. */
  133599. static _IsQuest: boolean;
  133600. /**
  133601. * Fired when the secondary trigger on this controller is modified
  133602. */
  133603. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133604. /**
  133605. * Fired when the thumb rest on this controller is modified
  133606. */
  133607. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133608. /**
  133609. * Creates a new OculusTouchController from a gamepad
  133610. * @param vrGamepad the gamepad that the controller should be created from
  133611. */
  133612. constructor(vrGamepad: any);
  133613. /**
  133614. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133615. * @param scene scene in which to add meshes
  133616. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133617. */
  133618. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133619. /**
  133620. * Fired when the A button on this controller is modified
  133621. */
  133622. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133623. /**
  133624. * Fired when the B button on this controller is modified
  133625. */
  133626. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133627. /**
  133628. * Fired when the X button on this controller is modified
  133629. */
  133630. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133631. /**
  133632. * Fired when the Y button on this controller is modified
  133633. */
  133634. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133635. /**
  133636. * Called once for each button that changed state since the last frame
  133637. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133638. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133639. * 2) secondary trigger (same)
  133640. * 3) A (right) X (left), touch, pressed = value
  133641. * 4) B / Y
  133642. * 5) thumb rest
  133643. * @param buttonIdx Which button index changed
  133644. * @param state New state of the button
  133645. * @param changes Which properties on the state changed since last frame
  133646. */
  133647. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133648. }
  133649. }
  133650. declare module BABYLON {
  133651. /**
  133652. * Vive Controller
  133653. */
  133654. export class ViveController extends WebVRController {
  133655. /**
  133656. * Base Url for the controller model.
  133657. */
  133658. static MODEL_BASE_URL: string;
  133659. /**
  133660. * File name for the controller model.
  133661. */
  133662. static MODEL_FILENAME: string;
  133663. /**
  133664. * Creates a new ViveController from a gamepad
  133665. * @param vrGamepad the gamepad that the controller should be created from
  133666. */
  133667. constructor(vrGamepad: any);
  133668. /**
  133669. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133670. * @param scene scene in which to add meshes
  133671. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133672. */
  133673. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133674. /**
  133675. * Fired when the left button on this controller is modified
  133676. */
  133677. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133678. /**
  133679. * Fired when the right button on this controller is modified
  133680. */
  133681. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133682. /**
  133683. * Fired when the menu button on this controller is modified
  133684. */
  133685. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133686. /**
  133687. * Called once for each button that changed state since the last frame
  133688. * Vive mapping:
  133689. * 0: touchpad
  133690. * 1: trigger
  133691. * 2: left AND right buttons
  133692. * 3: menu button
  133693. * @param buttonIdx Which button index changed
  133694. * @param state New state of the button
  133695. * @param changes Which properties on the state changed since last frame
  133696. */
  133697. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133698. }
  133699. }
  133700. declare module BABYLON {
  133701. /**
  133702. * Defines the WindowsMotionController object that the state of the windows motion controller
  133703. */
  133704. export class WindowsMotionController extends WebVRController {
  133705. /**
  133706. * The base url used to load the left and right controller models
  133707. */
  133708. static MODEL_BASE_URL: string;
  133709. /**
  133710. * The name of the left controller model file
  133711. */
  133712. static MODEL_LEFT_FILENAME: string;
  133713. /**
  133714. * The name of the right controller model file
  133715. */
  133716. static MODEL_RIGHT_FILENAME: string;
  133717. /**
  133718. * The controller name prefix for this controller type
  133719. */
  133720. static readonly GAMEPAD_ID_PREFIX: string;
  133721. /**
  133722. * The controller id pattern for this controller type
  133723. */
  133724. private static readonly GAMEPAD_ID_PATTERN;
  133725. private _loadedMeshInfo;
  133726. protected readonly _mapping: {
  133727. buttons: string[];
  133728. buttonMeshNames: {
  133729. trigger: string;
  133730. menu: string;
  133731. grip: string;
  133732. thumbstick: string;
  133733. trackpad: string;
  133734. };
  133735. buttonObservableNames: {
  133736. trigger: string;
  133737. menu: string;
  133738. grip: string;
  133739. thumbstick: string;
  133740. trackpad: string;
  133741. };
  133742. axisMeshNames: string[];
  133743. pointingPoseMeshName: string;
  133744. };
  133745. /**
  133746. * Fired when the trackpad on this controller is clicked
  133747. */
  133748. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133749. /**
  133750. * Fired when the trackpad on this controller is modified
  133751. */
  133752. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133753. /**
  133754. * The current x and y values of this controller's trackpad
  133755. */
  133756. trackpad: StickValues;
  133757. /**
  133758. * Creates a new WindowsMotionController from a gamepad
  133759. * @param vrGamepad the gamepad that the controller should be created from
  133760. */
  133761. constructor(vrGamepad: any);
  133762. /**
  133763. * Fired when the trigger on this controller is modified
  133764. */
  133765. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133766. /**
  133767. * Fired when the menu button on this controller is modified
  133768. */
  133769. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133770. /**
  133771. * Fired when the grip button on this controller is modified
  133772. */
  133773. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133774. /**
  133775. * Fired when the thumbstick button on this controller is modified
  133776. */
  133777. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133778. /**
  133779. * Fired when the touchpad button on this controller is modified
  133780. */
  133781. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133782. /**
  133783. * Fired when the touchpad values on this controller are modified
  133784. */
  133785. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  133786. protected _updateTrackpad(): void;
  133787. /**
  133788. * Called once per frame by the engine.
  133789. */
  133790. update(): void;
  133791. /**
  133792. * Called once for each button that changed state since the last frame
  133793. * @param buttonIdx Which button index changed
  133794. * @param state New state of the button
  133795. * @param changes Which properties on the state changed since last frame
  133796. */
  133797. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133798. /**
  133799. * Moves the buttons on the controller mesh based on their current state
  133800. * @param buttonName the name of the button to move
  133801. * @param buttonValue the value of the button which determines the buttons new position
  133802. */
  133803. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  133804. /**
  133805. * Moves the axis on the controller mesh based on its current state
  133806. * @param axis the index of the axis
  133807. * @param axisValue the value of the axis which determines the meshes new position
  133808. * @hidden
  133809. */
  133810. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  133811. /**
  133812. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133813. * @param scene scene in which to add meshes
  133814. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133815. */
  133816. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  133817. /**
  133818. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  133819. * can be transformed by button presses and axes values, based on this._mapping.
  133820. *
  133821. * @param scene scene in which the meshes exist
  133822. * @param meshes list of meshes that make up the controller model to process
  133823. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  133824. */
  133825. private processModel;
  133826. private createMeshInfo;
  133827. /**
  133828. * Gets the ray of the controller in the direction the controller is pointing
  133829. * @param length the length the resulting ray should be
  133830. * @returns a ray in the direction the controller is pointing
  133831. */
  133832. getForwardRay(length?: number): Ray;
  133833. /**
  133834. * Disposes of the controller
  133835. */
  133836. dispose(): void;
  133837. }
  133838. /**
  133839. * This class represents a new windows motion controller in XR.
  133840. */
  133841. export class XRWindowsMotionController extends WindowsMotionController {
  133842. /**
  133843. * Changing the original WIndowsMotionController mapping to fir the new mapping
  133844. */
  133845. protected readonly _mapping: {
  133846. buttons: string[];
  133847. buttonMeshNames: {
  133848. trigger: string;
  133849. menu: string;
  133850. grip: string;
  133851. thumbstick: string;
  133852. trackpad: string;
  133853. };
  133854. buttonObservableNames: {
  133855. trigger: string;
  133856. menu: string;
  133857. grip: string;
  133858. thumbstick: string;
  133859. trackpad: string;
  133860. };
  133861. axisMeshNames: string[];
  133862. pointingPoseMeshName: string;
  133863. };
  133864. /**
  133865. * Construct a new XR-Based windows motion controller
  133866. *
  133867. * @param gamepadInfo the gamepad object from the browser
  133868. */
  133869. constructor(gamepadInfo: any);
  133870. /**
  133871. * holds the thumbstick values (X,Y)
  133872. */
  133873. thumbstickValues: StickValues;
  133874. /**
  133875. * Fired when the thumbstick on this controller is clicked
  133876. */
  133877. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133878. /**
  133879. * Fired when the thumbstick on this controller is modified
  133880. */
  133881. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133882. /**
  133883. * Fired when the touchpad button on this controller is modified
  133884. */
  133885. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133886. /**
  133887. * Fired when the touchpad values on this controller are modified
  133888. */
  133889. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133890. /**
  133891. * Fired when the thumbstick button on this controller is modified
  133892. * here to prevent breaking changes
  133893. */
  133894. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133895. /**
  133896. * updating the thumbstick(!) and not the trackpad.
  133897. * This is named this way due to the difference between WebVR and XR and to avoid
  133898. * changing the parent class.
  133899. */
  133900. protected _updateTrackpad(): void;
  133901. /**
  133902. * Disposes the class with joy
  133903. */
  133904. dispose(): void;
  133905. }
  133906. }
  133907. declare module BABYLON {
  133908. /**
  133909. * Class containing static functions to help procedurally build meshes
  133910. */
  133911. export class PolyhedronBuilder {
  133912. /**
  133913. * Creates a polyhedron mesh
  133914. * * 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
  133915. * * The parameter `size` (positive float, default 1) sets the polygon size
  133916. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133917. * * 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`
  133918. * * 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
  133919. * * 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)`)
  133920. * * 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
  133921. * * 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
  133922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133925. * @param name defines the name of the mesh
  133926. * @param options defines the options used to create the mesh
  133927. * @param scene defines the hosting scene
  133928. * @returns the polyhedron mesh
  133929. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133930. */
  133931. static CreatePolyhedron(name: string, options: {
  133932. type?: number;
  133933. size?: number;
  133934. sizeX?: number;
  133935. sizeY?: number;
  133936. sizeZ?: number;
  133937. custom?: any;
  133938. faceUV?: Vector4[];
  133939. faceColors?: Color4[];
  133940. flat?: boolean;
  133941. updatable?: boolean;
  133942. sideOrientation?: number;
  133943. frontUVs?: Vector4;
  133944. backUVs?: Vector4;
  133945. }, scene?: Nullable<Scene>): Mesh;
  133946. }
  133947. }
  133948. declare module BABYLON {
  133949. /**
  133950. * Gizmo that enables scaling a mesh along 3 axis
  133951. */
  133952. export class ScaleGizmo extends Gizmo {
  133953. /**
  133954. * Internal gizmo used for interactions on the x axis
  133955. */
  133956. xGizmo: AxisScaleGizmo;
  133957. /**
  133958. * Internal gizmo used for interactions on the y axis
  133959. */
  133960. yGizmo: AxisScaleGizmo;
  133961. /**
  133962. * Internal gizmo used for interactions on the z axis
  133963. */
  133964. zGizmo: AxisScaleGizmo;
  133965. /**
  133966. * Internal gizmo used to scale all axis equally
  133967. */
  133968. uniformScaleGizmo: AxisScaleGizmo;
  133969. private _meshAttached;
  133970. private _nodeAttached;
  133971. private _snapDistance;
  133972. private _uniformScalingMesh;
  133973. private _octahedron;
  133974. private _sensitivity;
  133975. /** Fires an event when any of it's sub gizmos are dragged */
  133976. onDragStartObservable: Observable<unknown>;
  133977. /** Fires an event when any of it's sub gizmos are released from dragging */
  133978. onDragEndObservable: Observable<unknown>;
  133979. get attachedMesh(): Nullable<AbstractMesh>;
  133980. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133981. get attachedNode(): Nullable<Node>;
  133982. set attachedNode(node: Nullable<Node>);
  133983. /**
  133984. * True when the mouse pointer is hovering a gizmo mesh
  133985. */
  133986. get isHovered(): boolean;
  133987. /**
  133988. * Creates a ScaleGizmo
  133989. * @param gizmoLayer The utility layer the gizmo will be added to
  133990. * @param thickness display gizmo axis thickness
  133991. */
  133992. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133993. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133994. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133995. /**
  133996. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133997. */
  133998. set snapDistance(value: number);
  133999. get snapDistance(): number;
  134000. /**
  134001. * Ratio for the scale of the gizmo (Default: 1)
  134002. */
  134003. set scaleRatio(value: number);
  134004. get scaleRatio(): number;
  134005. /**
  134006. * Sensitivity factor for dragging (Default: 1)
  134007. */
  134008. set sensitivity(value: number);
  134009. get sensitivity(): number;
  134010. /**
  134011. * Disposes of the gizmo
  134012. */
  134013. dispose(): void;
  134014. }
  134015. }
  134016. declare module BABYLON {
  134017. /**
  134018. * Single axis scale gizmo
  134019. */
  134020. export class AxisScaleGizmo extends Gizmo {
  134021. /**
  134022. * Drag behavior responsible for the gizmos dragging interactions
  134023. */
  134024. dragBehavior: PointerDragBehavior;
  134025. private _pointerObserver;
  134026. /**
  134027. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134028. */
  134029. snapDistance: number;
  134030. /**
  134031. * Event that fires each time the gizmo snaps to a new location.
  134032. * * snapDistance is the the change in distance
  134033. */
  134034. onSnapObservable: Observable<{
  134035. snapDistance: number;
  134036. }>;
  134037. /**
  134038. * If the scaling operation should be done on all axis (default: false)
  134039. */
  134040. uniformScaling: boolean;
  134041. /**
  134042. * Custom sensitivity value for the drag strength
  134043. */
  134044. sensitivity: number;
  134045. private _isEnabled;
  134046. private _parent;
  134047. private _arrow;
  134048. private _coloredMaterial;
  134049. private _hoverMaterial;
  134050. /**
  134051. * Creates an AxisScaleGizmo
  134052. * @param gizmoLayer The utility layer the gizmo will be added to
  134053. * @param dragAxis The axis which the gizmo will be able to scale on
  134054. * @param color The color of the gizmo
  134055. * @param thickness display gizmo axis thickness
  134056. */
  134057. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  134058. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134059. /**
  134060. * If the gizmo is enabled
  134061. */
  134062. set isEnabled(value: boolean);
  134063. get isEnabled(): boolean;
  134064. /**
  134065. * Disposes of the gizmo
  134066. */
  134067. dispose(): void;
  134068. /**
  134069. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134070. * @param mesh The mesh to replace the default mesh of the gizmo
  134071. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  134072. */
  134073. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  134074. }
  134075. }
  134076. declare module BABYLON {
  134077. /**
  134078. * Bounding box gizmo
  134079. */
  134080. export class BoundingBoxGizmo extends Gizmo {
  134081. private _lineBoundingBox;
  134082. private _rotateSpheresParent;
  134083. private _scaleBoxesParent;
  134084. private _boundingDimensions;
  134085. private _renderObserver;
  134086. private _pointerObserver;
  134087. private _scaleDragSpeed;
  134088. private _tmpQuaternion;
  134089. private _tmpVector;
  134090. private _tmpRotationMatrix;
  134091. /**
  134092. * 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)
  134093. */
  134094. ignoreChildren: boolean;
  134095. /**
  134096. * 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)
  134097. */
  134098. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  134099. /**
  134100. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  134101. */
  134102. rotationSphereSize: number;
  134103. /**
  134104. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  134105. */
  134106. scaleBoxSize: number;
  134107. /**
  134108. * 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)
  134109. */
  134110. fixedDragMeshScreenSize: boolean;
  134111. /**
  134112. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  134113. */
  134114. fixedDragMeshScreenSizeDistanceFactor: number;
  134115. /**
  134116. * Fired when a rotation sphere or scale box is dragged
  134117. */
  134118. onDragStartObservable: Observable<{}>;
  134119. /**
  134120. * Fired when a scale box is dragged
  134121. */
  134122. onScaleBoxDragObservable: Observable<{}>;
  134123. /**
  134124. * Fired when a scale box drag is ended
  134125. */
  134126. onScaleBoxDragEndObservable: Observable<{}>;
  134127. /**
  134128. * Fired when a rotation sphere is dragged
  134129. */
  134130. onRotationSphereDragObservable: Observable<{}>;
  134131. /**
  134132. * Fired when a rotation sphere drag is ended
  134133. */
  134134. onRotationSphereDragEndObservable: Observable<{}>;
  134135. /**
  134136. * 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)
  134137. */
  134138. scalePivot: Nullable<Vector3>;
  134139. /**
  134140. * Mesh used as a pivot to rotate the attached node
  134141. */
  134142. private _anchorMesh;
  134143. private _existingMeshScale;
  134144. private _dragMesh;
  134145. private pointerDragBehavior;
  134146. private coloredMaterial;
  134147. private hoverColoredMaterial;
  134148. /**
  134149. * Sets the color of the bounding box gizmo
  134150. * @param color the color to set
  134151. */
  134152. setColor(color: Color3): void;
  134153. /**
  134154. * Creates an BoundingBoxGizmo
  134155. * @param gizmoLayer The utility layer the gizmo will be added to
  134156. * @param color The color of the gizmo
  134157. */
  134158. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  134159. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  134160. private _selectNode;
  134161. /**
  134162. * Updates the bounding box information for the Gizmo
  134163. */
  134164. updateBoundingBox(): void;
  134165. private _updateRotationSpheres;
  134166. private _updateScaleBoxes;
  134167. /**
  134168. * Enables rotation on the specified axis and disables rotation on the others
  134169. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  134170. */
  134171. setEnabledRotationAxis(axis: string): void;
  134172. /**
  134173. * Enables/disables scaling
  134174. * @param enable if scaling should be enabled
  134175. * @param homogeneousScaling defines if scaling should only be homogeneous
  134176. */
  134177. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  134178. private _updateDummy;
  134179. /**
  134180. * Enables a pointer drag behavior on the bounding box of the gizmo
  134181. */
  134182. enableDragBehavior(): void;
  134183. /**
  134184. * Disposes of the gizmo
  134185. */
  134186. dispose(): void;
  134187. /**
  134188. * 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)
  134189. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  134190. * @returns the bounding box mesh with the passed in mesh as a child
  134191. */
  134192. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  134193. /**
  134194. * CustomMeshes are not supported by this gizmo
  134195. * @param mesh The mesh to replace the default mesh of the gizmo
  134196. */
  134197. setCustomMesh(mesh: Mesh): void;
  134198. }
  134199. }
  134200. declare module BABYLON {
  134201. /**
  134202. * Single plane rotation gizmo
  134203. */
  134204. export class PlaneRotationGizmo extends Gizmo {
  134205. /**
  134206. * Drag behavior responsible for the gizmos dragging interactions
  134207. */
  134208. dragBehavior: PointerDragBehavior;
  134209. private _pointerObserver;
  134210. /**
  134211. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  134212. */
  134213. snapDistance: number;
  134214. /**
  134215. * Event that fires each time the gizmo snaps to a new location.
  134216. * * snapDistance is the the change in distance
  134217. */
  134218. onSnapObservable: Observable<{
  134219. snapDistance: number;
  134220. }>;
  134221. private _isEnabled;
  134222. private _parent;
  134223. /**
  134224. * Creates a PlaneRotationGizmo
  134225. * @param gizmoLayer The utility layer the gizmo will be added to
  134226. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  134227. * @param color The color of the gizmo
  134228. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134229. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134230. * @param thickness display gizmo axis thickness
  134231. */
  134232. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  134233. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134234. /**
  134235. * If the gizmo is enabled
  134236. */
  134237. set isEnabled(value: boolean);
  134238. get isEnabled(): boolean;
  134239. /**
  134240. * Disposes of the gizmo
  134241. */
  134242. dispose(): void;
  134243. }
  134244. }
  134245. declare module BABYLON {
  134246. /**
  134247. * Gizmo that enables rotating a mesh along 3 axis
  134248. */
  134249. export class RotationGizmo extends Gizmo {
  134250. /**
  134251. * Internal gizmo used for interactions on the x axis
  134252. */
  134253. xGizmo: PlaneRotationGizmo;
  134254. /**
  134255. * Internal gizmo used for interactions on the y axis
  134256. */
  134257. yGizmo: PlaneRotationGizmo;
  134258. /**
  134259. * Internal gizmo used for interactions on the z axis
  134260. */
  134261. zGizmo: PlaneRotationGizmo;
  134262. /** Fires an event when any of it's sub gizmos are dragged */
  134263. onDragStartObservable: Observable<unknown>;
  134264. /** Fires an event when any of it's sub gizmos are released from dragging */
  134265. onDragEndObservable: Observable<unknown>;
  134266. private _meshAttached;
  134267. private _nodeAttached;
  134268. get attachedMesh(): Nullable<AbstractMesh>;
  134269. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134270. get attachedNode(): Nullable<Node>;
  134271. set attachedNode(node: Nullable<Node>);
  134272. /**
  134273. * True when the mouse pointer is hovering a gizmo mesh
  134274. */
  134275. get isHovered(): boolean;
  134276. /**
  134277. * Creates a RotationGizmo
  134278. * @param gizmoLayer The utility layer the gizmo will be added to
  134279. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134280. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134281. * @param thickness display gizmo axis thickness
  134282. */
  134283. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  134284. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134285. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134286. /**
  134287. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134288. */
  134289. set snapDistance(value: number);
  134290. get snapDistance(): number;
  134291. /**
  134292. * Ratio for the scale of the gizmo (Default: 1)
  134293. */
  134294. set scaleRatio(value: number);
  134295. get scaleRatio(): number;
  134296. /**
  134297. * Disposes of the gizmo
  134298. */
  134299. dispose(): void;
  134300. /**
  134301. * CustomMeshes are not supported by this gizmo
  134302. * @param mesh The mesh to replace the default mesh of the gizmo
  134303. */
  134304. setCustomMesh(mesh: Mesh): void;
  134305. }
  134306. }
  134307. declare module BABYLON {
  134308. /**
  134309. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  134310. */
  134311. export class GizmoManager implements IDisposable {
  134312. private scene;
  134313. /**
  134314. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  134315. */
  134316. gizmos: {
  134317. positionGizmo: Nullable<PositionGizmo>;
  134318. rotationGizmo: Nullable<RotationGizmo>;
  134319. scaleGizmo: Nullable<ScaleGizmo>;
  134320. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  134321. };
  134322. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  134323. clearGizmoOnEmptyPointerEvent: boolean;
  134324. /** Fires an event when the manager is attached to a mesh */
  134325. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  134326. /** Fires an event when the manager is attached to a node */
  134327. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  134328. private _gizmosEnabled;
  134329. private _pointerObserver;
  134330. private _attachedMesh;
  134331. private _attachedNode;
  134332. private _boundingBoxColor;
  134333. private _defaultUtilityLayer;
  134334. private _defaultKeepDepthUtilityLayer;
  134335. private _thickness;
  134336. /**
  134337. * When bounding box gizmo is enabled, this can be used to track drag/end events
  134338. */
  134339. boundingBoxDragBehavior: SixDofDragBehavior;
  134340. /**
  134341. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  134342. */
  134343. attachableMeshes: Nullable<Array<AbstractMesh>>;
  134344. /**
  134345. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  134346. */
  134347. attachableNodes: Nullable<Array<Node>>;
  134348. /**
  134349. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  134350. */
  134351. usePointerToAttachGizmos: boolean;
  134352. /**
  134353. * Utility layer that the bounding box gizmo belongs to
  134354. */
  134355. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  134356. /**
  134357. * Utility layer that all gizmos besides bounding box belong to
  134358. */
  134359. get utilityLayer(): UtilityLayerRenderer;
  134360. /**
  134361. * True when the mouse pointer is hovering a gizmo mesh
  134362. */
  134363. get isHovered(): boolean;
  134364. /**
  134365. * Instatiates a gizmo manager
  134366. * @param scene the scene to overlay the gizmos on top of
  134367. * @param thickness display gizmo axis thickness
  134368. */
  134369. constructor(scene: Scene, thickness?: number);
  134370. /**
  134371. * Attaches a set of gizmos to the specified mesh
  134372. * @param mesh The mesh the gizmo's should be attached to
  134373. */
  134374. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  134375. /**
  134376. * Attaches a set of gizmos to the specified node
  134377. * @param node The node the gizmo's should be attached to
  134378. */
  134379. attachToNode(node: Nullable<Node>): void;
  134380. /**
  134381. * If the position gizmo is enabled
  134382. */
  134383. set positionGizmoEnabled(value: boolean);
  134384. get positionGizmoEnabled(): boolean;
  134385. /**
  134386. * If the rotation gizmo is enabled
  134387. */
  134388. set rotationGizmoEnabled(value: boolean);
  134389. get rotationGizmoEnabled(): boolean;
  134390. /**
  134391. * If the scale gizmo is enabled
  134392. */
  134393. set scaleGizmoEnabled(value: boolean);
  134394. get scaleGizmoEnabled(): boolean;
  134395. /**
  134396. * If the boundingBox gizmo is enabled
  134397. */
  134398. set boundingBoxGizmoEnabled(value: boolean);
  134399. get boundingBoxGizmoEnabled(): boolean;
  134400. /**
  134401. * Disposes of the gizmo manager
  134402. */
  134403. dispose(): void;
  134404. }
  134405. }
  134406. declare module BABYLON {
  134407. /**
  134408. * A directional light is defined by a direction (what a surprise!).
  134409. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  134410. * 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.
  134411. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134412. */
  134413. export class DirectionalLight extends ShadowLight {
  134414. private _shadowFrustumSize;
  134415. /**
  134416. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  134417. */
  134418. get shadowFrustumSize(): number;
  134419. /**
  134420. * Specifies a fix frustum size for the shadow generation.
  134421. */
  134422. set shadowFrustumSize(value: number);
  134423. private _shadowOrthoScale;
  134424. /**
  134425. * Gets the shadow projection scale against the optimal computed one.
  134426. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134427. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134428. */
  134429. get shadowOrthoScale(): number;
  134430. /**
  134431. * Sets the shadow projection scale against the optimal computed one.
  134432. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134433. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134434. */
  134435. set shadowOrthoScale(value: number);
  134436. /**
  134437. * Automatically compute the projection matrix to best fit (including all the casters)
  134438. * on each frame.
  134439. */
  134440. autoUpdateExtends: boolean;
  134441. /**
  134442. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  134443. * on each frame. autoUpdateExtends must be set to true for this to work
  134444. */
  134445. autoCalcShadowZBounds: boolean;
  134446. private _orthoLeft;
  134447. private _orthoRight;
  134448. private _orthoTop;
  134449. private _orthoBottom;
  134450. /**
  134451. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  134452. * The directional light is emitted from everywhere in the given direction.
  134453. * It can cast shadows.
  134454. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134455. * @param name The friendly name of the light
  134456. * @param direction The direction of the light
  134457. * @param scene The scene the light belongs to
  134458. */
  134459. constructor(name: string, direction: Vector3, scene: Scene);
  134460. /**
  134461. * Returns the string "DirectionalLight".
  134462. * @return The class name
  134463. */
  134464. getClassName(): string;
  134465. /**
  134466. * Returns the integer 1.
  134467. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134468. */
  134469. getTypeID(): number;
  134470. /**
  134471. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  134472. * Returns the DirectionalLight Shadow projection matrix.
  134473. */
  134474. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134475. /**
  134476. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  134477. * Returns the DirectionalLight Shadow projection matrix.
  134478. */
  134479. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  134480. /**
  134481. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  134482. * Returns the DirectionalLight Shadow projection matrix.
  134483. */
  134484. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134485. protected _buildUniformLayout(): void;
  134486. /**
  134487. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  134488. * @param effect The effect to update
  134489. * @param lightIndex The index of the light in the effect to update
  134490. * @returns The directional light
  134491. */
  134492. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  134493. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  134494. /**
  134495. * Gets the minZ used for shadow according to both the scene and the light.
  134496. *
  134497. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134498. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134499. * @param activeCamera The camera we are returning the min for
  134500. * @returns the depth min z
  134501. */
  134502. getDepthMinZ(activeCamera: Camera): number;
  134503. /**
  134504. * Gets the maxZ used for shadow according to both the scene and the light.
  134505. *
  134506. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134507. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134508. * @param activeCamera The camera we are returning the max for
  134509. * @returns the depth max z
  134510. */
  134511. getDepthMaxZ(activeCamera: Camera): number;
  134512. /**
  134513. * Prepares the list of defines specific to the light type.
  134514. * @param defines the list of defines
  134515. * @param lightIndex defines the index of the light for the effect
  134516. */
  134517. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134518. }
  134519. }
  134520. declare module BABYLON {
  134521. /**
  134522. * Class containing static functions to help procedurally build meshes
  134523. */
  134524. export class HemisphereBuilder {
  134525. /**
  134526. * Creates a hemisphere mesh
  134527. * @param name defines the name of the mesh
  134528. * @param options defines the options used to create the mesh
  134529. * @param scene defines the hosting scene
  134530. * @returns the hemisphere mesh
  134531. */
  134532. static CreateHemisphere(name: string, options: {
  134533. segments?: number;
  134534. diameter?: number;
  134535. sideOrientation?: number;
  134536. }, scene: any): Mesh;
  134537. }
  134538. }
  134539. declare module BABYLON {
  134540. /**
  134541. * A spot light is defined by a position, a direction, an angle, and an exponent.
  134542. * These values define a cone of light starting from the position, emitting toward the direction.
  134543. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  134544. * and the exponent defines the speed of the decay of the light with distance (reach).
  134545. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134546. */
  134547. export class SpotLight extends ShadowLight {
  134548. private _angle;
  134549. private _innerAngle;
  134550. private _cosHalfAngle;
  134551. private _lightAngleScale;
  134552. private _lightAngleOffset;
  134553. /**
  134554. * Gets the cone angle of the spot light in Radians.
  134555. */
  134556. get angle(): number;
  134557. /**
  134558. * Sets the cone angle of the spot light in Radians.
  134559. */
  134560. set angle(value: number);
  134561. /**
  134562. * Only used in gltf falloff mode, this defines the angle where
  134563. * the directional falloff will start before cutting at angle which could be seen
  134564. * as outer angle.
  134565. */
  134566. get innerAngle(): number;
  134567. /**
  134568. * Only used in gltf falloff mode, this defines the angle where
  134569. * the directional falloff will start before cutting at angle which could be seen
  134570. * as outer angle.
  134571. */
  134572. set innerAngle(value: number);
  134573. private _shadowAngleScale;
  134574. /**
  134575. * Allows scaling the angle of the light for shadow generation only.
  134576. */
  134577. get shadowAngleScale(): number;
  134578. /**
  134579. * Allows scaling the angle of the light for shadow generation only.
  134580. */
  134581. set shadowAngleScale(value: number);
  134582. /**
  134583. * The light decay speed with the distance from the emission spot.
  134584. */
  134585. exponent: number;
  134586. private _projectionTextureMatrix;
  134587. /**
  134588. * Allows reading the projecton texture
  134589. */
  134590. get projectionTextureMatrix(): Matrix;
  134591. protected _projectionTextureLightNear: number;
  134592. /**
  134593. * Gets the near clip of the Spotlight for texture projection.
  134594. */
  134595. get projectionTextureLightNear(): number;
  134596. /**
  134597. * Sets the near clip of the Spotlight for texture projection.
  134598. */
  134599. set projectionTextureLightNear(value: number);
  134600. protected _projectionTextureLightFar: number;
  134601. /**
  134602. * Gets the far clip of the Spotlight for texture projection.
  134603. */
  134604. get projectionTextureLightFar(): number;
  134605. /**
  134606. * Sets the far clip of the Spotlight for texture projection.
  134607. */
  134608. set projectionTextureLightFar(value: number);
  134609. protected _projectionTextureUpDirection: Vector3;
  134610. /**
  134611. * Gets the Up vector of the Spotlight for texture projection.
  134612. */
  134613. get projectionTextureUpDirection(): Vector3;
  134614. /**
  134615. * Sets the Up vector of the Spotlight for texture projection.
  134616. */
  134617. set projectionTextureUpDirection(value: Vector3);
  134618. private _projectionTexture;
  134619. /**
  134620. * Gets the projection texture of the light.
  134621. */
  134622. get projectionTexture(): Nullable<BaseTexture>;
  134623. /**
  134624. * Sets the projection texture of the light.
  134625. */
  134626. set projectionTexture(value: Nullable<BaseTexture>);
  134627. private _projectionTextureViewLightDirty;
  134628. private _projectionTextureProjectionLightDirty;
  134629. private _projectionTextureDirty;
  134630. private _projectionTextureViewTargetVector;
  134631. private _projectionTextureViewLightMatrix;
  134632. private _projectionTextureProjectionLightMatrix;
  134633. private _projectionTextureScalingMatrix;
  134634. /**
  134635. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134636. * It can cast shadows.
  134637. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134638. * @param name The light friendly name
  134639. * @param position The position of the spot light in the scene
  134640. * @param direction The direction of the light in the scene
  134641. * @param angle The cone angle of the light in Radians
  134642. * @param exponent The light decay speed with the distance from the emission spot
  134643. * @param scene The scene the lights belongs to
  134644. */
  134645. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  134646. /**
  134647. * Returns the string "SpotLight".
  134648. * @returns the class name
  134649. */
  134650. getClassName(): string;
  134651. /**
  134652. * Returns the integer 2.
  134653. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134654. */
  134655. getTypeID(): number;
  134656. /**
  134657. * Overrides the direction setter to recompute the projection texture view light Matrix.
  134658. */
  134659. protected _setDirection(value: Vector3): void;
  134660. /**
  134661. * Overrides the position setter to recompute the projection texture view light Matrix.
  134662. */
  134663. protected _setPosition(value: Vector3): void;
  134664. /**
  134665. * 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.
  134666. * Returns the SpotLight.
  134667. */
  134668. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134669. protected _computeProjectionTextureViewLightMatrix(): void;
  134670. protected _computeProjectionTextureProjectionLightMatrix(): void;
  134671. /**
  134672. * Main function for light texture projection matrix computing.
  134673. */
  134674. protected _computeProjectionTextureMatrix(): void;
  134675. protected _buildUniformLayout(): void;
  134676. private _computeAngleValues;
  134677. /**
  134678. * Sets the passed Effect "effect" with the Light textures.
  134679. * @param effect The effect to update
  134680. * @param lightIndex The index of the light in the effect to update
  134681. * @returns The light
  134682. */
  134683. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134684. /**
  134685. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134686. * @param effect The effect to update
  134687. * @param lightIndex The index of the light in the effect to update
  134688. * @returns The spot light
  134689. */
  134690. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  134691. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  134692. /**
  134693. * Disposes the light and the associated resources.
  134694. */
  134695. dispose(): void;
  134696. /**
  134697. * Prepares the list of defines specific to the light type.
  134698. * @param defines the list of defines
  134699. * @param lightIndex defines the index of the light for the effect
  134700. */
  134701. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134702. }
  134703. }
  134704. declare module BABYLON {
  134705. /**
  134706. * Gizmo that enables viewing a light
  134707. */
  134708. export class LightGizmo extends Gizmo {
  134709. private _lightMesh;
  134710. private _material;
  134711. private _cachedPosition;
  134712. private _cachedForward;
  134713. private _attachedMeshParent;
  134714. private _pointerObserver;
  134715. /**
  134716. * Event that fires each time the gizmo is clicked
  134717. */
  134718. onClickedObservable: Observable<Light>;
  134719. /**
  134720. * Creates a LightGizmo
  134721. * @param gizmoLayer The utility layer the gizmo will be added to
  134722. */
  134723. constructor(gizmoLayer?: UtilityLayerRenderer);
  134724. private _light;
  134725. /**
  134726. * The light that the gizmo is attached to
  134727. */
  134728. set light(light: Nullable<Light>);
  134729. get light(): Nullable<Light>;
  134730. /**
  134731. * Gets the material used to render the light gizmo
  134732. */
  134733. get material(): StandardMaterial;
  134734. /**
  134735. * @hidden
  134736. * Updates the gizmo to match the attached mesh's position/rotation
  134737. */
  134738. protected _update(): void;
  134739. private static _Scale;
  134740. /**
  134741. * Creates the lines for a light mesh
  134742. */
  134743. private static _CreateLightLines;
  134744. /**
  134745. * Disposes of the light gizmo
  134746. */
  134747. dispose(): void;
  134748. private static _CreateHemisphericLightMesh;
  134749. private static _CreatePointLightMesh;
  134750. private static _CreateSpotLightMesh;
  134751. private static _CreateDirectionalLightMesh;
  134752. }
  134753. }
  134754. declare module BABYLON {
  134755. /**
  134756. * Gizmo that enables viewing a camera
  134757. */
  134758. export class CameraGizmo extends Gizmo {
  134759. private _cameraMesh;
  134760. private _cameraLinesMesh;
  134761. private _material;
  134762. private _pointerObserver;
  134763. /**
  134764. * Event that fires each time the gizmo is clicked
  134765. */
  134766. onClickedObservable: Observable<Camera>;
  134767. /**
  134768. * Creates a CameraGizmo
  134769. * @param gizmoLayer The utility layer the gizmo will be added to
  134770. */
  134771. constructor(gizmoLayer?: UtilityLayerRenderer);
  134772. private _camera;
  134773. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  134774. get displayFrustum(): boolean;
  134775. set displayFrustum(value: boolean);
  134776. /**
  134777. * The camera that the gizmo is attached to
  134778. */
  134779. set camera(camera: Nullable<Camera>);
  134780. get camera(): Nullable<Camera>;
  134781. /**
  134782. * Gets the material used to render the camera gizmo
  134783. */
  134784. get material(): StandardMaterial;
  134785. /**
  134786. * @hidden
  134787. * Updates the gizmo to match the attached mesh's position/rotation
  134788. */
  134789. protected _update(): void;
  134790. private static _Scale;
  134791. private _invProjection;
  134792. /**
  134793. * Disposes of the camera gizmo
  134794. */
  134795. dispose(): void;
  134796. private static _CreateCameraMesh;
  134797. private static _CreateCameraFrustum;
  134798. }
  134799. }
  134800. declare module BABYLON {
  134801. /** @hidden */
  134802. export var backgroundFragmentDeclaration: {
  134803. name: string;
  134804. shader: string;
  134805. };
  134806. }
  134807. declare module BABYLON {
  134808. /** @hidden */
  134809. export var backgroundUboDeclaration: {
  134810. name: string;
  134811. shader: string;
  134812. };
  134813. }
  134814. declare module BABYLON {
  134815. /** @hidden */
  134816. export var backgroundPixelShader: {
  134817. name: string;
  134818. shader: string;
  134819. };
  134820. }
  134821. declare module BABYLON {
  134822. /** @hidden */
  134823. export var backgroundVertexDeclaration: {
  134824. name: string;
  134825. shader: string;
  134826. };
  134827. }
  134828. declare module BABYLON {
  134829. /** @hidden */
  134830. export var backgroundVertexShader: {
  134831. name: string;
  134832. shader: string;
  134833. };
  134834. }
  134835. declare module BABYLON {
  134836. /**
  134837. * Background material used to create an efficient environement around your scene.
  134838. */
  134839. export class BackgroundMaterial extends PushMaterial {
  134840. /**
  134841. * Standard reflectance value at parallel view angle.
  134842. */
  134843. static StandardReflectance0: number;
  134844. /**
  134845. * Standard reflectance value at grazing angle.
  134846. */
  134847. static StandardReflectance90: number;
  134848. protected _primaryColor: Color3;
  134849. /**
  134850. * Key light Color (multiply against the environement texture)
  134851. */
  134852. primaryColor: Color3;
  134853. protected __perceptualColor: Nullable<Color3>;
  134854. /**
  134855. * Experimental Internal Use Only.
  134856. *
  134857. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  134858. * This acts as a helper to set the primary color to a more "human friendly" value.
  134859. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  134860. * output color as close as possible from the chosen value.
  134861. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  134862. * part of lighting setup.)
  134863. */
  134864. get _perceptualColor(): Nullable<Color3>;
  134865. set _perceptualColor(value: Nullable<Color3>);
  134866. protected _primaryColorShadowLevel: float;
  134867. /**
  134868. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  134869. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134870. */
  134871. get primaryColorShadowLevel(): float;
  134872. set primaryColorShadowLevel(value: float);
  134873. protected _primaryColorHighlightLevel: float;
  134874. /**
  134875. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134876. * The primary color is used at the level chosen to define what the white area would look.
  134877. */
  134878. get primaryColorHighlightLevel(): float;
  134879. set primaryColorHighlightLevel(value: float);
  134880. protected _reflectionTexture: Nullable<BaseTexture>;
  134881. /**
  134882. * Reflection Texture used in the material.
  134883. * Should be author in a specific way for the best result (refer to the documentation).
  134884. */
  134885. reflectionTexture: Nullable<BaseTexture>;
  134886. protected _reflectionBlur: float;
  134887. /**
  134888. * Reflection Texture level of blur.
  134889. *
  134890. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134891. * texture twice.
  134892. */
  134893. reflectionBlur: float;
  134894. protected _diffuseTexture: Nullable<BaseTexture>;
  134895. /**
  134896. * Diffuse Texture used in the material.
  134897. * Should be author in a specific way for the best result (refer to the documentation).
  134898. */
  134899. diffuseTexture: Nullable<BaseTexture>;
  134900. protected _shadowLights: Nullable<IShadowLight[]>;
  134901. /**
  134902. * Specify the list of lights casting shadow on the material.
  134903. * All scene shadow lights will be included if null.
  134904. */
  134905. shadowLights: Nullable<IShadowLight[]>;
  134906. protected _shadowLevel: float;
  134907. /**
  134908. * Helps adjusting the shadow to a softer level if required.
  134909. * 0 means black shadows and 1 means no shadows.
  134910. */
  134911. shadowLevel: float;
  134912. protected _sceneCenter: Vector3;
  134913. /**
  134914. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134915. * It is usually zero but might be interesting to modify according to your setup.
  134916. */
  134917. sceneCenter: Vector3;
  134918. protected _opacityFresnel: boolean;
  134919. /**
  134920. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134921. * This helps ensuring a nice transition when the camera goes under the ground.
  134922. */
  134923. opacityFresnel: boolean;
  134924. protected _reflectionFresnel: boolean;
  134925. /**
  134926. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134927. * This helps adding a mirror texture on the ground.
  134928. */
  134929. reflectionFresnel: boolean;
  134930. protected _reflectionFalloffDistance: number;
  134931. /**
  134932. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134933. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134934. */
  134935. reflectionFalloffDistance: number;
  134936. protected _reflectionAmount: number;
  134937. /**
  134938. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134939. */
  134940. reflectionAmount: number;
  134941. protected _reflectionReflectance0: number;
  134942. /**
  134943. * This specifies the weight of the reflection at grazing angle.
  134944. */
  134945. reflectionReflectance0: number;
  134946. protected _reflectionReflectance90: number;
  134947. /**
  134948. * This specifies the weight of the reflection at a perpendicular point of view.
  134949. */
  134950. reflectionReflectance90: number;
  134951. /**
  134952. * Sets the reflection reflectance fresnel values according to the default standard
  134953. * empirically know to work well :-)
  134954. */
  134955. set reflectionStandardFresnelWeight(value: number);
  134956. protected _useRGBColor: boolean;
  134957. /**
  134958. * Helps to directly use the maps channels instead of their level.
  134959. */
  134960. useRGBColor: boolean;
  134961. protected _enableNoise: boolean;
  134962. /**
  134963. * This helps reducing the banding effect that could occur on the background.
  134964. */
  134965. enableNoise: boolean;
  134966. /**
  134967. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134968. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  134969. * Recommended to be keep at 1.0 except for special cases.
  134970. */
  134971. get fovMultiplier(): number;
  134972. set fovMultiplier(value: number);
  134973. private _fovMultiplier;
  134974. /**
  134975. * Enable the FOV adjustment feature controlled by fovMultiplier.
  134976. */
  134977. useEquirectangularFOV: boolean;
  134978. private _maxSimultaneousLights;
  134979. /**
  134980. * Number of Simultaneous lights allowed on the material.
  134981. */
  134982. maxSimultaneousLights: int;
  134983. private _shadowOnly;
  134984. /**
  134985. * Make the material only render shadows
  134986. */
  134987. shadowOnly: boolean;
  134988. /**
  134989. * Default configuration related to image processing available in the Background Material.
  134990. */
  134991. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134992. /**
  134993. * Keep track of the image processing observer to allow dispose and replace.
  134994. */
  134995. private _imageProcessingObserver;
  134996. /**
  134997. * Attaches a new image processing configuration to the PBR Material.
  134998. * @param configuration (if null the scene configuration will be use)
  134999. */
  135000. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135001. /**
  135002. * Gets the image processing configuration used either in this material.
  135003. */
  135004. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  135005. /**
  135006. * Sets the Default image processing configuration used either in the this material.
  135007. *
  135008. * If sets to null, the scene one is in use.
  135009. */
  135010. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  135011. /**
  135012. * Gets wether the color curves effect is enabled.
  135013. */
  135014. get cameraColorCurvesEnabled(): boolean;
  135015. /**
  135016. * Sets wether the color curves effect is enabled.
  135017. */
  135018. set cameraColorCurvesEnabled(value: boolean);
  135019. /**
  135020. * Gets wether the color grading effect is enabled.
  135021. */
  135022. get cameraColorGradingEnabled(): boolean;
  135023. /**
  135024. * Gets wether the color grading effect is enabled.
  135025. */
  135026. set cameraColorGradingEnabled(value: boolean);
  135027. /**
  135028. * Gets wether tonemapping is enabled or not.
  135029. */
  135030. get cameraToneMappingEnabled(): boolean;
  135031. /**
  135032. * Sets wether tonemapping is enabled or not
  135033. */
  135034. set cameraToneMappingEnabled(value: boolean);
  135035. /**
  135036. * The camera exposure used on this material.
  135037. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135038. * This corresponds to a photographic exposure.
  135039. */
  135040. get cameraExposure(): float;
  135041. /**
  135042. * The camera exposure used on this material.
  135043. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135044. * This corresponds to a photographic exposure.
  135045. */
  135046. set cameraExposure(value: float);
  135047. /**
  135048. * Gets The camera contrast used on this material.
  135049. */
  135050. get cameraContrast(): float;
  135051. /**
  135052. * Sets The camera contrast used on this material.
  135053. */
  135054. set cameraContrast(value: float);
  135055. /**
  135056. * Gets the Color Grading 2D Lookup Texture.
  135057. */
  135058. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135059. /**
  135060. * Sets the Color Grading 2D Lookup Texture.
  135061. */
  135062. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135063. /**
  135064. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135065. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135066. * 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;
  135067. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135068. */
  135069. get cameraColorCurves(): Nullable<ColorCurves>;
  135070. /**
  135071. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135072. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135073. * 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;
  135074. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135075. */
  135076. set cameraColorCurves(value: Nullable<ColorCurves>);
  135077. /**
  135078. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  135079. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  135080. */
  135081. switchToBGR: boolean;
  135082. private _renderTargets;
  135083. private _reflectionControls;
  135084. private _white;
  135085. private _primaryShadowColor;
  135086. private _primaryHighlightColor;
  135087. /**
  135088. * Instantiates a Background Material in the given scene
  135089. * @param name The friendly name of the material
  135090. * @param scene The scene to add the material to
  135091. */
  135092. constructor(name: string, scene: Scene);
  135093. /**
  135094. * Gets a boolean indicating that current material needs to register RTT
  135095. */
  135096. get hasRenderTargetTextures(): boolean;
  135097. /**
  135098. * The entire material has been created in order to prevent overdraw.
  135099. * @returns false
  135100. */
  135101. needAlphaTesting(): boolean;
  135102. /**
  135103. * The entire material has been created in order to prevent overdraw.
  135104. * @returns true if blending is enable
  135105. */
  135106. needAlphaBlending(): boolean;
  135107. /**
  135108. * Checks wether the material is ready to be rendered for a given mesh.
  135109. * @param mesh The mesh to render
  135110. * @param subMesh The submesh to check against
  135111. * @param useInstances Specify wether or not the material is used with instances
  135112. * @returns true if all the dependencies are ready (Textures, Effects...)
  135113. */
  135114. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135115. /**
  135116. * Compute the primary color according to the chosen perceptual color.
  135117. */
  135118. private _computePrimaryColorFromPerceptualColor;
  135119. /**
  135120. * Compute the highlights and shadow colors according to their chosen levels.
  135121. */
  135122. private _computePrimaryColors;
  135123. /**
  135124. * Build the uniform buffer used in the material.
  135125. */
  135126. buildUniformLayout(): void;
  135127. /**
  135128. * Unbind the material.
  135129. */
  135130. unbind(): void;
  135131. /**
  135132. * Bind only the world matrix to the material.
  135133. * @param world The world matrix to bind.
  135134. */
  135135. bindOnlyWorldMatrix(world: Matrix): void;
  135136. /**
  135137. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  135138. * @param world The world matrix to bind.
  135139. * @param subMesh The submesh to bind for.
  135140. */
  135141. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135142. /**
  135143. * Checks to see if a texture is used in the material.
  135144. * @param texture - Base texture to use.
  135145. * @returns - Boolean specifying if a texture is used in the material.
  135146. */
  135147. hasTexture(texture: BaseTexture): boolean;
  135148. /**
  135149. * Dispose the material.
  135150. * @param forceDisposeEffect Force disposal of the associated effect.
  135151. * @param forceDisposeTextures Force disposal of the associated textures.
  135152. */
  135153. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135154. /**
  135155. * Clones the material.
  135156. * @param name The cloned name.
  135157. * @returns The cloned material.
  135158. */
  135159. clone(name: string): BackgroundMaterial;
  135160. /**
  135161. * Serializes the current material to its JSON representation.
  135162. * @returns The JSON representation.
  135163. */
  135164. serialize(): any;
  135165. /**
  135166. * Gets the class name of the material
  135167. * @returns "BackgroundMaterial"
  135168. */
  135169. getClassName(): string;
  135170. /**
  135171. * Parse a JSON input to create back a background material.
  135172. * @param source The JSON data to parse
  135173. * @param scene The scene to create the parsed material in
  135174. * @param rootUrl The root url of the assets the material depends upon
  135175. * @returns the instantiated BackgroundMaterial.
  135176. */
  135177. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  135178. }
  135179. }
  135180. declare module BABYLON {
  135181. /**
  135182. * Represents the different options available during the creation of
  135183. * a Environment helper.
  135184. *
  135185. * This can control the default ground, skybox and image processing setup of your scene.
  135186. */
  135187. export interface IEnvironmentHelperOptions {
  135188. /**
  135189. * Specifies whether or not to create a ground.
  135190. * True by default.
  135191. */
  135192. createGround: boolean;
  135193. /**
  135194. * Specifies the ground size.
  135195. * 15 by default.
  135196. */
  135197. groundSize: number;
  135198. /**
  135199. * The texture used on the ground for the main color.
  135200. * Comes from the BabylonJS CDN by default.
  135201. *
  135202. * Remarks: Can be either a texture or a url.
  135203. */
  135204. groundTexture: string | BaseTexture;
  135205. /**
  135206. * The color mixed in the ground texture by default.
  135207. * BabylonJS clearColor by default.
  135208. */
  135209. groundColor: Color3;
  135210. /**
  135211. * Specifies the ground opacity.
  135212. * 1 by default.
  135213. */
  135214. groundOpacity: number;
  135215. /**
  135216. * Enables the ground to receive shadows.
  135217. * True by default.
  135218. */
  135219. enableGroundShadow: boolean;
  135220. /**
  135221. * Helps preventing the shadow to be fully black on the ground.
  135222. * 0.5 by default.
  135223. */
  135224. groundShadowLevel: number;
  135225. /**
  135226. * Creates a mirror texture attach to the ground.
  135227. * false by default.
  135228. */
  135229. enableGroundMirror: boolean;
  135230. /**
  135231. * Specifies the ground mirror size ratio.
  135232. * 0.3 by default as the default kernel is 64.
  135233. */
  135234. groundMirrorSizeRatio: number;
  135235. /**
  135236. * Specifies the ground mirror blur kernel size.
  135237. * 64 by default.
  135238. */
  135239. groundMirrorBlurKernel: number;
  135240. /**
  135241. * Specifies the ground mirror visibility amount.
  135242. * 1 by default
  135243. */
  135244. groundMirrorAmount: number;
  135245. /**
  135246. * Specifies the ground mirror reflectance weight.
  135247. * This uses the standard weight of the background material to setup the fresnel effect
  135248. * of the mirror.
  135249. * 1 by default.
  135250. */
  135251. groundMirrorFresnelWeight: number;
  135252. /**
  135253. * Specifies the ground mirror Falloff distance.
  135254. * This can helps reducing the size of the reflection.
  135255. * 0 by Default.
  135256. */
  135257. groundMirrorFallOffDistance: number;
  135258. /**
  135259. * Specifies the ground mirror texture type.
  135260. * Unsigned Int by Default.
  135261. */
  135262. groundMirrorTextureType: number;
  135263. /**
  135264. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  135265. * the shown objects.
  135266. */
  135267. groundYBias: number;
  135268. /**
  135269. * Specifies whether or not to create a skybox.
  135270. * True by default.
  135271. */
  135272. createSkybox: boolean;
  135273. /**
  135274. * Specifies the skybox size.
  135275. * 20 by default.
  135276. */
  135277. skyboxSize: number;
  135278. /**
  135279. * The texture used on the skybox for the main color.
  135280. * Comes from the BabylonJS CDN by default.
  135281. *
  135282. * Remarks: Can be either a texture or a url.
  135283. */
  135284. skyboxTexture: string | BaseTexture;
  135285. /**
  135286. * The color mixed in the skybox texture by default.
  135287. * BabylonJS clearColor by default.
  135288. */
  135289. skyboxColor: Color3;
  135290. /**
  135291. * The background rotation around the Y axis of the scene.
  135292. * This helps aligning the key lights of your scene with the background.
  135293. * 0 by default.
  135294. */
  135295. backgroundYRotation: number;
  135296. /**
  135297. * Compute automatically the size of the elements to best fit with the scene.
  135298. */
  135299. sizeAuto: boolean;
  135300. /**
  135301. * Default position of the rootMesh if autoSize is not true.
  135302. */
  135303. rootPosition: Vector3;
  135304. /**
  135305. * Sets up the image processing in the scene.
  135306. * true by default.
  135307. */
  135308. setupImageProcessing: boolean;
  135309. /**
  135310. * The texture used as your environment texture in the scene.
  135311. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  135312. *
  135313. * Remarks: Can be either a texture or a url.
  135314. */
  135315. environmentTexture: string | BaseTexture;
  135316. /**
  135317. * The value of the exposure to apply to the scene.
  135318. * 0.6 by default if setupImageProcessing is true.
  135319. */
  135320. cameraExposure: number;
  135321. /**
  135322. * The value of the contrast to apply to the scene.
  135323. * 1.6 by default if setupImageProcessing is true.
  135324. */
  135325. cameraContrast: number;
  135326. /**
  135327. * Specifies whether or not tonemapping should be enabled in the scene.
  135328. * true by default if setupImageProcessing is true.
  135329. */
  135330. toneMappingEnabled: boolean;
  135331. }
  135332. /**
  135333. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  135334. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  135335. * It also helps with the default setup of your imageProcessing configuration.
  135336. */
  135337. export class EnvironmentHelper {
  135338. /**
  135339. * Default ground texture URL.
  135340. */
  135341. private static _groundTextureCDNUrl;
  135342. /**
  135343. * Default skybox texture URL.
  135344. */
  135345. private static _skyboxTextureCDNUrl;
  135346. /**
  135347. * Default environment texture URL.
  135348. */
  135349. private static _environmentTextureCDNUrl;
  135350. /**
  135351. * Creates the default options for the helper.
  135352. */
  135353. private static _getDefaultOptions;
  135354. private _rootMesh;
  135355. /**
  135356. * Gets the root mesh created by the helper.
  135357. */
  135358. get rootMesh(): Mesh;
  135359. private _skybox;
  135360. /**
  135361. * Gets the skybox created by the helper.
  135362. */
  135363. get skybox(): Nullable<Mesh>;
  135364. private _skyboxTexture;
  135365. /**
  135366. * Gets the skybox texture created by the helper.
  135367. */
  135368. get skyboxTexture(): Nullable<BaseTexture>;
  135369. private _skyboxMaterial;
  135370. /**
  135371. * Gets the skybox material created by the helper.
  135372. */
  135373. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  135374. private _ground;
  135375. /**
  135376. * Gets the ground mesh created by the helper.
  135377. */
  135378. get ground(): Nullable<Mesh>;
  135379. private _groundTexture;
  135380. /**
  135381. * Gets the ground texture created by the helper.
  135382. */
  135383. get groundTexture(): Nullable<BaseTexture>;
  135384. private _groundMirror;
  135385. /**
  135386. * Gets the ground mirror created by the helper.
  135387. */
  135388. get groundMirror(): Nullable<MirrorTexture>;
  135389. /**
  135390. * Gets the ground mirror render list to helps pushing the meshes
  135391. * you wish in the ground reflection.
  135392. */
  135393. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  135394. private _groundMaterial;
  135395. /**
  135396. * Gets the ground material created by the helper.
  135397. */
  135398. get groundMaterial(): Nullable<BackgroundMaterial>;
  135399. /**
  135400. * Stores the creation options.
  135401. */
  135402. private readonly _scene;
  135403. private _options;
  135404. /**
  135405. * This observable will be notified with any error during the creation of the environment,
  135406. * mainly texture creation errors.
  135407. */
  135408. onErrorObservable: Observable<{
  135409. message?: string;
  135410. exception?: any;
  135411. }>;
  135412. /**
  135413. * constructor
  135414. * @param options Defines the options we want to customize the helper
  135415. * @param scene The scene to add the material to
  135416. */
  135417. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  135418. /**
  135419. * Updates the background according to the new options
  135420. * @param options
  135421. */
  135422. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  135423. /**
  135424. * Sets the primary color of all the available elements.
  135425. * @param color the main color to affect to the ground and the background
  135426. */
  135427. setMainColor(color: Color3): void;
  135428. /**
  135429. * Setup the image processing according to the specified options.
  135430. */
  135431. private _setupImageProcessing;
  135432. /**
  135433. * Setup the environment texture according to the specified options.
  135434. */
  135435. private _setupEnvironmentTexture;
  135436. /**
  135437. * Setup the background according to the specified options.
  135438. */
  135439. private _setupBackground;
  135440. /**
  135441. * Get the scene sizes according to the setup.
  135442. */
  135443. private _getSceneSize;
  135444. /**
  135445. * Setup the ground according to the specified options.
  135446. */
  135447. private _setupGround;
  135448. /**
  135449. * Setup the ground material according to the specified options.
  135450. */
  135451. private _setupGroundMaterial;
  135452. /**
  135453. * Setup the ground diffuse texture according to the specified options.
  135454. */
  135455. private _setupGroundDiffuseTexture;
  135456. /**
  135457. * Setup the ground mirror texture according to the specified options.
  135458. */
  135459. private _setupGroundMirrorTexture;
  135460. /**
  135461. * Setup the ground to receive the mirror texture.
  135462. */
  135463. private _setupMirrorInGroundMaterial;
  135464. /**
  135465. * Setup the skybox according to the specified options.
  135466. */
  135467. private _setupSkybox;
  135468. /**
  135469. * Setup the skybox material according to the specified options.
  135470. */
  135471. private _setupSkyboxMaterial;
  135472. /**
  135473. * Setup the skybox reflection texture according to the specified options.
  135474. */
  135475. private _setupSkyboxReflectionTexture;
  135476. private _errorHandler;
  135477. /**
  135478. * Dispose all the elements created by the Helper.
  135479. */
  135480. dispose(): void;
  135481. }
  135482. }
  135483. declare module BABYLON {
  135484. /**
  135485. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  135486. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  135487. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135488. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135489. */
  135490. export abstract class TextureDome<T extends Texture> extends TransformNode {
  135491. protected onError: Nullable<(message?: string, exception?: any) => void>;
  135492. /**
  135493. * Define the source as a Monoscopic panoramic 360/180.
  135494. */
  135495. static readonly MODE_MONOSCOPIC: number;
  135496. /**
  135497. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  135498. */
  135499. static readonly MODE_TOPBOTTOM: number;
  135500. /**
  135501. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  135502. */
  135503. static readonly MODE_SIDEBYSIDE: number;
  135504. private _halfDome;
  135505. protected _useDirectMapping: boolean;
  135506. /**
  135507. * The texture being displayed on the sphere
  135508. */
  135509. protected _texture: T;
  135510. /**
  135511. * Gets the texture being displayed on the sphere
  135512. */
  135513. get texture(): T;
  135514. /**
  135515. * Sets the texture being displayed on the sphere
  135516. */
  135517. set texture(newTexture: T);
  135518. /**
  135519. * The skybox material
  135520. */
  135521. protected _material: BackgroundMaterial;
  135522. /**
  135523. * The surface used for the dome
  135524. */
  135525. protected _mesh: Mesh;
  135526. /**
  135527. * Gets the mesh used for the dome.
  135528. */
  135529. get mesh(): Mesh;
  135530. /**
  135531. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  135532. */
  135533. private _halfDomeMask;
  135534. /**
  135535. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135536. * Also see the options.resolution property.
  135537. */
  135538. get fovMultiplier(): number;
  135539. set fovMultiplier(value: number);
  135540. protected _textureMode: number;
  135541. /**
  135542. * Gets or set the current texture mode for the texture. It can be:
  135543. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135544. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135545. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135546. */
  135547. get textureMode(): number;
  135548. /**
  135549. * Sets the current texture mode for the texture. It can be:
  135550. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135551. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135552. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135553. */
  135554. set textureMode(value: number);
  135555. /**
  135556. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135557. */
  135558. get halfDome(): boolean;
  135559. /**
  135560. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135561. */
  135562. set halfDome(enabled: boolean);
  135563. /**
  135564. * Oberserver used in Stereoscopic VR Mode.
  135565. */
  135566. private _onBeforeCameraRenderObserver;
  135567. /**
  135568. * Observable raised when an error occured while loading the 360 image
  135569. */
  135570. onLoadErrorObservable: Observable<string>;
  135571. /**
  135572. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135573. * @param name Element's name, child elements will append suffixes for their own names.
  135574. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135575. * @param options An object containing optional or exposed sub element properties
  135576. */
  135577. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135578. resolution?: number;
  135579. clickToPlay?: boolean;
  135580. autoPlay?: boolean;
  135581. loop?: boolean;
  135582. size?: number;
  135583. poster?: string;
  135584. faceForward?: boolean;
  135585. useDirectMapping?: boolean;
  135586. halfDomeMode?: boolean;
  135587. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135588. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135589. protected _changeTextureMode(value: number): void;
  135590. /**
  135591. * Releases resources associated with this node.
  135592. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135593. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135594. */
  135595. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135596. }
  135597. }
  135598. declare module BABYLON {
  135599. /**
  135600. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135601. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135602. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135603. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135604. */
  135605. export class PhotoDome extends TextureDome<Texture> {
  135606. /**
  135607. * Define the image as a Monoscopic panoramic 360 image.
  135608. */
  135609. static readonly MODE_MONOSCOPIC: number;
  135610. /**
  135611. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135612. */
  135613. static readonly MODE_TOPBOTTOM: number;
  135614. /**
  135615. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135616. */
  135617. static readonly MODE_SIDEBYSIDE: number;
  135618. /**
  135619. * Gets or sets the texture being displayed on the sphere
  135620. */
  135621. get photoTexture(): Texture;
  135622. /**
  135623. * sets the texture being displayed on the sphere
  135624. */
  135625. set photoTexture(value: Texture);
  135626. /**
  135627. * Gets the current video mode for the video. It can be:
  135628. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135629. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135630. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135631. */
  135632. get imageMode(): number;
  135633. /**
  135634. * Sets the current video mode for the video. It can be:
  135635. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135636. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135637. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135638. */
  135639. set imageMode(value: number);
  135640. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135641. }
  135642. }
  135643. declare module BABYLON {
  135644. /**
  135645. * Class used to host RGBD texture specific utilities
  135646. */
  135647. export class RGBDTextureTools {
  135648. /**
  135649. * Expand the RGBD Texture from RGBD to Half Float if possible.
  135650. * @param texture the texture to expand.
  135651. */
  135652. static ExpandRGBDTexture(texture: Texture): void;
  135653. }
  135654. }
  135655. declare module BABYLON {
  135656. /**
  135657. * Class used to host texture specific utilities
  135658. */
  135659. export class BRDFTextureTools {
  135660. /**
  135661. * Prevents texture cache collision
  135662. */
  135663. private static _instanceNumber;
  135664. /**
  135665. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  135666. * @param scene defines the hosting scene
  135667. * @returns the environment BRDF texture
  135668. */
  135669. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  135670. private static _environmentBRDFBase64Texture;
  135671. }
  135672. }
  135673. declare module BABYLON {
  135674. /**
  135675. * @hidden
  135676. */
  135677. export interface IMaterialClearCoatDefines {
  135678. CLEARCOAT: boolean;
  135679. CLEARCOAT_DEFAULTIOR: boolean;
  135680. CLEARCOAT_TEXTURE: boolean;
  135681. CLEARCOAT_TEXTUREDIRECTUV: number;
  135682. CLEARCOAT_BUMP: boolean;
  135683. CLEARCOAT_BUMPDIRECTUV: number;
  135684. CLEARCOAT_TINT: boolean;
  135685. CLEARCOAT_TINT_TEXTURE: boolean;
  135686. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135687. /** @hidden */
  135688. _areTexturesDirty: boolean;
  135689. }
  135690. /**
  135691. * Define the code related to the clear coat parameters of the pbr material.
  135692. */
  135693. export class PBRClearCoatConfiguration {
  135694. /**
  135695. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135696. * The default fits with a polyurethane material.
  135697. */
  135698. private static readonly _DefaultIndexOfRefraction;
  135699. private _isEnabled;
  135700. /**
  135701. * Defines if the clear coat is enabled in the material.
  135702. */
  135703. isEnabled: boolean;
  135704. /**
  135705. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  135706. */
  135707. intensity: number;
  135708. /**
  135709. * Defines the clear coat layer roughness.
  135710. */
  135711. roughness: number;
  135712. private _indexOfRefraction;
  135713. /**
  135714. * Defines the index of refraction of the clear coat.
  135715. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135716. * The default fits with a polyurethane material.
  135717. * Changing the default value is more performance intensive.
  135718. */
  135719. indexOfRefraction: number;
  135720. private _texture;
  135721. /**
  135722. * Stores the clear coat values in a texture.
  135723. */
  135724. texture: Nullable<BaseTexture>;
  135725. private _bumpTexture;
  135726. /**
  135727. * Define the clear coat specific bump texture.
  135728. */
  135729. bumpTexture: Nullable<BaseTexture>;
  135730. private _isTintEnabled;
  135731. /**
  135732. * Defines if the clear coat tint is enabled in the material.
  135733. */
  135734. isTintEnabled: boolean;
  135735. /**
  135736. * Defines the clear coat tint of the material.
  135737. * This is only use if tint is enabled
  135738. */
  135739. tintColor: Color3;
  135740. /**
  135741. * Defines the distance at which the tint color should be found in the
  135742. * clear coat media.
  135743. * This is only use if tint is enabled
  135744. */
  135745. tintColorAtDistance: number;
  135746. /**
  135747. * Defines the clear coat layer thickness.
  135748. * This is only use if tint is enabled
  135749. */
  135750. tintThickness: number;
  135751. private _tintTexture;
  135752. /**
  135753. * Stores the clear tint values in a texture.
  135754. * rgb is tint
  135755. * a is a thickness factor
  135756. */
  135757. tintTexture: Nullable<BaseTexture>;
  135758. /** @hidden */
  135759. private _internalMarkAllSubMeshesAsTexturesDirty;
  135760. /** @hidden */
  135761. _markAllSubMeshesAsTexturesDirty(): void;
  135762. /**
  135763. * Instantiate a new istance of clear coat configuration.
  135764. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135765. */
  135766. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135767. /**
  135768. * Gets wehter the submesh is ready to be used or not.
  135769. * @param defines the list of "defines" to update.
  135770. * @param scene defines the scene the material belongs to.
  135771. * @param engine defines the engine the material belongs to.
  135772. * @param disableBumpMap defines wether the material disables bump or not.
  135773. * @returns - boolean indicating that the submesh is ready or not.
  135774. */
  135775. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  135776. /**
  135777. * Checks to see if a texture is used in the material.
  135778. * @param defines the list of "defines" to update.
  135779. * @param scene defines the scene to the material belongs to.
  135780. */
  135781. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  135782. /**
  135783. * Binds the material data.
  135784. * @param uniformBuffer defines the Uniform buffer to fill in.
  135785. * @param scene defines the scene the material belongs to.
  135786. * @param engine defines the engine the material belongs to.
  135787. * @param disableBumpMap defines wether the material disables bump or not.
  135788. * @param isFrozen defines wether the material is frozen or not.
  135789. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135790. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135791. */
  135792. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  135793. /**
  135794. * Checks to see if a texture is used in the material.
  135795. * @param texture - Base texture to use.
  135796. * @returns - Boolean specifying if a texture is used in the material.
  135797. */
  135798. hasTexture(texture: BaseTexture): boolean;
  135799. /**
  135800. * Returns an array of the actively used textures.
  135801. * @param activeTextures Array of BaseTextures
  135802. */
  135803. getActiveTextures(activeTextures: BaseTexture[]): void;
  135804. /**
  135805. * Returns the animatable textures.
  135806. * @param animatables Array of animatable textures.
  135807. */
  135808. getAnimatables(animatables: IAnimatable[]): void;
  135809. /**
  135810. * Disposes the resources of the material.
  135811. * @param forceDisposeTextures - Forces the disposal of all textures.
  135812. */
  135813. dispose(forceDisposeTextures?: boolean): void;
  135814. /**
  135815. * Get the current class name of the texture useful for serialization or dynamic coding.
  135816. * @returns "PBRClearCoatConfiguration"
  135817. */
  135818. getClassName(): string;
  135819. /**
  135820. * Add fallbacks to the effect fallbacks list.
  135821. * @param defines defines the Base texture to use.
  135822. * @param fallbacks defines the current fallback list.
  135823. * @param currentRank defines the current fallback rank.
  135824. * @returns the new fallback rank.
  135825. */
  135826. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135827. /**
  135828. * Add the required uniforms to the current list.
  135829. * @param uniforms defines the current uniform list.
  135830. */
  135831. static AddUniforms(uniforms: string[]): void;
  135832. /**
  135833. * Add the required samplers to the current list.
  135834. * @param samplers defines the current sampler list.
  135835. */
  135836. static AddSamplers(samplers: string[]): void;
  135837. /**
  135838. * Add the required uniforms to the current buffer.
  135839. * @param uniformBuffer defines the current uniform buffer.
  135840. */
  135841. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135842. /**
  135843. * Makes a duplicate of the current configuration into another one.
  135844. * @param clearCoatConfiguration define the config where to copy the info
  135845. */
  135846. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  135847. /**
  135848. * Serializes this clear coat configuration.
  135849. * @returns - An object with the serialized config.
  135850. */
  135851. serialize(): any;
  135852. /**
  135853. * Parses a anisotropy Configuration from a serialized object.
  135854. * @param source - Serialized object.
  135855. * @param scene Defines the scene we are parsing for
  135856. * @param rootUrl Defines the rootUrl to load from
  135857. */
  135858. parse(source: any, scene: Scene, rootUrl: string): void;
  135859. }
  135860. }
  135861. declare module BABYLON {
  135862. /**
  135863. * @hidden
  135864. */
  135865. export interface IMaterialAnisotropicDefines {
  135866. ANISOTROPIC: boolean;
  135867. ANISOTROPIC_TEXTURE: boolean;
  135868. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135869. MAINUV1: boolean;
  135870. _areTexturesDirty: boolean;
  135871. _needUVs: boolean;
  135872. }
  135873. /**
  135874. * Define the code related to the anisotropic parameters of the pbr material.
  135875. */
  135876. export class PBRAnisotropicConfiguration {
  135877. private _isEnabled;
  135878. /**
  135879. * Defines if the anisotropy is enabled in the material.
  135880. */
  135881. isEnabled: boolean;
  135882. /**
  135883. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135884. */
  135885. intensity: number;
  135886. /**
  135887. * Defines if the effect is along the tangents, bitangents or in between.
  135888. * By default, the effect is "strectching" the highlights along the tangents.
  135889. */
  135890. direction: Vector2;
  135891. private _texture;
  135892. /**
  135893. * Stores the anisotropy values in a texture.
  135894. * rg is direction (like normal from -1 to 1)
  135895. * b is a intensity
  135896. */
  135897. texture: Nullable<BaseTexture>;
  135898. /** @hidden */
  135899. private _internalMarkAllSubMeshesAsTexturesDirty;
  135900. /** @hidden */
  135901. _markAllSubMeshesAsTexturesDirty(): void;
  135902. /**
  135903. * Instantiate a new istance of anisotropy configuration.
  135904. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135905. */
  135906. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135907. /**
  135908. * Specifies that the submesh is ready to be used.
  135909. * @param defines the list of "defines" to update.
  135910. * @param scene defines the scene the material belongs to.
  135911. * @returns - boolean indicating that the submesh is ready or not.
  135912. */
  135913. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135914. /**
  135915. * Checks to see if a texture is used in the material.
  135916. * @param defines the list of "defines" to update.
  135917. * @param mesh the mesh we are preparing the defines for.
  135918. * @param scene defines the scene the material belongs to.
  135919. */
  135920. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135921. /**
  135922. * Binds the material data.
  135923. * @param uniformBuffer defines the Uniform buffer to fill in.
  135924. * @param scene defines the scene the material belongs to.
  135925. * @param isFrozen defines wether the material is frozen or not.
  135926. */
  135927. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135928. /**
  135929. * Checks to see if a texture is used in the material.
  135930. * @param texture - Base texture to use.
  135931. * @returns - Boolean specifying if a texture is used in the material.
  135932. */
  135933. hasTexture(texture: BaseTexture): boolean;
  135934. /**
  135935. * Returns an array of the actively used textures.
  135936. * @param activeTextures Array of BaseTextures
  135937. */
  135938. getActiveTextures(activeTextures: BaseTexture[]): void;
  135939. /**
  135940. * Returns the animatable textures.
  135941. * @param animatables Array of animatable textures.
  135942. */
  135943. getAnimatables(animatables: IAnimatable[]): void;
  135944. /**
  135945. * Disposes the resources of the material.
  135946. * @param forceDisposeTextures - Forces the disposal of all textures.
  135947. */
  135948. dispose(forceDisposeTextures?: boolean): void;
  135949. /**
  135950. * Get the current class name of the texture useful for serialization or dynamic coding.
  135951. * @returns "PBRAnisotropicConfiguration"
  135952. */
  135953. getClassName(): string;
  135954. /**
  135955. * Add fallbacks to the effect fallbacks list.
  135956. * @param defines defines the Base texture to use.
  135957. * @param fallbacks defines the current fallback list.
  135958. * @param currentRank defines the current fallback rank.
  135959. * @returns the new fallback rank.
  135960. */
  135961. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135962. /**
  135963. * Add the required uniforms to the current list.
  135964. * @param uniforms defines the current uniform list.
  135965. */
  135966. static AddUniforms(uniforms: string[]): void;
  135967. /**
  135968. * Add the required uniforms to the current buffer.
  135969. * @param uniformBuffer defines the current uniform buffer.
  135970. */
  135971. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135972. /**
  135973. * Add the required samplers to the current list.
  135974. * @param samplers defines the current sampler list.
  135975. */
  135976. static AddSamplers(samplers: string[]): void;
  135977. /**
  135978. * Makes a duplicate of the current configuration into another one.
  135979. * @param anisotropicConfiguration define the config where to copy the info
  135980. */
  135981. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  135982. /**
  135983. * Serializes this anisotropy configuration.
  135984. * @returns - An object with the serialized config.
  135985. */
  135986. serialize(): any;
  135987. /**
  135988. * Parses a anisotropy Configuration from a serialized object.
  135989. * @param source - Serialized object.
  135990. * @param scene Defines the scene we are parsing for
  135991. * @param rootUrl Defines the rootUrl to load from
  135992. */
  135993. parse(source: any, scene: Scene, rootUrl: string): void;
  135994. }
  135995. }
  135996. declare module BABYLON {
  135997. /**
  135998. * @hidden
  135999. */
  136000. export interface IMaterialBRDFDefines {
  136001. BRDF_V_HEIGHT_CORRELATED: boolean;
  136002. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136003. SPHERICAL_HARMONICS: boolean;
  136004. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136005. /** @hidden */
  136006. _areMiscDirty: boolean;
  136007. }
  136008. /**
  136009. * Define the code related to the BRDF parameters of the pbr material.
  136010. */
  136011. export class PBRBRDFConfiguration {
  136012. /**
  136013. * Default value used for the energy conservation.
  136014. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136015. */
  136016. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  136017. /**
  136018. * Default value used for the Smith Visibility Height Correlated mode.
  136019. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136020. */
  136021. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  136022. /**
  136023. * Default value used for the IBL diffuse part.
  136024. * This can help switching back to the polynomials mode globally which is a tiny bit
  136025. * less GPU intensive at the drawback of a lower quality.
  136026. */
  136027. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  136028. /**
  136029. * Default value used for activating energy conservation for the specular workflow.
  136030. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136031. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136032. */
  136033. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  136034. private _useEnergyConservation;
  136035. /**
  136036. * Defines if the material uses energy conservation.
  136037. */
  136038. useEnergyConservation: boolean;
  136039. private _useSmithVisibilityHeightCorrelated;
  136040. /**
  136041. * LEGACY Mode set to false
  136042. * Defines if the material uses height smith correlated visibility term.
  136043. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  136044. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  136045. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  136046. * Not relying on height correlated will also disable energy conservation.
  136047. */
  136048. useSmithVisibilityHeightCorrelated: boolean;
  136049. private _useSphericalHarmonics;
  136050. /**
  136051. * LEGACY Mode set to false
  136052. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  136053. * diffuse part of the IBL.
  136054. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  136055. * to the ground truth.
  136056. */
  136057. useSphericalHarmonics: boolean;
  136058. private _useSpecularGlossinessInputEnergyConservation;
  136059. /**
  136060. * Defines if the material uses energy conservation, when the specular workflow is active.
  136061. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136062. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136063. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  136064. */
  136065. useSpecularGlossinessInputEnergyConservation: boolean;
  136066. /** @hidden */
  136067. private _internalMarkAllSubMeshesAsMiscDirty;
  136068. /** @hidden */
  136069. _markAllSubMeshesAsMiscDirty(): void;
  136070. /**
  136071. * Instantiate a new istance of clear coat configuration.
  136072. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  136073. */
  136074. constructor(markAllSubMeshesAsMiscDirty: () => void);
  136075. /**
  136076. * Checks to see if a texture is used in the material.
  136077. * @param defines the list of "defines" to update.
  136078. */
  136079. prepareDefines(defines: IMaterialBRDFDefines): void;
  136080. /**
  136081. * Get the current class name of the texture useful for serialization or dynamic coding.
  136082. * @returns "PBRClearCoatConfiguration"
  136083. */
  136084. getClassName(): string;
  136085. /**
  136086. * Makes a duplicate of the current configuration into another one.
  136087. * @param brdfConfiguration define the config where to copy the info
  136088. */
  136089. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  136090. /**
  136091. * Serializes this BRDF configuration.
  136092. * @returns - An object with the serialized config.
  136093. */
  136094. serialize(): any;
  136095. /**
  136096. * Parses a anisotropy Configuration from a serialized object.
  136097. * @param source - Serialized object.
  136098. * @param scene Defines the scene we are parsing for
  136099. * @param rootUrl Defines the rootUrl to load from
  136100. */
  136101. parse(source: any, scene: Scene, rootUrl: string): void;
  136102. }
  136103. }
  136104. declare module BABYLON {
  136105. /**
  136106. * @hidden
  136107. */
  136108. export interface IMaterialSheenDefines {
  136109. SHEEN: boolean;
  136110. SHEEN_TEXTURE: boolean;
  136111. SHEEN_TEXTUREDIRECTUV: number;
  136112. SHEEN_LINKWITHALBEDO: boolean;
  136113. SHEEN_ROUGHNESS: boolean;
  136114. SHEEN_ALBEDOSCALING: boolean;
  136115. /** @hidden */
  136116. _areTexturesDirty: boolean;
  136117. }
  136118. /**
  136119. * Define the code related to the Sheen parameters of the pbr material.
  136120. */
  136121. export class PBRSheenConfiguration {
  136122. private _isEnabled;
  136123. /**
  136124. * Defines if the material uses sheen.
  136125. */
  136126. isEnabled: boolean;
  136127. private _linkSheenWithAlbedo;
  136128. /**
  136129. * Defines if the sheen is linked to the sheen color.
  136130. */
  136131. linkSheenWithAlbedo: boolean;
  136132. /**
  136133. * Defines the sheen intensity.
  136134. */
  136135. intensity: number;
  136136. /**
  136137. * Defines the sheen color.
  136138. */
  136139. color: Color3;
  136140. private _texture;
  136141. /**
  136142. * Stores the sheen tint values in a texture.
  136143. * rgb is tint
  136144. * a is a intensity or roughness if roughness has been defined
  136145. */
  136146. texture: Nullable<BaseTexture>;
  136147. private _roughness;
  136148. /**
  136149. * Defines the sheen roughness.
  136150. * It is not taken into account if linkSheenWithAlbedo is true.
  136151. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  136152. */
  136153. roughness: Nullable<number>;
  136154. private _albedoScaling;
  136155. /**
  136156. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  136157. * It allows the strength of the sheen effect to not depend on the base color of the material,
  136158. * making it easier to setup and tweak the effect
  136159. */
  136160. albedoScaling: boolean;
  136161. /** @hidden */
  136162. private _internalMarkAllSubMeshesAsTexturesDirty;
  136163. /** @hidden */
  136164. _markAllSubMeshesAsTexturesDirty(): void;
  136165. /**
  136166. * Instantiate a new istance of clear coat configuration.
  136167. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136168. */
  136169. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136170. /**
  136171. * Specifies that the submesh is ready to be used.
  136172. * @param defines the list of "defines" to update.
  136173. * @param scene defines the scene the material belongs to.
  136174. * @returns - boolean indicating that the submesh is ready or not.
  136175. */
  136176. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  136177. /**
  136178. * Checks to see if a texture is used in the material.
  136179. * @param defines the list of "defines" to update.
  136180. * @param scene defines the scene the material belongs to.
  136181. */
  136182. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  136183. /**
  136184. * Binds the material data.
  136185. * @param uniformBuffer defines the Uniform buffer to fill in.
  136186. * @param scene defines the scene the material belongs to.
  136187. * @param isFrozen defines wether the material is frozen or not.
  136188. */
  136189. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136190. /**
  136191. * Checks to see if a texture is used in the material.
  136192. * @param texture - Base texture to use.
  136193. * @returns - Boolean specifying if a texture is used in the material.
  136194. */
  136195. hasTexture(texture: BaseTexture): boolean;
  136196. /**
  136197. * Returns an array of the actively used textures.
  136198. * @param activeTextures Array of BaseTextures
  136199. */
  136200. getActiveTextures(activeTextures: BaseTexture[]): void;
  136201. /**
  136202. * Returns the animatable textures.
  136203. * @param animatables Array of animatable textures.
  136204. */
  136205. getAnimatables(animatables: IAnimatable[]): void;
  136206. /**
  136207. * Disposes the resources of the material.
  136208. * @param forceDisposeTextures - Forces the disposal of all textures.
  136209. */
  136210. dispose(forceDisposeTextures?: boolean): void;
  136211. /**
  136212. * Get the current class name of the texture useful for serialization or dynamic coding.
  136213. * @returns "PBRSheenConfiguration"
  136214. */
  136215. getClassName(): string;
  136216. /**
  136217. * Add fallbacks to the effect fallbacks list.
  136218. * @param defines defines the Base texture to use.
  136219. * @param fallbacks defines the current fallback list.
  136220. * @param currentRank defines the current fallback rank.
  136221. * @returns the new fallback rank.
  136222. */
  136223. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136224. /**
  136225. * Add the required uniforms to the current list.
  136226. * @param uniforms defines the current uniform list.
  136227. */
  136228. static AddUniforms(uniforms: string[]): void;
  136229. /**
  136230. * Add the required uniforms to the current buffer.
  136231. * @param uniformBuffer defines the current uniform buffer.
  136232. */
  136233. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136234. /**
  136235. * Add the required samplers to the current list.
  136236. * @param samplers defines the current sampler list.
  136237. */
  136238. static AddSamplers(samplers: string[]): void;
  136239. /**
  136240. * Makes a duplicate of the current configuration into another one.
  136241. * @param sheenConfiguration define the config where to copy the info
  136242. */
  136243. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  136244. /**
  136245. * Serializes this BRDF configuration.
  136246. * @returns - An object with the serialized config.
  136247. */
  136248. serialize(): any;
  136249. /**
  136250. * Parses a anisotropy Configuration from a serialized object.
  136251. * @param source - Serialized object.
  136252. * @param scene Defines the scene we are parsing for
  136253. * @param rootUrl Defines the rootUrl to load from
  136254. */
  136255. parse(source: any, scene: Scene, rootUrl: string): void;
  136256. }
  136257. }
  136258. declare module BABYLON {
  136259. /**
  136260. * @hidden
  136261. */
  136262. export interface IMaterialSubSurfaceDefines {
  136263. SUBSURFACE: boolean;
  136264. SS_REFRACTION: boolean;
  136265. SS_TRANSLUCENCY: boolean;
  136266. SS_SCATTERING: boolean;
  136267. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136268. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136269. SS_REFRACTIONMAP_3D: boolean;
  136270. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136271. SS_LODINREFRACTIONALPHA: boolean;
  136272. SS_GAMMAREFRACTION: boolean;
  136273. SS_RGBDREFRACTION: boolean;
  136274. SS_LINEARSPECULARREFRACTION: boolean;
  136275. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136276. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136277. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136278. /** @hidden */
  136279. _areTexturesDirty: boolean;
  136280. }
  136281. /**
  136282. * Define the code related to the sub surface parameters of the pbr material.
  136283. */
  136284. export class PBRSubSurfaceConfiguration {
  136285. private _isRefractionEnabled;
  136286. /**
  136287. * Defines if the refraction is enabled in the material.
  136288. */
  136289. isRefractionEnabled: boolean;
  136290. private _isTranslucencyEnabled;
  136291. /**
  136292. * Defines if the translucency is enabled in the material.
  136293. */
  136294. isTranslucencyEnabled: boolean;
  136295. private _isScatteringEnabled;
  136296. /**
  136297. * Defines if the sub surface scattering is enabled in the material.
  136298. */
  136299. isScatteringEnabled: boolean;
  136300. private _scatteringDiffusionProfileIndex;
  136301. /**
  136302. * Diffusion profile for subsurface scattering.
  136303. * Useful for better scattering in the skins or foliages.
  136304. */
  136305. get scatteringDiffusionProfile(): Nullable<Color3>;
  136306. set scatteringDiffusionProfile(c: Nullable<Color3>);
  136307. /**
  136308. * Defines the refraction intensity of the material.
  136309. * The refraction when enabled replaces the Diffuse part of the material.
  136310. * The intensity helps transitionning between diffuse and refraction.
  136311. */
  136312. refractionIntensity: number;
  136313. /**
  136314. * Defines the translucency intensity of the material.
  136315. * When translucency has been enabled, this defines how much of the "translucency"
  136316. * is addded to the diffuse part of the material.
  136317. */
  136318. translucencyIntensity: number;
  136319. /**
  136320. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  136321. */
  136322. useAlbedoToTintRefraction: boolean;
  136323. private _thicknessTexture;
  136324. /**
  136325. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  136326. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  136327. * 0 would mean minimumThickness
  136328. * 1 would mean maximumThickness
  136329. * The other channels might be use as a mask to vary the different effects intensity.
  136330. */
  136331. thicknessTexture: Nullable<BaseTexture>;
  136332. private _refractionTexture;
  136333. /**
  136334. * Defines the texture to use for refraction.
  136335. */
  136336. refractionTexture: Nullable<BaseTexture>;
  136337. private _indexOfRefraction;
  136338. /**
  136339. * Index of refraction of the material base layer.
  136340. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136341. *
  136342. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136343. *
  136344. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136345. */
  136346. indexOfRefraction: number;
  136347. private _volumeIndexOfRefraction;
  136348. /**
  136349. * Index of refraction of the material's volume.
  136350. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136351. *
  136352. * This ONLY impacts refraction. If not provided or given a non-valid value,
  136353. * the volume will use the same IOR as the surface.
  136354. */
  136355. get volumeIndexOfRefraction(): number;
  136356. set volumeIndexOfRefraction(value: number);
  136357. private _invertRefractionY;
  136358. /**
  136359. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136360. */
  136361. invertRefractionY: boolean;
  136362. private _linkRefractionWithTransparency;
  136363. /**
  136364. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136365. * Materials half opaque for instance using refraction could benefit from this control.
  136366. */
  136367. linkRefractionWithTransparency: boolean;
  136368. /**
  136369. * Defines the minimum thickness stored in the thickness map.
  136370. * If no thickness map is defined, this value will be used to simulate thickness.
  136371. */
  136372. minimumThickness: number;
  136373. /**
  136374. * Defines the maximum thickness stored in the thickness map.
  136375. */
  136376. maximumThickness: number;
  136377. /**
  136378. * Defines the volume tint of the material.
  136379. * This is used for both translucency and scattering.
  136380. */
  136381. tintColor: Color3;
  136382. /**
  136383. * Defines the distance at which the tint color should be found in the media.
  136384. * This is used for refraction only.
  136385. */
  136386. tintColorAtDistance: number;
  136387. /**
  136388. * Defines how far each channel transmit through the media.
  136389. * It is defined as a color to simplify it selection.
  136390. */
  136391. diffusionDistance: Color3;
  136392. private _useMaskFromThicknessTexture;
  136393. /**
  136394. * Stores the intensity of the different subsurface effects in the thickness texture.
  136395. * * the green channel is the translucency intensity.
  136396. * * the blue channel is the scattering intensity.
  136397. * * the alpha channel is the refraction intensity.
  136398. */
  136399. useMaskFromThicknessTexture: boolean;
  136400. private _scene;
  136401. /** @hidden */
  136402. private _internalMarkAllSubMeshesAsTexturesDirty;
  136403. private _internalMarkScenePrePassDirty;
  136404. /** @hidden */
  136405. _markAllSubMeshesAsTexturesDirty(): void;
  136406. /** @hidden */
  136407. _markScenePrePassDirty(): void;
  136408. /**
  136409. * Instantiate a new istance of sub surface configuration.
  136410. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136411. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  136412. * @param scene The scene
  136413. */
  136414. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  136415. /**
  136416. * Gets wehter the submesh is ready to be used or not.
  136417. * @param defines the list of "defines" to update.
  136418. * @param scene defines the scene the material belongs to.
  136419. * @returns - boolean indicating that the submesh is ready or not.
  136420. */
  136421. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  136422. /**
  136423. * Checks to see if a texture is used in the material.
  136424. * @param defines the list of "defines" to update.
  136425. * @param scene defines the scene to the material belongs to.
  136426. */
  136427. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  136428. /**
  136429. * Binds the material data.
  136430. * @param uniformBuffer defines the Uniform buffer to fill in.
  136431. * @param scene defines the scene the material belongs to.
  136432. * @param engine defines the engine the material belongs to.
  136433. * @param isFrozen defines whether the material is frozen or not.
  136434. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  136435. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  136436. */
  136437. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  136438. /**
  136439. * Unbinds the material from the mesh.
  136440. * @param activeEffect defines the effect that should be unbound from.
  136441. * @returns true if unbound, otherwise false
  136442. */
  136443. unbind(activeEffect: Effect): boolean;
  136444. /**
  136445. * Returns the texture used for refraction or null if none is used.
  136446. * @param scene defines the scene the material belongs to.
  136447. * @returns - Refraction texture if present. If no refraction texture and refraction
  136448. * is linked with transparency, returns environment texture. Otherwise, returns null.
  136449. */
  136450. private _getRefractionTexture;
  136451. /**
  136452. * Returns true if alpha blending should be disabled.
  136453. */
  136454. get disableAlphaBlending(): boolean;
  136455. /**
  136456. * Fills the list of render target textures.
  136457. * @param renderTargets the list of render targets to update
  136458. */
  136459. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  136460. /**
  136461. * Checks to see if a texture is used in the material.
  136462. * @param texture - Base texture to use.
  136463. * @returns - Boolean specifying if a texture is used in the material.
  136464. */
  136465. hasTexture(texture: BaseTexture): boolean;
  136466. /**
  136467. * Gets a boolean indicating that current material needs to register RTT
  136468. * @returns true if this uses a render target otherwise false.
  136469. */
  136470. hasRenderTargetTextures(): boolean;
  136471. /**
  136472. * Returns an array of the actively used textures.
  136473. * @param activeTextures Array of BaseTextures
  136474. */
  136475. getActiveTextures(activeTextures: BaseTexture[]): void;
  136476. /**
  136477. * Returns the animatable textures.
  136478. * @param animatables Array of animatable textures.
  136479. */
  136480. getAnimatables(animatables: IAnimatable[]): void;
  136481. /**
  136482. * Disposes the resources of the material.
  136483. * @param forceDisposeTextures - Forces the disposal of all textures.
  136484. */
  136485. dispose(forceDisposeTextures?: boolean): void;
  136486. /**
  136487. * Get the current class name of the texture useful for serialization or dynamic coding.
  136488. * @returns "PBRSubSurfaceConfiguration"
  136489. */
  136490. getClassName(): string;
  136491. /**
  136492. * Add fallbacks to the effect fallbacks list.
  136493. * @param defines defines the Base texture to use.
  136494. * @param fallbacks defines the current fallback list.
  136495. * @param currentRank defines the current fallback rank.
  136496. * @returns the new fallback rank.
  136497. */
  136498. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136499. /**
  136500. * Add the required uniforms to the current list.
  136501. * @param uniforms defines the current uniform list.
  136502. */
  136503. static AddUniforms(uniforms: string[]): void;
  136504. /**
  136505. * Add the required samplers to the current list.
  136506. * @param samplers defines the current sampler list.
  136507. */
  136508. static AddSamplers(samplers: string[]): void;
  136509. /**
  136510. * Add the required uniforms to the current buffer.
  136511. * @param uniformBuffer defines the current uniform buffer.
  136512. */
  136513. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136514. /**
  136515. * Makes a duplicate of the current configuration into another one.
  136516. * @param configuration define the config where to copy the info
  136517. */
  136518. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  136519. /**
  136520. * Serializes this Sub Surface configuration.
  136521. * @returns - An object with the serialized config.
  136522. */
  136523. serialize(): any;
  136524. /**
  136525. * Parses a anisotropy Configuration from a serialized object.
  136526. * @param source - Serialized object.
  136527. * @param scene Defines the scene we are parsing for
  136528. * @param rootUrl Defines the rootUrl to load from
  136529. */
  136530. parse(source: any, scene: Scene, rootUrl: string): void;
  136531. }
  136532. }
  136533. declare module BABYLON {
  136534. /** @hidden */
  136535. export var pbrFragmentDeclaration: {
  136536. name: string;
  136537. shader: string;
  136538. };
  136539. }
  136540. declare module BABYLON {
  136541. /** @hidden */
  136542. export var pbrUboDeclaration: {
  136543. name: string;
  136544. shader: string;
  136545. };
  136546. }
  136547. declare module BABYLON {
  136548. /** @hidden */
  136549. export var pbrFragmentExtraDeclaration: {
  136550. name: string;
  136551. shader: string;
  136552. };
  136553. }
  136554. declare module BABYLON {
  136555. /** @hidden */
  136556. export var pbrFragmentSamplersDeclaration: {
  136557. name: string;
  136558. shader: string;
  136559. };
  136560. }
  136561. declare module BABYLON {
  136562. /** @hidden */
  136563. export var subSurfaceScatteringFunctions: {
  136564. name: string;
  136565. shader: string;
  136566. };
  136567. }
  136568. declare module BABYLON {
  136569. /** @hidden */
  136570. export var importanceSampling: {
  136571. name: string;
  136572. shader: string;
  136573. };
  136574. }
  136575. declare module BABYLON {
  136576. /** @hidden */
  136577. export var pbrHelperFunctions: {
  136578. name: string;
  136579. shader: string;
  136580. };
  136581. }
  136582. declare module BABYLON {
  136583. /** @hidden */
  136584. export var harmonicsFunctions: {
  136585. name: string;
  136586. shader: string;
  136587. };
  136588. }
  136589. declare module BABYLON {
  136590. /** @hidden */
  136591. export var pbrDirectLightingSetupFunctions: {
  136592. name: string;
  136593. shader: string;
  136594. };
  136595. }
  136596. declare module BABYLON {
  136597. /** @hidden */
  136598. export var pbrDirectLightingFalloffFunctions: {
  136599. name: string;
  136600. shader: string;
  136601. };
  136602. }
  136603. declare module BABYLON {
  136604. /** @hidden */
  136605. export var pbrBRDFFunctions: {
  136606. name: string;
  136607. shader: string;
  136608. };
  136609. }
  136610. declare module BABYLON {
  136611. /** @hidden */
  136612. export var hdrFilteringFunctions: {
  136613. name: string;
  136614. shader: string;
  136615. };
  136616. }
  136617. declare module BABYLON {
  136618. /** @hidden */
  136619. export var pbrDirectLightingFunctions: {
  136620. name: string;
  136621. shader: string;
  136622. };
  136623. }
  136624. declare module BABYLON {
  136625. /** @hidden */
  136626. export var pbrIBLFunctions: {
  136627. name: string;
  136628. shader: string;
  136629. };
  136630. }
  136631. declare module BABYLON {
  136632. /** @hidden */
  136633. export var pbrBlockAlbedoOpacity: {
  136634. name: string;
  136635. shader: string;
  136636. };
  136637. }
  136638. declare module BABYLON {
  136639. /** @hidden */
  136640. export var pbrBlockReflectivity: {
  136641. name: string;
  136642. shader: string;
  136643. };
  136644. }
  136645. declare module BABYLON {
  136646. /** @hidden */
  136647. export var pbrBlockAmbientOcclusion: {
  136648. name: string;
  136649. shader: string;
  136650. };
  136651. }
  136652. declare module BABYLON {
  136653. /** @hidden */
  136654. export var pbrBlockAlphaFresnel: {
  136655. name: string;
  136656. shader: string;
  136657. };
  136658. }
  136659. declare module BABYLON {
  136660. /** @hidden */
  136661. export var pbrBlockAnisotropic: {
  136662. name: string;
  136663. shader: string;
  136664. };
  136665. }
  136666. declare module BABYLON {
  136667. /** @hidden */
  136668. export var pbrBlockReflection: {
  136669. name: string;
  136670. shader: string;
  136671. };
  136672. }
  136673. declare module BABYLON {
  136674. /** @hidden */
  136675. export var pbrBlockSheen: {
  136676. name: string;
  136677. shader: string;
  136678. };
  136679. }
  136680. declare module BABYLON {
  136681. /** @hidden */
  136682. export var pbrBlockClearcoat: {
  136683. name: string;
  136684. shader: string;
  136685. };
  136686. }
  136687. declare module BABYLON {
  136688. /** @hidden */
  136689. export var pbrBlockSubSurface: {
  136690. name: string;
  136691. shader: string;
  136692. };
  136693. }
  136694. declare module BABYLON {
  136695. /** @hidden */
  136696. export var pbrBlockNormalGeometric: {
  136697. name: string;
  136698. shader: string;
  136699. };
  136700. }
  136701. declare module BABYLON {
  136702. /** @hidden */
  136703. export var pbrBlockNormalFinal: {
  136704. name: string;
  136705. shader: string;
  136706. };
  136707. }
  136708. declare module BABYLON {
  136709. /** @hidden */
  136710. export var pbrBlockLightmapInit: {
  136711. name: string;
  136712. shader: string;
  136713. };
  136714. }
  136715. declare module BABYLON {
  136716. /** @hidden */
  136717. export var pbrBlockGeometryInfo: {
  136718. name: string;
  136719. shader: string;
  136720. };
  136721. }
  136722. declare module BABYLON {
  136723. /** @hidden */
  136724. export var pbrBlockReflectance0: {
  136725. name: string;
  136726. shader: string;
  136727. };
  136728. }
  136729. declare module BABYLON {
  136730. /** @hidden */
  136731. export var pbrBlockReflectance: {
  136732. name: string;
  136733. shader: string;
  136734. };
  136735. }
  136736. declare module BABYLON {
  136737. /** @hidden */
  136738. export var pbrBlockDirectLighting: {
  136739. name: string;
  136740. shader: string;
  136741. };
  136742. }
  136743. declare module BABYLON {
  136744. /** @hidden */
  136745. export var pbrBlockFinalLitComponents: {
  136746. name: string;
  136747. shader: string;
  136748. };
  136749. }
  136750. declare module BABYLON {
  136751. /** @hidden */
  136752. export var pbrBlockFinalUnlitComponents: {
  136753. name: string;
  136754. shader: string;
  136755. };
  136756. }
  136757. declare module BABYLON {
  136758. /** @hidden */
  136759. export var pbrBlockFinalColorComposition: {
  136760. name: string;
  136761. shader: string;
  136762. };
  136763. }
  136764. declare module BABYLON {
  136765. /** @hidden */
  136766. export var pbrBlockImageProcessing: {
  136767. name: string;
  136768. shader: string;
  136769. };
  136770. }
  136771. declare module BABYLON {
  136772. /** @hidden */
  136773. export var pbrDebug: {
  136774. name: string;
  136775. shader: string;
  136776. };
  136777. }
  136778. declare module BABYLON {
  136779. /** @hidden */
  136780. export var pbrPixelShader: {
  136781. name: string;
  136782. shader: string;
  136783. };
  136784. }
  136785. declare module BABYLON {
  136786. /** @hidden */
  136787. export var pbrVertexDeclaration: {
  136788. name: string;
  136789. shader: string;
  136790. };
  136791. }
  136792. declare module BABYLON {
  136793. /** @hidden */
  136794. export var pbrVertexShader: {
  136795. name: string;
  136796. shader: string;
  136797. };
  136798. }
  136799. declare module BABYLON {
  136800. /**
  136801. * Manages the defines for the PBR Material.
  136802. * @hidden
  136803. */
  136804. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  136805. PBR: boolean;
  136806. NUM_SAMPLES: string;
  136807. REALTIME_FILTERING: boolean;
  136808. MAINUV1: boolean;
  136809. MAINUV2: boolean;
  136810. UV1: boolean;
  136811. UV2: boolean;
  136812. ALBEDO: boolean;
  136813. GAMMAALBEDO: boolean;
  136814. ALBEDODIRECTUV: number;
  136815. VERTEXCOLOR: boolean;
  136816. DETAIL: boolean;
  136817. DETAILDIRECTUV: number;
  136818. DETAIL_NORMALBLENDMETHOD: number;
  136819. AMBIENT: boolean;
  136820. AMBIENTDIRECTUV: number;
  136821. AMBIENTINGRAYSCALE: boolean;
  136822. OPACITY: boolean;
  136823. VERTEXALPHA: boolean;
  136824. OPACITYDIRECTUV: number;
  136825. OPACITYRGB: boolean;
  136826. ALPHATEST: boolean;
  136827. DEPTHPREPASS: boolean;
  136828. ALPHABLEND: boolean;
  136829. ALPHAFROMALBEDO: boolean;
  136830. ALPHATESTVALUE: string;
  136831. SPECULAROVERALPHA: boolean;
  136832. RADIANCEOVERALPHA: boolean;
  136833. ALPHAFRESNEL: boolean;
  136834. LINEARALPHAFRESNEL: boolean;
  136835. PREMULTIPLYALPHA: boolean;
  136836. EMISSIVE: boolean;
  136837. EMISSIVEDIRECTUV: number;
  136838. REFLECTIVITY: boolean;
  136839. REFLECTIVITYDIRECTUV: number;
  136840. SPECULARTERM: boolean;
  136841. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  136842. MICROSURFACEAUTOMATIC: boolean;
  136843. LODBASEDMICROSFURACE: boolean;
  136844. MICROSURFACEMAP: boolean;
  136845. MICROSURFACEMAPDIRECTUV: number;
  136846. METALLICWORKFLOW: boolean;
  136847. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  136848. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  136849. METALLNESSSTOREINMETALMAPBLUE: boolean;
  136850. AOSTOREINMETALMAPRED: boolean;
  136851. METALLIC_REFLECTANCE: boolean;
  136852. METALLIC_REFLECTANCEDIRECTUV: number;
  136853. ENVIRONMENTBRDF: boolean;
  136854. ENVIRONMENTBRDF_RGBD: boolean;
  136855. NORMAL: boolean;
  136856. TANGENT: boolean;
  136857. BUMP: boolean;
  136858. BUMPDIRECTUV: number;
  136859. OBJECTSPACE_NORMALMAP: boolean;
  136860. PARALLAX: boolean;
  136861. PARALLAXOCCLUSION: boolean;
  136862. NORMALXYSCALE: boolean;
  136863. LIGHTMAP: boolean;
  136864. LIGHTMAPDIRECTUV: number;
  136865. USELIGHTMAPASSHADOWMAP: boolean;
  136866. GAMMALIGHTMAP: boolean;
  136867. RGBDLIGHTMAP: boolean;
  136868. REFLECTION: boolean;
  136869. REFLECTIONMAP_3D: boolean;
  136870. REFLECTIONMAP_SPHERICAL: boolean;
  136871. REFLECTIONMAP_PLANAR: boolean;
  136872. REFLECTIONMAP_CUBIC: boolean;
  136873. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  136874. REFLECTIONMAP_PROJECTION: boolean;
  136875. REFLECTIONMAP_SKYBOX: boolean;
  136876. REFLECTIONMAP_EXPLICIT: boolean;
  136877. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136878. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136879. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136880. INVERTCUBICMAP: boolean;
  136881. USESPHERICALFROMREFLECTIONMAP: boolean;
  136882. USEIRRADIANCEMAP: boolean;
  136883. SPHERICAL_HARMONICS: boolean;
  136884. USESPHERICALINVERTEX: boolean;
  136885. REFLECTIONMAP_OPPOSITEZ: boolean;
  136886. LODINREFLECTIONALPHA: boolean;
  136887. GAMMAREFLECTION: boolean;
  136888. RGBDREFLECTION: boolean;
  136889. LINEARSPECULARREFLECTION: boolean;
  136890. RADIANCEOCCLUSION: boolean;
  136891. HORIZONOCCLUSION: boolean;
  136892. INSTANCES: boolean;
  136893. THIN_INSTANCES: boolean;
  136894. PREPASS: boolean;
  136895. PREPASS_IRRADIANCE: boolean;
  136896. PREPASS_IRRADIANCE_INDEX: number;
  136897. PREPASS_ALBEDO: boolean;
  136898. PREPASS_ALBEDO_INDEX: number;
  136899. PREPASS_DEPTHNORMAL: boolean;
  136900. PREPASS_DEPTHNORMAL_INDEX: number;
  136901. SCENE_MRT_COUNT: number;
  136902. NUM_BONE_INFLUENCERS: number;
  136903. BonesPerMesh: number;
  136904. BONETEXTURE: boolean;
  136905. NONUNIFORMSCALING: boolean;
  136906. MORPHTARGETS: boolean;
  136907. MORPHTARGETS_NORMAL: boolean;
  136908. MORPHTARGETS_TANGENT: boolean;
  136909. MORPHTARGETS_UV: boolean;
  136910. NUM_MORPH_INFLUENCERS: number;
  136911. IMAGEPROCESSING: boolean;
  136912. VIGNETTE: boolean;
  136913. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136914. VIGNETTEBLENDMODEOPAQUE: boolean;
  136915. TONEMAPPING: boolean;
  136916. TONEMAPPING_ACES: boolean;
  136917. CONTRAST: boolean;
  136918. COLORCURVES: boolean;
  136919. COLORGRADING: boolean;
  136920. COLORGRADING3D: boolean;
  136921. SAMPLER3DGREENDEPTH: boolean;
  136922. SAMPLER3DBGRMAP: boolean;
  136923. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136924. EXPOSURE: boolean;
  136925. MULTIVIEW: boolean;
  136926. USEPHYSICALLIGHTFALLOFF: boolean;
  136927. USEGLTFLIGHTFALLOFF: boolean;
  136928. TWOSIDEDLIGHTING: boolean;
  136929. SHADOWFLOAT: boolean;
  136930. CLIPPLANE: boolean;
  136931. CLIPPLANE2: boolean;
  136932. CLIPPLANE3: boolean;
  136933. CLIPPLANE4: boolean;
  136934. CLIPPLANE5: boolean;
  136935. CLIPPLANE6: boolean;
  136936. POINTSIZE: boolean;
  136937. FOG: boolean;
  136938. LOGARITHMICDEPTH: boolean;
  136939. FORCENORMALFORWARD: boolean;
  136940. SPECULARAA: boolean;
  136941. CLEARCOAT: boolean;
  136942. CLEARCOAT_DEFAULTIOR: boolean;
  136943. CLEARCOAT_TEXTURE: boolean;
  136944. CLEARCOAT_TEXTUREDIRECTUV: number;
  136945. CLEARCOAT_BUMP: boolean;
  136946. CLEARCOAT_BUMPDIRECTUV: number;
  136947. CLEARCOAT_TINT: boolean;
  136948. CLEARCOAT_TINT_TEXTURE: boolean;
  136949. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136950. ANISOTROPIC: boolean;
  136951. ANISOTROPIC_TEXTURE: boolean;
  136952. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136953. BRDF_V_HEIGHT_CORRELATED: boolean;
  136954. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136955. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136956. SHEEN: boolean;
  136957. SHEEN_TEXTURE: boolean;
  136958. SHEEN_TEXTUREDIRECTUV: number;
  136959. SHEEN_LINKWITHALBEDO: boolean;
  136960. SHEEN_ROUGHNESS: boolean;
  136961. SHEEN_ALBEDOSCALING: boolean;
  136962. SUBSURFACE: boolean;
  136963. SS_REFRACTION: boolean;
  136964. SS_TRANSLUCENCY: boolean;
  136965. SS_SCATTERING: boolean;
  136966. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136967. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136968. SS_REFRACTIONMAP_3D: boolean;
  136969. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136970. SS_LODINREFRACTIONALPHA: boolean;
  136971. SS_GAMMAREFRACTION: boolean;
  136972. SS_RGBDREFRACTION: boolean;
  136973. SS_LINEARSPECULARREFRACTION: boolean;
  136974. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136975. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136976. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136977. UNLIT: boolean;
  136978. DEBUGMODE: number;
  136979. /**
  136980. * Initializes the PBR Material defines.
  136981. */
  136982. constructor();
  136983. /**
  136984. * Resets the PBR Material defines.
  136985. */
  136986. reset(): void;
  136987. }
  136988. /**
  136989. * The Physically based material base class of BJS.
  136990. *
  136991. * This offers the main features of a standard PBR material.
  136992. * For more information, please refer to the documentation :
  136993. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136994. */
  136995. export abstract class PBRBaseMaterial extends PushMaterial {
  136996. /**
  136997. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136998. */
  136999. static readonly PBRMATERIAL_OPAQUE: number;
  137000. /**
  137001. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137002. */
  137003. static readonly PBRMATERIAL_ALPHATEST: number;
  137004. /**
  137005. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137006. */
  137007. static readonly PBRMATERIAL_ALPHABLEND: number;
  137008. /**
  137009. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137010. * They are also discarded below the alpha cutoff threshold to improve performances.
  137011. */
  137012. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137013. /**
  137014. * Defines the default value of how much AO map is occluding the analytical lights
  137015. * (point spot...).
  137016. */
  137017. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137018. /**
  137019. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  137020. */
  137021. static readonly LIGHTFALLOFF_PHYSICAL: number;
  137022. /**
  137023. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  137024. * to enhance interoperability with other engines.
  137025. */
  137026. static readonly LIGHTFALLOFF_GLTF: number;
  137027. /**
  137028. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  137029. * to enhance interoperability with other materials.
  137030. */
  137031. static readonly LIGHTFALLOFF_STANDARD: number;
  137032. /**
  137033. * Intensity of the direct lights e.g. the four lights available in your scene.
  137034. * This impacts both the direct diffuse and specular highlights.
  137035. */
  137036. protected _directIntensity: number;
  137037. /**
  137038. * Intensity of the emissive part of the material.
  137039. * This helps controlling the emissive effect without modifying the emissive color.
  137040. */
  137041. protected _emissiveIntensity: number;
  137042. /**
  137043. * Intensity of the environment e.g. how much the environment will light the object
  137044. * either through harmonics for rough material or through the refelction for shiny ones.
  137045. */
  137046. protected _environmentIntensity: number;
  137047. /**
  137048. * This is a special control allowing the reduction of the specular highlights coming from the
  137049. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137050. */
  137051. protected _specularIntensity: number;
  137052. /**
  137053. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  137054. */
  137055. private _lightingInfos;
  137056. /**
  137057. * Debug Control allowing disabling the bump map on this material.
  137058. */
  137059. protected _disableBumpMap: boolean;
  137060. /**
  137061. * AKA Diffuse Texture in standard nomenclature.
  137062. */
  137063. protected _albedoTexture: Nullable<BaseTexture>;
  137064. /**
  137065. * AKA Occlusion Texture in other nomenclature.
  137066. */
  137067. protected _ambientTexture: Nullable<BaseTexture>;
  137068. /**
  137069. * AKA Occlusion Texture Intensity in other nomenclature.
  137070. */
  137071. protected _ambientTextureStrength: number;
  137072. /**
  137073. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137074. * 1 means it completely occludes it
  137075. * 0 mean it has no impact
  137076. */
  137077. protected _ambientTextureImpactOnAnalyticalLights: number;
  137078. /**
  137079. * Stores the alpha values in a texture.
  137080. */
  137081. protected _opacityTexture: Nullable<BaseTexture>;
  137082. /**
  137083. * Stores the reflection values in a texture.
  137084. */
  137085. protected _reflectionTexture: Nullable<BaseTexture>;
  137086. /**
  137087. * Stores the emissive values in a texture.
  137088. */
  137089. protected _emissiveTexture: Nullable<BaseTexture>;
  137090. /**
  137091. * AKA Specular texture in other nomenclature.
  137092. */
  137093. protected _reflectivityTexture: Nullable<BaseTexture>;
  137094. /**
  137095. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137096. */
  137097. protected _metallicTexture: Nullable<BaseTexture>;
  137098. /**
  137099. * Specifies the metallic scalar of the metallic/roughness workflow.
  137100. * Can also be used to scale the metalness values of the metallic texture.
  137101. */
  137102. protected _metallic: Nullable<number>;
  137103. /**
  137104. * Specifies the roughness scalar of the metallic/roughness workflow.
  137105. * Can also be used to scale the roughness values of the metallic texture.
  137106. */
  137107. protected _roughness: Nullable<number>;
  137108. /**
  137109. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137110. * By default the indexOfrefraction is used to compute F0;
  137111. *
  137112. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137113. *
  137114. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137115. * F90 = metallicReflectanceColor;
  137116. */
  137117. protected _metallicF0Factor: number;
  137118. /**
  137119. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137120. * By default the F90 is always 1;
  137121. *
  137122. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137123. *
  137124. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137125. * F90 = metallicReflectanceColor;
  137126. */
  137127. protected _metallicReflectanceColor: Color3;
  137128. /**
  137129. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137130. * This is multiply against the scalar values defined in the material.
  137131. */
  137132. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  137133. /**
  137134. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137135. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137136. */
  137137. protected _microSurfaceTexture: Nullable<BaseTexture>;
  137138. /**
  137139. * Stores surface normal data used to displace a mesh in a texture.
  137140. */
  137141. protected _bumpTexture: Nullable<BaseTexture>;
  137142. /**
  137143. * Stores the pre-calculated light information of a mesh in a texture.
  137144. */
  137145. protected _lightmapTexture: Nullable<BaseTexture>;
  137146. /**
  137147. * The color of a material in ambient lighting.
  137148. */
  137149. protected _ambientColor: Color3;
  137150. /**
  137151. * AKA Diffuse Color in other nomenclature.
  137152. */
  137153. protected _albedoColor: Color3;
  137154. /**
  137155. * AKA Specular Color in other nomenclature.
  137156. */
  137157. protected _reflectivityColor: Color3;
  137158. /**
  137159. * The color applied when light is reflected from a material.
  137160. */
  137161. protected _reflectionColor: Color3;
  137162. /**
  137163. * The color applied when light is emitted from a material.
  137164. */
  137165. protected _emissiveColor: Color3;
  137166. /**
  137167. * AKA Glossiness in other nomenclature.
  137168. */
  137169. protected _microSurface: number;
  137170. /**
  137171. * Specifies that the material will use the light map as a show map.
  137172. */
  137173. protected _useLightmapAsShadowmap: boolean;
  137174. /**
  137175. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137176. * makes the reflect vector face the model (under horizon).
  137177. */
  137178. protected _useHorizonOcclusion: boolean;
  137179. /**
  137180. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137181. * too much the area relying on ambient texture to define their ambient occlusion.
  137182. */
  137183. protected _useRadianceOcclusion: boolean;
  137184. /**
  137185. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137186. */
  137187. protected _useAlphaFromAlbedoTexture: boolean;
  137188. /**
  137189. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  137190. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137191. */
  137192. protected _useSpecularOverAlpha: boolean;
  137193. /**
  137194. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137195. */
  137196. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137197. /**
  137198. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137199. */
  137200. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  137201. /**
  137202. * Specifies if the metallic texture contains the roughness information in its green channel.
  137203. */
  137204. protected _useRoughnessFromMetallicTextureGreen: boolean;
  137205. /**
  137206. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137207. */
  137208. protected _useMetallnessFromMetallicTextureBlue: boolean;
  137209. /**
  137210. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137211. */
  137212. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  137213. /**
  137214. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137215. */
  137216. protected _useAmbientInGrayScale: boolean;
  137217. /**
  137218. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137219. * The material will try to infer what glossiness each pixel should be.
  137220. */
  137221. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  137222. /**
  137223. * Defines the falloff type used in this material.
  137224. * It by default is Physical.
  137225. */
  137226. protected _lightFalloff: number;
  137227. /**
  137228. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137229. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137230. */
  137231. protected _useRadianceOverAlpha: boolean;
  137232. /**
  137233. * Allows using an object space normal map (instead of tangent space).
  137234. */
  137235. protected _useObjectSpaceNormalMap: boolean;
  137236. /**
  137237. * Allows using the bump map in parallax mode.
  137238. */
  137239. protected _useParallax: boolean;
  137240. /**
  137241. * Allows using the bump map in parallax occlusion mode.
  137242. */
  137243. protected _useParallaxOcclusion: boolean;
  137244. /**
  137245. * Controls the scale bias of the parallax mode.
  137246. */
  137247. protected _parallaxScaleBias: number;
  137248. /**
  137249. * If sets to true, disables all the lights affecting the material.
  137250. */
  137251. protected _disableLighting: boolean;
  137252. /**
  137253. * Number of Simultaneous lights allowed on the material.
  137254. */
  137255. protected _maxSimultaneousLights: number;
  137256. /**
  137257. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  137258. */
  137259. protected _invertNormalMapX: boolean;
  137260. /**
  137261. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  137262. */
  137263. protected _invertNormalMapY: boolean;
  137264. /**
  137265. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137266. */
  137267. protected _twoSidedLighting: boolean;
  137268. /**
  137269. * Defines the alpha limits in alpha test mode.
  137270. */
  137271. protected _alphaCutOff: number;
  137272. /**
  137273. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137274. */
  137275. protected _forceAlphaTest: boolean;
  137276. /**
  137277. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137278. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137279. */
  137280. protected _useAlphaFresnel: boolean;
  137281. /**
  137282. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137283. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137284. */
  137285. protected _useLinearAlphaFresnel: boolean;
  137286. /**
  137287. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  137288. * from cos thetav and roughness:
  137289. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  137290. */
  137291. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  137292. /**
  137293. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137294. */
  137295. protected _forceIrradianceInFragment: boolean;
  137296. private _realTimeFiltering;
  137297. /**
  137298. * Enables realtime filtering on the texture.
  137299. */
  137300. get realTimeFiltering(): boolean;
  137301. set realTimeFiltering(b: boolean);
  137302. private _realTimeFilteringQuality;
  137303. /**
  137304. * Quality switch for realtime filtering
  137305. */
  137306. get realTimeFilteringQuality(): number;
  137307. set realTimeFilteringQuality(n: number);
  137308. /**
  137309. * Can this material render to several textures at once
  137310. */
  137311. get canRenderToMRT(): boolean;
  137312. /**
  137313. * Force normal to face away from face.
  137314. */
  137315. protected _forceNormalForward: boolean;
  137316. /**
  137317. * Enables specular anti aliasing in the PBR shader.
  137318. * It will both interacts on the Geometry for analytical and IBL lighting.
  137319. * It also prefilter the roughness map based on the bump values.
  137320. */
  137321. protected _enableSpecularAntiAliasing: boolean;
  137322. /**
  137323. * Default configuration related to image processing available in the PBR Material.
  137324. */
  137325. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  137326. /**
  137327. * Keep track of the image processing observer to allow dispose and replace.
  137328. */
  137329. private _imageProcessingObserver;
  137330. /**
  137331. * Attaches a new image processing configuration to the PBR Material.
  137332. * @param configuration
  137333. */
  137334. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  137335. /**
  137336. * Stores the available render targets.
  137337. */
  137338. private _renderTargets;
  137339. /**
  137340. * Sets the global ambient color for the material used in lighting calculations.
  137341. */
  137342. private _globalAmbientColor;
  137343. /**
  137344. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  137345. */
  137346. private _useLogarithmicDepth;
  137347. /**
  137348. * If set to true, no lighting calculations will be applied.
  137349. */
  137350. private _unlit;
  137351. private _debugMode;
  137352. /**
  137353. * @hidden
  137354. * This is reserved for the inspector.
  137355. * Defines the material debug mode.
  137356. * It helps seeing only some components of the material while troubleshooting.
  137357. */
  137358. debugMode: number;
  137359. /**
  137360. * @hidden
  137361. * This is reserved for the inspector.
  137362. * Specify from where on screen the debug mode should start.
  137363. * The value goes from -1 (full screen) to 1 (not visible)
  137364. * It helps with side by side comparison against the final render
  137365. * This defaults to -1
  137366. */
  137367. private debugLimit;
  137368. /**
  137369. * @hidden
  137370. * This is reserved for the inspector.
  137371. * As the default viewing range might not be enough (if the ambient is really small for instance)
  137372. * You can use the factor to better multiply the final value.
  137373. */
  137374. private debugFactor;
  137375. /**
  137376. * Defines the clear coat layer parameters for the material.
  137377. */
  137378. readonly clearCoat: PBRClearCoatConfiguration;
  137379. /**
  137380. * Defines the anisotropic parameters for the material.
  137381. */
  137382. readonly anisotropy: PBRAnisotropicConfiguration;
  137383. /**
  137384. * Defines the BRDF parameters for the material.
  137385. */
  137386. readonly brdf: PBRBRDFConfiguration;
  137387. /**
  137388. * Defines the Sheen parameters for the material.
  137389. */
  137390. readonly sheen: PBRSheenConfiguration;
  137391. /**
  137392. * Defines the SubSurface parameters for the material.
  137393. */
  137394. readonly subSurface: PBRSubSurfaceConfiguration;
  137395. /**
  137396. * Defines the detail map parameters for the material.
  137397. */
  137398. readonly detailMap: DetailMapConfiguration;
  137399. protected _rebuildInParallel: boolean;
  137400. /**
  137401. * Instantiates a new PBRMaterial instance.
  137402. *
  137403. * @param name The material name
  137404. * @param scene The scene the material will be use in.
  137405. */
  137406. constructor(name: string, scene: Scene);
  137407. /**
  137408. * Gets a boolean indicating that current material needs to register RTT
  137409. */
  137410. get hasRenderTargetTextures(): boolean;
  137411. /**
  137412. * Gets the name of the material class.
  137413. */
  137414. getClassName(): string;
  137415. /**
  137416. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137417. */
  137418. get useLogarithmicDepth(): boolean;
  137419. /**
  137420. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137421. */
  137422. set useLogarithmicDepth(value: boolean);
  137423. /**
  137424. * Returns true if alpha blending should be disabled.
  137425. */
  137426. protected get _disableAlphaBlending(): boolean;
  137427. /**
  137428. * Specifies whether or not this material should be rendered in alpha blend mode.
  137429. */
  137430. needAlphaBlending(): boolean;
  137431. /**
  137432. * Specifies whether or not this material should be rendered in alpha test mode.
  137433. */
  137434. needAlphaTesting(): boolean;
  137435. /**
  137436. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  137437. */
  137438. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  137439. /**
  137440. * Gets the texture used for the alpha test.
  137441. */
  137442. getAlphaTestTexture(): Nullable<BaseTexture>;
  137443. /**
  137444. * Specifies that the submesh is ready to be used.
  137445. * @param mesh - BJS mesh.
  137446. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  137447. * @param useInstances - Specifies that instances should be used.
  137448. * @returns - boolean indicating that the submesh is ready or not.
  137449. */
  137450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  137451. /**
  137452. * Specifies if the material uses metallic roughness workflow.
  137453. * @returns boolean specifiying if the material uses metallic roughness workflow.
  137454. */
  137455. isMetallicWorkflow(): boolean;
  137456. private _prepareEffect;
  137457. private _prepareDefines;
  137458. /**
  137459. * Force shader compilation
  137460. */
  137461. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  137462. /**
  137463. * Initializes the uniform buffer layout for the shader.
  137464. */
  137465. buildUniformLayout(): void;
  137466. /**
  137467. * Unbinds the material from the mesh
  137468. */
  137469. unbind(): void;
  137470. /**
  137471. * Binds the submesh data.
  137472. * @param world - The world matrix.
  137473. * @param mesh - The BJS mesh.
  137474. * @param subMesh - A submesh of the BJS mesh.
  137475. */
  137476. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  137477. /**
  137478. * Returns the animatable textures.
  137479. * @returns - Array of animatable textures.
  137480. */
  137481. getAnimatables(): IAnimatable[];
  137482. /**
  137483. * Returns the texture used for reflections.
  137484. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  137485. */
  137486. private _getReflectionTexture;
  137487. /**
  137488. * Returns an array of the actively used textures.
  137489. * @returns - Array of BaseTextures
  137490. */
  137491. getActiveTextures(): BaseTexture[];
  137492. /**
  137493. * Checks to see if a texture is used in the material.
  137494. * @param texture - Base texture to use.
  137495. * @returns - Boolean specifying if a texture is used in the material.
  137496. */
  137497. hasTexture(texture: BaseTexture): boolean;
  137498. /**
  137499. * Sets the required values to the prepass renderer.
  137500. * @param prePassRenderer defines the prepass renderer to setup
  137501. */
  137502. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  137503. /**
  137504. * Disposes the resources of the material.
  137505. * @param forceDisposeEffect - Forces the disposal of effects.
  137506. * @param forceDisposeTextures - Forces the disposal of all textures.
  137507. */
  137508. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  137509. }
  137510. }
  137511. declare module BABYLON {
  137512. /**
  137513. * The Physically based material of BJS.
  137514. *
  137515. * This offers the main features of a standard PBR material.
  137516. * For more information, please refer to the documentation :
  137517. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137518. */
  137519. export class PBRMaterial extends PBRBaseMaterial {
  137520. /**
  137521. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137522. */
  137523. static readonly PBRMATERIAL_OPAQUE: number;
  137524. /**
  137525. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137526. */
  137527. static readonly PBRMATERIAL_ALPHATEST: number;
  137528. /**
  137529. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137530. */
  137531. static readonly PBRMATERIAL_ALPHABLEND: number;
  137532. /**
  137533. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137534. * They are also discarded below the alpha cutoff threshold to improve performances.
  137535. */
  137536. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137537. /**
  137538. * Defines the default value of how much AO map is occluding the analytical lights
  137539. * (point spot...).
  137540. */
  137541. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137542. /**
  137543. * Intensity of the direct lights e.g. the four lights available in your scene.
  137544. * This impacts both the direct diffuse and specular highlights.
  137545. */
  137546. directIntensity: number;
  137547. /**
  137548. * Intensity of the emissive part of the material.
  137549. * This helps controlling the emissive effect without modifying the emissive color.
  137550. */
  137551. emissiveIntensity: number;
  137552. /**
  137553. * Intensity of the environment e.g. how much the environment will light the object
  137554. * either through harmonics for rough material or through the refelction for shiny ones.
  137555. */
  137556. environmentIntensity: number;
  137557. /**
  137558. * This is a special control allowing the reduction of the specular highlights coming from the
  137559. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137560. */
  137561. specularIntensity: number;
  137562. /**
  137563. * Debug Control allowing disabling the bump map on this material.
  137564. */
  137565. disableBumpMap: boolean;
  137566. /**
  137567. * AKA Diffuse Texture in standard nomenclature.
  137568. */
  137569. albedoTexture: BaseTexture;
  137570. /**
  137571. * AKA Occlusion Texture in other nomenclature.
  137572. */
  137573. ambientTexture: BaseTexture;
  137574. /**
  137575. * AKA Occlusion Texture Intensity in other nomenclature.
  137576. */
  137577. ambientTextureStrength: number;
  137578. /**
  137579. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137580. * 1 means it completely occludes it
  137581. * 0 mean it has no impact
  137582. */
  137583. ambientTextureImpactOnAnalyticalLights: number;
  137584. /**
  137585. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137586. */
  137587. opacityTexture: BaseTexture;
  137588. /**
  137589. * Stores the reflection values in a texture.
  137590. */
  137591. reflectionTexture: Nullable<BaseTexture>;
  137592. /**
  137593. * Stores the emissive values in a texture.
  137594. */
  137595. emissiveTexture: BaseTexture;
  137596. /**
  137597. * AKA Specular texture in other nomenclature.
  137598. */
  137599. reflectivityTexture: BaseTexture;
  137600. /**
  137601. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137602. */
  137603. metallicTexture: BaseTexture;
  137604. /**
  137605. * Specifies the metallic scalar of the metallic/roughness workflow.
  137606. * Can also be used to scale the metalness values of the metallic texture.
  137607. */
  137608. metallic: Nullable<number>;
  137609. /**
  137610. * Specifies the roughness scalar of the metallic/roughness workflow.
  137611. * Can also be used to scale the roughness values of the metallic texture.
  137612. */
  137613. roughness: Nullable<number>;
  137614. /**
  137615. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137616. * By default the indexOfrefraction is used to compute F0;
  137617. *
  137618. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137619. *
  137620. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137621. * F90 = metallicReflectanceColor;
  137622. */
  137623. metallicF0Factor: number;
  137624. /**
  137625. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137626. * By default the F90 is always 1;
  137627. *
  137628. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137629. *
  137630. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137631. * F90 = metallicReflectanceColor;
  137632. */
  137633. metallicReflectanceColor: Color3;
  137634. /**
  137635. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137636. * This is multiply against the scalar values defined in the material.
  137637. */
  137638. metallicReflectanceTexture: Nullable<BaseTexture>;
  137639. /**
  137640. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137641. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137642. */
  137643. microSurfaceTexture: BaseTexture;
  137644. /**
  137645. * Stores surface normal data used to displace a mesh in a texture.
  137646. */
  137647. bumpTexture: BaseTexture;
  137648. /**
  137649. * Stores the pre-calculated light information of a mesh in a texture.
  137650. */
  137651. lightmapTexture: BaseTexture;
  137652. /**
  137653. * Stores the refracted light information in a texture.
  137654. */
  137655. get refractionTexture(): Nullable<BaseTexture>;
  137656. set refractionTexture(value: Nullable<BaseTexture>);
  137657. /**
  137658. * The color of a material in ambient lighting.
  137659. */
  137660. ambientColor: Color3;
  137661. /**
  137662. * AKA Diffuse Color in other nomenclature.
  137663. */
  137664. albedoColor: Color3;
  137665. /**
  137666. * AKA Specular Color in other nomenclature.
  137667. */
  137668. reflectivityColor: Color3;
  137669. /**
  137670. * The color reflected from the material.
  137671. */
  137672. reflectionColor: Color3;
  137673. /**
  137674. * The color emitted from the material.
  137675. */
  137676. emissiveColor: Color3;
  137677. /**
  137678. * AKA Glossiness in other nomenclature.
  137679. */
  137680. microSurface: number;
  137681. /**
  137682. * Index of refraction of the material base layer.
  137683. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  137684. *
  137685. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  137686. *
  137687. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  137688. */
  137689. get indexOfRefraction(): number;
  137690. set indexOfRefraction(value: number);
  137691. /**
  137692. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  137693. */
  137694. get invertRefractionY(): boolean;
  137695. set invertRefractionY(value: boolean);
  137696. /**
  137697. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  137698. * Materials half opaque for instance using refraction could benefit from this control.
  137699. */
  137700. get linkRefractionWithTransparency(): boolean;
  137701. set linkRefractionWithTransparency(value: boolean);
  137702. /**
  137703. * If true, the light map contains occlusion information instead of lighting info.
  137704. */
  137705. useLightmapAsShadowmap: boolean;
  137706. /**
  137707. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137708. */
  137709. useAlphaFromAlbedoTexture: boolean;
  137710. /**
  137711. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137712. */
  137713. forceAlphaTest: boolean;
  137714. /**
  137715. * Defines the alpha limits in alpha test mode.
  137716. */
  137717. alphaCutOff: number;
  137718. /**
  137719. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  137720. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137721. */
  137722. useSpecularOverAlpha: boolean;
  137723. /**
  137724. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137725. */
  137726. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137727. /**
  137728. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137729. */
  137730. useRoughnessFromMetallicTextureAlpha: boolean;
  137731. /**
  137732. * Specifies if the metallic texture contains the roughness information in its green channel.
  137733. */
  137734. useRoughnessFromMetallicTextureGreen: boolean;
  137735. /**
  137736. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137737. */
  137738. useMetallnessFromMetallicTextureBlue: boolean;
  137739. /**
  137740. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137741. */
  137742. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137743. /**
  137744. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137745. */
  137746. useAmbientInGrayScale: boolean;
  137747. /**
  137748. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137749. * The material will try to infer what glossiness each pixel should be.
  137750. */
  137751. useAutoMicroSurfaceFromReflectivityMap: boolean;
  137752. /**
  137753. * BJS is using an harcoded light falloff based on a manually sets up range.
  137754. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137755. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137756. */
  137757. get usePhysicalLightFalloff(): boolean;
  137758. /**
  137759. * BJS is using an harcoded light falloff based on a manually sets up range.
  137760. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137761. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137762. */
  137763. set usePhysicalLightFalloff(value: boolean);
  137764. /**
  137765. * In order to support the falloff compatibility with gltf, a special mode has been added
  137766. * to reproduce the gltf light falloff.
  137767. */
  137768. get useGLTFLightFalloff(): boolean;
  137769. /**
  137770. * In order to support the falloff compatibility with gltf, a special mode has been added
  137771. * to reproduce the gltf light falloff.
  137772. */
  137773. set useGLTFLightFalloff(value: boolean);
  137774. /**
  137775. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137776. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137777. */
  137778. useRadianceOverAlpha: boolean;
  137779. /**
  137780. * Allows using an object space normal map (instead of tangent space).
  137781. */
  137782. useObjectSpaceNormalMap: boolean;
  137783. /**
  137784. * Allows using the bump map in parallax mode.
  137785. */
  137786. useParallax: boolean;
  137787. /**
  137788. * Allows using the bump map in parallax occlusion mode.
  137789. */
  137790. useParallaxOcclusion: boolean;
  137791. /**
  137792. * Controls the scale bias of the parallax mode.
  137793. */
  137794. parallaxScaleBias: number;
  137795. /**
  137796. * If sets to true, disables all the lights affecting the material.
  137797. */
  137798. disableLighting: boolean;
  137799. /**
  137800. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137801. */
  137802. forceIrradianceInFragment: boolean;
  137803. /**
  137804. * Number of Simultaneous lights allowed on the material.
  137805. */
  137806. maxSimultaneousLights: number;
  137807. /**
  137808. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137809. */
  137810. invertNormalMapX: boolean;
  137811. /**
  137812. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137813. */
  137814. invertNormalMapY: boolean;
  137815. /**
  137816. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137817. */
  137818. twoSidedLighting: boolean;
  137819. /**
  137820. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137821. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137822. */
  137823. useAlphaFresnel: boolean;
  137824. /**
  137825. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137826. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137827. */
  137828. useLinearAlphaFresnel: boolean;
  137829. /**
  137830. * Let user defines the brdf lookup texture used for IBL.
  137831. * A default 8bit version is embedded but you could point at :
  137832. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  137833. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  137834. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  137835. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  137836. */
  137837. environmentBRDFTexture: Nullable<BaseTexture>;
  137838. /**
  137839. * Force normal to face away from face.
  137840. */
  137841. forceNormalForward: boolean;
  137842. /**
  137843. * Enables specular anti aliasing in the PBR shader.
  137844. * It will both interacts on the Geometry for analytical and IBL lighting.
  137845. * It also prefilter the roughness map based on the bump values.
  137846. */
  137847. enableSpecularAntiAliasing: boolean;
  137848. /**
  137849. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137850. * makes the reflect vector face the model (under horizon).
  137851. */
  137852. useHorizonOcclusion: boolean;
  137853. /**
  137854. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137855. * too much the area relying on ambient texture to define their ambient occlusion.
  137856. */
  137857. useRadianceOcclusion: boolean;
  137858. /**
  137859. * If set to true, no lighting calculations will be applied.
  137860. */
  137861. unlit: boolean;
  137862. /**
  137863. * Gets the image processing configuration used either in this material.
  137864. */
  137865. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  137866. /**
  137867. * Sets the Default image processing configuration used either in the this material.
  137868. *
  137869. * If sets to null, the scene one is in use.
  137870. */
  137871. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  137872. /**
  137873. * Gets wether the color curves effect is enabled.
  137874. */
  137875. get cameraColorCurvesEnabled(): boolean;
  137876. /**
  137877. * Sets wether the color curves effect is enabled.
  137878. */
  137879. set cameraColorCurvesEnabled(value: boolean);
  137880. /**
  137881. * Gets wether the color grading effect is enabled.
  137882. */
  137883. get cameraColorGradingEnabled(): boolean;
  137884. /**
  137885. * Gets wether the color grading effect is enabled.
  137886. */
  137887. set cameraColorGradingEnabled(value: boolean);
  137888. /**
  137889. * Gets wether tonemapping is enabled or not.
  137890. */
  137891. get cameraToneMappingEnabled(): boolean;
  137892. /**
  137893. * Sets wether tonemapping is enabled or not
  137894. */
  137895. set cameraToneMappingEnabled(value: boolean);
  137896. /**
  137897. * The camera exposure used on this material.
  137898. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137899. * This corresponds to a photographic exposure.
  137900. */
  137901. get cameraExposure(): number;
  137902. /**
  137903. * The camera exposure used on this material.
  137904. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137905. * This corresponds to a photographic exposure.
  137906. */
  137907. set cameraExposure(value: number);
  137908. /**
  137909. * Gets The camera contrast used on this material.
  137910. */
  137911. get cameraContrast(): number;
  137912. /**
  137913. * Sets The camera contrast used on this material.
  137914. */
  137915. set cameraContrast(value: number);
  137916. /**
  137917. * Gets the Color Grading 2D Lookup Texture.
  137918. */
  137919. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137920. /**
  137921. * Sets the Color Grading 2D Lookup Texture.
  137922. */
  137923. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137924. /**
  137925. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137926. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137927. * 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;
  137928. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137929. */
  137930. get cameraColorCurves(): Nullable<ColorCurves>;
  137931. /**
  137932. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137933. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137934. * 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;
  137935. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137936. */
  137937. set cameraColorCurves(value: Nullable<ColorCurves>);
  137938. /**
  137939. * Instantiates a new PBRMaterial instance.
  137940. *
  137941. * @param name The material name
  137942. * @param scene The scene the material will be use in.
  137943. */
  137944. constructor(name: string, scene: Scene);
  137945. /**
  137946. * Returns the name of this material class.
  137947. */
  137948. getClassName(): string;
  137949. /**
  137950. * Makes a duplicate of the current material.
  137951. * @param name - name to use for the new material.
  137952. */
  137953. clone(name: string): PBRMaterial;
  137954. /**
  137955. * Serializes this PBR Material.
  137956. * @returns - An object with the serialized material.
  137957. */
  137958. serialize(): any;
  137959. /**
  137960. * Parses a PBR Material from a serialized object.
  137961. * @param source - Serialized object.
  137962. * @param scene - BJS scene instance.
  137963. * @param rootUrl - url for the scene object
  137964. * @returns - PBRMaterial
  137965. */
  137966. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  137967. }
  137968. }
  137969. declare module BABYLON {
  137970. /**
  137971. * Direct draw surface info
  137972. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  137973. */
  137974. export interface DDSInfo {
  137975. /**
  137976. * Width of the texture
  137977. */
  137978. width: number;
  137979. /**
  137980. * Width of the texture
  137981. */
  137982. height: number;
  137983. /**
  137984. * Number of Mipmaps for the texture
  137985. * @see https://en.wikipedia.org/wiki/Mipmap
  137986. */
  137987. mipmapCount: number;
  137988. /**
  137989. * If the textures format is a known fourCC format
  137990. * @see https://www.fourcc.org/
  137991. */
  137992. isFourCC: boolean;
  137993. /**
  137994. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  137995. */
  137996. isRGB: boolean;
  137997. /**
  137998. * If the texture is a lumincance format
  137999. */
  138000. isLuminance: boolean;
  138001. /**
  138002. * If this is a cube texture
  138003. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  138004. */
  138005. isCube: boolean;
  138006. /**
  138007. * If the texture is a compressed format eg. FOURCC_DXT1
  138008. */
  138009. isCompressed: boolean;
  138010. /**
  138011. * The dxgiFormat of the texture
  138012. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  138013. */
  138014. dxgiFormat: number;
  138015. /**
  138016. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  138017. */
  138018. textureType: number;
  138019. /**
  138020. * Sphericle polynomial created for the dds texture
  138021. */
  138022. sphericalPolynomial?: SphericalPolynomial;
  138023. }
  138024. /**
  138025. * Class used to provide DDS decompression tools
  138026. */
  138027. export class DDSTools {
  138028. /**
  138029. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138030. */
  138031. static StoreLODInAlphaChannel: boolean;
  138032. /**
  138033. * Gets DDS information from an array buffer
  138034. * @param data defines the array buffer view to read data from
  138035. * @returns the DDS information
  138036. */
  138037. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138038. private static _FloatView;
  138039. private static _Int32View;
  138040. private static _ToHalfFloat;
  138041. private static _FromHalfFloat;
  138042. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138043. private static _GetHalfFloatRGBAArrayBuffer;
  138044. private static _GetFloatRGBAArrayBuffer;
  138045. private static _GetFloatAsUIntRGBAArrayBuffer;
  138046. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138047. private static _GetRGBAArrayBuffer;
  138048. private static _ExtractLongWordOrder;
  138049. private static _GetRGBArrayBuffer;
  138050. private static _GetLuminanceArrayBuffer;
  138051. /**
  138052. * Uploads DDS Levels to a Babylon Texture
  138053. * @hidden
  138054. */
  138055. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138056. }
  138057. interface ThinEngine {
  138058. /**
  138059. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138060. * @param rootUrl defines the url where the file to load is located
  138061. * @param scene defines the current scene
  138062. * @param lodScale defines scale to apply to the mip map selection
  138063. * @param lodOffset defines offset to apply to the mip map selection
  138064. * @param onLoad defines an optional callback raised when the texture is loaded
  138065. * @param onError defines an optional callback raised if there is an issue to load the texture
  138066. * @param format defines the format of the data
  138067. * @param forcedExtension defines the extension to use to pick the right loader
  138068. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138069. * @returns the cube texture as an InternalTexture
  138070. */
  138071. 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;
  138072. }
  138073. }
  138074. declare module BABYLON {
  138075. /**
  138076. * Implementation of the DDS Texture Loader.
  138077. * @hidden
  138078. */
  138079. export class _DDSTextureLoader implements IInternalTextureLoader {
  138080. /**
  138081. * Defines wether the loader supports cascade loading the different faces.
  138082. */
  138083. readonly supportCascades: boolean;
  138084. /**
  138085. * This returns if the loader support the current file information.
  138086. * @param extension defines the file extension of the file being loaded
  138087. * @returns true if the loader can load the specified file
  138088. */
  138089. canLoad(extension: string): boolean;
  138090. /**
  138091. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138092. * @param data contains the texture data
  138093. * @param texture defines the BabylonJS internal texture
  138094. * @param createPolynomials will be true if polynomials have been requested
  138095. * @param onLoad defines the callback to trigger once the texture is ready
  138096. * @param onError defines the callback to trigger in case of error
  138097. */
  138098. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138099. /**
  138100. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138101. * @param data contains the texture data
  138102. * @param texture defines the BabylonJS internal texture
  138103. * @param callback defines the method to call once ready to upload
  138104. */
  138105. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138106. }
  138107. }
  138108. declare module BABYLON {
  138109. /**
  138110. * Implementation of the ENV Texture Loader.
  138111. * @hidden
  138112. */
  138113. export class _ENVTextureLoader implements IInternalTextureLoader {
  138114. /**
  138115. * Defines wether the loader supports cascade loading the different faces.
  138116. */
  138117. readonly supportCascades: boolean;
  138118. /**
  138119. * This returns if the loader support the current file information.
  138120. * @param extension defines the file extension of the file being loaded
  138121. * @returns true if the loader can load the specified file
  138122. */
  138123. canLoad(extension: string): boolean;
  138124. /**
  138125. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138126. * @param data contains the texture data
  138127. * @param texture defines the BabylonJS internal texture
  138128. * @param createPolynomials will be true if polynomials have been requested
  138129. * @param onLoad defines the callback to trigger once the texture is ready
  138130. * @param onError defines the callback to trigger in case of error
  138131. */
  138132. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138133. /**
  138134. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138135. * @param data contains the texture data
  138136. * @param texture defines the BabylonJS internal texture
  138137. * @param callback defines the method to call once ready to upload
  138138. */
  138139. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138140. }
  138141. }
  138142. declare module BABYLON {
  138143. /**
  138144. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138145. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138146. */
  138147. export class KhronosTextureContainer {
  138148. /** contents of the KTX container file */
  138149. data: ArrayBufferView;
  138150. private static HEADER_LEN;
  138151. private static COMPRESSED_2D;
  138152. private static COMPRESSED_3D;
  138153. private static TEX_2D;
  138154. private static TEX_3D;
  138155. /**
  138156. * Gets the openGL type
  138157. */
  138158. glType: number;
  138159. /**
  138160. * Gets the openGL type size
  138161. */
  138162. glTypeSize: number;
  138163. /**
  138164. * Gets the openGL format
  138165. */
  138166. glFormat: number;
  138167. /**
  138168. * Gets the openGL internal format
  138169. */
  138170. glInternalFormat: number;
  138171. /**
  138172. * Gets the base internal format
  138173. */
  138174. glBaseInternalFormat: number;
  138175. /**
  138176. * Gets image width in pixel
  138177. */
  138178. pixelWidth: number;
  138179. /**
  138180. * Gets image height in pixel
  138181. */
  138182. pixelHeight: number;
  138183. /**
  138184. * Gets image depth in pixels
  138185. */
  138186. pixelDepth: number;
  138187. /**
  138188. * Gets the number of array elements
  138189. */
  138190. numberOfArrayElements: number;
  138191. /**
  138192. * Gets the number of faces
  138193. */
  138194. numberOfFaces: number;
  138195. /**
  138196. * Gets the number of mipmap levels
  138197. */
  138198. numberOfMipmapLevels: number;
  138199. /**
  138200. * Gets the bytes of key value data
  138201. */
  138202. bytesOfKeyValueData: number;
  138203. /**
  138204. * Gets the load type
  138205. */
  138206. loadType: number;
  138207. /**
  138208. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  138209. */
  138210. isInvalid: boolean;
  138211. /**
  138212. * Creates a new KhronosTextureContainer
  138213. * @param data contents of the KTX container file
  138214. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  138215. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  138216. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  138217. */
  138218. constructor(
  138219. /** contents of the KTX container file */
  138220. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  138221. /**
  138222. * Uploads KTX content to a Babylon Texture.
  138223. * It is assumed that the texture has already been created & is currently bound
  138224. * @hidden
  138225. */
  138226. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  138227. private _upload2DCompressedLevels;
  138228. /**
  138229. * Checks if the given data starts with a KTX file identifier.
  138230. * @param data the data to check
  138231. * @returns true if the data is a KTX file or false otherwise
  138232. */
  138233. static IsValid(data: ArrayBufferView): boolean;
  138234. }
  138235. }
  138236. declare module BABYLON {
  138237. /**
  138238. * Helper class to push actions to a pool of workers.
  138239. */
  138240. export class WorkerPool implements IDisposable {
  138241. private _workerInfos;
  138242. private _pendingActions;
  138243. /**
  138244. * Constructor
  138245. * @param workers Array of workers to use for actions
  138246. */
  138247. constructor(workers: Array<Worker>);
  138248. /**
  138249. * Terminates all workers and clears any pending actions.
  138250. */
  138251. dispose(): void;
  138252. /**
  138253. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138254. * pended until a worker has completed its action.
  138255. * @param action The action to perform. Call onComplete when the action is complete.
  138256. */
  138257. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138258. private _execute;
  138259. }
  138260. }
  138261. declare module BABYLON {
  138262. /**
  138263. * Class for loading KTX2 files
  138264. * @hidden
  138265. */
  138266. export class KhronosTextureContainer2 {
  138267. private static _WorkerPoolPromise?;
  138268. private static _Initialized;
  138269. private static _Ktx2Decoder;
  138270. /**
  138271. * URL to use when loading the KTX2 decoder module
  138272. */
  138273. static JSModuleURL: string;
  138274. /**
  138275. * Default number of workers used to handle data decoding
  138276. */
  138277. static DefaultNumWorkers: number;
  138278. private static GetDefaultNumWorkers;
  138279. private _engine;
  138280. private static _CreateWorkerPool;
  138281. /**
  138282. * Constructor
  138283. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138284. */
  138285. constructor(engine: ThinEngine, numWorkers?: number);
  138286. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  138287. /**
  138288. * Stop all async operations and release resources.
  138289. */
  138290. dispose(): void;
  138291. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  138292. /**
  138293. * Checks if the given data starts with a KTX2 file identifier.
  138294. * @param data the data to check
  138295. * @returns true if the data is a KTX2 file or false otherwise
  138296. */
  138297. static IsValid(data: ArrayBufferView): boolean;
  138298. }
  138299. export function workerFunc(): void;
  138300. }
  138301. declare module BABYLON {
  138302. /**
  138303. * Implementation of the KTX Texture Loader.
  138304. * @hidden
  138305. */
  138306. export class _KTXTextureLoader implements IInternalTextureLoader {
  138307. /**
  138308. * Defines wether the loader supports cascade loading the different faces.
  138309. */
  138310. readonly supportCascades: boolean;
  138311. /**
  138312. * This returns if the loader support the current file information.
  138313. * @param extension defines the file extension of the file being loaded
  138314. * @param mimeType defines the optional mime type of the file being loaded
  138315. * @returns true if the loader can load the specified file
  138316. */
  138317. canLoad(extension: string, mimeType?: string): boolean;
  138318. /**
  138319. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138320. * @param data contains the texture data
  138321. * @param texture defines the BabylonJS internal texture
  138322. * @param createPolynomials will be true if polynomials have been requested
  138323. * @param onLoad defines the callback to trigger once the texture is ready
  138324. * @param onError defines the callback to trigger in case of error
  138325. */
  138326. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138327. /**
  138328. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138329. * @param data contains the texture data
  138330. * @param texture defines the BabylonJS internal texture
  138331. * @param callback defines the method to call once ready to upload
  138332. */
  138333. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  138334. }
  138335. }
  138336. declare module BABYLON {
  138337. /** @hidden */
  138338. export var _forceSceneHelpersToBundle: boolean;
  138339. interface Scene {
  138340. /**
  138341. * Creates a default light for the scene.
  138342. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  138343. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  138344. */
  138345. createDefaultLight(replace?: boolean): void;
  138346. /**
  138347. * Creates a default camera for the scene.
  138348. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  138349. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138350. * @param replace has default false, when true replaces the active camera in the scene
  138351. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  138352. */
  138353. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138354. /**
  138355. * Creates a default camera and a default light.
  138356. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  138357. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138358. * @param replace has the default false, when true replaces the active camera/light in the scene
  138359. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  138360. */
  138361. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138362. /**
  138363. * Creates a new sky box
  138364. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  138365. * @param environmentTexture defines the texture to use as environment texture
  138366. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  138367. * @param scale defines the overall scale of the skybox
  138368. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  138369. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  138370. * @returns a new mesh holding the sky box
  138371. */
  138372. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  138373. /**
  138374. * Creates a new environment
  138375. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  138376. * @param options defines the options you can use to configure the environment
  138377. * @returns the new EnvironmentHelper
  138378. */
  138379. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  138380. /**
  138381. * Creates a new VREXperienceHelper
  138382. * @see https://doc.babylonjs.com/how_to/webvr_helper
  138383. * @param webVROptions defines the options used to create the new VREXperienceHelper
  138384. * @returns a new VREXperienceHelper
  138385. */
  138386. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  138387. /**
  138388. * Creates a new WebXRDefaultExperience
  138389. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  138390. * @param options experience options
  138391. * @returns a promise for a new WebXRDefaultExperience
  138392. */
  138393. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  138394. }
  138395. }
  138396. declare module BABYLON {
  138397. /**
  138398. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  138399. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  138400. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  138401. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138402. */
  138403. export class VideoDome extends TextureDome<VideoTexture> {
  138404. /**
  138405. * Define the video source as a Monoscopic panoramic 360 video.
  138406. */
  138407. static readonly MODE_MONOSCOPIC: number;
  138408. /**
  138409. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  138410. */
  138411. static readonly MODE_TOPBOTTOM: number;
  138412. /**
  138413. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  138414. */
  138415. static readonly MODE_SIDEBYSIDE: number;
  138416. /**
  138417. * Get the video texture associated with this video dome
  138418. */
  138419. get videoTexture(): VideoTexture;
  138420. /**
  138421. * Get the video mode of this dome
  138422. */
  138423. get videoMode(): number;
  138424. /**
  138425. * Set the video mode of this dome.
  138426. * @see textureMode
  138427. */
  138428. set videoMode(value: number);
  138429. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  138430. }
  138431. }
  138432. declare module BABYLON {
  138433. /**
  138434. * This class can be used to get instrumentation data from a Babylon engine
  138435. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138436. */
  138437. export class EngineInstrumentation implements IDisposable {
  138438. /**
  138439. * Define the instrumented engine.
  138440. */
  138441. engine: Engine;
  138442. private _captureGPUFrameTime;
  138443. private _gpuFrameTimeToken;
  138444. private _gpuFrameTime;
  138445. private _captureShaderCompilationTime;
  138446. private _shaderCompilationTime;
  138447. private _onBeginFrameObserver;
  138448. private _onEndFrameObserver;
  138449. private _onBeforeShaderCompilationObserver;
  138450. private _onAfterShaderCompilationObserver;
  138451. /**
  138452. * Gets the perf counter used for GPU frame time
  138453. */
  138454. get gpuFrameTimeCounter(): PerfCounter;
  138455. /**
  138456. * Gets the GPU frame time capture status
  138457. */
  138458. get captureGPUFrameTime(): boolean;
  138459. /**
  138460. * Enable or disable the GPU frame time capture
  138461. */
  138462. set captureGPUFrameTime(value: boolean);
  138463. /**
  138464. * Gets the perf counter used for shader compilation time
  138465. */
  138466. get shaderCompilationTimeCounter(): PerfCounter;
  138467. /**
  138468. * Gets the shader compilation time capture status
  138469. */
  138470. get captureShaderCompilationTime(): boolean;
  138471. /**
  138472. * Enable or disable the shader compilation time capture
  138473. */
  138474. set captureShaderCompilationTime(value: boolean);
  138475. /**
  138476. * Instantiates a new engine instrumentation.
  138477. * This class can be used to get instrumentation data from a Babylon engine
  138478. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138479. * @param engine Defines the engine to instrument
  138480. */
  138481. constructor(
  138482. /**
  138483. * Define the instrumented engine.
  138484. */
  138485. engine: Engine);
  138486. /**
  138487. * Dispose and release associated resources.
  138488. */
  138489. dispose(): void;
  138490. }
  138491. }
  138492. declare module BABYLON {
  138493. /**
  138494. * This class can be used to get instrumentation data from a Babylon engine
  138495. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138496. */
  138497. export class SceneInstrumentation implements IDisposable {
  138498. /**
  138499. * Defines the scene to instrument
  138500. */
  138501. scene: Scene;
  138502. private _captureActiveMeshesEvaluationTime;
  138503. private _activeMeshesEvaluationTime;
  138504. private _captureRenderTargetsRenderTime;
  138505. private _renderTargetsRenderTime;
  138506. private _captureFrameTime;
  138507. private _frameTime;
  138508. private _captureRenderTime;
  138509. private _renderTime;
  138510. private _captureInterFrameTime;
  138511. private _interFrameTime;
  138512. private _captureParticlesRenderTime;
  138513. private _particlesRenderTime;
  138514. private _captureSpritesRenderTime;
  138515. private _spritesRenderTime;
  138516. private _capturePhysicsTime;
  138517. private _physicsTime;
  138518. private _captureAnimationsTime;
  138519. private _animationsTime;
  138520. private _captureCameraRenderTime;
  138521. private _cameraRenderTime;
  138522. private _onBeforeActiveMeshesEvaluationObserver;
  138523. private _onAfterActiveMeshesEvaluationObserver;
  138524. private _onBeforeRenderTargetsRenderObserver;
  138525. private _onAfterRenderTargetsRenderObserver;
  138526. private _onAfterRenderObserver;
  138527. private _onBeforeDrawPhaseObserver;
  138528. private _onAfterDrawPhaseObserver;
  138529. private _onBeforeAnimationsObserver;
  138530. private _onBeforeParticlesRenderingObserver;
  138531. private _onAfterParticlesRenderingObserver;
  138532. private _onBeforeSpritesRenderingObserver;
  138533. private _onAfterSpritesRenderingObserver;
  138534. private _onBeforePhysicsObserver;
  138535. private _onAfterPhysicsObserver;
  138536. private _onAfterAnimationsObserver;
  138537. private _onBeforeCameraRenderObserver;
  138538. private _onAfterCameraRenderObserver;
  138539. /**
  138540. * Gets the perf counter used for active meshes evaluation time
  138541. */
  138542. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  138543. /**
  138544. * Gets the active meshes evaluation time capture status
  138545. */
  138546. get captureActiveMeshesEvaluationTime(): boolean;
  138547. /**
  138548. * Enable or disable the active meshes evaluation time capture
  138549. */
  138550. set captureActiveMeshesEvaluationTime(value: boolean);
  138551. /**
  138552. * Gets the perf counter used for render targets render time
  138553. */
  138554. get renderTargetsRenderTimeCounter(): PerfCounter;
  138555. /**
  138556. * Gets the render targets render time capture status
  138557. */
  138558. get captureRenderTargetsRenderTime(): boolean;
  138559. /**
  138560. * Enable or disable the render targets render time capture
  138561. */
  138562. set captureRenderTargetsRenderTime(value: boolean);
  138563. /**
  138564. * Gets the perf counter used for particles render time
  138565. */
  138566. get particlesRenderTimeCounter(): PerfCounter;
  138567. /**
  138568. * Gets the particles render time capture status
  138569. */
  138570. get captureParticlesRenderTime(): boolean;
  138571. /**
  138572. * Enable or disable the particles render time capture
  138573. */
  138574. set captureParticlesRenderTime(value: boolean);
  138575. /**
  138576. * Gets the perf counter used for sprites render time
  138577. */
  138578. get spritesRenderTimeCounter(): PerfCounter;
  138579. /**
  138580. * Gets the sprites render time capture status
  138581. */
  138582. get captureSpritesRenderTime(): boolean;
  138583. /**
  138584. * Enable or disable the sprites render time capture
  138585. */
  138586. set captureSpritesRenderTime(value: boolean);
  138587. /**
  138588. * Gets the perf counter used for physics time
  138589. */
  138590. get physicsTimeCounter(): PerfCounter;
  138591. /**
  138592. * Gets the physics time capture status
  138593. */
  138594. get capturePhysicsTime(): boolean;
  138595. /**
  138596. * Enable or disable the physics time capture
  138597. */
  138598. set capturePhysicsTime(value: boolean);
  138599. /**
  138600. * Gets the perf counter used for animations time
  138601. */
  138602. get animationsTimeCounter(): PerfCounter;
  138603. /**
  138604. * Gets the animations time capture status
  138605. */
  138606. get captureAnimationsTime(): boolean;
  138607. /**
  138608. * Enable or disable the animations time capture
  138609. */
  138610. set captureAnimationsTime(value: boolean);
  138611. /**
  138612. * Gets the perf counter used for frame time capture
  138613. */
  138614. get frameTimeCounter(): PerfCounter;
  138615. /**
  138616. * Gets the frame time capture status
  138617. */
  138618. get captureFrameTime(): boolean;
  138619. /**
  138620. * Enable or disable the frame time capture
  138621. */
  138622. set captureFrameTime(value: boolean);
  138623. /**
  138624. * Gets the perf counter used for inter-frames time capture
  138625. */
  138626. get interFrameTimeCounter(): PerfCounter;
  138627. /**
  138628. * Gets the inter-frames time capture status
  138629. */
  138630. get captureInterFrameTime(): boolean;
  138631. /**
  138632. * Enable or disable the inter-frames time capture
  138633. */
  138634. set captureInterFrameTime(value: boolean);
  138635. /**
  138636. * Gets the perf counter used for render time capture
  138637. */
  138638. get renderTimeCounter(): PerfCounter;
  138639. /**
  138640. * Gets the render time capture status
  138641. */
  138642. get captureRenderTime(): boolean;
  138643. /**
  138644. * Enable or disable the render time capture
  138645. */
  138646. set captureRenderTime(value: boolean);
  138647. /**
  138648. * Gets the perf counter used for camera render time capture
  138649. */
  138650. get cameraRenderTimeCounter(): PerfCounter;
  138651. /**
  138652. * Gets the camera render time capture status
  138653. */
  138654. get captureCameraRenderTime(): boolean;
  138655. /**
  138656. * Enable or disable the camera render time capture
  138657. */
  138658. set captureCameraRenderTime(value: boolean);
  138659. /**
  138660. * Gets the perf counter used for draw calls
  138661. */
  138662. get drawCallsCounter(): PerfCounter;
  138663. /**
  138664. * Instantiates a new scene instrumentation.
  138665. * This class can be used to get instrumentation data from a Babylon engine
  138666. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138667. * @param scene Defines the scene to instrument
  138668. */
  138669. constructor(
  138670. /**
  138671. * Defines the scene to instrument
  138672. */
  138673. scene: Scene);
  138674. /**
  138675. * Dispose and release associated resources.
  138676. */
  138677. dispose(): void;
  138678. }
  138679. }
  138680. declare module BABYLON {
  138681. /** @hidden */
  138682. export var glowMapGenerationPixelShader: {
  138683. name: string;
  138684. shader: string;
  138685. };
  138686. }
  138687. declare module BABYLON {
  138688. /** @hidden */
  138689. export var glowMapGenerationVertexShader: {
  138690. name: string;
  138691. shader: string;
  138692. };
  138693. }
  138694. declare module BABYLON {
  138695. /**
  138696. * Effect layer options. This helps customizing the behaviour
  138697. * of the effect layer.
  138698. */
  138699. export interface IEffectLayerOptions {
  138700. /**
  138701. * Multiplication factor apply to the canvas size to compute the render target size
  138702. * used to generated the objects (the smaller the faster).
  138703. */
  138704. mainTextureRatio: number;
  138705. /**
  138706. * Enforces a fixed size texture to ensure effect stability across devices.
  138707. */
  138708. mainTextureFixedSize?: number;
  138709. /**
  138710. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  138711. */
  138712. alphaBlendingMode: number;
  138713. /**
  138714. * The camera attached to the layer.
  138715. */
  138716. camera: Nullable<Camera>;
  138717. /**
  138718. * The rendering group to draw the layer in.
  138719. */
  138720. renderingGroupId: number;
  138721. }
  138722. /**
  138723. * The effect layer Helps adding post process effect blended with the main pass.
  138724. *
  138725. * This can be for instance use to generate glow or higlight effects on the scene.
  138726. *
  138727. * The effect layer class can not be used directly and is intented to inherited from to be
  138728. * customized per effects.
  138729. */
  138730. export abstract class EffectLayer {
  138731. private _vertexBuffers;
  138732. private _indexBuffer;
  138733. private _cachedDefines;
  138734. private _effectLayerMapGenerationEffect;
  138735. private _effectLayerOptions;
  138736. private _mergeEffect;
  138737. protected _scene: Scene;
  138738. protected _engine: Engine;
  138739. protected _maxSize: number;
  138740. protected _mainTextureDesiredSize: ISize;
  138741. protected _mainTexture: RenderTargetTexture;
  138742. protected _shouldRender: boolean;
  138743. protected _postProcesses: PostProcess[];
  138744. protected _textures: BaseTexture[];
  138745. protected _emissiveTextureAndColor: {
  138746. texture: Nullable<BaseTexture>;
  138747. color: Color4;
  138748. };
  138749. /**
  138750. * The name of the layer
  138751. */
  138752. name: string;
  138753. /**
  138754. * The clear color of the texture used to generate the glow map.
  138755. */
  138756. neutralColor: Color4;
  138757. /**
  138758. * Specifies whether the highlight layer is enabled or not.
  138759. */
  138760. isEnabled: boolean;
  138761. /**
  138762. * Gets the camera attached to the layer.
  138763. */
  138764. get camera(): Nullable<Camera>;
  138765. /**
  138766. * Gets the rendering group id the layer should render in.
  138767. */
  138768. get renderingGroupId(): number;
  138769. set renderingGroupId(renderingGroupId: number);
  138770. /**
  138771. * An event triggered when the effect layer has been disposed.
  138772. */
  138773. onDisposeObservable: Observable<EffectLayer>;
  138774. /**
  138775. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  138776. */
  138777. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  138778. /**
  138779. * An event triggered when the generated texture is being merged in the scene.
  138780. */
  138781. onBeforeComposeObservable: Observable<EffectLayer>;
  138782. /**
  138783. * An event triggered when the mesh is rendered into the effect render target.
  138784. */
  138785. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  138786. /**
  138787. * An event triggered after the mesh has been rendered into the effect render target.
  138788. */
  138789. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  138790. /**
  138791. * An event triggered when the generated texture has been merged in the scene.
  138792. */
  138793. onAfterComposeObservable: Observable<EffectLayer>;
  138794. /**
  138795. * An event triggered when the efffect layer changes its size.
  138796. */
  138797. onSizeChangedObservable: Observable<EffectLayer>;
  138798. /** @hidden */
  138799. static _SceneComponentInitialization: (scene: Scene) => void;
  138800. /**
  138801. * Instantiates a new effect Layer and references it in the scene.
  138802. * @param name The name of the layer
  138803. * @param scene The scene to use the layer in
  138804. */
  138805. constructor(
  138806. /** The Friendly of the effect in the scene */
  138807. name: string, scene: Scene);
  138808. /**
  138809. * Get the effect name of the layer.
  138810. * @return The effect name
  138811. */
  138812. abstract getEffectName(): string;
  138813. /**
  138814. * Checks for the readiness of the element composing the layer.
  138815. * @param subMesh the mesh to check for
  138816. * @param useInstances specify whether or not to use instances to render the mesh
  138817. * @return true if ready otherwise, false
  138818. */
  138819. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138820. /**
  138821. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138822. * @returns true if the effect requires stencil during the main canvas render pass.
  138823. */
  138824. abstract needStencil(): boolean;
  138825. /**
  138826. * Create the merge effect. This is the shader use to blit the information back
  138827. * to the main canvas at the end of the scene rendering.
  138828. * @returns The effect containing the shader used to merge the effect on the main canvas
  138829. */
  138830. protected abstract _createMergeEffect(): Effect;
  138831. /**
  138832. * Creates the render target textures and post processes used in the effect layer.
  138833. */
  138834. protected abstract _createTextureAndPostProcesses(): void;
  138835. /**
  138836. * Implementation specific of rendering the generating effect on the main canvas.
  138837. * @param effect The effect used to render through
  138838. */
  138839. protected abstract _internalRender(effect: Effect): void;
  138840. /**
  138841. * Sets the required values for both the emissive texture and and the main color.
  138842. */
  138843. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138844. /**
  138845. * Free any resources and references associated to a mesh.
  138846. * Internal use
  138847. * @param mesh The mesh to free.
  138848. */
  138849. abstract _disposeMesh(mesh: Mesh): void;
  138850. /**
  138851. * Serializes this layer (Glow or Highlight for example)
  138852. * @returns a serialized layer object
  138853. */
  138854. abstract serialize?(): any;
  138855. /**
  138856. * Initializes the effect layer with the required options.
  138857. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  138858. */
  138859. protected _init(options: Partial<IEffectLayerOptions>): void;
  138860. /**
  138861. * Generates the index buffer of the full screen quad blending to the main canvas.
  138862. */
  138863. private _generateIndexBuffer;
  138864. /**
  138865. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  138866. */
  138867. private _generateVertexBuffer;
  138868. /**
  138869. * Sets the main texture desired size which is the closest power of two
  138870. * of the engine canvas size.
  138871. */
  138872. private _setMainTextureSize;
  138873. /**
  138874. * Creates the main texture for the effect layer.
  138875. */
  138876. protected _createMainTexture(): void;
  138877. /**
  138878. * Adds specific effects defines.
  138879. * @param defines The defines to add specifics to.
  138880. */
  138881. protected _addCustomEffectDefines(defines: string[]): void;
  138882. /**
  138883. * Checks for the readiness of the element composing the layer.
  138884. * @param subMesh the mesh to check for
  138885. * @param useInstances specify whether or not to use instances to render the mesh
  138886. * @param emissiveTexture the associated emissive texture used to generate the glow
  138887. * @return true if ready otherwise, false
  138888. */
  138889. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  138890. /**
  138891. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  138892. */
  138893. render(): void;
  138894. /**
  138895. * Determine if a given mesh will be used in the current effect.
  138896. * @param mesh mesh to test
  138897. * @returns true if the mesh will be used
  138898. */
  138899. hasMesh(mesh: AbstractMesh): boolean;
  138900. /**
  138901. * Returns true if the layer contains information to display, otherwise false.
  138902. * @returns true if the glow layer should be rendered
  138903. */
  138904. shouldRender(): boolean;
  138905. /**
  138906. * Returns true if the mesh should render, otherwise false.
  138907. * @param mesh The mesh to render
  138908. * @returns true if it should render otherwise false
  138909. */
  138910. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  138911. /**
  138912. * Returns true if the mesh can be rendered, otherwise false.
  138913. * @param mesh The mesh to render
  138914. * @param material The material used on the mesh
  138915. * @returns true if it can be rendered otherwise false
  138916. */
  138917. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138918. /**
  138919. * Returns true if the mesh should render, otherwise false.
  138920. * @param mesh The mesh to render
  138921. * @returns true if it should render otherwise false
  138922. */
  138923. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  138924. /**
  138925. * Renders the submesh passed in parameter to the generation map.
  138926. */
  138927. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  138928. /**
  138929. * Defines whether the current material of the mesh should be use to render the effect.
  138930. * @param mesh defines the current mesh to render
  138931. */
  138932. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138933. /**
  138934. * Rebuild the required buffers.
  138935. * @hidden Internal use only.
  138936. */
  138937. _rebuild(): void;
  138938. /**
  138939. * Dispose only the render target textures and post process.
  138940. */
  138941. private _disposeTextureAndPostProcesses;
  138942. /**
  138943. * Dispose the highlight layer and free resources.
  138944. */
  138945. dispose(): void;
  138946. /**
  138947. * Gets the class name of the effect layer
  138948. * @returns the string with the class name of the effect layer
  138949. */
  138950. getClassName(): string;
  138951. /**
  138952. * Creates an effect layer from parsed effect layer data
  138953. * @param parsedEffectLayer defines effect layer data
  138954. * @param scene defines the current scene
  138955. * @param rootUrl defines the root URL containing the effect layer information
  138956. * @returns a parsed effect Layer
  138957. */
  138958. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  138959. }
  138960. }
  138961. declare module BABYLON {
  138962. interface AbstractScene {
  138963. /**
  138964. * The list of effect layers (highlights/glow) added to the scene
  138965. * @see https://doc.babylonjs.com/how_to/highlight_layer
  138966. * @see https://doc.babylonjs.com/how_to/glow_layer
  138967. */
  138968. effectLayers: Array<EffectLayer>;
  138969. /**
  138970. * Removes the given effect layer from this scene.
  138971. * @param toRemove defines the effect layer to remove
  138972. * @returns the index of the removed effect layer
  138973. */
  138974. removeEffectLayer(toRemove: EffectLayer): number;
  138975. /**
  138976. * Adds the given effect layer to this scene
  138977. * @param newEffectLayer defines the effect layer to add
  138978. */
  138979. addEffectLayer(newEffectLayer: EffectLayer): void;
  138980. }
  138981. /**
  138982. * Defines the layer scene component responsible to manage any effect layers
  138983. * in a given scene.
  138984. */
  138985. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  138986. /**
  138987. * The component name helpfull to identify the component in the list of scene components.
  138988. */
  138989. readonly name: string;
  138990. /**
  138991. * The scene the component belongs to.
  138992. */
  138993. scene: Scene;
  138994. private _engine;
  138995. private _renderEffects;
  138996. private _needStencil;
  138997. private _previousStencilState;
  138998. /**
  138999. * Creates a new instance of the component for the given scene
  139000. * @param scene Defines the scene to register the component in
  139001. */
  139002. constructor(scene: Scene);
  139003. /**
  139004. * Registers the component in a given scene
  139005. */
  139006. register(): void;
  139007. /**
  139008. * Rebuilds the elements related to this component in case of
  139009. * context lost for instance.
  139010. */
  139011. rebuild(): void;
  139012. /**
  139013. * Serializes the component data to the specified json object
  139014. * @param serializationObject The object to serialize to
  139015. */
  139016. serialize(serializationObject: any): void;
  139017. /**
  139018. * Adds all the elements from the container to the scene
  139019. * @param container the container holding the elements
  139020. */
  139021. addFromContainer(container: AbstractScene): void;
  139022. /**
  139023. * Removes all the elements in the container from the scene
  139024. * @param container contains the elements to remove
  139025. * @param dispose if the removed element should be disposed (default: false)
  139026. */
  139027. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139028. /**
  139029. * Disposes the component and the associated ressources.
  139030. */
  139031. dispose(): void;
  139032. private _isReadyForMesh;
  139033. private _renderMainTexture;
  139034. private _setStencil;
  139035. private _setStencilBack;
  139036. private _draw;
  139037. private _drawCamera;
  139038. private _drawRenderingGroup;
  139039. }
  139040. }
  139041. declare module BABYLON {
  139042. /** @hidden */
  139043. export var glowMapMergePixelShader: {
  139044. name: string;
  139045. shader: string;
  139046. };
  139047. }
  139048. declare module BABYLON {
  139049. /** @hidden */
  139050. export var glowMapMergeVertexShader: {
  139051. name: string;
  139052. shader: string;
  139053. };
  139054. }
  139055. declare module BABYLON {
  139056. interface AbstractScene {
  139057. /**
  139058. * Return a the first highlight layer of the scene with a given name.
  139059. * @param name The name of the highlight layer to look for.
  139060. * @return The highlight layer if found otherwise null.
  139061. */
  139062. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139063. }
  139064. /**
  139065. * Glow layer options. This helps customizing the behaviour
  139066. * of the glow layer.
  139067. */
  139068. export interface IGlowLayerOptions {
  139069. /**
  139070. * Multiplication factor apply to the canvas size to compute the render target size
  139071. * used to generated the glowing objects (the smaller the faster).
  139072. */
  139073. mainTextureRatio: number;
  139074. /**
  139075. * Enforces a fixed size texture to ensure resize independant blur.
  139076. */
  139077. mainTextureFixedSize?: number;
  139078. /**
  139079. * How big is the kernel of the blur texture.
  139080. */
  139081. blurKernelSize: number;
  139082. /**
  139083. * The camera attached to the layer.
  139084. */
  139085. camera: Nullable<Camera>;
  139086. /**
  139087. * Enable MSAA by chosing the number of samples.
  139088. */
  139089. mainTextureSamples?: number;
  139090. /**
  139091. * The rendering group to draw the layer in.
  139092. */
  139093. renderingGroupId: number;
  139094. }
  139095. /**
  139096. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  139097. *
  139098. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  139099. *
  139100. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  139101. */
  139102. export class GlowLayer extends EffectLayer {
  139103. /**
  139104. * Effect Name of the layer.
  139105. */
  139106. static readonly EffectName: string;
  139107. /**
  139108. * The default blur kernel size used for the glow.
  139109. */
  139110. static DefaultBlurKernelSize: number;
  139111. /**
  139112. * The default texture size ratio used for the glow.
  139113. */
  139114. static DefaultTextureRatio: number;
  139115. /**
  139116. * Sets the kernel size of the blur.
  139117. */
  139118. set blurKernelSize(value: number);
  139119. /**
  139120. * Gets the kernel size of the blur.
  139121. */
  139122. get blurKernelSize(): number;
  139123. /**
  139124. * Sets the glow intensity.
  139125. */
  139126. set intensity(value: number);
  139127. /**
  139128. * Gets the glow intensity.
  139129. */
  139130. get intensity(): number;
  139131. private _options;
  139132. private _intensity;
  139133. private _horizontalBlurPostprocess1;
  139134. private _verticalBlurPostprocess1;
  139135. private _horizontalBlurPostprocess2;
  139136. private _verticalBlurPostprocess2;
  139137. private _blurTexture1;
  139138. private _blurTexture2;
  139139. private _postProcesses1;
  139140. private _postProcesses2;
  139141. private _includedOnlyMeshes;
  139142. private _excludedMeshes;
  139143. private _meshesUsingTheirOwnMaterials;
  139144. /**
  139145. * Callback used to let the user override the color selection on a per mesh basis
  139146. */
  139147. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139148. /**
  139149. * Callback used to let the user override the texture selection on a per mesh basis
  139150. */
  139151. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139152. /**
  139153. * Instantiates a new glow Layer and references it to the scene.
  139154. * @param name The name of the layer
  139155. * @param scene The scene to use the layer in
  139156. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139157. */
  139158. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139159. /**
  139160. * Get the effect name of the layer.
  139161. * @return The effect name
  139162. */
  139163. getEffectName(): string;
  139164. /**
  139165. * Create the merge effect. This is the shader use to blit the information back
  139166. * to the main canvas at the end of the scene rendering.
  139167. */
  139168. protected _createMergeEffect(): Effect;
  139169. /**
  139170. * Creates the render target textures and post processes used in the glow layer.
  139171. */
  139172. protected _createTextureAndPostProcesses(): void;
  139173. /**
  139174. * Checks for the readiness of the element composing the layer.
  139175. * @param subMesh the mesh to check for
  139176. * @param useInstances specify wether or not to use instances to render the mesh
  139177. * @param emissiveTexture the associated emissive texture used to generate the glow
  139178. * @return true if ready otherwise, false
  139179. */
  139180. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139181. /**
  139182. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139183. */
  139184. needStencil(): boolean;
  139185. /**
  139186. * Returns true if the mesh can be rendered, otherwise false.
  139187. * @param mesh The mesh to render
  139188. * @param material The material used on the mesh
  139189. * @returns true if it can be rendered otherwise false
  139190. */
  139191. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139192. /**
  139193. * Implementation specific of rendering the generating effect on the main canvas.
  139194. * @param effect The effect used to render through
  139195. */
  139196. protected _internalRender(effect: Effect): void;
  139197. /**
  139198. * Sets the required values for both the emissive texture and and the main color.
  139199. */
  139200. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139201. /**
  139202. * Returns true if the mesh should render, otherwise false.
  139203. * @param mesh The mesh to render
  139204. * @returns true if it should render otherwise false
  139205. */
  139206. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139207. /**
  139208. * Adds specific effects defines.
  139209. * @param defines The defines to add specifics to.
  139210. */
  139211. protected _addCustomEffectDefines(defines: string[]): void;
  139212. /**
  139213. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  139214. * @param mesh The mesh to exclude from the glow layer
  139215. */
  139216. addExcludedMesh(mesh: Mesh): void;
  139217. /**
  139218. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  139219. * @param mesh The mesh to remove
  139220. */
  139221. removeExcludedMesh(mesh: Mesh): void;
  139222. /**
  139223. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  139224. * @param mesh The mesh to include in the glow layer
  139225. */
  139226. addIncludedOnlyMesh(mesh: Mesh): void;
  139227. /**
  139228. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  139229. * @param mesh The mesh to remove
  139230. */
  139231. removeIncludedOnlyMesh(mesh: Mesh): void;
  139232. /**
  139233. * Determine if a given mesh will be used in the glow layer
  139234. * @param mesh The mesh to test
  139235. * @returns true if the mesh will be highlighted by the current glow layer
  139236. */
  139237. hasMesh(mesh: AbstractMesh): boolean;
  139238. /**
  139239. * Defines whether the current material of the mesh should be use to render the effect.
  139240. * @param mesh defines the current mesh to render
  139241. */
  139242. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139243. /**
  139244. * Add a mesh to be rendered through its own material and not with emissive only.
  139245. * @param mesh The mesh for which we need to use its material
  139246. */
  139247. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  139248. /**
  139249. * Remove a mesh from being rendered through its own material and not with emissive only.
  139250. * @param mesh The mesh for which we need to not use its material
  139251. */
  139252. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  139253. /**
  139254. * Free any resources and references associated to a mesh.
  139255. * Internal use
  139256. * @param mesh The mesh to free.
  139257. * @hidden
  139258. */
  139259. _disposeMesh(mesh: Mesh): void;
  139260. /**
  139261. * Gets the class name of the effect layer
  139262. * @returns the string with the class name of the effect layer
  139263. */
  139264. getClassName(): string;
  139265. /**
  139266. * Serializes this glow layer
  139267. * @returns a serialized glow layer object
  139268. */
  139269. serialize(): any;
  139270. /**
  139271. * Creates a Glow Layer from parsed glow layer data
  139272. * @param parsedGlowLayer defines glow layer data
  139273. * @param scene defines the current scene
  139274. * @param rootUrl defines the root URL containing the glow layer information
  139275. * @returns a parsed Glow Layer
  139276. */
  139277. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  139278. }
  139279. }
  139280. declare module BABYLON {
  139281. /** @hidden */
  139282. export var glowBlurPostProcessPixelShader: {
  139283. name: string;
  139284. shader: string;
  139285. };
  139286. }
  139287. declare module BABYLON {
  139288. interface AbstractScene {
  139289. /**
  139290. * Return a the first highlight layer of the scene with a given name.
  139291. * @param name The name of the highlight layer to look for.
  139292. * @return The highlight layer if found otherwise null.
  139293. */
  139294. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  139295. }
  139296. /**
  139297. * Highlight layer options. This helps customizing the behaviour
  139298. * of the highlight layer.
  139299. */
  139300. export interface IHighlightLayerOptions {
  139301. /**
  139302. * Multiplication factor apply to the canvas size to compute the render target size
  139303. * used to generated the glowing objects (the smaller the faster).
  139304. */
  139305. mainTextureRatio: number;
  139306. /**
  139307. * Enforces a fixed size texture to ensure resize independant blur.
  139308. */
  139309. mainTextureFixedSize?: number;
  139310. /**
  139311. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  139312. * of the picture to blur (the smaller the faster).
  139313. */
  139314. blurTextureSizeRatio: number;
  139315. /**
  139316. * How big in texel of the blur texture is the vertical blur.
  139317. */
  139318. blurVerticalSize: number;
  139319. /**
  139320. * How big in texel of the blur texture is the horizontal blur.
  139321. */
  139322. blurHorizontalSize: number;
  139323. /**
  139324. * Alpha blending mode used to apply the blur. Default is combine.
  139325. */
  139326. alphaBlendingMode: number;
  139327. /**
  139328. * The camera attached to the layer.
  139329. */
  139330. camera: Nullable<Camera>;
  139331. /**
  139332. * Should we display highlight as a solid stroke?
  139333. */
  139334. isStroke?: boolean;
  139335. /**
  139336. * The rendering group to draw the layer in.
  139337. */
  139338. renderingGroupId: number;
  139339. }
  139340. /**
  139341. * The highlight layer Helps adding a glow effect around a mesh.
  139342. *
  139343. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  139344. * glowy meshes to your scene.
  139345. *
  139346. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  139347. */
  139348. export class HighlightLayer extends EffectLayer {
  139349. name: string;
  139350. /**
  139351. * Effect Name of the highlight layer.
  139352. */
  139353. static readonly EffectName: string;
  139354. /**
  139355. * The neutral color used during the preparation of the glow effect.
  139356. * This is black by default as the blend operation is a blend operation.
  139357. */
  139358. static NeutralColor: Color4;
  139359. /**
  139360. * Stencil value used for glowing meshes.
  139361. */
  139362. static GlowingMeshStencilReference: number;
  139363. /**
  139364. * Stencil value used for the other meshes in the scene.
  139365. */
  139366. static NormalMeshStencilReference: number;
  139367. /**
  139368. * Specifies whether or not the inner glow is ACTIVE in the layer.
  139369. */
  139370. innerGlow: boolean;
  139371. /**
  139372. * Specifies whether or not the outer glow is ACTIVE in the layer.
  139373. */
  139374. outerGlow: boolean;
  139375. /**
  139376. * Specifies the horizontal size of the blur.
  139377. */
  139378. set blurHorizontalSize(value: number);
  139379. /**
  139380. * Specifies the vertical size of the blur.
  139381. */
  139382. set blurVerticalSize(value: number);
  139383. /**
  139384. * Gets the horizontal size of the blur.
  139385. */
  139386. get blurHorizontalSize(): number;
  139387. /**
  139388. * Gets the vertical size of the blur.
  139389. */
  139390. get blurVerticalSize(): number;
  139391. /**
  139392. * An event triggered when the highlight layer is being blurred.
  139393. */
  139394. onBeforeBlurObservable: Observable<HighlightLayer>;
  139395. /**
  139396. * An event triggered when the highlight layer has been blurred.
  139397. */
  139398. onAfterBlurObservable: Observable<HighlightLayer>;
  139399. private _instanceGlowingMeshStencilReference;
  139400. private _options;
  139401. private _downSamplePostprocess;
  139402. private _horizontalBlurPostprocess;
  139403. private _verticalBlurPostprocess;
  139404. private _blurTexture;
  139405. private _meshes;
  139406. private _excludedMeshes;
  139407. /**
  139408. * Instantiates a new highlight Layer and references it to the scene..
  139409. * @param name The name of the layer
  139410. * @param scene The scene to use the layer in
  139411. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  139412. */
  139413. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  139414. /**
  139415. * Get the effect name of the layer.
  139416. * @return The effect name
  139417. */
  139418. getEffectName(): string;
  139419. /**
  139420. * Create the merge effect. This is the shader use to blit the information back
  139421. * to the main canvas at the end of the scene rendering.
  139422. */
  139423. protected _createMergeEffect(): Effect;
  139424. /**
  139425. * Creates the render target textures and post processes used in the highlight layer.
  139426. */
  139427. protected _createTextureAndPostProcesses(): void;
  139428. /**
  139429. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  139430. */
  139431. needStencil(): boolean;
  139432. /**
  139433. * Checks for the readiness of the element composing the layer.
  139434. * @param subMesh the mesh to check for
  139435. * @param useInstances specify wether or not to use instances to render the mesh
  139436. * @param emissiveTexture the associated emissive texture used to generate the glow
  139437. * @return true if ready otherwise, false
  139438. */
  139439. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139440. /**
  139441. * Implementation specific of rendering the generating effect on the main canvas.
  139442. * @param effect The effect used to render through
  139443. */
  139444. protected _internalRender(effect: Effect): void;
  139445. /**
  139446. * Returns true if the layer contains information to display, otherwise false.
  139447. */
  139448. shouldRender(): boolean;
  139449. /**
  139450. * Returns true if the mesh should render, otherwise false.
  139451. * @param mesh The mesh to render
  139452. * @returns true if it should render otherwise false
  139453. */
  139454. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139455. /**
  139456. * Returns true if the mesh can be rendered, otherwise false.
  139457. * @param mesh The mesh to render
  139458. * @param material The material used on the mesh
  139459. * @returns true if it can be rendered otherwise false
  139460. */
  139461. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139462. /**
  139463. * Adds specific effects defines.
  139464. * @param defines The defines to add specifics to.
  139465. */
  139466. protected _addCustomEffectDefines(defines: string[]): void;
  139467. /**
  139468. * Sets the required values for both the emissive texture and and the main color.
  139469. */
  139470. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139471. /**
  139472. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  139473. * @param mesh The mesh to exclude from the highlight layer
  139474. */
  139475. addExcludedMesh(mesh: Mesh): void;
  139476. /**
  139477. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  139478. * @param mesh The mesh to highlight
  139479. */
  139480. removeExcludedMesh(mesh: Mesh): void;
  139481. /**
  139482. * Determine if a given mesh will be highlighted by the current HighlightLayer
  139483. * @param mesh mesh to test
  139484. * @returns true if the mesh will be highlighted by the current HighlightLayer
  139485. */
  139486. hasMesh(mesh: AbstractMesh): boolean;
  139487. /**
  139488. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  139489. * @param mesh The mesh to highlight
  139490. * @param color The color of the highlight
  139491. * @param glowEmissiveOnly Extract the glow from the emissive texture
  139492. */
  139493. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  139494. /**
  139495. * Remove a mesh from the highlight layer in order to make it stop glowing.
  139496. * @param mesh The mesh to highlight
  139497. */
  139498. removeMesh(mesh: Mesh): void;
  139499. /**
  139500. * Remove all the meshes currently referenced in the highlight layer
  139501. */
  139502. removeAllMeshes(): void;
  139503. /**
  139504. * Force the stencil to the normal expected value for none glowing parts
  139505. */
  139506. private _defaultStencilReference;
  139507. /**
  139508. * Free any resources and references associated to a mesh.
  139509. * Internal use
  139510. * @param mesh The mesh to free.
  139511. * @hidden
  139512. */
  139513. _disposeMesh(mesh: Mesh): void;
  139514. /**
  139515. * Dispose the highlight layer and free resources.
  139516. */
  139517. dispose(): void;
  139518. /**
  139519. * Gets the class name of the effect layer
  139520. * @returns the string with the class name of the effect layer
  139521. */
  139522. getClassName(): string;
  139523. /**
  139524. * Serializes this Highlight layer
  139525. * @returns a serialized Highlight layer object
  139526. */
  139527. serialize(): any;
  139528. /**
  139529. * Creates a Highlight layer from parsed Highlight layer data
  139530. * @param parsedHightlightLayer defines the Highlight layer data
  139531. * @param scene defines the current scene
  139532. * @param rootUrl defines the root URL containing the Highlight layer information
  139533. * @returns a parsed Highlight layer
  139534. */
  139535. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  139536. }
  139537. }
  139538. declare module BABYLON {
  139539. interface AbstractScene {
  139540. /**
  139541. * The list of layers (background and foreground) of the scene
  139542. */
  139543. layers: Array<Layer>;
  139544. }
  139545. /**
  139546. * Defines the layer scene component responsible to manage any layers
  139547. * in a given scene.
  139548. */
  139549. export class LayerSceneComponent implements ISceneComponent {
  139550. /**
  139551. * The component name helpfull to identify the component in the list of scene components.
  139552. */
  139553. readonly name: string;
  139554. /**
  139555. * The scene the component belongs to.
  139556. */
  139557. scene: Scene;
  139558. private _engine;
  139559. /**
  139560. * Creates a new instance of the component for the given scene
  139561. * @param scene Defines the scene to register the component in
  139562. */
  139563. constructor(scene: Scene);
  139564. /**
  139565. * Registers the component in a given scene
  139566. */
  139567. register(): void;
  139568. /**
  139569. * Rebuilds the elements related to this component in case of
  139570. * context lost for instance.
  139571. */
  139572. rebuild(): void;
  139573. /**
  139574. * Disposes the component and the associated ressources.
  139575. */
  139576. dispose(): void;
  139577. private _draw;
  139578. private _drawCameraPredicate;
  139579. private _drawCameraBackground;
  139580. private _drawCameraForeground;
  139581. private _drawRenderTargetPredicate;
  139582. private _drawRenderTargetBackground;
  139583. private _drawRenderTargetForeground;
  139584. /**
  139585. * Adds all the elements from the container to the scene
  139586. * @param container the container holding the elements
  139587. */
  139588. addFromContainer(container: AbstractScene): void;
  139589. /**
  139590. * Removes all the elements in the container from the scene
  139591. * @param container contains the elements to remove
  139592. * @param dispose if the removed element should be disposed (default: false)
  139593. */
  139594. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139595. }
  139596. }
  139597. declare module BABYLON {
  139598. /** @hidden */
  139599. export var layerPixelShader: {
  139600. name: string;
  139601. shader: string;
  139602. };
  139603. }
  139604. declare module BABYLON {
  139605. /** @hidden */
  139606. export var layerVertexShader: {
  139607. name: string;
  139608. shader: string;
  139609. };
  139610. }
  139611. declare module BABYLON {
  139612. /**
  139613. * This represents a full screen 2d layer.
  139614. * This can be useful to display a picture in the background of your scene for instance.
  139615. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139616. */
  139617. export class Layer {
  139618. /**
  139619. * Define the name of the layer.
  139620. */
  139621. name: string;
  139622. /**
  139623. * Define the texture the layer should display.
  139624. */
  139625. texture: Nullable<Texture>;
  139626. /**
  139627. * Is the layer in background or foreground.
  139628. */
  139629. isBackground: boolean;
  139630. /**
  139631. * Define the color of the layer (instead of texture).
  139632. */
  139633. color: Color4;
  139634. /**
  139635. * Define the scale of the layer in order to zoom in out of the texture.
  139636. */
  139637. scale: Vector2;
  139638. /**
  139639. * Define an offset for the layer in order to shift the texture.
  139640. */
  139641. offset: Vector2;
  139642. /**
  139643. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  139644. */
  139645. alphaBlendingMode: number;
  139646. /**
  139647. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  139648. * Alpha test will not mix with the background color in case of transparency.
  139649. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  139650. */
  139651. alphaTest: boolean;
  139652. /**
  139653. * Define a mask to restrict the layer to only some of the scene cameras.
  139654. */
  139655. layerMask: number;
  139656. /**
  139657. * Define the list of render target the layer is visible into.
  139658. */
  139659. renderTargetTextures: RenderTargetTexture[];
  139660. /**
  139661. * Define if the layer is only used in renderTarget or if it also
  139662. * renders in the main frame buffer of the canvas.
  139663. */
  139664. renderOnlyInRenderTargetTextures: boolean;
  139665. private _scene;
  139666. private _vertexBuffers;
  139667. private _indexBuffer;
  139668. private _effect;
  139669. private _previousDefines;
  139670. /**
  139671. * An event triggered when the layer is disposed.
  139672. */
  139673. onDisposeObservable: Observable<Layer>;
  139674. private _onDisposeObserver;
  139675. /**
  139676. * Back compatibility with callback before the onDisposeObservable existed.
  139677. * The set callback will be triggered when the layer has been disposed.
  139678. */
  139679. set onDispose(callback: () => void);
  139680. /**
  139681. * An event triggered before rendering the scene
  139682. */
  139683. onBeforeRenderObservable: Observable<Layer>;
  139684. private _onBeforeRenderObserver;
  139685. /**
  139686. * Back compatibility with callback before the onBeforeRenderObservable existed.
  139687. * The set callback will be triggered just before rendering the layer.
  139688. */
  139689. set onBeforeRender(callback: () => void);
  139690. /**
  139691. * An event triggered after rendering the scene
  139692. */
  139693. onAfterRenderObservable: Observable<Layer>;
  139694. private _onAfterRenderObserver;
  139695. /**
  139696. * Back compatibility with callback before the onAfterRenderObservable existed.
  139697. * The set callback will be triggered just after rendering the layer.
  139698. */
  139699. set onAfterRender(callback: () => void);
  139700. /**
  139701. * Instantiates a new layer.
  139702. * This represents a full screen 2d layer.
  139703. * This can be useful to display a picture in the background of your scene for instance.
  139704. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139705. * @param name Define the name of the layer in the scene
  139706. * @param imgUrl Define the url of the texture to display in the layer
  139707. * @param scene Define the scene the layer belongs to
  139708. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  139709. * @param color Defines a color for the layer
  139710. */
  139711. constructor(
  139712. /**
  139713. * Define the name of the layer.
  139714. */
  139715. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  139716. private _createIndexBuffer;
  139717. /** @hidden */
  139718. _rebuild(): void;
  139719. /**
  139720. * Renders the layer in the scene.
  139721. */
  139722. render(): void;
  139723. /**
  139724. * Disposes and releases the associated ressources.
  139725. */
  139726. dispose(): void;
  139727. }
  139728. }
  139729. declare module BABYLON {
  139730. /** @hidden */
  139731. export var lensFlarePixelShader: {
  139732. name: string;
  139733. shader: string;
  139734. };
  139735. }
  139736. declare module BABYLON {
  139737. /** @hidden */
  139738. export var lensFlareVertexShader: {
  139739. name: string;
  139740. shader: string;
  139741. };
  139742. }
  139743. declare module BABYLON {
  139744. /**
  139745. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139746. * It is usually composed of several `lensFlare`.
  139747. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139748. */
  139749. export class LensFlareSystem {
  139750. /**
  139751. * Define the name of the lens flare system
  139752. */
  139753. name: string;
  139754. /**
  139755. * List of lens flares used in this system.
  139756. */
  139757. lensFlares: LensFlare[];
  139758. /**
  139759. * Define a limit from the border the lens flare can be visible.
  139760. */
  139761. borderLimit: number;
  139762. /**
  139763. * Define a viewport border we do not want to see the lens flare in.
  139764. */
  139765. viewportBorder: number;
  139766. /**
  139767. * Define a predicate which could limit the list of meshes able to occlude the effect.
  139768. */
  139769. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  139770. /**
  139771. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  139772. */
  139773. layerMask: number;
  139774. /**
  139775. * Define the id of the lens flare system in the scene.
  139776. * (equal to name by default)
  139777. */
  139778. id: string;
  139779. private _scene;
  139780. private _emitter;
  139781. private _vertexBuffers;
  139782. private _indexBuffer;
  139783. private _effect;
  139784. private _positionX;
  139785. private _positionY;
  139786. private _isEnabled;
  139787. /** @hidden */
  139788. static _SceneComponentInitialization: (scene: Scene) => void;
  139789. /**
  139790. * Instantiates a lens flare system.
  139791. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139792. * It is usually composed of several `lensFlare`.
  139793. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139794. * @param name Define the name of the lens flare system in the scene
  139795. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  139796. * @param scene Define the scene the lens flare system belongs to
  139797. */
  139798. constructor(
  139799. /**
  139800. * Define the name of the lens flare system
  139801. */
  139802. name: string, emitter: any, scene: Scene);
  139803. /**
  139804. * Define if the lens flare system is enabled.
  139805. */
  139806. get isEnabled(): boolean;
  139807. set isEnabled(value: boolean);
  139808. /**
  139809. * Get the scene the effects belongs to.
  139810. * @returns the scene holding the lens flare system
  139811. */
  139812. getScene(): Scene;
  139813. /**
  139814. * Get the emitter of the lens flare system.
  139815. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139816. * @returns the emitter of the lens flare system
  139817. */
  139818. getEmitter(): any;
  139819. /**
  139820. * Set the emitter of the lens flare system.
  139821. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139822. * @param newEmitter Define the new emitter of the system
  139823. */
  139824. setEmitter(newEmitter: any): void;
  139825. /**
  139826. * Get the lens flare system emitter position.
  139827. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  139828. * @returns the position
  139829. */
  139830. getEmitterPosition(): Vector3;
  139831. /**
  139832. * @hidden
  139833. */
  139834. computeEffectivePosition(globalViewport: Viewport): boolean;
  139835. /** @hidden */
  139836. _isVisible(): boolean;
  139837. /**
  139838. * @hidden
  139839. */
  139840. render(): boolean;
  139841. /**
  139842. * Dispose and release the lens flare with its associated resources.
  139843. */
  139844. dispose(): void;
  139845. /**
  139846. * Parse a lens flare system from a JSON repressentation
  139847. * @param parsedLensFlareSystem Define the JSON to parse
  139848. * @param scene Define the scene the parsed system should be instantiated in
  139849. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  139850. * @returns the parsed system
  139851. */
  139852. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  139853. /**
  139854. * Serialize the current Lens Flare System into a JSON representation.
  139855. * @returns the serialized JSON
  139856. */
  139857. serialize(): any;
  139858. }
  139859. }
  139860. declare module BABYLON {
  139861. /**
  139862. * This represents one of the lens effect in a `lensFlareSystem`.
  139863. * It controls one of the indiviual texture used in the effect.
  139864. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139865. */
  139866. export class LensFlare {
  139867. /**
  139868. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139869. */
  139870. size: number;
  139871. /**
  139872. * 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.
  139873. */
  139874. position: number;
  139875. /**
  139876. * Define the lens color.
  139877. */
  139878. color: Color3;
  139879. /**
  139880. * Define the lens texture.
  139881. */
  139882. texture: Nullable<Texture>;
  139883. /**
  139884. * Define the alpha mode to render this particular lens.
  139885. */
  139886. alphaMode: number;
  139887. private _system;
  139888. /**
  139889. * Creates a new Lens Flare.
  139890. * This represents one of the lens effect in a `lensFlareSystem`.
  139891. * It controls one of the indiviual texture used in the effect.
  139892. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139893. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  139894. * @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.
  139895. * @param color Define the lens color
  139896. * @param imgUrl Define the lens texture url
  139897. * @param system Define the `lensFlareSystem` this flare is part of
  139898. * @returns The newly created Lens Flare
  139899. */
  139900. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  139901. /**
  139902. * Instantiates a new Lens Flare.
  139903. * This represents one of the lens effect in a `lensFlareSystem`.
  139904. * It controls one of the indiviual texture used in the effect.
  139905. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139906. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  139907. * @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.
  139908. * @param color Define the lens color
  139909. * @param imgUrl Define the lens texture url
  139910. * @param system Define the `lensFlareSystem` this flare is part of
  139911. */
  139912. constructor(
  139913. /**
  139914. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139915. */
  139916. size: number,
  139917. /**
  139918. * 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.
  139919. */
  139920. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  139921. /**
  139922. * Dispose and release the lens flare with its associated resources.
  139923. */
  139924. dispose(): void;
  139925. }
  139926. }
  139927. declare module BABYLON {
  139928. interface AbstractScene {
  139929. /**
  139930. * The list of lens flare system added to the scene
  139931. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139932. */
  139933. lensFlareSystems: Array<LensFlareSystem>;
  139934. /**
  139935. * Removes the given lens flare system from this scene.
  139936. * @param toRemove The lens flare system to remove
  139937. * @returns The index of the removed lens flare system
  139938. */
  139939. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  139940. /**
  139941. * Adds the given lens flare system to this scene
  139942. * @param newLensFlareSystem The lens flare system to add
  139943. */
  139944. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  139945. /**
  139946. * Gets a lens flare system using its name
  139947. * @param name defines the name to look for
  139948. * @returns the lens flare system or null if not found
  139949. */
  139950. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  139951. /**
  139952. * Gets a lens flare system using its id
  139953. * @param id defines the id to look for
  139954. * @returns the lens flare system or null if not found
  139955. */
  139956. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  139957. }
  139958. /**
  139959. * Defines the lens flare scene component responsible to manage any lens flares
  139960. * in a given scene.
  139961. */
  139962. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  139963. /**
  139964. * The component name helpfull to identify the component in the list of scene components.
  139965. */
  139966. readonly name: string;
  139967. /**
  139968. * The scene the component belongs to.
  139969. */
  139970. scene: Scene;
  139971. /**
  139972. * Creates a new instance of the component for the given scene
  139973. * @param scene Defines the scene to register the component in
  139974. */
  139975. constructor(scene: Scene);
  139976. /**
  139977. * Registers the component in a given scene
  139978. */
  139979. register(): void;
  139980. /**
  139981. * Rebuilds the elements related to this component in case of
  139982. * context lost for instance.
  139983. */
  139984. rebuild(): void;
  139985. /**
  139986. * Adds all the elements from the container to the scene
  139987. * @param container the container holding the elements
  139988. */
  139989. addFromContainer(container: AbstractScene): void;
  139990. /**
  139991. * Removes all the elements in the container from the scene
  139992. * @param container contains the elements to remove
  139993. * @param dispose if the removed element should be disposed (default: false)
  139994. */
  139995. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139996. /**
  139997. * Serializes the component data to the specified json object
  139998. * @param serializationObject The object to serialize to
  139999. */
  140000. serialize(serializationObject: any): void;
  140001. /**
  140002. * Disposes the component and the associated ressources.
  140003. */
  140004. dispose(): void;
  140005. private _draw;
  140006. }
  140007. }
  140008. declare module BABYLON {
  140009. /** @hidden */
  140010. export var depthPixelShader: {
  140011. name: string;
  140012. shader: string;
  140013. };
  140014. }
  140015. declare module BABYLON {
  140016. /** @hidden */
  140017. export var depthVertexShader: {
  140018. name: string;
  140019. shader: string;
  140020. };
  140021. }
  140022. declare module BABYLON {
  140023. /**
  140024. * This represents a depth renderer in Babylon.
  140025. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140026. */
  140027. export class DepthRenderer {
  140028. private _scene;
  140029. private _depthMap;
  140030. private _effect;
  140031. private readonly _storeNonLinearDepth;
  140032. private readonly _clearColor;
  140033. /** Get if the depth renderer is using packed depth or not */
  140034. readonly isPacked: boolean;
  140035. private _cachedDefines;
  140036. private _camera;
  140037. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140038. enabled: boolean;
  140039. /**
  140040. * Specifiess that the depth renderer will only be used within
  140041. * the camera it is created for.
  140042. * This can help forcing its rendering during the camera processing.
  140043. */
  140044. useOnlyInActiveCamera: boolean;
  140045. /** @hidden */
  140046. static _SceneComponentInitialization: (scene: Scene) => void;
  140047. /**
  140048. * Instantiates a depth renderer
  140049. * @param scene The scene the renderer belongs to
  140050. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140051. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140052. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140053. */
  140054. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140055. /**
  140056. * Creates the depth rendering effect and checks if the effect is ready.
  140057. * @param subMesh The submesh to be used to render the depth map of
  140058. * @param useInstances If multiple world instances should be used
  140059. * @returns if the depth renderer is ready to render the depth map
  140060. */
  140061. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140062. /**
  140063. * Gets the texture which the depth map will be written to.
  140064. * @returns The depth map texture
  140065. */
  140066. getDepthMap(): RenderTargetTexture;
  140067. /**
  140068. * Disposes of the depth renderer.
  140069. */
  140070. dispose(): void;
  140071. }
  140072. }
  140073. declare module BABYLON {
  140074. /** @hidden */
  140075. export var minmaxReduxPixelShader: {
  140076. name: string;
  140077. shader: string;
  140078. };
  140079. }
  140080. declare module BABYLON {
  140081. /**
  140082. * This class computes a min/max reduction from a texture: it means it computes the minimum
  140083. * and maximum values from all values of the texture.
  140084. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  140085. * The source values are read from the red channel of the texture.
  140086. */
  140087. export class MinMaxReducer {
  140088. /**
  140089. * Observable triggered when the computation has been performed
  140090. */
  140091. onAfterReductionPerformed: Observable<{
  140092. min: number;
  140093. max: number;
  140094. }>;
  140095. protected _camera: Camera;
  140096. protected _sourceTexture: Nullable<RenderTargetTexture>;
  140097. protected _reductionSteps: Nullable<Array<PostProcess>>;
  140098. protected _postProcessManager: PostProcessManager;
  140099. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  140100. protected _forceFullscreenViewport: boolean;
  140101. /**
  140102. * Creates a min/max reducer
  140103. * @param camera The camera to use for the post processes
  140104. */
  140105. constructor(camera: Camera);
  140106. /**
  140107. * Gets the texture used to read the values from.
  140108. */
  140109. get sourceTexture(): Nullable<RenderTargetTexture>;
  140110. /**
  140111. * Sets the source texture to read the values from.
  140112. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140113. * because in such textures '1' value must not be taken into account to compute the maximum
  140114. * as this value is used to clear the texture.
  140115. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140116. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140117. * @param depthRedux Indicates if the texture is a depth texture or not
  140118. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140119. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140120. */
  140121. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140122. /**
  140123. * Defines the refresh rate of the computation.
  140124. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140125. */
  140126. get refreshRate(): number;
  140127. set refreshRate(value: number);
  140128. protected _activated: boolean;
  140129. /**
  140130. * Gets the activation status of the reducer
  140131. */
  140132. get activated(): boolean;
  140133. /**
  140134. * Activates the reduction computation.
  140135. * When activated, the observers registered in onAfterReductionPerformed are
  140136. * called after the compuation is performed
  140137. */
  140138. activate(): void;
  140139. /**
  140140. * Deactivates the reduction computation.
  140141. */
  140142. deactivate(): void;
  140143. /**
  140144. * Disposes the min/max reducer
  140145. * @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.
  140146. */
  140147. dispose(disposeAll?: boolean): void;
  140148. }
  140149. }
  140150. declare module BABYLON {
  140151. /**
  140152. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140153. */
  140154. export class DepthReducer extends MinMaxReducer {
  140155. private _depthRenderer;
  140156. private _depthRendererId;
  140157. /**
  140158. * Gets the depth renderer used for the computation.
  140159. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140160. */
  140161. get depthRenderer(): Nullable<DepthRenderer>;
  140162. /**
  140163. * Creates a depth reducer
  140164. * @param camera The camera used to render the depth texture
  140165. */
  140166. constructor(camera: Camera);
  140167. /**
  140168. * Sets the depth renderer to use to generate the depth map
  140169. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140170. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140171. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140172. */
  140173. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140174. /** @hidden */
  140175. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140176. /**
  140177. * Activates the reduction computation.
  140178. * When activated, the observers registered in onAfterReductionPerformed are
  140179. * called after the compuation is performed
  140180. */
  140181. activate(): void;
  140182. /**
  140183. * Deactivates the reduction computation.
  140184. */
  140185. deactivate(): void;
  140186. /**
  140187. * Disposes the depth reducer
  140188. * @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.
  140189. */
  140190. dispose(disposeAll?: boolean): void;
  140191. }
  140192. }
  140193. declare module BABYLON {
  140194. /**
  140195. * A CSM implementation allowing casting shadows on large scenes.
  140196. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140197. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  140198. */
  140199. export class CascadedShadowGenerator extends ShadowGenerator {
  140200. private static readonly frustumCornersNDCSpace;
  140201. /**
  140202. * Name of the CSM class
  140203. */
  140204. static CLASSNAME: string;
  140205. /**
  140206. * Defines the default number of cascades used by the CSM.
  140207. */
  140208. static readonly DEFAULT_CASCADES_COUNT: number;
  140209. /**
  140210. * Defines the minimum number of cascades used by the CSM.
  140211. */
  140212. static readonly MIN_CASCADES_COUNT: number;
  140213. /**
  140214. * Defines the maximum number of cascades used by the CSM.
  140215. */
  140216. static readonly MAX_CASCADES_COUNT: number;
  140217. protected _validateFilter(filter: number): number;
  140218. /**
  140219. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  140220. */
  140221. penumbraDarkness: number;
  140222. private _numCascades;
  140223. /**
  140224. * Gets or set the number of cascades used by the CSM.
  140225. */
  140226. get numCascades(): number;
  140227. set numCascades(value: number);
  140228. /**
  140229. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  140230. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  140231. */
  140232. stabilizeCascades: boolean;
  140233. private _freezeShadowCastersBoundingInfo;
  140234. private _freezeShadowCastersBoundingInfoObservable;
  140235. /**
  140236. * Enables or disables the shadow casters bounding info computation.
  140237. * If your shadow casters don't move, you can disable this feature.
  140238. * If it is enabled, the bounding box computation is done every frame.
  140239. */
  140240. get freezeShadowCastersBoundingInfo(): boolean;
  140241. set freezeShadowCastersBoundingInfo(freeze: boolean);
  140242. private _scbiMin;
  140243. private _scbiMax;
  140244. protected _computeShadowCastersBoundingInfo(): void;
  140245. protected _shadowCastersBoundingInfo: BoundingInfo;
  140246. /**
  140247. * Gets or sets the shadow casters bounding info.
  140248. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  140249. * so that the system won't overwrite the bounds you provide
  140250. */
  140251. get shadowCastersBoundingInfo(): BoundingInfo;
  140252. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  140253. protected _breaksAreDirty: boolean;
  140254. protected _minDistance: number;
  140255. protected _maxDistance: number;
  140256. /**
  140257. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  140258. *
  140259. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  140260. * If you don't know these values, simply leave them to their defaults and don't call this function.
  140261. * @param min minimal distance for the breaks (default to 0.)
  140262. * @param max maximal distance for the breaks (default to 1.)
  140263. */
  140264. setMinMaxDistance(min: number, max: number): void;
  140265. /** Gets the minimal distance used in the cascade break computation */
  140266. get minDistance(): number;
  140267. /** Gets the maximal distance used in the cascade break computation */
  140268. get maxDistance(): number;
  140269. /**
  140270. * Gets the class name of that object
  140271. * @returns "CascadedShadowGenerator"
  140272. */
  140273. getClassName(): string;
  140274. private _cascadeMinExtents;
  140275. private _cascadeMaxExtents;
  140276. /**
  140277. * Gets a cascade minimum extents
  140278. * @param cascadeIndex index of the cascade
  140279. * @returns the minimum cascade extents
  140280. */
  140281. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  140282. /**
  140283. * Gets a cascade maximum extents
  140284. * @param cascadeIndex index of the cascade
  140285. * @returns the maximum cascade extents
  140286. */
  140287. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  140288. private _cascades;
  140289. private _currentLayer;
  140290. private _viewSpaceFrustumsZ;
  140291. private _viewMatrices;
  140292. private _projectionMatrices;
  140293. private _transformMatrices;
  140294. private _transformMatricesAsArray;
  140295. private _frustumLengths;
  140296. private _lightSizeUVCorrection;
  140297. private _depthCorrection;
  140298. private _frustumCornersWorldSpace;
  140299. private _frustumCenter;
  140300. private _shadowCameraPos;
  140301. private _shadowMaxZ;
  140302. /**
  140303. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  140304. * It defaults to camera.maxZ
  140305. */
  140306. get shadowMaxZ(): number;
  140307. /**
  140308. * Sets the shadow max z distance.
  140309. */
  140310. set shadowMaxZ(value: number);
  140311. protected _debug: boolean;
  140312. /**
  140313. * Gets or sets the debug flag.
  140314. * When enabled, the cascades are materialized by different colors on the screen.
  140315. */
  140316. get debug(): boolean;
  140317. set debug(dbg: boolean);
  140318. private _depthClamp;
  140319. /**
  140320. * Gets or sets the depth clamping value.
  140321. *
  140322. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  140323. * to account for the shadow casters far away.
  140324. *
  140325. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  140326. */
  140327. get depthClamp(): boolean;
  140328. set depthClamp(value: boolean);
  140329. private _cascadeBlendPercentage;
  140330. /**
  140331. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  140332. * It defaults to 0.1 (10% blending).
  140333. */
  140334. get cascadeBlendPercentage(): number;
  140335. set cascadeBlendPercentage(value: number);
  140336. private _lambda;
  140337. /**
  140338. * Gets or set the lambda parameter.
  140339. * This parameter is used to split the camera frustum and create the cascades.
  140340. * 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.
  140341. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  140342. */
  140343. get lambda(): number;
  140344. set lambda(value: number);
  140345. /**
  140346. * Gets the view matrix corresponding to a given cascade
  140347. * @param cascadeNum cascade to retrieve the view matrix from
  140348. * @returns the cascade view matrix
  140349. */
  140350. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  140351. /**
  140352. * Gets the projection matrix corresponding to a given cascade
  140353. * @param cascadeNum cascade to retrieve the projection matrix from
  140354. * @returns the cascade projection matrix
  140355. */
  140356. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  140357. /**
  140358. * Gets the transformation matrix corresponding to a given cascade
  140359. * @param cascadeNum cascade to retrieve the transformation matrix from
  140360. * @returns the cascade transformation matrix
  140361. */
  140362. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  140363. private _depthRenderer;
  140364. /**
  140365. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  140366. *
  140367. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  140368. *
  140369. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  140370. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  140371. * @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
  140372. */
  140373. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  140374. private _depthReducer;
  140375. private _autoCalcDepthBounds;
  140376. /**
  140377. * Gets or sets the autoCalcDepthBounds property.
  140378. *
  140379. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  140380. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  140381. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  140382. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  140383. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  140384. */
  140385. get autoCalcDepthBounds(): boolean;
  140386. set autoCalcDepthBounds(value: boolean);
  140387. /**
  140388. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  140389. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140390. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  140391. * for setting the refresh rate on the renderer yourself!
  140392. */
  140393. get autoCalcDepthBoundsRefreshRate(): number;
  140394. set autoCalcDepthBoundsRefreshRate(value: number);
  140395. /**
  140396. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  140397. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  140398. * you change the camera near/far planes!
  140399. */
  140400. splitFrustum(): void;
  140401. private _splitFrustum;
  140402. private _computeMatrices;
  140403. private _computeFrustumInWorldSpace;
  140404. private _computeCascadeFrustum;
  140405. /**
  140406. * Support test.
  140407. */
  140408. static get IsSupported(): boolean;
  140409. /** @hidden */
  140410. static _SceneComponentInitialization: (scene: Scene) => void;
  140411. /**
  140412. * Creates a Cascaded Shadow Generator object.
  140413. * A ShadowGenerator is the required tool to use the shadows.
  140414. * Each directional light casting shadows needs to use its own ShadowGenerator.
  140415. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140416. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  140417. * @param light The directional light object generating the shadows.
  140418. * @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.
  140419. */
  140420. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  140421. protected _initializeGenerator(): void;
  140422. protected _createTargetRenderTexture(): void;
  140423. protected _initializeShadowMap(): void;
  140424. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  140425. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  140426. /**
  140427. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  140428. * @param defines Defines of the material we want to update
  140429. * @param lightIndex Index of the light in the enabled light list of the material
  140430. */
  140431. prepareDefines(defines: any, lightIndex: number): void;
  140432. /**
  140433. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  140434. * defined in the generator but impacting the effect).
  140435. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  140436. * @param effect The effect we are binfing the information for
  140437. */
  140438. bindShadowLight(lightIndex: string, effect: Effect): void;
  140439. /**
  140440. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  140441. * (eq to view projection * shadow projection matrices)
  140442. * @returns The transform matrix used to create the shadow map
  140443. */
  140444. getTransformMatrix(): Matrix;
  140445. /**
  140446. * Disposes the ShadowGenerator.
  140447. * Returns nothing.
  140448. */
  140449. dispose(): void;
  140450. /**
  140451. * Serializes the shadow generator setup to a json object.
  140452. * @returns The serialized JSON object
  140453. */
  140454. serialize(): any;
  140455. /**
  140456. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  140457. * @param parsedShadowGenerator The JSON object to parse
  140458. * @param scene The scene to create the shadow map for
  140459. * @returns The parsed shadow generator
  140460. */
  140461. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  140462. }
  140463. }
  140464. declare module BABYLON {
  140465. /**
  140466. * Defines the shadow generator component responsible to manage any shadow generators
  140467. * in a given scene.
  140468. */
  140469. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  140470. /**
  140471. * The component name helpfull to identify the component in the list of scene components.
  140472. */
  140473. readonly name: string;
  140474. /**
  140475. * The scene the component belongs to.
  140476. */
  140477. scene: Scene;
  140478. /**
  140479. * Creates a new instance of the component for the given scene
  140480. * @param scene Defines the scene to register the component in
  140481. */
  140482. constructor(scene: Scene);
  140483. /**
  140484. * Registers the component in a given scene
  140485. */
  140486. register(): void;
  140487. /**
  140488. * Rebuilds the elements related to this component in case of
  140489. * context lost for instance.
  140490. */
  140491. rebuild(): void;
  140492. /**
  140493. * Serializes the component data to the specified json object
  140494. * @param serializationObject The object to serialize to
  140495. */
  140496. serialize(serializationObject: any): void;
  140497. /**
  140498. * Adds all the elements from the container to the scene
  140499. * @param container the container holding the elements
  140500. */
  140501. addFromContainer(container: AbstractScene): void;
  140502. /**
  140503. * Removes all the elements in the container from the scene
  140504. * @param container contains the elements to remove
  140505. * @param dispose if the removed element should be disposed (default: false)
  140506. */
  140507. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140508. /**
  140509. * Rebuilds the elements related to this component in case of
  140510. * context lost for instance.
  140511. */
  140512. dispose(): void;
  140513. private _gatherRenderTargets;
  140514. }
  140515. }
  140516. declare module BABYLON {
  140517. /**
  140518. * A point light is a light defined by an unique point in world space.
  140519. * The light is emitted in every direction from this point.
  140520. * A good example of a point light is a standard light bulb.
  140521. * Documentation: https://doc.babylonjs.com/babylon101/lights
  140522. */
  140523. export class PointLight extends ShadowLight {
  140524. private _shadowAngle;
  140525. /**
  140526. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140527. * This specifies what angle the shadow will use to be created.
  140528. *
  140529. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140530. */
  140531. get shadowAngle(): number;
  140532. /**
  140533. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140534. * This specifies what angle the shadow will use to be created.
  140535. *
  140536. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140537. */
  140538. set shadowAngle(value: number);
  140539. /**
  140540. * Gets the direction if it has been set.
  140541. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140542. */
  140543. get direction(): Vector3;
  140544. /**
  140545. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140546. */
  140547. set direction(value: Vector3);
  140548. /**
  140549. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  140550. * A PointLight emits the light in every direction.
  140551. * It can cast shadows.
  140552. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  140553. * ```javascript
  140554. * var pointLight = new PointLight("pl", camera.position, scene);
  140555. * ```
  140556. * Documentation : https://doc.babylonjs.com/babylon101/lights
  140557. * @param name The light friendly name
  140558. * @param position The position of the point light in the scene
  140559. * @param scene The scene the lights belongs to
  140560. */
  140561. constructor(name: string, position: Vector3, scene: Scene);
  140562. /**
  140563. * Returns the string "PointLight"
  140564. * @returns the class name
  140565. */
  140566. getClassName(): string;
  140567. /**
  140568. * Returns the integer 0.
  140569. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140570. */
  140571. getTypeID(): number;
  140572. /**
  140573. * Specifies wether or not the shadowmap should be a cube texture.
  140574. * @returns true if the shadowmap needs to be a cube texture.
  140575. */
  140576. needCube(): boolean;
  140577. /**
  140578. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140579. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140580. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140581. */
  140582. getShadowDirection(faceIndex?: number): Vector3;
  140583. /**
  140584. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140585. * - fov = PI / 2
  140586. * - aspect ratio : 1.0
  140587. * - z-near and far equal to the active camera minZ and maxZ.
  140588. * Returns the PointLight.
  140589. */
  140590. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140591. protected _buildUniformLayout(): void;
  140592. /**
  140593. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140594. * @param effect The effect to update
  140595. * @param lightIndex The index of the light in the effect to update
  140596. * @returns The point light
  140597. */
  140598. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140599. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140600. /**
  140601. * Prepares the list of defines specific to the light type.
  140602. * @param defines the list of defines
  140603. * @param lightIndex defines the index of the light for the effect
  140604. */
  140605. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140606. }
  140607. }
  140608. declare module BABYLON {
  140609. /**
  140610. * Header information of HDR texture files.
  140611. */
  140612. export interface HDRInfo {
  140613. /**
  140614. * The height of the texture in pixels.
  140615. */
  140616. height: number;
  140617. /**
  140618. * The width of the texture in pixels.
  140619. */
  140620. width: number;
  140621. /**
  140622. * The index of the beginning of the data in the binary file.
  140623. */
  140624. dataPosition: number;
  140625. }
  140626. /**
  140627. * This groups tools to convert HDR texture to native colors array.
  140628. */
  140629. export class HDRTools {
  140630. private static Ldexp;
  140631. private static Rgbe2float;
  140632. private static readStringLine;
  140633. /**
  140634. * Reads header information from an RGBE texture stored in a native array.
  140635. * More information on this format are available here:
  140636. * https://en.wikipedia.org/wiki/RGBE_image_format
  140637. *
  140638. * @param uint8array The binary file stored in native array.
  140639. * @return The header information.
  140640. */
  140641. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  140642. /**
  140643. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  140644. * This RGBE texture needs to store the information as a panorama.
  140645. *
  140646. * More information on this format are available here:
  140647. * https://en.wikipedia.org/wiki/RGBE_image_format
  140648. *
  140649. * @param buffer The binary file stored in an array buffer.
  140650. * @param size The expected size of the extracted cubemap.
  140651. * @return The Cube Map information.
  140652. */
  140653. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  140654. /**
  140655. * Returns the pixels data extracted from an RGBE texture.
  140656. * This pixels will be stored left to right up to down in the R G B order in one array.
  140657. *
  140658. * More information on this format are available here:
  140659. * https://en.wikipedia.org/wiki/RGBE_image_format
  140660. *
  140661. * @param uint8array The binary file stored in an array buffer.
  140662. * @param hdrInfo The header information of the file.
  140663. * @return The pixels data in RGB right to left up to down order.
  140664. */
  140665. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  140666. private static RGBE_ReadPixels_RLE;
  140667. private static RGBE_ReadPixels_NOT_RLE;
  140668. }
  140669. }
  140670. declare module BABYLON {
  140671. /**
  140672. * Effect Render Options
  140673. */
  140674. export interface IEffectRendererOptions {
  140675. /**
  140676. * Defines the vertices positions.
  140677. */
  140678. positions?: number[];
  140679. /**
  140680. * Defines the indices.
  140681. */
  140682. indices?: number[];
  140683. }
  140684. /**
  140685. * Helper class to render one or more effects.
  140686. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  140687. */
  140688. export class EffectRenderer {
  140689. private engine;
  140690. private static _DefaultOptions;
  140691. private _vertexBuffers;
  140692. private _indexBuffer;
  140693. private _fullscreenViewport;
  140694. /**
  140695. * Creates an effect renderer
  140696. * @param engine the engine to use for rendering
  140697. * @param options defines the options of the effect renderer
  140698. */
  140699. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  140700. /**
  140701. * Sets the current viewport in normalized coordinates 0-1
  140702. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  140703. */
  140704. setViewport(viewport?: Viewport): void;
  140705. /**
  140706. * Binds the embedded attributes buffer to the effect.
  140707. * @param effect Defines the effect to bind the attributes for
  140708. */
  140709. bindBuffers(effect: Effect): void;
  140710. /**
  140711. * Sets the current effect wrapper to use during draw.
  140712. * The effect needs to be ready before calling this api.
  140713. * This also sets the default full screen position attribute.
  140714. * @param effectWrapper Defines the effect to draw with
  140715. */
  140716. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  140717. /**
  140718. * Restores engine states
  140719. */
  140720. restoreStates(): void;
  140721. /**
  140722. * Draws a full screen quad.
  140723. */
  140724. draw(): void;
  140725. private isRenderTargetTexture;
  140726. /**
  140727. * renders one or more effects to a specified texture
  140728. * @param effectWrapper the effect to renderer
  140729. * @param outputTexture texture to draw to, if null it will render to the screen.
  140730. */
  140731. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  140732. /**
  140733. * Disposes of the effect renderer
  140734. */
  140735. dispose(): void;
  140736. }
  140737. /**
  140738. * Options to create an EffectWrapper
  140739. */
  140740. interface EffectWrapperCreationOptions {
  140741. /**
  140742. * Engine to use to create the effect
  140743. */
  140744. engine: ThinEngine;
  140745. /**
  140746. * Fragment shader for the effect
  140747. */
  140748. fragmentShader: string;
  140749. /**
  140750. * Use the shader store instead of direct source code
  140751. */
  140752. useShaderStore?: boolean;
  140753. /**
  140754. * Vertex shader for the effect
  140755. */
  140756. vertexShader?: string;
  140757. /**
  140758. * Attributes to use in the shader
  140759. */
  140760. attributeNames?: Array<string>;
  140761. /**
  140762. * Uniforms to use in the shader
  140763. */
  140764. uniformNames?: Array<string>;
  140765. /**
  140766. * Texture sampler names to use in the shader
  140767. */
  140768. samplerNames?: Array<string>;
  140769. /**
  140770. * Defines to use in the shader
  140771. */
  140772. defines?: Array<string>;
  140773. /**
  140774. * Callback when effect is compiled
  140775. */
  140776. onCompiled?: Nullable<(effect: Effect) => void>;
  140777. /**
  140778. * The friendly name of the effect displayed in Spector.
  140779. */
  140780. name?: string;
  140781. }
  140782. /**
  140783. * Wraps an effect to be used for rendering
  140784. */
  140785. export class EffectWrapper {
  140786. /**
  140787. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  140788. */
  140789. onApplyObservable: Observable<{}>;
  140790. /**
  140791. * The underlying effect
  140792. */
  140793. effect: Effect;
  140794. /**
  140795. * Creates an effect to be renderer
  140796. * @param creationOptions options to create the effect
  140797. */
  140798. constructor(creationOptions: EffectWrapperCreationOptions);
  140799. /**
  140800. * Disposes of the effect wrapper
  140801. */
  140802. dispose(): void;
  140803. }
  140804. }
  140805. declare module BABYLON {
  140806. /** @hidden */
  140807. export var hdrFilteringVertexShader: {
  140808. name: string;
  140809. shader: string;
  140810. };
  140811. }
  140812. declare module BABYLON {
  140813. /** @hidden */
  140814. export var hdrFilteringPixelShader: {
  140815. name: string;
  140816. shader: string;
  140817. };
  140818. }
  140819. declare module BABYLON {
  140820. /**
  140821. * Options for texture filtering
  140822. */
  140823. interface IHDRFilteringOptions {
  140824. /**
  140825. * Scales pixel intensity for the input HDR map.
  140826. */
  140827. hdrScale?: number;
  140828. /**
  140829. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  140830. */
  140831. quality?: number;
  140832. }
  140833. /**
  140834. * Filters HDR maps to get correct renderings of PBR reflections
  140835. */
  140836. export class HDRFiltering {
  140837. private _engine;
  140838. private _effectRenderer;
  140839. private _effectWrapper;
  140840. private _lodGenerationOffset;
  140841. private _lodGenerationScale;
  140842. /**
  140843. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  140844. * you care about baking speed.
  140845. */
  140846. quality: number;
  140847. /**
  140848. * Scales pixel intensity for the input HDR map.
  140849. */
  140850. hdrScale: number;
  140851. /**
  140852. * Instantiates HDR filter for reflection maps
  140853. *
  140854. * @param engine Thin engine
  140855. * @param options Options
  140856. */
  140857. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  140858. private _createRenderTarget;
  140859. private _prefilterInternal;
  140860. private _createEffect;
  140861. /**
  140862. * Get a value indicating if the filter is ready to be used
  140863. * @param texture Texture to filter
  140864. * @returns true if the filter is ready
  140865. */
  140866. isReady(texture: BaseTexture): boolean;
  140867. /**
  140868. * Prefilters a cube texture to have mipmap levels representing roughness values.
  140869. * Prefiltering will be invoked at the end of next rendering pass.
  140870. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  140871. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  140872. * @param texture Texture to filter
  140873. * @param onFinished Callback when filtering is done
  140874. * @return Promise called when prefiltering is done
  140875. */
  140876. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  140877. }
  140878. }
  140879. declare module BABYLON {
  140880. /**
  140881. * This represents a texture coming from an HDR input.
  140882. *
  140883. * The only supported format is currently panorama picture stored in RGBE format.
  140884. * Example of such files can be found on HDRLib: http://hdrlib.com/
  140885. */
  140886. export class HDRCubeTexture extends BaseTexture {
  140887. private static _facesMapping;
  140888. private _generateHarmonics;
  140889. private _noMipmap;
  140890. private _prefilterOnLoad;
  140891. private _textureMatrix;
  140892. private _size;
  140893. private _onLoad;
  140894. private _onError;
  140895. /**
  140896. * The texture URL.
  140897. */
  140898. url: string;
  140899. protected _isBlocking: boolean;
  140900. /**
  140901. * Sets wether or not the texture is blocking during loading.
  140902. */
  140903. set isBlocking(value: boolean);
  140904. /**
  140905. * Gets wether or not the texture is blocking during loading.
  140906. */
  140907. get isBlocking(): boolean;
  140908. protected _rotationY: number;
  140909. /**
  140910. * Sets texture matrix rotation angle around Y axis in radians.
  140911. */
  140912. set rotationY(value: number);
  140913. /**
  140914. * Gets texture matrix rotation angle around Y axis radians.
  140915. */
  140916. get rotationY(): number;
  140917. /**
  140918. * Gets or sets the center of the bounding box associated with the cube texture
  140919. * It must define where the camera used to render the texture was set
  140920. */
  140921. boundingBoxPosition: Vector3;
  140922. private _boundingBoxSize;
  140923. /**
  140924. * Gets or sets the size of the bounding box associated with the cube texture
  140925. * When defined, the cubemap will switch to local mode
  140926. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  140927. * @example https://www.babylonjs-playground.com/#RNASML
  140928. */
  140929. set boundingBoxSize(value: Vector3);
  140930. get boundingBoxSize(): Vector3;
  140931. /**
  140932. * Instantiates an HDRTexture from the following parameters.
  140933. *
  140934. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  140935. * @param sceneOrEngine The scene or engine the texture will be used in
  140936. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140937. * @param noMipmap Forces to not generate the mipmap if true
  140938. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  140939. * @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)
  140940. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  140941. */
  140942. 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>);
  140943. /**
  140944. * Get the current class name of the texture useful for serialization or dynamic coding.
  140945. * @returns "HDRCubeTexture"
  140946. */
  140947. getClassName(): string;
  140948. /**
  140949. * Occurs when the file is raw .hdr file.
  140950. */
  140951. private loadTexture;
  140952. clone(): HDRCubeTexture;
  140953. delayLoad(): void;
  140954. /**
  140955. * Get the texture reflection matrix used to rotate/transform the reflection.
  140956. * @returns the reflection matrix
  140957. */
  140958. getReflectionTextureMatrix(): Matrix;
  140959. /**
  140960. * Set the texture reflection matrix used to rotate/transform the reflection.
  140961. * @param value Define the reflection matrix to set
  140962. */
  140963. setReflectionTextureMatrix(value: Matrix): void;
  140964. /**
  140965. * Parses a JSON representation of an HDR Texture in order to create the texture
  140966. * @param parsedTexture Define the JSON representation
  140967. * @param scene Define the scene the texture should be created in
  140968. * @param rootUrl Define the root url in case we need to load relative dependencies
  140969. * @returns the newly created texture after parsing
  140970. */
  140971. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  140972. serialize(): any;
  140973. }
  140974. }
  140975. declare module BABYLON {
  140976. /**
  140977. * Class used to control physics engine
  140978. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140979. */
  140980. export class PhysicsEngine implements IPhysicsEngine {
  140981. private _physicsPlugin;
  140982. /**
  140983. * Global value used to control the smallest number supported by the simulation
  140984. */
  140985. static Epsilon: number;
  140986. private _impostors;
  140987. private _joints;
  140988. private _subTimeStep;
  140989. /**
  140990. * Gets the gravity vector used by the simulation
  140991. */
  140992. gravity: Vector3;
  140993. /**
  140994. * Factory used to create the default physics plugin.
  140995. * @returns The default physics plugin
  140996. */
  140997. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  140998. /**
  140999. * Creates a new Physics Engine
  141000. * @param gravity defines the gravity vector used by the simulation
  141001. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  141002. */
  141003. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  141004. /**
  141005. * Sets the gravity vector used by the simulation
  141006. * @param gravity defines the gravity vector to use
  141007. */
  141008. setGravity(gravity: Vector3): void;
  141009. /**
  141010. * Set the time step of the physics engine.
  141011. * Default is 1/60.
  141012. * To slow it down, enter 1/600 for example.
  141013. * To speed it up, 1/30
  141014. * @param newTimeStep defines the new timestep to apply to this world.
  141015. */
  141016. setTimeStep(newTimeStep?: number): void;
  141017. /**
  141018. * Get the time step of the physics engine.
  141019. * @returns the current time step
  141020. */
  141021. getTimeStep(): number;
  141022. /**
  141023. * Set the sub time step of the physics engine.
  141024. * Default is 0 meaning there is no sub steps
  141025. * To increase physics resolution precision, set a small value (like 1 ms)
  141026. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141027. */
  141028. setSubTimeStep(subTimeStep?: number): void;
  141029. /**
  141030. * Get the sub time step of the physics engine.
  141031. * @returns the current sub time step
  141032. */
  141033. getSubTimeStep(): number;
  141034. /**
  141035. * Release all resources
  141036. */
  141037. dispose(): void;
  141038. /**
  141039. * Gets the name of the current physics plugin
  141040. * @returns the name of the plugin
  141041. */
  141042. getPhysicsPluginName(): string;
  141043. /**
  141044. * Adding a new impostor for the impostor tracking.
  141045. * This will be done by the impostor itself.
  141046. * @param impostor the impostor to add
  141047. */
  141048. addImpostor(impostor: PhysicsImpostor): void;
  141049. /**
  141050. * Remove an impostor from the engine.
  141051. * This impostor and its mesh will not longer be updated by the physics engine.
  141052. * @param impostor the impostor to remove
  141053. */
  141054. removeImpostor(impostor: PhysicsImpostor): void;
  141055. /**
  141056. * Add a joint to the physics engine
  141057. * @param mainImpostor defines the main impostor to which the joint is added.
  141058. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141059. * @param joint defines the joint that will connect both impostors.
  141060. */
  141061. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141062. /**
  141063. * Removes a joint from the simulation
  141064. * @param mainImpostor defines the impostor used with the joint
  141065. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141066. * @param joint defines the joint to remove
  141067. */
  141068. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141069. /**
  141070. * Called by the scene. No need to call it.
  141071. * @param delta defines the timespam between frames
  141072. */
  141073. _step(delta: number): void;
  141074. /**
  141075. * Gets the current plugin used to run the simulation
  141076. * @returns current plugin
  141077. */
  141078. getPhysicsPlugin(): IPhysicsEnginePlugin;
  141079. /**
  141080. * Gets the list of physic impostors
  141081. * @returns an array of PhysicsImpostor
  141082. */
  141083. getImpostors(): Array<PhysicsImpostor>;
  141084. /**
  141085. * Gets the impostor for a physics enabled object
  141086. * @param object defines the object impersonated by the impostor
  141087. * @returns the PhysicsImpostor or null if not found
  141088. */
  141089. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  141090. /**
  141091. * Gets the impostor for a physics body object
  141092. * @param body defines physics body used by the impostor
  141093. * @returns the PhysicsImpostor or null if not found
  141094. */
  141095. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  141096. /**
  141097. * Does a raycast in the physics world
  141098. * @param from when should the ray start?
  141099. * @param to when should the ray end?
  141100. * @returns PhysicsRaycastResult
  141101. */
  141102. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141103. }
  141104. }
  141105. declare module BABYLON {
  141106. /** @hidden */
  141107. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141108. private _useDeltaForWorldStep;
  141109. world: any;
  141110. name: string;
  141111. private _physicsMaterials;
  141112. private _fixedTimeStep;
  141113. private _cannonRaycastResult;
  141114. private _raycastResult;
  141115. private _physicsBodysToRemoveAfterStep;
  141116. private _firstFrame;
  141117. BJSCANNON: any;
  141118. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141119. setGravity(gravity: Vector3): void;
  141120. setTimeStep(timeStep: number): void;
  141121. getTimeStep(): number;
  141122. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141123. private _removeMarkedPhysicsBodiesFromWorld;
  141124. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141125. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141126. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141127. private _processChildMeshes;
  141128. removePhysicsBody(impostor: PhysicsImpostor): void;
  141129. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141130. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141131. private _addMaterial;
  141132. private _checkWithEpsilon;
  141133. private _createShape;
  141134. private _createHeightmap;
  141135. private _minus90X;
  141136. private _plus90X;
  141137. private _tmpPosition;
  141138. private _tmpDeltaPosition;
  141139. private _tmpUnityRotation;
  141140. private _updatePhysicsBodyTransformation;
  141141. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141142. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141143. isSupported(): boolean;
  141144. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141145. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141146. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141147. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141148. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141149. getBodyMass(impostor: PhysicsImpostor): number;
  141150. getBodyFriction(impostor: PhysicsImpostor): number;
  141151. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141152. getBodyRestitution(impostor: PhysicsImpostor): number;
  141153. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141154. sleepBody(impostor: PhysicsImpostor): void;
  141155. wakeUpBody(impostor: PhysicsImpostor): void;
  141156. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141157. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141158. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141159. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141160. getRadius(impostor: PhysicsImpostor): number;
  141161. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141162. dispose(): void;
  141163. private _extendNamespace;
  141164. /**
  141165. * Does a raycast in the physics world
  141166. * @param from when should the ray start?
  141167. * @param to when should the ray end?
  141168. * @returns PhysicsRaycastResult
  141169. */
  141170. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141171. }
  141172. }
  141173. declare module BABYLON {
  141174. /** @hidden */
  141175. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141176. private _useDeltaForWorldStep;
  141177. world: any;
  141178. name: string;
  141179. BJSOIMO: any;
  141180. private _raycastResult;
  141181. private _fixedTimeStep;
  141182. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141183. setGravity(gravity: Vector3): void;
  141184. setTimeStep(timeStep: number): void;
  141185. getTimeStep(): number;
  141186. private _tmpImpostorsArray;
  141187. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141188. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141189. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141190. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141191. private _tmpPositionVector;
  141192. removePhysicsBody(impostor: PhysicsImpostor): void;
  141193. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141194. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141195. isSupported(): boolean;
  141196. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141197. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141198. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141199. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141200. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141201. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141202. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141203. getBodyMass(impostor: PhysicsImpostor): number;
  141204. getBodyFriction(impostor: PhysicsImpostor): number;
  141205. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141206. getBodyRestitution(impostor: PhysicsImpostor): number;
  141207. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141208. sleepBody(impostor: PhysicsImpostor): void;
  141209. wakeUpBody(impostor: PhysicsImpostor): void;
  141210. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141211. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  141212. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  141213. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141214. getRadius(impostor: PhysicsImpostor): number;
  141215. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141216. dispose(): void;
  141217. /**
  141218. * Does a raycast in the physics world
  141219. * @param from when should the ray start?
  141220. * @param to when should the ray end?
  141221. * @returns PhysicsRaycastResult
  141222. */
  141223. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141224. }
  141225. }
  141226. declare module BABYLON {
  141227. /**
  141228. * AmmoJS Physics plugin
  141229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141230. * @see https://github.com/kripken/ammo.js/
  141231. */
  141232. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  141233. private _useDeltaForWorldStep;
  141234. /**
  141235. * Reference to the Ammo library
  141236. */
  141237. bjsAMMO: any;
  141238. /**
  141239. * Created ammoJS world which physics bodies are added to
  141240. */
  141241. world: any;
  141242. /**
  141243. * Name of the plugin
  141244. */
  141245. name: string;
  141246. private _timeStep;
  141247. private _fixedTimeStep;
  141248. private _maxSteps;
  141249. private _tmpQuaternion;
  141250. private _tmpAmmoTransform;
  141251. private _tmpAmmoQuaternion;
  141252. private _tmpAmmoConcreteContactResultCallback;
  141253. private _collisionConfiguration;
  141254. private _dispatcher;
  141255. private _overlappingPairCache;
  141256. private _solver;
  141257. private _softBodySolver;
  141258. private _tmpAmmoVectorA;
  141259. private _tmpAmmoVectorB;
  141260. private _tmpAmmoVectorC;
  141261. private _tmpAmmoVectorD;
  141262. private _tmpContactCallbackResult;
  141263. private _tmpAmmoVectorRCA;
  141264. private _tmpAmmoVectorRCB;
  141265. private _raycastResult;
  141266. private static readonly DISABLE_COLLISION_FLAG;
  141267. private static readonly KINEMATIC_FLAG;
  141268. private static readonly DISABLE_DEACTIVATION_FLAG;
  141269. /**
  141270. * Initializes the ammoJS plugin
  141271. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  141272. * @param ammoInjection can be used to inject your own ammo reference
  141273. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  141274. */
  141275. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  141276. /**
  141277. * Sets the gravity of the physics world (m/(s^2))
  141278. * @param gravity Gravity to set
  141279. */
  141280. setGravity(gravity: Vector3): void;
  141281. /**
  141282. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  141283. * @param timeStep timestep to use in seconds
  141284. */
  141285. setTimeStep(timeStep: number): void;
  141286. /**
  141287. * 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)
  141288. * @param fixedTimeStep fixedTimeStep to use in seconds
  141289. */
  141290. setFixedTimeStep(fixedTimeStep: number): void;
  141291. /**
  141292. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  141293. * @param maxSteps the maximum number of steps by the physics engine per frame
  141294. */
  141295. setMaxSteps(maxSteps: number): void;
  141296. /**
  141297. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  141298. * @returns the current timestep in seconds
  141299. */
  141300. getTimeStep(): number;
  141301. /**
  141302. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  141303. */
  141304. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  141305. private _isImpostorInContact;
  141306. private _isImpostorPairInContact;
  141307. private _stepSimulation;
  141308. /**
  141309. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  141310. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  141311. * After the step the babylon meshes are set to the position of the physics imposters
  141312. * @param delta amount of time to step forward
  141313. * @param impostors array of imposters to update before/after the step
  141314. */
  141315. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141316. /**
  141317. * Update babylon mesh to match physics world object
  141318. * @param impostor imposter to match
  141319. */
  141320. private _afterSoftStep;
  141321. /**
  141322. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141323. * @param impostor imposter to match
  141324. */
  141325. private _ropeStep;
  141326. /**
  141327. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141328. * @param impostor imposter to match
  141329. */
  141330. private _softbodyOrClothStep;
  141331. private _tmpMatrix;
  141332. /**
  141333. * Applies an impulse on the imposter
  141334. * @param impostor imposter to apply impulse to
  141335. * @param force amount of force to be applied to the imposter
  141336. * @param contactPoint the location to apply the impulse on the imposter
  141337. */
  141338. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141339. /**
  141340. * Applies a force on the imposter
  141341. * @param impostor imposter to apply force
  141342. * @param force amount of force to be applied to the imposter
  141343. * @param contactPoint the location to apply the force on the imposter
  141344. */
  141345. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141346. /**
  141347. * Creates a physics body using the plugin
  141348. * @param impostor the imposter to create the physics body on
  141349. */
  141350. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141351. /**
  141352. * Removes the physics body from the imposter and disposes of the body's memory
  141353. * @param impostor imposter to remove the physics body from
  141354. */
  141355. removePhysicsBody(impostor: PhysicsImpostor): void;
  141356. /**
  141357. * Generates a joint
  141358. * @param impostorJoint the imposter joint to create the joint with
  141359. */
  141360. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141361. /**
  141362. * Removes a joint
  141363. * @param impostorJoint the imposter joint to remove the joint from
  141364. */
  141365. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141366. private _addMeshVerts;
  141367. /**
  141368. * Initialise the soft body vertices to match its object's (mesh) vertices
  141369. * Softbody vertices (nodes) are in world space and to match this
  141370. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  141371. * @param impostor to create the softbody for
  141372. */
  141373. private _softVertexData;
  141374. /**
  141375. * Create an impostor's soft body
  141376. * @param impostor to create the softbody for
  141377. */
  141378. private _createSoftbody;
  141379. /**
  141380. * Create cloth for an impostor
  141381. * @param impostor to create the softbody for
  141382. */
  141383. private _createCloth;
  141384. /**
  141385. * Create rope for an impostor
  141386. * @param impostor to create the softbody for
  141387. */
  141388. private _createRope;
  141389. /**
  141390. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  141391. * @param impostor to create the custom physics shape for
  141392. */
  141393. private _createCustom;
  141394. private _addHullVerts;
  141395. private _createShape;
  141396. /**
  141397. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  141398. * @param impostor imposter containing the physics body and babylon object
  141399. */
  141400. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141401. /**
  141402. * Sets the babylon object's position/rotation from the physics body's position/rotation
  141403. * @param impostor imposter containing the physics body and babylon object
  141404. * @param newPosition new position
  141405. * @param newRotation new rotation
  141406. */
  141407. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141408. /**
  141409. * If this plugin is supported
  141410. * @returns true if its supported
  141411. */
  141412. isSupported(): boolean;
  141413. /**
  141414. * Sets the linear velocity of the physics body
  141415. * @param impostor imposter to set the velocity on
  141416. * @param velocity velocity to set
  141417. */
  141418. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141419. /**
  141420. * Sets the angular velocity of the physics body
  141421. * @param impostor imposter to set the velocity on
  141422. * @param velocity velocity to set
  141423. */
  141424. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141425. /**
  141426. * gets the linear velocity
  141427. * @param impostor imposter to get linear velocity from
  141428. * @returns linear velocity
  141429. */
  141430. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141431. /**
  141432. * gets the angular velocity
  141433. * @param impostor imposter to get angular velocity from
  141434. * @returns angular velocity
  141435. */
  141436. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141437. /**
  141438. * Sets the mass of physics body
  141439. * @param impostor imposter to set the mass on
  141440. * @param mass mass to set
  141441. */
  141442. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141443. /**
  141444. * Gets the mass of the physics body
  141445. * @param impostor imposter to get the mass from
  141446. * @returns mass
  141447. */
  141448. getBodyMass(impostor: PhysicsImpostor): number;
  141449. /**
  141450. * Gets friction of the impostor
  141451. * @param impostor impostor to get friction from
  141452. * @returns friction value
  141453. */
  141454. getBodyFriction(impostor: PhysicsImpostor): number;
  141455. /**
  141456. * Sets friction of the impostor
  141457. * @param impostor impostor to set friction on
  141458. * @param friction friction value
  141459. */
  141460. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141461. /**
  141462. * Gets restitution of the impostor
  141463. * @param impostor impostor to get restitution from
  141464. * @returns restitution value
  141465. */
  141466. getBodyRestitution(impostor: PhysicsImpostor): number;
  141467. /**
  141468. * Sets resitution of the impostor
  141469. * @param impostor impostor to set resitution on
  141470. * @param restitution resitution value
  141471. */
  141472. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141473. /**
  141474. * Gets pressure inside the impostor
  141475. * @param impostor impostor to get pressure from
  141476. * @returns pressure value
  141477. */
  141478. getBodyPressure(impostor: PhysicsImpostor): number;
  141479. /**
  141480. * Sets pressure inside a soft body impostor
  141481. * Cloth and rope must remain 0 pressure
  141482. * @param impostor impostor to set pressure on
  141483. * @param pressure pressure value
  141484. */
  141485. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  141486. /**
  141487. * Gets stiffness of the impostor
  141488. * @param impostor impostor to get stiffness from
  141489. * @returns pressure value
  141490. */
  141491. getBodyStiffness(impostor: PhysicsImpostor): number;
  141492. /**
  141493. * Sets stiffness of the impostor
  141494. * @param impostor impostor to set stiffness on
  141495. * @param stiffness stiffness value from 0 to 1
  141496. */
  141497. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  141498. /**
  141499. * Gets velocityIterations of the impostor
  141500. * @param impostor impostor to get velocity iterations from
  141501. * @returns velocityIterations value
  141502. */
  141503. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  141504. /**
  141505. * Sets velocityIterations of the impostor
  141506. * @param impostor impostor to set velocity iterations on
  141507. * @param velocityIterations velocityIterations value
  141508. */
  141509. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  141510. /**
  141511. * Gets positionIterations of the impostor
  141512. * @param impostor impostor to get position iterations from
  141513. * @returns positionIterations value
  141514. */
  141515. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  141516. /**
  141517. * Sets positionIterations of the impostor
  141518. * @param impostor impostor to set position on
  141519. * @param positionIterations positionIterations value
  141520. */
  141521. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  141522. /**
  141523. * Append an anchor to a cloth object
  141524. * @param impostor is the cloth impostor to add anchor to
  141525. * @param otherImpostor is the rigid impostor to anchor to
  141526. * @param width ratio across width from 0 to 1
  141527. * @param height ratio up height from 0 to 1
  141528. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  141529. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141530. */
  141531. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141532. /**
  141533. * Append an hook to a rope object
  141534. * @param impostor is the rope impostor to add hook to
  141535. * @param otherImpostor is the rigid impostor to hook to
  141536. * @param length ratio along the rope from 0 to 1
  141537. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  141538. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141539. */
  141540. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141541. /**
  141542. * Sleeps the physics body and stops it from being active
  141543. * @param impostor impostor to sleep
  141544. */
  141545. sleepBody(impostor: PhysicsImpostor): void;
  141546. /**
  141547. * Activates the physics body
  141548. * @param impostor impostor to activate
  141549. */
  141550. wakeUpBody(impostor: PhysicsImpostor): void;
  141551. /**
  141552. * Updates the distance parameters of the joint
  141553. * @param joint joint to update
  141554. * @param maxDistance maximum distance of the joint
  141555. * @param minDistance minimum distance of the joint
  141556. */
  141557. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141558. /**
  141559. * Sets a motor on the joint
  141560. * @param joint joint to set motor on
  141561. * @param speed speed of the motor
  141562. * @param maxForce maximum force of the motor
  141563. * @param motorIndex index of the motor
  141564. */
  141565. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141566. /**
  141567. * Sets the motors limit
  141568. * @param joint joint to set limit on
  141569. * @param upperLimit upper limit
  141570. * @param lowerLimit lower limit
  141571. */
  141572. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141573. /**
  141574. * Syncs the position and rotation of a mesh with the impostor
  141575. * @param mesh mesh to sync
  141576. * @param impostor impostor to update the mesh with
  141577. */
  141578. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141579. /**
  141580. * Gets the radius of the impostor
  141581. * @param impostor impostor to get radius from
  141582. * @returns the radius
  141583. */
  141584. getRadius(impostor: PhysicsImpostor): number;
  141585. /**
  141586. * Gets the box size of the impostor
  141587. * @param impostor impostor to get box size from
  141588. * @param result the resulting box size
  141589. */
  141590. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141591. /**
  141592. * Disposes of the impostor
  141593. */
  141594. dispose(): void;
  141595. /**
  141596. * Does a raycast in the physics world
  141597. * @param from when should the ray start?
  141598. * @param to when should the ray end?
  141599. * @returns PhysicsRaycastResult
  141600. */
  141601. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141602. }
  141603. }
  141604. declare module BABYLON {
  141605. interface AbstractScene {
  141606. /**
  141607. * The list of reflection probes added to the scene
  141608. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141609. */
  141610. reflectionProbes: Array<ReflectionProbe>;
  141611. /**
  141612. * Removes the given reflection probe from this scene.
  141613. * @param toRemove The reflection probe to remove
  141614. * @returns The index of the removed reflection probe
  141615. */
  141616. removeReflectionProbe(toRemove: ReflectionProbe): number;
  141617. /**
  141618. * Adds the given reflection probe to this scene.
  141619. * @param newReflectionProbe The reflection probe to add
  141620. */
  141621. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  141622. }
  141623. /**
  141624. * Class used to generate realtime reflection / refraction cube textures
  141625. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141626. */
  141627. export class ReflectionProbe {
  141628. /** defines the name of the probe */
  141629. name: string;
  141630. private _scene;
  141631. private _renderTargetTexture;
  141632. private _projectionMatrix;
  141633. private _viewMatrix;
  141634. private _target;
  141635. private _add;
  141636. private _attachedMesh;
  141637. private _invertYAxis;
  141638. /** Gets or sets probe position (center of the cube map) */
  141639. position: Vector3;
  141640. /**
  141641. * Creates a new reflection probe
  141642. * @param name defines the name of the probe
  141643. * @param size defines the texture resolution (for each face)
  141644. * @param scene defines the hosting scene
  141645. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  141646. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  141647. */
  141648. constructor(
  141649. /** defines the name of the probe */
  141650. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  141651. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  141652. get samples(): number;
  141653. set samples(value: number);
  141654. /** Gets or sets the refresh rate to use (on every frame by default) */
  141655. get refreshRate(): number;
  141656. set refreshRate(value: number);
  141657. /**
  141658. * Gets the hosting scene
  141659. * @returns a Scene
  141660. */
  141661. getScene(): Scene;
  141662. /** Gets the internal CubeTexture used to render to */
  141663. get cubeTexture(): RenderTargetTexture;
  141664. /** Gets the list of meshes to render */
  141665. get renderList(): Nullable<AbstractMesh[]>;
  141666. /**
  141667. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  141668. * @param mesh defines the mesh to attach to
  141669. */
  141670. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  141671. /**
  141672. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  141673. * @param renderingGroupId The rendering group id corresponding to its index
  141674. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  141675. */
  141676. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  141677. /**
  141678. * Clean all associated resources
  141679. */
  141680. dispose(): void;
  141681. /**
  141682. * Converts the reflection probe information to a readable string for debug purpose.
  141683. * @param fullDetails Supports for multiple levels of logging within scene loading
  141684. * @returns the human readable reflection probe info
  141685. */
  141686. toString(fullDetails?: boolean): string;
  141687. /**
  141688. * Get the class name of the relfection probe.
  141689. * @returns "ReflectionProbe"
  141690. */
  141691. getClassName(): string;
  141692. /**
  141693. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  141694. * @returns The JSON representation of the texture
  141695. */
  141696. serialize(): any;
  141697. /**
  141698. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  141699. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  141700. * @param scene Define the scene the parsed reflection probe should be instantiated in
  141701. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  141702. * @returns The parsed reflection probe if successful
  141703. */
  141704. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  141705. }
  141706. }
  141707. declare module BABYLON {
  141708. /** @hidden */
  141709. export var _BabylonLoaderRegistered: boolean;
  141710. /**
  141711. * Helps setting up some configuration for the babylon file loader.
  141712. */
  141713. export class BabylonFileLoaderConfiguration {
  141714. /**
  141715. * The loader does not allow injecting custom physix engine into the plugins.
  141716. * Unfortunately in ES6, we need to manually inject them into the plugin.
  141717. * So you could set this variable to your engine import to make it work.
  141718. */
  141719. static LoaderInjectedPhysicsEngine: any;
  141720. }
  141721. }
  141722. declare module BABYLON {
  141723. /**
  141724. * The Physically based simple base material of BJS.
  141725. *
  141726. * This enables better naming and convention enforcements on top of the pbrMaterial.
  141727. * It is used as the base class for both the specGloss and metalRough conventions.
  141728. */
  141729. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  141730. /**
  141731. * Number of Simultaneous lights allowed on the material.
  141732. */
  141733. maxSimultaneousLights: number;
  141734. /**
  141735. * If sets to true, disables all the lights affecting the material.
  141736. */
  141737. disableLighting: boolean;
  141738. /**
  141739. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  141740. */
  141741. environmentTexture: BaseTexture;
  141742. /**
  141743. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  141744. */
  141745. invertNormalMapX: boolean;
  141746. /**
  141747. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  141748. */
  141749. invertNormalMapY: boolean;
  141750. /**
  141751. * Normal map used in the model.
  141752. */
  141753. normalTexture: BaseTexture;
  141754. /**
  141755. * Emissivie color used to self-illuminate the model.
  141756. */
  141757. emissiveColor: Color3;
  141758. /**
  141759. * Emissivie texture used to self-illuminate the model.
  141760. */
  141761. emissiveTexture: BaseTexture;
  141762. /**
  141763. * Occlusion Channel Strenght.
  141764. */
  141765. occlusionStrength: number;
  141766. /**
  141767. * Occlusion Texture of the material (adding extra occlusion effects).
  141768. */
  141769. occlusionTexture: BaseTexture;
  141770. /**
  141771. * Defines the alpha limits in alpha test mode.
  141772. */
  141773. alphaCutOff: number;
  141774. /**
  141775. * Gets the current double sided mode.
  141776. */
  141777. get doubleSided(): boolean;
  141778. /**
  141779. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  141780. */
  141781. set doubleSided(value: boolean);
  141782. /**
  141783. * Stores the pre-calculated light information of a mesh in a texture.
  141784. */
  141785. lightmapTexture: BaseTexture;
  141786. /**
  141787. * If true, the light map contains occlusion information instead of lighting info.
  141788. */
  141789. useLightmapAsShadowmap: boolean;
  141790. /**
  141791. * Instantiates a new PBRMaterial instance.
  141792. *
  141793. * @param name The material name
  141794. * @param scene The scene the material will be use in.
  141795. */
  141796. constructor(name: string, scene: Scene);
  141797. getClassName(): string;
  141798. }
  141799. }
  141800. declare module BABYLON {
  141801. /**
  141802. * The PBR material of BJS following the metal roughness convention.
  141803. *
  141804. * This fits to the PBR convention in the GLTF definition:
  141805. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  141806. */
  141807. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  141808. /**
  141809. * The base color has two different interpretations depending on the value of metalness.
  141810. * When the material is a metal, the base color is the specific measured reflectance value
  141811. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  141812. * of the material.
  141813. */
  141814. baseColor: Color3;
  141815. /**
  141816. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  141817. * well as opacity information in the alpha channel.
  141818. */
  141819. baseTexture: BaseTexture;
  141820. /**
  141821. * Specifies the metallic scalar value of the material.
  141822. * Can also be used to scale the metalness values of the metallic texture.
  141823. */
  141824. metallic: number;
  141825. /**
  141826. * Specifies the roughness scalar value of the material.
  141827. * Can also be used to scale the roughness values of the metallic texture.
  141828. */
  141829. roughness: number;
  141830. /**
  141831. * Texture containing both the metallic value in the B channel and the
  141832. * roughness value in the G channel to keep better precision.
  141833. */
  141834. metallicRoughnessTexture: BaseTexture;
  141835. /**
  141836. * Instantiates a new PBRMetalRoughnessMaterial instance.
  141837. *
  141838. * @param name The material name
  141839. * @param scene The scene the material will be use in.
  141840. */
  141841. constructor(name: string, scene: Scene);
  141842. /**
  141843. * Return the currrent class name of the material.
  141844. */
  141845. getClassName(): string;
  141846. /**
  141847. * Makes a duplicate of the current material.
  141848. * @param name - name to use for the new material.
  141849. */
  141850. clone(name: string): PBRMetallicRoughnessMaterial;
  141851. /**
  141852. * Serialize the material to a parsable JSON object.
  141853. */
  141854. serialize(): any;
  141855. /**
  141856. * Parses a JSON object correponding to the serialize function.
  141857. */
  141858. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  141859. }
  141860. }
  141861. declare module BABYLON {
  141862. /**
  141863. * The PBR material of BJS following the specular glossiness convention.
  141864. *
  141865. * This fits to the PBR convention in the GLTF definition:
  141866. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  141867. */
  141868. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  141869. /**
  141870. * Specifies the diffuse color of the material.
  141871. */
  141872. diffuseColor: Color3;
  141873. /**
  141874. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  141875. * channel.
  141876. */
  141877. diffuseTexture: BaseTexture;
  141878. /**
  141879. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  141880. */
  141881. specularColor: Color3;
  141882. /**
  141883. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  141884. */
  141885. glossiness: number;
  141886. /**
  141887. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  141888. */
  141889. specularGlossinessTexture: BaseTexture;
  141890. /**
  141891. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  141892. *
  141893. * @param name The material name
  141894. * @param scene The scene the material will be use in.
  141895. */
  141896. constructor(name: string, scene: Scene);
  141897. /**
  141898. * Return the currrent class name of the material.
  141899. */
  141900. getClassName(): string;
  141901. /**
  141902. * Makes a duplicate of the current material.
  141903. * @param name - name to use for the new material.
  141904. */
  141905. clone(name: string): PBRSpecularGlossinessMaterial;
  141906. /**
  141907. * Serialize the material to a parsable JSON object.
  141908. */
  141909. serialize(): any;
  141910. /**
  141911. * Parses a JSON object correponding to the serialize function.
  141912. */
  141913. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  141914. }
  141915. }
  141916. declare module BABYLON {
  141917. /**
  141918. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  141919. * It can help converting any input color in a desired output one. This can then be used to create effects
  141920. * from sepia, black and white to sixties or futuristic rendering...
  141921. *
  141922. * The only supported format is currently 3dl.
  141923. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  141924. */
  141925. export class ColorGradingTexture extends BaseTexture {
  141926. /**
  141927. * The texture URL.
  141928. */
  141929. url: string;
  141930. /**
  141931. * Empty line regex stored for GC.
  141932. */
  141933. private static _noneEmptyLineRegex;
  141934. private _textureMatrix;
  141935. private _onLoad;
  141936. /**
  141937. * Instantiates a ColorGradingTexture from the following parameters.
  141938. *
  141939. * @param url The location of the color gradind data (currently only supporting 3dl)
  141940. * @param sceneOrEngine The scene or engine the texture will be used in
  141941. * @param onLoad defines a callback triggered when the texture has been loaded
  141942. */
  141943. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  141944. /**
  141945. * Fires the onload event from the constructor if requested.
  141946. */
  141947. private _triggerOnLoad;
  141948. /**
  141949. * Returns the texture matrix used in most of the material.
  141950. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  141951. */
  141952. getTextureMatrix(): Matrix;
  141953. /**
  141954. * Occurs when the file being loaded is a .3dl LUT file.
  141955. */
  141956. private load3dlTexture;
  141957. /**
  141958. * Starts the loading process of the texture.
  141959. */
  141960. private loadTexture;
  141961. /**
  141962. * Clones the color gradind texture.
  141963. */
  141964. clone(): ColorGradingTexture;
  141965. /**
  141966. * Called during delayed load for textures.
  141967. */
  141968. delayLoad(): void;
  141969. /**
  141970. * Parses a color grading texture serialized by Babylon.
  141971. * @param parsedTexture The texture information being parsedTexture
  141972. * @param scene The scene to load the texture in
  141973. * @param rootUrl The root url of the data assets to load
  141974. * @return A color gradind texture
  141975. */
  141976. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  141977. /**
  141978. * Serializes the LUT texture to json format.
  141979. */
  141980. serialize(): any;
  141981. }
  141982. }
  141983. declare module BABYLON {
  141984. /**
  141985. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  141986. */
  141987. export class EquiRectangularCubeTexture extends BaseTexture {
  141988. /** The six faces of the cube. */
  141989. private static _FacesMapping;
  141990. private _noMipmap;
  141991. private _onLoad;
  141992. private _onError;
  141993. /** The size of the cubemap. */
  141994. private _size;
  141995. /** The buffer of the image. */
  141996. private _buffer;
  141997. /** The width of the input image. */
  141998. private _width;
  141999. /** The height of the input image. */
  142000. private _height;
  142001. /** The URL to the image. */
  142002. url: string;
  142003. /**
  142004. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  142005. * @param url The location of the image
  142006. * @param scene The scene the texture will be used in
  142007. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142008. * @param noMipmap Forces to not generate the mipmap if true
  142009. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142010. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142011. * @param onLoad — defines a callback called when texture is loaded
  142012. * @param onError — defines a callback called if there is an error
  142013. */
  142014. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  142015. /**
  142016. * Load the image data, by putting the image on a canvas and extracting its buffer.
  142017. */
  142018. private loadImage;
  142019. /**
  142020. * Convert the image buffer into a cubemap and create a CubeTexture.
  142021. */
  142022. private loadTexture;
  142023. /**
  142024. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142025. * @param buffer The ArrayBuffer that should be converted.
  142026. * @returns The buffer as Float32Array.
  142027. */
  142028. private getFloat32ArrayFromArrayBuffer;
  142029. /**
  142030. * Get the current class name of the texture useful for serialization or dynamic coding.
  142031. * @returns "EquiRectangularCubeTexture"
  142032. */
  142033. getClassName(): string;
  142034. /**
  142035. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142036. * @returns A clone of the current EquiRectangularCubeTexture.
  142037. */
  142038. clone(): EquiRectangularCubeTexture;
  142039. }
  142040. }
  142041. declare module BABYLON {
  142042. /**
  142043. * Defines the options related to the creation of an HtmlElementTexture
  142044. */
  142045. export interface IHtmlElementTextureOptions {
  142046. /**
  142047. * Defines wether mip maps should be created or not.
  142048. */
  142049. generateMipMaps?: boolean;
  142050. /**
  142051. * Defines the sampling mode of the texture.
  142052. */
  142053. samplingMode?: number;
  142054. /**
  142055. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142056. */
  142057. engine: Nullable<ThinEngine>;
  142058. /**
  142059. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142060. */
  142061. scene: Nullable<Scene>;
  142062. }
  142063. /**
  142064. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142065. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142066. * is automatically managed.
  142067. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142068. * in your application.
  142069. *
  142070. * As the update is not automatic, you need to call them manually.
  142071. */
  142072. export class HtmlElementTexture extends BaseTexture {
  142073. /**
  142074. * The texture URL.
  142075. */
  142076. element: HTMLVideoElement | HTMLCanvasElement;
  142077. private static readonly DefaultOptions;
  142078. private _textureMatrix;
  142079. private _isVideo;
  142080. private _generateMipMaps;
  142081. private _samplingMode;
  142082. /**
  142083. * Instantiates a HtmlElementTexture from the following parameters.
  142084. *
  142085. * @param name Defines the name of the texture
  142086. * @param element Defines the video or canvas the texture is filled with
  142087. * @param options Defines the other none mandatory texture creation options
  142088. */
  142089. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  142090. private _createInternalTexture;
  142091. /**
  142092. * Returns the texture matrix used in most of the material.
  142093. */
  142094. getTextureMatrix(): Matrix;
  142095. /**
  142096. * Updates the content of the texture.
  142097. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  142098. */
  142099. update(invertY?: Nullable<boolean>): void;
  142100. }
  142101. }
  142102. declare module BABYLON {
  142103. /**
  142104. * Based on jsTGALoader - Javascript loader for TGA file
  142105. * By Vincent Thibault
  142106. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142107. */
  142108. export class TGATools {
  142109. private static _TYPE_INDEXED;
  142110. private static _TYPE_RGB;
  142111. private static _TYPE_GREY;
  142112. private static _TYPE_RLE_INDEXED;
  142113. private static _TYPE_RLE_RGB;
  142114. private static _TYPE_RLE_GREY;
  142115. private static _ORIGIN_MASK;
  142116. private static _ORIGIN_SHIFT;
  142117. private static _ORIGIN_BL;
  142118. private static _ORIGIN_BR;
  142119. private static _ORIGIN_UL;
  142120. private static _ORIGIN_UR;
  142121. /**
  142122. * Gets the header of a TGA file
  142123. * @param data defines the TGA data
  142124. * @returns the header
  142125. */
  142126. static GetTGAHeader(data: Uint8Array): any;
  142127. /**
  142128. * Uploads TGA content to a Babylon Texture
  142129. * @hidden
  142130. */
  142131. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142132. /** @hidden */
  142133. 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;
  142134. /** @hidden */
  142135. 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;
  142136. /** @hidden */
  142137. 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;
  142138. /** @hidden */
  142139. 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;
  142140. /** @hidden */
  142141. 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;
  142142. /** @hidden */
  142143. 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;
  142144. }
  142145. }
  142146. declare module BABYLON {
  142147. /**
  142148. * Implementation of the TGA Texture Loader.
  142149. * @hidden
  142150. */
  142151. export class _TGATextureLoader implements IInternalTextureLoader {
  142152. /**
  142153. * Defines wether the loader supports cascade loading the different faces.
  142154. */
  142155. readonly supportCascades: boolean;
  142156. /**
  142157. * This returns if the loader support the current file information.
  142158. * @param extension defines the file extension of the file being loaded
  142159. * @returns true if the loader can load the specified file
  142160. */
  142161. canLoad(extension: string): boolean;
  142162. /**
  142163. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142164. * @param data contains the texture data
  142165. * @param texture defines the BabylonJS internal texture
  142166. * @param createPolynomials will be true if polynomials have been requested
  142167. * @param onLoad defines the callback to trigger once the texture is ready
  142168. * @param onError defines the callback to trigger in case of error
  142169. */
  142170. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142171. /**
  142172. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142173. * @param data contains the texture data
  142174. * @param texture defines the BabylonJS internal texture
  142175. * @param callback defines the method to call once ready to upload
  142176. */
  142177. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142178. }
  142179. }
  142180. declare module BABYLON {
  142181. /**
  142182. * Info about the .basis files
  142183. */
  142184. class BasisFileInfo {
  142185. /**
  142186. * If the file has alpha
  142187. */
  142188. hasAlpha: boolean;
  142189. /**
  142190. * Info about each image of the basis file
  142191. */
  142192. images: Array<{
  142193. levels: Array<{
  142194. width: number;
  142195. height: number;
  142196. transcodedPixels: ArrayBufferView;
  142197. }>;
  142198. }>;
  142199. }
  142200. /**
  142201. * Result of transcoding a basis file
  142202. */
  142203. class TranscodeResult {
  142204. /**
  142205. * Info about the .basis file
  142206. */
  142207. fileInfo: BasisFileInfo;
  142208. /**
  142209. * Format to use when loading the file
  142210. */
  142211. format: number;
  142212. }
  142213. /**
  142214. * Configuration options for the Basis transcoder
  142215. */
  142216. export class BasisTranscodeConfiguration {
  142217. /**
  142218. * Supported compression formats used to determine the supported output format of the transcoder
  142219. */
  142220. supportedCompressionFormats?: {
  142221. /**
  142222. * etc1 compression format
  142223. */
  142224. etc1?: boolean;
  142225. /**
  142226. * s3tc compression format
  142227. */
  142228. s3tc?: boolean;
  142229. /**
  142230. * pvrtc compression format
  142231. */
  142232. pvrtc?: boolean;
  142233. /**
  142234. * etc2 compression format
  142235. */
  142236. etc2?: boolean;
  142237. };
  142238. /**
  142239. * If mipmap levels should be loaded for transcoded images (Default: true)
  142240. */
  142241. loadMipmapLevels?: boolean;
  142242. /**
  142243. * Index of a single image to load (Default: all images)
  142244. */
  142245. loadSingleImage?: number;
  142246. }
  142247. /**
  142248. * Used to load .Basis files
  142249. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  142250. */
  142251. export class BasisTools {
  142252. private static _IgnoreSupportedFormats;
  142253. /**
  142254. * URL to use when loading the basis transcoder
  142255. */
  142256. static JSModuleURL: string;
  142257. /**
  142258. * URL to use when loading the wasm module for the transcoder
  142259. */
  142260. static WasmModuleURL: string;
  142261. /**
  142262. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  142263. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  142264. * @returns internal format corresponding to the Basis format
  142265. */
  142266. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  142267. private static _WorkerPromise;
  142268. private static _Worker;
  142269. private static _actionId;
  142270. private static _CreateWorkerAsync;
  142271. /**
  142272. * Transcodes a loaded image file to compressed pixel data
  142273. * @param data image data to transcode
  142274. * @param config configuration options for the transcoding
  142275. * @returns a promise resulting in the transcoded image
  142276. */
  142277. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  142278. /**
  142279. * Loads a texture from the transcode result
  142280. * @param texture texture load to
  142281. * @param transcodeResult the result of transcoding the basis file to load from
  142282. */
  142283. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  142284. }
  142285. }
  142286. declare module BABYLON {
  142287. /**
  142288. * Loader for .basis file format
  142289. */
  142290. export class _BasisTextureLoader implements IInternalTextureLoader {
  142291. /**
  142292. * Defines whether the loader supports cascade loading the different faces.
  142293. */
  142294. readonly supportCascades: boolean;
  142295. /**
  142296. * This returns if the loader support the current file information.
  142297. * @param extension defines the file extension of the file being loaded
  142298. * @returns true if the loader can load the specified file
  142299. */
  142300. canLoad(extension: string): boolean;
  142301. /**
  142302. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142303. * @param data contains the texture data
  142304. * @param texture defines the BabylonJS internal texture
  142305. * @param createPolynomials will be true if polynomials have been requested
  142306. * @param onLoad defines the callback to trigger once the texture is ready
  142307. * @param onError defines the callback to trigger in case of error
  142308. */
  142309. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142310. /**
  142311. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142312. * @param data contains the texture data
  142313. * @param texture defines the BabylonJS internal texture
  142314. * @param callback defines the method to call once ready to upload
  142315. */
  142316. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142317. }
  142318. }
  142319. declare module BABYLON {
  142320. /**
  142321. * Defines the basic options interface of a TexturePacker Frame
  142322. */
  142323. export interface ITexturePackerFrame {
  142324. /**
  142325. * The frame ID
  142326. */
  142327. id: number;
  142328. /**
  142329. * The frames Scale
  142330. */
  142331. scale: Vector2;
  142332. /**
  142333. * The Frames offset
  142334. */
  142335. offset: Vector2;
  142336. }
  142337. /**
  142338. * This is a support class for frame Data on texture packer sets.
  142339. */
  142340. export class TexturePackerFrame implements ITexturePackerFrame {
  142341. /**
  142342. * The frame ID
  142343. */
  142344. id: number;
  142345. /**
  142346. * The frames Scale
  142347. */
  142348. scale: Vector2;
  142349. /**
  142350. * The Frames offset
  142351. */
  142352. offset: Vector2;
  142353. /**
  142354. * Initializes a texture package frame.
  142355. * @param id The numerical frame identifier
  142356. * @param scale Scalar Vector2 for UV frame
  142357. * @param offset Vector2 for the frame position in UV units.
  142358. * @returns TexturePackerFrame
  142359. */
  142360. constructor(id: number, scale: Vector2, offset: Vector2);
  142361. }
  142362. }
  142363. declare module BABYLON {
  142364. /**
  142365. * Defines the basic options interface of a TexturePacker
  142366. */
  142367. export interface ITexturePackerOptions {
  142368. /**
  142369. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  142370. */
  142371. map?: string[];
  142372. /**
  142373. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142374. */
  142375. uvsIn?: string;
  142376. /**
  142377. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142378. */
  142379. uvsOut?: string;
  142380. /**
  142381. * number representing the layout style. Defaults to LAYOUT_STRIP
  142382. */
  142383. layout?: number;
  142384. /**
  142385. * number of columns if using custom column count layout(2). This defaults to 4.
  142386. */
  142387. colnum?: number;
  142388. /**
  142389. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  142390. */
  142391. updateInputMeshes?: boolean;
  142392. /**
  142393. * boolean flag to dispose all the source textures. Defaults to true.
  142394. */
  142395. disposeSources?: boolean;
  142396. /**
  142397. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  142398. */
  142399. fillBlanks?: boolean;
  142400. /**
  142401. * string value representing the context fill style color. Defaults to 'black'.
  142402. */
  142403. customFillColor?: string;
  142404. /**
  142405. * Width and Height Value of each Frame in the TexturePacker Sets
  142406. */
  142407. frameSize?: number;
  142408. /**
  142409. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  142410. */
  142411. paddingRatio?: number;
  142412. /**
  142413. * Number that declares the fill method for the padding gutter.
  142414. */
  142415. paddingMode?: number;
  142416. /**
  142417. * If in SUBUV_COLOR padding mode what color to use.
  142418. */
  142419. paddingColor?: Color3 | Color4;
  142420. }
  142421. /**
  142422. * Defines the basic interface of a TexturePacker JSON File
  142423. */
  142424. export interface ITexturePackerJSON {
  142425. /**
  142426. * The frame ID
  142427. */
  142428. name: string;
  142429. /**
  142430. * The base64 channel data
  142431. */
  142432. sets: any;
  142433. /**
  142434. * The options of the Packer
  142435. */
  142436. options: ITexturePackerOptions;
  142437. /**
  142438. * The frame data of the Packer
  142439. */
  142440. frames: Array<number>;
  142441. }
  142442. /**
  142443. * This is a support class that generates a series of packed texture sets.
  142444. * @see https://doc.babylonjs.com/babylon101/materials
  142445. */
  142446. export class TexturePacker {
  142447. /** Packer Layout Constant 0 */
  142448. static readonly LAYOUT_STRIP: number;
  142449. /** Packer Layout Constant 1 */
  142450. static readonly LAYOUT_POWER2: number;
  142451. /** Packer Layout Constant 2 */
  142452. static readonly LAYOUT_COLNUM: number;
  142453. /** Packer Layout Constant 0 */
  142454. static readonly SUBUV_WRAP: number;
  142455. /** Packer Layout Constant 1 */
  142456. static readonly SUBUV_EXTEND: number;
  142457. /** Packer Layout Constant 2 */
  142458. static readonly SUBUV_COLOR: number;
  142459. /** The Name of the Texture Package */
  142460. name: string;
  142461. /** The scene scope of the TexturePacker */
  142462. scene: Scene;
  142463. /** The Meshes to target */
  142464. meshes: AbstractMesh[];
  142465. /** Arguments passed with the Constructor */
  142466. options: ITexturePackerOptions;
  142467. /** The promise that is started upon initialization */
  142468. promise: Nullable<Promise<TexturePacker | string>>;
  142469. /** The Container object for the channel sets that are generated */
  142470. sets: object;
  142471. /** The Container array for the frames that are generated */
  142472. frames: TexturePackerFrame[];
  142473. /** The expected number of textures the system is parsing. */
  142474. private _expecting;
  142475. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  142476. private _paddingValue;
  142477. /**
  142478. * Initializes a texture package series from an array of meshes or a single mesh.
  142479. * @param name The name of the package
  142480. * @param meshes The target meshes to compose the package from
  142481. * @param options The arguments that texture packer should follow while building.
  142482. * @param scene The scene which the textures are scoped to.
  142483. * @returns TexturePacker
  142484. */
  142485. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  142486. /**
  142487. * Starts the package process
  142488. * @param resolve The promises resolution function
  142489. * @returns TexturePacker
  142490. */
  142491. private _createFrames;
  142492. /**
  142493. * Calculates the Size of the Channel Sets
  142494. * @returns Vector2
  142495. */
  142496. private _calculateSize;
  142497. /**
  142498. * Calculates the UV data for the frames.
  142499. * @param baseSize the base frameSize
  142500. * @param padding the base frame padding
  142501. * @param dtSize size of the Dynamic Texture for that channel
  142502. * @param dtUnits is 1/dtSize
  142503. * @param update flag to update the input meshes
  142504. */
  142505. private _calculateMeshUVFrames;
  142506. /**
  142507. * Calculates the frames Offset.
  142508. * @param index of the frame
  142509. * @returns Vector2
  142510. */
  142511. private _getFrameOffset;
  142512. /**
  142513. * Updates a Mesh to the frame data
  142514. * @param mesh that is the target
  142515. * @param frameID or the frame index
  142516. */
  142517. private _updateMeshUV;
  142518. /**
  142519. * Updates a Meshes materials to use the texture packer channels
  142520. * @param m is the mesh to target
  142521. * @param force all channels on the packer to be set.
  142522. */
  142523. private _updateTextureReferences;
  142524. /**
  142525. * Public method to set a Mesh to a frame
  142526. * @param m that is the target
  142527. * @param frameID or the frame index
  142528. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  142529. */
  142530. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  142531. /**
  142532. * Starts the async promise to compile the texture packer.
  142533. * @returns Promise<void>
  142534. */
  142535. processAsync(): Promise<void>;
  142536. /**
  142537. * Disposes all textures associated with this packer
  142538. */
  142539. dispose(): void;
  142540. /**
  142541. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  142542. * @param imageType is the image type to use.
  142543. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  142544. */
  142545. download(imageType?: string, quality?: number): void;
  142546. /**
  142547. * Public method to load a texturePacker JSON file.
  142548. * @param data of the JSON file in string format.
  142549. */
  142550. updateFromJSON(data: string): void;
  142551. }
  142552. }
  142553. declare module BABYLON {
  142554. /**
  142555. * 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.
  142556. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142557. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142558. */
  142559. export class CustomProceduralTexture extends ProceduralTexture {
  142560. private _animate;
  142561. private _time;
  142562. private _config;
  142563. private _texturePath;
  142564. /**
  142565. * Instantiates a new Custom Procedural Texture.
  142566. * 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.
  142567. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142568. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142569. * @param name Define the name of the texture
  142570. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142571. * @param size Define the size of the texture to create
  142572. * @param scene Define the scene the texture belongs to
  142573. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142574. * @param generateMipMaps Define if the texture should creates mip maps or not
  142575. */
  142576. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142577. private _loadJson;
  142578. /**
  142579. * Is the texture ready to be used ? (rendered at least once)
  142580. * @returns true if ready, otherwise, false.
  142581. */
  142582. isReady(): boolean;
  142583. /**
  142584. * Render the texture to its associated render target.
  142585. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142586. */
  142587. render(useCameraPostProcess?: boolean): void;
  142588. /**
  142589. * Update the list of dependant textures samplers in the shader.
  142590. */
  142591. updateTextures(): void;
  142592. /**
  142593. * Update the uniform values of the procedural texture in the shader.
  142594. */
  142595. updateShaderUniforms(): void;
  142596. /**
  142597. * Define if the texture animates or not.
  142598. */
  142599. get animate(): boolean;
  142600. set animate(value: boolean);
  142601. }
  142602. }
  142603. declare module BABYLON {
  142604. /** @hidden */
  142605. export var noisePixelShader: {
  142606. name: string;
  142607. shader: string;
  142608. };
  142609. }
  142610. declare module BABYLON {
  142611. /**
  142612. * Class used to generate noise procedural textures
  142613. */
  142614. export class NoiseProceduralTexture extends ProceduralTexture {
  142615. /** Gets or sets the start time (default is 0) */
  142616. time: number;
  142617. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  142618. brightness: number;
  142619. /** Defines the number of octaves to process */
  142620. octaves: number;
  142621. /** Defines the level of persistence (0.8 by default) */
  142622. persistence: number;
  142623. /** Gets or sets animation speed factor (default is 1) */
  142624. animationSpeedFactor: number;
  142625. /**
  142626. * Creates a new NoiseProceduralTexture
  142627. * @param name defines the name fo the texture
  142628. * @param size defines the size of the texture (default is 256)
  142629. * @param scene defines the hosting scene
  142630. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  142631. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  142632. */
  142633. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142634. private _updateShaderUniforms;
  142635. protected _getDefines(): string;
  142636. /** Generate the current state of the procedural texture */
  142637. render(useCameraPostProcess?: boolean): void;
  142638. /**
  142639. * Serializes this noise procedural texture
  142640. * @returns a serialized noise procedural texture object
  142641. */
  142642. serialize(): any;
  142643. /**
  142644. * Clone the texture.
  142645. * @returns the cloned texture
  142646. */
  142647. clone(): NoiseProceduralTexture;
  142648. /**
  142649. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  142650. * @param parsedTexture defines parsed texture data
  142651. * @param scene defines the current scene
  142652. * @param rootUrl defines the root URL containing noise procedural texture information
  142653. * @returns a parsed NoiseProceduralTexture
  142654. */
  142655. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  142656. }
  142657. }
  142658. declare module BABYLON {
  142659. /**
  142660. * Raw cube texture where the raw buffers are passed in
  142661. */
  142662. export class RawCubeTexture extends CubeTexture {
  142663. /**
  142664. * Creates a cube texture where the raw buffers are passed in.
  142665. * @param scene defines the scene the texture is attached to
  142666. * @param data defines the array of data to use to create each face
  142667. * @param size defines the size of the textures
  142668. * @param format defines the format of the data
  142669. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  142670. * @param generateMipMaps defines if the engine should generate the mip levels
  142671. * @param invertY defines if data must be stored with Y axis inverted
  142672. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  142673. * @param compression defines the compression used (null by default)
  142674. */
  142675. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  142676. /**
  142677. * Updates the raw cube texture.
  142678. * @param data defines the data to store
  142679. * @param format defines the data format
  142680. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  142681. * @param invertY defines if data must be stored with Y axis inverted
  142682. * @param compression defines the compression used (null by default)
  142683. * @param level defines which level of the texture to update
  142684. */
  142685. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  142686. /**
  142687. * Updates a raw cube texture with RGBD encoded data.
  142688. * @param data defines the array of data [mipmap][face] to use to create each face
  142689. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  142690. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  142691. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  142692. * @returns a promsie that resolves when the operation is complete
  142693. */
  142694. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  142695. /**
  142696. * Clones the raw cube texture.
  142697. * @return a new cube texture
  142698. */
  142699. clone(): CubeTexture;
  142700. /** @hidden */
  142701. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  142702. }
  142703. }
  142704. declare module BABYLON {
  142705. /**
  142706. * Class used to store 2D array textures containing user data
  142707. */
  142708. export class RawTexture2DArray extends Texture {
  142709. /** Gets or sets the texture format to use */
  142710. format: number;
  142711. /**
  142712. * Create a new RawTexture2DArray
  142713. * @param data defines the data of the texture
  142714. * @param width defines the width of the texture
  142715. * @param height defines the height of the texture
  142716. * @param depth defines the number of layers of the texture
  142717. * @param format defines the texture format to use
  142718. * @param scene defines the hosting scene
  142719. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142720. * @param invertY defines if texture must be stored with Y axis inverted
  142721. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142722. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142723. */
  142724. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142725. /** Gets or sets the texture format to use */
  142726. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142727. /**
  142728. * Update the texture with new data
  142729. * @param data defines the data to store in the texture
  142730. */
  142731. update(data: ArrayBufferView): void;
  142732. }
  142733. }
  142734. declare module BABYLON {
  142735. /**
  142736. * Class used to store 3D textures containing user data
  142737. */
  142738. export class RawTexture3D extends Texture {
  142739. /** Gets or sets the texture format to use */
  142740. format: number;
  142741. /**
  142742. * Create a new RawTexture3D
  142743. * @param data defines the data of the texture
  142744. * @param width defines the width of the texture
  142745. * @param height defines the height of the texture
  142746. * @param depth defines the depth of the texture
  142747. * @param format defines the texture format to use
  142748. * @param scene defines the hosting scene
  142749. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142750. * @param invertY defines if texture must be stored with Y axis inverted
  142751. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142752. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142753. */
  142754. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142755. /** Gets or sets the texture format to use */
  142756. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142757. /**
  142758. * Update the texture with new data
  142759. * @param data defines the data to store in the texture
  142760. */
  142761. update(data: ArrayBufferView): void;
  142762. }
  142763. }
  142764. declare module BABYLON {
  142765. /**
  142766. * Creates a refraction texture used by refraction channel of the standard material.
  142767. * It is like a mirror but to see through a material.
  142768. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142769. */
  142770. export class RefractionTexture extends RenderTargetTexture {
  142771. /**
  142772. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  142773. * 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.
  142774. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142775. */
  142776. refractionPlane: Plane;
  142777. /**
  142778. * Define how deep under the surface we should see.
  142779. */
  142780. depth: number;
  142781. /**
  142782. * Creates a refraction texture used by refraction channel of the standard material.
  142783. * It is like a mirror but to see through a material.
  142784. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142785. * @param name Define the texture name
  142786. * @param size Define the size of the underlying texture
  142787. * @param scene Define the scene the refraction belongs to
  142788. * @param generateMipMaps Define if we need to generate mips level for the refraction
  142789. */
  142790. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  142791. /**
  142792. * Clone the refraction texture.
  142793. * @returns the cloned texture
  142794. */
  142795. clone(): RefractionTexture;
  142796. /**
  142797. * Serialize the texture to a JSON representation you could use in Parse later on
  142798. * @returns the serialized JSON representation
  142799. */
  142800. serialize(): any;
  142801. }
  142802. }
  142803. declare module BABYLON {
  142804. /**
  142805. * Block used to add support for vertex skinning (bones)
  142806. */
  142807. export class BonesBlock extends NodeMaterialBlock {
  142808. /**
  142809. * Creates a new BonesBlock
  142810. * @param name defines the block name
  142811. */
  142812. constructor(name: string);
  142813. /**
  142814. * Initialize the block and prepare the context for build
  142815. * @param state defines the state that will be used for the build
  142816. */
  142817. initialize(state: NodeMaterialBuildState): void;
  142818. /**
  142819. * Gets the current class name
  142820. * @returns the class name
  142821. */
  142822. getClassName(): string;
  142823. /**
  142824. * Gets the matrix indices input component
  142825. */
  142826. get matricesIndices(): NodeMaterialConnectionPoint;
  142827. /**
  142828. * Gets the matrix weights input component
  142829. */
  142830. get matricesWeights(): NodeMaterialConnectionPoint;
  142831. /**
  142832. * Gets the extra matrix indices input component
  142833. */
  142834. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  142835. /**
  142836. * Gets the extra matrix weights input component
  142837. */
  142838. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  142839. /**
  142840. * Gets the world input component
  142841. */
  142842. get world(): NodeMaterialConnectionPoint;
  142843. /**
  142844. * Gets the output component
  142845. */
  142846. get output(): NodeMaterialConnectionPoint;
  142847. autoConfigure(material: NodeMaterial): void;
  142848. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  142849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142850. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142851. protected _buildBlock(state: NodeMaterialBuildState): this;
  142852. }
  142853. }
  142854. declare module BABYLON {
  142855. /**
  142856. * Block used to add support for instances
  142857. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  142858. */
  142859. export class InstancesBlock extends NodeMaterialBlock {
  142860. /**
  142861. * Creates a new InstancesBlock
  142862. * @param name defines the block name
  142863. */
  142864. constructor(name: string);
  142865. /**
  142866. * Gets the current class name
  142867. * @returns the class name
  142868. */
  142869. getClassName(): string;
  142870. /**
  142871. * Gets the first world row input component
  142872. */
  142873. get world0(): NodeMaterialConnectionPoint;
  142874. /**
  142875. * Gets the second world row input component
  142876. */
  142877. get world1(): NodeMaterialConnectionPoint;
  142878. /**
  142879. * Gets the third world row input component
  142880. */
  142881. get world2(): NodeMaterialConnectionPoint;
  142882. /**
  142883. * Gets the forth world row input component
  142884. */
  142885. get world3(): NodeMaterialConnectionPoint;
  142886. /**
  142887. * Gets the world input component
  142888. */
  142889. get world(): NodeMaterialConnectionPoint;
  142890. /**
  142891. * Gets the output component
  142892. */
  142893. get output(): NodeMaterialConnectionPoint;
  142894. /**
  142895. * Gets the isntanceID component
  142896. */
  142897. get instanceID(): NodeMaterialConnectionPoint;
  142898. autoConfigure(material: NodeMaterial): void;
  142899. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  142900. protected _buildBlock(state: NodeMaterialBuildState): this;
  142901. }
  142902. }
  142903. declare module BABYLON {
  142904. /**
  142905. * Block used to add morph targets support to vertex shader
  142906. */
  142907. export class MorphTargetsBlock extends NodeMaterialBlock {
  142908. private _repeatableContentAnchor;
  142909. /**
  142910. * Create a new MorphTargetsBlock
  142911. * @param name defines the block name
  142912. */
  142913. constructor(name: string);
  142914. /**
  142915. * Gets the current class name
  142916. * @returns the class name
  142917. */
  142918. getClassName(): string;
  142919. /**
  142920. * Gets the position input component
  142921. */
  142922. get position(): NodeMaterialConnectionPoint;
  142923. /**
  142924. * Gets the normal input component
  142925. */
  142926. get normal(): NodeMaterialConnectionPoint;
  142927. /**
  142928. * Gets the tangent input component
  142929. */
  142930. get tangent(): NodeMaterialConnectionPoint;
  142931. /**
  142932. * Gets the tangent input component
  142933. */
  142934. get uv(): NodeMaterialConnectionPoint;
  142935. /**
  142936. * Gets the position output component
  142937. */
  142938. get positionOutput(): NodeMaterialConnectionPoint;
  142939. /**
  142940. * Gets the normal output component
  142941. */
  142942. get normalOutput(): NodeMaterialConnectionPoint;
  142943. /**
  142944. * Gets the tangent output component
  142945. */
  142946. get tangentOutput(): NodeMaterialConnectionPoint;
  142947. /**
  142948. * Gets the tangent output component
  142949. */
  142950. get uvOutput(): NodeMaterialConnectionPoint;
  142951. initialize(state: NodeMaterialBuildState): void;
  142952. autoConfigure(material: NodeMaterial): void;
  142953. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142954. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142955. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  142956. protected _buildBlock(state: NodeMaterialBuildState): this;
  142957. }
  142958. }
  142959. declare module BABYLON {
  142960. /**
  142961. * Block used to get data information from a light
  142962. */
  142963. export class LightInformationBlock extends NodeMaterialBlock {
  142964. private _lightDataUniformName;
  142965. private _lightColorUniformName;
  142966. private _lightTypeDefineName;
  142967. /**
  142968. * Gets or sets the light associated with this block
  142969. */
  142970. light: Nullable<Light>;
  142971. /**
  142972. * Creates a new LightInformationBlock
  142973. * @param name defines the block name
  142974. */
  142975. constructor(name: string);
  142976. /**
  142977. * Gets the current class name
  142978. * @returns the class name
  142979. */
  142980. getClassName(): string;
  142981. /**
  142982. * Gets the world position input component
  142983. */
  142984. get worldPosition(): NodeMaterialConnectionPoint;
  142985. /**
  142986. * Gets the direction output component
  142987. */
  142988. get direction(): NodeMaterialConnectionPoint;
  142989. /**
  142990. * Gets the direction output component
  142991. */
  142992. get color(): NodeMaterialConnectionPoint;
  142993. /**
  142994. * Gets the direction output component
  142995. */
  142996. get intensity(): NodeMaterialConnectionPoint;
  142997. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142998. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142999. protected _buildBlock(state: NodeMaterialBuildState): this;
  143000. serialize(): any;
  143001. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143002. }
  143003. }
  143004. declare module BABYLON {
  143005. /**
  143006. * Block used to add image processing support to fragment shader
  143007. */
  143008. export class ImageProcessingBlock extends NodeMaterialBlock {
  143009. /**
  143010. * Create a new ImageProcessingBlock
  143011. * @param name defines the block name
  143012. */
  143013. constructor(name: string);
  143014. /**
  143015. * Gets the current class name
  143016. * @returns the class name
  143017. */
  143018. getClassName(): string;
  143019. /**
  143020. * Gets the color input component
  143021. */
  143022. get color(): NodeMaterialConnectionPoint;
  143023. /**
  143024. * Gets the output component
  143025. */
  143026. get output(): NodeMaterialConnectionPoint;
  143027. /**
  143028. * Initialize the block and prepare the context for build
  143029. * @param state defines the state that will be used for the build
  143030. */
  143031. initialize(state: NodeMaterialBuildState): void;
  143032. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143034. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143035. protected _buildBlock(state: NodeMaterialBuildState): this;
  143036. }
  143037. }
  143038. declare module BABYLON {
  143039. /**
  143040. * Block used to pertub normals based on a normal map
  143041. */
  143042. export class PerturbNormalBlock extends NodeMaterialBlock {
  143043. private _tangentSpaceParameterName;
  143044. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143045. invertX: boolean;
  143046. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143047. invertY: boolean;
  143048. /**
  143049. * Create a new PerturbNormalBlock
  143050. * @param name defines the block name
  143051. */
  143052. constructor(name: string);
  143053. /**
  143054. * Gets the current class name
  143055. * @returns the class name
  143056. */
  143057. getClassName(): string;
  143058. /**
  143059. * Gets the world position input component
  143060. */
  143061. get worldPosition(): NodeMaterialConnectionPoint;
  143062. /**
  143063. * Gets the world normal input component
  143064. */
  143065. get worldNormal(): NodeMaterialConnectionPoint;
  143066. /**
  143067. * Gets the world tangent input component
  143068. */
  143069. get worldTangent(): NodeMaterialConnectionPoint;
  143070. /**
  143071. * Gets the uv input component
  143072. */
  143073. get uv(): NodeMaterialConnectionPoint;
  143074. /**
  143075. * Gets the normal map color input component
  143076. */
  143077. get normalMapColor(): NodeMaterialConnectionPoint;
  143078. /**
  143079. * Gets the strength input component
  143080. */
  143081. get strength(): NodeMaterialConnectionPoint;
  143082. /**
  143083. * Gets the output component
  143084. */
  143085. get output(): NodeMaterialConnectionPoint;
  143086. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143087. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143088. autoConfigure(material: NodeMaterial): void;
  143089. protected _buildBlock(state: NodeMaterialBuildState): this;
  143090. protected _dumpPropertiesCode(): string;
  143091. serialize(): any;
  143092. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143093. }
  143094. }
  143095. declare module BABYLON {
  143096. /**
  143097. * Block used to discard a pixel if a value is smaller than a cutoff
  143098. */
  143099. export class DiscardBlock extends NodeMaterialBlock {
  143100. /**
  143101. * Create a new DiscardBlock
  143102. * @param name defines the block name
  143103. */
  143104. constructor(name: string);
  143105. /**
  143106. * Gets the current class name
  143107. * @returns the class name
  143108. */
  143109. getClassName(): string;
  143110. /**
  143111. * Gets the color input component
  143112. */
  143113. get value(): NodeMaterialConnectionPoint;
  143114. /**
  143115. * Gets the cutoff input component
  143116. */
  143117. get cutoff(): NodeMaterialConnectionPoint;
  143118. protected _buildBlock(state: NodeMaterialBuildState): this;
  143119. }
  143120. }
  143121. declare module BABYLON {
  143122. /**
  143123. * Block used to test if the fragment shader is front facing
  143124. */
  143125. export class FrontFacingBlock extends NodeMaterialBlock {
  143126. /**
  143127. * Creates a new FrontFacingBlock
  143128. * @param name defines the block name
  143129. */
  143130. constructor(name: string);
  143131. /**
  143132. * Gets the current class name
  143133. * @returns the class name
  143134. */
  143135. getClassName(): string;
  143136. /**
  143137. * Gets the output component
  143138. */
  143139. get output(): NodeMaterialConnectionPoint;
  143140. protected _buildBlock(state: NodeMaterialBuildState): this;
  143141. }
  143142. }
  143143. declare module BABYLON {
  143144. /**
  143145. * Block used to get the derivative value on x and y of a given input
  143146. */
  143147. export class DerivativeBlock extends NodeMaterialBlock {
  143148. /**
  143149. * Create a new DerivativeBlock
  143150. * @param name defines the block name
  143151. */
  143152. constructor(name: string);
  143153. /**
  143154. * Gets the current class name
  143155. * @returns the class name
  143156. */
  143157. getClassName(): string;
  143158. /**
  143159. * Gets the input component
  143160. */
  143161. get input(): NodeMaterialConnectionPoint;
  143162. /**
  143163. * Gets the derivative output on x
  143164. */
  143165. get dx(): NodeMaterialConnectionPoint;
  143166. /**
  143167. * Gets the derivative output on y
  143168. */
  143169. get dy(): NodeMaterialConnectionPoint;
  143170. protected _buildBlock(state: NodeMaterialBuildState): this;
  143171. }
  143172. }
  143173. declare module BABYLON {
  143174. /**
  143175. * Block used to make gl_FragCoord available
  143176. */
  143177. export class FragCoordBlock extends NodeMaterialBlock {
  143178. /**
  143179. * Creates a new FragCoordBlock
  143180. * @param name defines the block name
  143181. */
  143182. constructor(name: string);
  143183. /**
  143184. * Gets the current class name
  143185. * @returns the class name
  143186. */
  143187. getClassName(): string;
  143188. /**
  143189. * Gets the xy component
  143190. */
  143191. get xy(): NodeMaterialConnectionPoint;
  143192. /**
  143193. * Gets the xyz component
  143194. */
  143195. get xyz(): NodeMaterialConnectionPoint;
  143196. /**
  143197. * Gets the xyzw component
  143198. */
  143199. get xyzw(): NodeMaterialConnectionPoint;
  143200. /**
  143201. * Gets the x component
  143202. */
  143203. get x(): NodeMaterialConnectionPoint;
  143204. /**
  143205. * Gets the y component
  143206. */
  143207. get y(): NodeMaterialConnectionPoint;
  143208. /**
  143209. * Gets the z component
  143210. */
  143211. get z(): NodeMaterialConnectionPoint;
  143212. /**
  143213. * Gets the w component
  143214. */
  143215. get output(): NodeMaterialConnectionPoint;
  143216. protected writeOutputs(state: NodeMaterialBuildState): string;
  143217. protected _buildBlock(state: NodeMaterialBuildState): this;
  143218. }
  143219. }
  143220. declare module BABYLON {
  143221. /**
  143222. * Block used to get the screen sizes
  143223. */
  143224. export class ScreenSizeBlock extends NodeMaterialBlock {
  143225. private _varName;
  143226. private _scene;
  143227. /**
  143228. * Creates a new ScreenSizeBlock
  143229. * @param name defines the block name
  143230. */
  143231. constructor(name: string);
  143232. /**
  143233. * Gets the current class name
  143234. * @returns the class name
  143235. */
  143236. getClassName(): string;
  143237. /**
  143238. * Gets the xy component
  143239. */
  143240. get xy(): NodeMaterialConnectionPoint;
  143241. /**
  143242. * Gets the x component
  143243. */
  143244. get x(): NodeMaterialConnectionPoint;
  143245. /**
  143246. * Gets the y component
  143247. */
  143248. get y(): NodeMaterialConnectionPoint;
  143249. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143250. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  143251. protected _buildBlock(state: NodeMaterialBuildState): this;
  143252. }
  143253. }
  143254. declare module BABYLON {
  143255. /**
  143256. * Block used to add support for scene fog
  143257. */
  143258. export class FogBlock extends NodeMaterialBlock {
  143259. private _fogDistanceName;
  143260. private _fogParameters;
  143261. /**
  143262. * Create a new FogBlock
  143263. * @param name defines the block name
  143264. */
  143265. constructor(name: string);
  143266. /**
  143267. * Gets the current class name
  143268. * @returns the class name
  143269. */
  143270. getClassName(): string;
  143271. /**
  143272. * Gets the world position input component
  143273. */
  143274. get worldPosition(): NodeMaterialConnectionPoint;
  143275. /**
  143276. * Gets the view input component
  143277. */
  143278. get view(): NodeMaterialConnectionPoint;
  143279. /**
  143280. * Gets the color input component
  143281. */
  143282. get input(): NodeMaterialConnectionPoint;
  143283. /**
  143284. * Gets the fog color input component
  143285. */
  143286. get fogColor(): NodeMaterialConnectionPoint;
  143287. /**
  143288. * Gets the output component
  143289. */
  143290. get output(): NodeMaterialConnectionPoint;
  143291. autoConfigure(material: NodeMaterial): void;
  143292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143293. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143294. protected _buildBlock(state: NodeMaterialBuildState): this;
  143295. }
  143296. }
  143297. declare module BABYLON {
  143298. /**
  143299. * Block used to add light in the fragment shader
  143300. */
  143301. export class LightBlock extends NodeMaterialBlock {
  143302. private _lightId;
  143303. /**
  143304. * Gets or sets the light associated with this block
  143305. */
  143306. light: Nullable<Light>;
  143307. /**
  143308. * Create a new LightBlock
  143309. * @param name defines the block name
  143310. */
  143311. constructor(name: string);
  143312. /**
  143313. * Gets the current class name
  143314. * @returns the class name
  143315. */
  143316. getClassName(): string;
  143317. /**
  143318. * Gets the world position input component
  143319. */
  143320. get worldPosition(): NodeMaterialConnectionPoint;
  143321. /**
  143322. * Gets the world normal input component
  143323. */
  143324. get worldNormal(): NodeMaterialConnectionPoint;
  143325. /**
  143326. * Gets the camera (or eye) position component
  143327. */
  143328. get cameraPosition(): NodeMaterialConnectionPoint;
  143329. /**
  143330. * Gets the glossiness component
  143331. */
  143332. get glossiness(): NodeMaterialConnectionPoint;
  143333. /**
  143334. * Gets the glossinness power component
  143335. */
  143336. get glossPower(): NodeMaterialConnectionPoint;
  143337. /**
  143338. * Gets the diffuse color component
  143339. */
  143340. get diffuseColor(): NodeMaterialConnectionPoint;
  143341. /**
  143342. * Gets the specular color component
  143343. */
  143344. get specularColor(): NodeMaterialConnectionPoint;
  143345. /**
  143346. * Gets the diffuse output component
  143347. */
  143348. get diffuseOutput(): NodeMaterialConnectionPoint;
  143349. /**
  143350. * Gets the specular output component
  143351. */
  143352. get specularOutput(): NodeMaterialConnectionPoint;
  143353. /**
  143354. * Gets the shadow output component
  143355. */
  143356. get shadow(): NodeMaterialConnectionPoint;
  143357. autoConfigure(material: NodeMaterial): void;
  143358. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143359. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143360. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143361. private _injectVertexCode;
  143362. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143363. serialize(): any;
  143364. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143365. }
  143366. }
  143367. declare module BABYLON {
  143368. /**
  143369. * Block used to read a reflection texture from a sampler
  143370. */
  143371. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  143372. /**
  143373. * Create a new ReflectionTextureBlock
  143374. * @param name defines the block name
  143375. */
  143376. constructor(name: string);
  143377. /**
  143378. * Gets the current class name
  143379. * @returns the class name
  143380. */
  143381. getClassName(): string;
  143382. /**
  143383. * Gets the world position input component
  143384. */
  143385. get position(): NodeMaterialConnectionPoint;
  143386. /**
  143387. * Gets the world position input component
  143388. */
  143389. get worldPosition(): NodeMaterialConnectionPoint;
  143390. /**
  143391. * Gets the world normal input component
  143392. */
  143393. get worldNormal(): NodeMaterialConnectionPoint;
  143394. /**
  143395. * Gets the world input component
  143396. */
  143397. get world(): NodeMaterialConnectionPoint;
  143398. /**
  143399. * Gets the camera (or eye) position component
  143400. */
  143401. get cameraPosition(): NodeMaterialConnectionPoint;
  143402. /**
  143403. * Gets the view input component
  143404. */
  143405. get view(): NodeMaterialConnectionPoint;
  143406. /**
  143407. * Gets the rgb output component
  143408. */
  143409. get rgb(): NodeMaterialConnectionPoint;
  143410. /**
  143411. * Gets the rgba output component
  143412. */
  143413. get rgba(): NodeMaterialConnectionPoint;
  143414. /**
  143415. * Gets the r output component
  143416. */
  143417. get r(): NodeMaterialConnectionPoint;
  143418. /**
  143419. * Gets the g output component
  143420. */
  143421. get g(): NodeMaterialConnectionPoint;
  143422. /**
  143423. * Gets the b output component
  143424. */
  143425. get b(): NodeMaterialConnectionPoint;
  143426. /**
  143427. * Gets the a output component
  143428. */
  143429. get a(): NodeMaterialConnectionPoint;
  143430. autoConfigure(material: NodeMaterial): void;
  143431. protected _buildBlock(state: NodeMaterialBuildState): this;
  143432. }
  143433. }
  143434. declare module BABYLON {
  143435. /**
  143436. * Block used to add 2 vectors
  143437. */
  143438. export class AddBlock extends NodeMaterialBlock {
  143439. /**
  143440. * Creates a new AddBlock
  143441. * @param name defines the block name
  143442. */
  143443. constructor(name: string);
  143444. /**
  143445. * Gets the current class name
  143446. * @returns the class name
  143447. */
  143448. getClassName(): string;
  143449. /**
  143450. * Gets the left operand input component
  143451. */
  143452. get left(): NodeMaterialConnectionPoint;
  143453. /**
  143454. * Gets the right operand input component
  143455. */
  143456. get right(): NodeMaterialConnectionPoint;
  143457. /**
  143458. * Gets the output component
  143459. */
  143460. get output(): NodeMaterialConnectionPoint;
  143461. protected _buildBlock(state: NodeMaterialBuildState): this;
  143462. }
  143463. }
  143464. declare module BABYLON {
  143465. /**
  143466. * Block used to scale a vector by a float
  143467. */
  143468. export class ScaleBlock extends NodeMaterialBlock {
  143469. /**
  143470. * Creates a new ScaleBlock
  143471. * @param name defines the block name
  143472. */
  143473. constructor(name: string);
  143474. /**
  143475. * Gets the current class name
  143476. * @returns the class name
  143477. */
  143478. getClassName(): string;
  143479. /**
  143480. * Gets the input component
  143481. */
  143482. get input(): NodeMaterialConnectionPoint;
  143483. /**
  143484. * Gets the factor input component
  143485. */
  143486. get factor(): NodeMaterialConnectionPoint;
  143487. /**
  143488. * Gets the output component
  143489. */
  143490. get output(): NodeMaterialConnectionPoint;
  143491. protected _buildBlock(state: NodeMaterialBuildState): this;
  143492. }
  143493. }
  143494. declare module BABYLON {
  143495. /**
  143496. * Block used to clamp a float
  143497. */
  143498. export class ClampBlock extends NodeMaterialBlock {
  143499. /** Gets or sets the minimum range */
  143500. minimum: number;
  143501. /** Gets or sets the maximum range */
  143502. maximum: number;
  143503. /**
  143504. * Creates a new ClampBlock
  143505. * @param name defines the block name
  143506. */
  143507. constructor(name: string);
  143508. /**
  143509. * Gets the current class name
  143510. * @returns the class name
  143511. */
  143512. getClassName(): string;
  143513. /**
  143514. * Gets the value input component
  143515. */
  143516. get value(): NodeMaterialConnectionPoint;
  143517. /**
  143518. * Gets the output component
  143519. */
  143520. get output(): NodeMaterialConnectionPoint;
  143521. protected _buildBlock(state: NodeMaterialBuildState): this;
  143522. protected _dumpPropertiesCode(): string;
  143523. serialize(): any;
  143524. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143525. }
  143526. }
  143527. declare module BABYLON {
  143528. /**
  143529. * Block used to apply a cross product between 2 vectors
  143530. */
  143531. export class CrossBlock extends NodeMaterialBlock {
  143532. /**
  143533. * Creates a new CrossBlock
  143534. * @param name defines the block name
  143535. */
  143536. constructor(name: string);
  143537. /**
  143538. * Gets the current class name
  143539. * @returns the class name
  143540. */
  143541. getClassName(): string;
  143542. /**
  143543. * Gets the left operand input component
  143544. */
  143545. get left(): NodeMaterialConnectionPoint;
  143546. /**
  143547. * Gets the right operand input component
  143548. */
  143549. get right(): NodeMaterialConnectionPoint;
  143550. /**
  143551. * Gets the output component
  143552. */
  143553. get output(): NodeMaterialConnectionPoint;
  143554. protected _buildBlock(state: NodeMaterialBuildState): this;
  143555. }
  143556. }
  143557. declare module BABYLON {
  143558. /**
  143559. * Block used to apply a dot product between 2 vectors
  143560. */
  143561. export class DotBlock extends NodeMaterialBlock {
  143562. /**
  143563. * Creates a new DotBlock
  143564. * @param name defines the block name
  143565. */
  143566. constructor(name: string);
  143567. /**
  143568. * Gets the current class name
  143569. * @returns the class name
  143570. */
  143571. getClassName(): string;
  143572. /**
  143573. * Gets the left operand input component
  143574. */
  143575. get left(): NodeMaterialConnectionPoint;
  143576. /**
  143577. * Gets the right operand input component
  143578. */
  143579. get right(): NodeMaterialConnectionPoint;
  143580. /**
  143581. * Gets the output component
  143582. */
  143583. get output(): NodeMaterialConnectionPoint;
  143584. protected _buildBlock(state: NodeMaterialBuildState): this;
  143585. }
  143586. }
  143587. declare module BABYLON {
  143588. /**
  143589. * Block used to normalize a vector
  143590. */
  143591. export class NormalizeBlock extends NodeMaterialBlock {
  143592. /**
  143593. * Creates a new NormalizeBlock
  143594. * @param name defines the block name
  143595. */
  143596. constructor(name: string);
  143597. /**
  143598. * Gets the current class name
  143599. * @returns the class name
  143600. */
  143601. getClassName(): string;
  143602. /**
  143603. * Gets the input component
  143604. */
  143605. get input(): NodeMaterialConnectionPoint;
  143606. /**
  143607. * Gets the output component
  143608. */
  143609. get output(): NodeMaterialConnectionPoint;
  143610. protected _buildBlock(state: NodeMaterialBuildState): this;
  143611. }
  143612. }
  143613. declare module BABYLON {
  143614. /**
  143615. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143616. */
  143617. export class ColorMergerBlock extends NodeMaterialBlock {
  143618. /**
  143619. * Create a new ColorMergerBlock
  143620. * @param name defines the block name
  143621. */
  143622. constructor(name: string);
  143623. /**
  143624. * Gets the current class name
  143625. * @returns the class name
  143626. */
  143627. getClassName(): string;
  143628. /**
  143629. * Gets the rgb component (input)
  143630. */
  143631. get rgbIn(): NodeMaterialConnectionPoint;
  143632. /**
  143633. * Gets the r component (input)
  143634. */
  143635. get r(): NodeMaterialConnectionPoint;
  143636. /**
  143637. * Gets the g component (input)
  143638. */
  143639. get g(): NodeMaterialConnectionPoint;
  143640. /**
  143641. * Gets the b component (input)
  143642. */
  143643. get b(): NodeMaterialConnectionPoint;
  143644. /**
  143645. * Gets the a component (input)
  143646. */
  143647. get a(): NodeMaterialConnectionPoint;
  143648. /**
  143649. * Gets the rgba component (output)
  143650. */
  143651. get rgba(): NodeMaterialConnectionPoint;
  143652. /**
  143653. * Gets the rgb component (output)
  143654. */
  143655. get rgbOut(): NodeMaterialConnectionPoint;
  143656. /**
  143657. * Gets the rgb component (output)
  143658. * @deprecated Please use rgbOut instead.
  143659. */
  143660. get rgb(): NodeMaterialConnectionPoint;
  143661. protected _buildBlock(state: NodeMaterialBuildState): this;
  143662. }
  143663. }
  143664. declare module BABYLON {
  143665. /**
  143666. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  143667. */
  143668. export class VectorSplitterBlock extends NodeMaterialBlock {
  143669. /**
  143670. * Create a new VectorSplitterBlock
  143671. * @param name defines the block name
  143672. */
  143673. constructor(name: string);
  143674. /**
  143675. * Gets the current class name
  143676. * @returns the class name
  143677. */
  143678. getClassName(): string;
  143679. /**
  143680. * Gets the xyzw component (input)
  143681. */
  143682. get xyzw(): NodeMaterialConnectionPoint;
  143683. /**
  143684. * Gets the xyz component (input)
  143685. */
  143686. get xyzIn(): NodeMaterialConnectionPoint;
  143687. /**
  143688. * Gets the xy component (input)
  143689. */
  143690. get xyIn(): NodeMaterialConnectionPoint;
  143691. /**
  143692. * Gets the xyz component (output)
  143693. */
  143694. get xyzOut(): NodeMaterialConnectionPoint;
  143695. /**
  143696. * Gets the xy component (output)
  143697. */
  143698. get xyOut(): NodeMaterialConnectionPoint;
  143699. /**
  143700. * Gets the x component (output)
  143701. */
  143702. get x(): NodeMaterialConnectionPoint;
  143703. /**
  143704. * Gets the y component (output)
  143705. */
  143706. get y(): NodeMaterialConnectionPoint;
  143707. /**
  143708. * Gets the z component (output)
  143709. */
  143710. get z(): NodeMaterialConnectionPoint;
  143711. /**
  143712. * Gets the w component (output)
  143713. */
  143714. get w(): NodeMaterialConnectionPoint;
  143715. protected _inputRename(name: string): string;
  143716. protected _outputRename(name: string): string;
  143717. protected _buildBlock(state: NodeMaterialBuildState): this;
  143718. }
  143719. }
  143720. declare module BABYLON {
  143721. /**
  143722. * Block used to lerp between 2 values
  143723. */
  143724. export class LerpBlock extends NodeMaterialBlock {
  143725. /**
  143726. * Creates a new LerpBlock
  143727. * @param name defines the block name
  143728. */
  143729. constructor(name: string);
  143730. /**
  143731. * Gets the current class name
  143732. * @returns the class name
  143733. */
  143734. getClassName(): string;
  143735. /**
  143736. * Gets the left operand input component
  143737. */
  143738. get left(): NodeMaterialConnectionPoint;
  143739. /**
  143740. * Gets the right operand input component
  143741. */
  143742. get right(): NodeMaterialConnectionPoint;
  143743. /**
  143744. * Gets the gradient operand input component
  143745. */
  143746. get gradient(): NodeMaterialConnectionPoint;
  143747. /**
  143748. * Gets the output component
  143749. */
  143750. get output(): NodeMaterialConnectionPoint;
  143751. protected _buildBlock(state: NodeMaterialBuildState): this;
  143752. }
  143753. }
  143754. declare module BABYLON {
  143755. /**
  143756. * Block used to divide 2 vectors
  143757. */
  143758. export class DivideBlock extends NodeMaterialBlock {
  143759. /**
  143760. * Creates a new DivideBlock
  143761. * @param name defines the block name
  143762. */
  143763. constructor(name: string);
  143764. /**
  143765. * Gets the current class name
  143766. * @returns the class name
  143767. */
  143768. getClassName(): string;
  143769. /**
  143770. * Gets the left operand input component
  143771. */
  143772. get left(): NodeMaterialConnectionPoint;
  143773. /**
  143774. * Gets the right operand input component
  143775. */
  143776. get right(): NodeMaterialConnectionPoint;
  143777. /**
  143778. * Gets the output component
  143779. */
  143780. get output(): NodeMaterialConnectionPoint;
  143781. protected _buildBlock(state: NodeMaterialBuildState): this;
  143782. }
  143783. }
  143784. declare module BABYLON {
  143785. /**
  143786. * Block used to subtract 2 vectors
  143787. */
  143788. export class SubtractBlock extends NodeMaterialBlock {
  143789. /**
  143790. * Creates a new SubtractBlock
  143791. * @param name defines the block name
  143792. */
  143793. constructor(name: string);
  143794. /**
  143795. * Gets the current class name
  143796. * @returns the class name
  143797. */
  143798. getClassName(): string;
  143799. /**
  143800. * Gets the left operand input component
  143801. */
  143802. get left(): NodeMaterialConnectionPoint;
  143803. /**
  143804. * Gets the right operand input component
  143805. */
  143806. get right(): NodeMaterialConnectionPoint;
  143807. /**
  143808. * Gets the output component
  143809. */
  143810. get output(): NodeMaterialConnectionPoint;
  143811. protected _buildBlock(state: NodeMaterialBuildState): this;
  143812. }
  143813. }
  143814. declare module BABYLON {
  143815. /**
  143816. * Block used to step a value
  143817. */
  143818. export class StepBlock extends NodeMaterialBlock {
  143819. /**
  143820. * Creates a new StepBlock
  143821. * @param name defines the block name
  143822. */
  143823. constructor(name: string);
  143824. /**
  143825. * Gets the current class name
  143826. * @returns the class name
  143827. */
  143828. getClassName(): string;
  143829. /**
  143830. * Gets the value operand input component
  143831. */
  143832. get value(): NodeMaterialConnectionPoint;
  143833. /**
  143834. * Gets the edge operand input component
  143835. */
  143836. get edge(): NodeMaterialConnectionPoint;
  143837. /**
  143838. * Gets the output component
  143839. */
  143840. get output(): NodeMaterialConnectionPoint;
  143841. protected _buildBlock(state: NodeMaterialBuildState): this;
  143842. }
  143843. }
  143844. declare module BABYLON {
  143845. /**
  143846. * Block used to get the opposite (1 - x) of a value
  143847. */
  143848. export class OneMinusBlock extends NodeMaterialBlock {
  143849. /**
  143850. * Creates a new OneMinusBlock
  143851. * @param name defines the block name
  143852. */
  143853. constructor(name: string);
  143854. /**
  143855. * Gets the current class name
  143856. * @returns the class name
  143857. */
  143858. getClassName(): string;
  143859. /**
  143860. * Gets the input component
  143861. */
  143862. get input(): NodeMaterialConnectionPoint;
  143863. /**
  143864. * Gets the output component
  143865. */
  143866. get output(): NodeMaterialConnectionPoint;
  143867. protected _buildBlock(state: NodeMaterialBuildState): this;
  143868. }
  143869. }
  143870. declare module BABYLON {
  143871. /**
  143872. * Block used to get the view direction
  143873. */
  143874. export class ViewDirectionBlock extends NodeMaterialBlock {
  143875. /**
  143876. * Creates a new ViewDirectionBlock
  143877. * @param name defines the block name
  143878. */
  143879. constructor(name: string);
  143880. /**
  143881. * Gets the current class name
  143882. * @returns the class name
  143883. */
  143884. getClassName(): string;
  143885. /**
  143886. * Gets the world position component
  143887. */
  143888. get worldPosition(): NodeMaterialConnectionPoint;
  143889. /**
  143890. * Gets the camera position component
  143891. */
  143892. get cameraPosition(): NodeMaterialConnectionPoint;
  143893. /**
  143894. * Gets the output component
  143895. */
  143896. get output(): NodeMaterialConnectionPoint;
  143897. autoConfigure(material: NodeMaterial): void;
  143898. protected _buildBlock(state: NodeMaterialBuildState): this;
  143899. }
  143900. }
  143901. declare module BABYLON {
  143902. /**
  143903. * Block used to compute fresnel value
  143904. */
  143905. export class FresnelBlock extends NodeMaterialBlock {
  143906. /**
  143907. * Create a new FresnelBlock
  143908. * @param name defines the block name
  143909. */
  143910. constructor(name: string);
  143911. /**
  143912. * Gets the current class name
  143913. * @returns the class name
  143914. */
  143915. getClassName(): string;
  143916. /**
  143917. * Gets the world normal input component
  143918. */
  143919. get worldNormal(): NodeMaterialConnectionPoint;
  143920. /**
  143921. * Gets the view direction input component
  143922. */
  143923. get viewDirection(): NodeMaterialConnectionPoint;
  143924. /**
  143925. * Gets the bias input component
  143926. */
  143927. get bias(): NodeMaterialConnectionPoint;
  143928. /**
  143929. * Gets the camera (or eye) position component
  143930. */
  143931. get power(): NodeMaterialConnectionPoint;
  143932. /**
  143933. * Gets the fresnel output component
  143934. */
  143935. get fresnel(): NodeMaterialConnectionPoint;
  143936. autoConfigure(material: NodeMaterial): void;
  143937. protected _buildBlock(state: NodeMaterialBuildState): this;
  143938. }
  143939. }
  143940. declare module BABYLON {
  143941. /**
  143942. * Block used to get the max of 2 values
  143943. */
  143944. export class MaxBlock extends NodeMaterialBlock {
  143945. /**
  143946. * Creates a new MaxBlock
  143947. * @param name defines the block name
  143948. */
  143949. constructor(name: string);
  143950. /**
  143951. * Gets the current class name
  143952. * @returns the class name
  143953. */
  143954. getClassName(): string;
  143955. /**
  143956. * Gets the left operand input component
  143957. */
  143958. get left(): NodeMaterialConnectionPoint;
  143959. /**
  143960. * Gets the right operand input component
  143961. */
  143962. get right(): NodeMaterialConnectionPoint;
  143963. /**
  143964. * Gets the output component
  143965. */
  143966. get output(): NodeMaterialConnectionPoint;
  143967. protected _buildBlock(state: NodeMaterialBuildState): this;
  143968. }
  143969. }
  143970. declare module BABYLON {
  143971. /**
  143972. * Block used to get the min of 2 values
  143973. */
  143974. export class MinBlock extends NodeMaterialBlock {
  143975. /**
  143976. * Creates a new MinBlock
  143977. * @param name defines the block name
  143978. */
  143979. constructor(name: string);
  143980. /**
  143981. * Gets the current class name
  143982. * @returns the class name
  143983. */
  143984. getClassName(): string;
  143985. /**
  143986. * Gets the left operand input component
  143987. */
  143988. get left(): NodeMaterialConnectionPoint;
  143989. /**
  143990. * Gets the right operand input component
  143991. */
  143992. get right(): NodeMaterialConnectionPoint;
  143993. /**
  143994. * Gets the output component
  143995. */
  143996. get output(): NodeMaterialConnectionPoint;
  143997. protected _buildBlock(state: NodeMaterialBuildState): this;
  143998. }
  143999. }
  144000. declare module BABYLON {
  144001. /**
  144002. * Block used to get the distance between 2 values
  144003. */
  144004. export class DistanceBlock extends NodeMaterialBlock {
  144005. /**
  144006. * Creates a new DistanceBlock
  144007. * @param name defines the block name
  144008. */
  144009. constructor(name: string);
  144010. /**
  144011. * Gets the current class name
  144012. * @returns the class name
  144013. */
  144014. getClassName(): string;
  144015. /**
  144016. * Gets the left operand input component
  144017. */
  144018. get left(): NodeMaterialConnectionPoint;
  144019. /**
  144020. * Gets the right operand input component
  144021. */
  144022. get right(): NodeMaterialConnectionPoint;
  144023. /**
  144024. * Gets the output component
  144025. */
  144026. get output(): NodeMaterialConnectionPoint;
  144027. protected _buildBlock(state: NodeMaterialBuildState): this;
  144028. }
  144029. }
  144030. declare module BABYLON {
  144031. /**
  144032. * Block used to get the length of a vector
  144033. */
  144034. export class LengthBlock extends NodeMaterialBlock {
  144035. /**
  144036. * Creates a new LengthBlock
  144037. * @param name defines the block name
  144038. */
  144039. constructor(name: string);
  144040. /**
  144041. * Gets the current class name
  144042. * @returns the class name
  144043. */
  144044. getClassName(): string;
  144045. /**
  144046. * Gets the value input component
  144047. */
  144048. get value(): NodeMaterialConnectionPoint;
  144049. /**
  144050. * Gets the output component
  144051. */
  144052. get output(): NodeMaterialConnectionPoint;
  144053. protected _buildBlock(state: NodeMaterialBuildState): this;
  144054. }
  144055. }
  144056. declare module BABYLON {
  144057. /**
  144058. * Block used to get negative version of a value (i.e. x * -1)
  144059. */
  144060. export class NegateBlock extends NodeMaterialBlock {
  144061. /**
  144062. * Creates a new NegateBlock
  144063. * @param name defines the block name
  144064. */
  144065. constructor(name: string);
  144066. /**
  144067. * Gets the current class name
  144068. * @returns the class name
  144069. */
  144070. getClassName(): string;
  144071. /**
  144072. * Gets the value input component
  144073. */
  144074. get value(): NodeMaterialConnectionPoint;
  144075. /**
  144076. * Gets the output component
  144077. */
  144078. get output(): NodeMaterialConnectionPoint;
  144079. protected _buildBlock(state: NodeMaterialBuildState): this;
  144080. }
  144081. }
  144082. declare module BABYLON {
  144083. /**
  144084. * Block used to get the value of the first parameter raised to the power of the second
  144085. */
  144086. export class PowBlock extends NodeMaterialBlock {
  144087. /**
  144088. * Creates a new PowBlock
  144089. * @param name defines the block name
  144090. */
  144091. constructor(name: string);
  144092. /**
  144093. * Gets the current class name
  144094. * @returns the class name
  144095. */
  144096. getClassName(): string;
  144097. /**
  144098. * Gets the value operand input component
  144099. */
  144100. get value(): NodeMaterialConnectionPoint;
  144101. /**
  144102. * Gets the power operand input component
  144103. */
  144104. get power(): NodeMaterialConnectionPoint;
  144105. /**
  144106. * Gets the output component
  144107. */
  144108. get output(): NodeMaterialConnectionPoint;
  144109. protected _buildBlock(state: NodeMaterialBuildState): this;
  144110. }
  144111. }
  144112. declare module BABYLON {
  144113. /**
  144114. * Block used to get a random number
  144115. */
  144116. export class RandomNumberBlock extends NodeMaterialBlock {
  144117. /**
  144118. * Creates a new RandomNumberBlock
  144119. * @param name defines the block name
  144120. */
  144121. constructor(name: string);
  144122. /**
  144123. * Gets the current class name
  144124. * @returns the class name
  144125. */
  144126. getClassName(): string;
  144127. /**
  144128. * Gets the seed input component
  144129. */
  144130. get seed(): NodeMaterialConnectionPoint;
  144131. /**
  144132. * Gets the output component
  144133. */
  144134. get output(): NodeMaterialConnectionPoint;
  144135. protected _buildBlock(state: NodeMaterialBuildState): this;
  144136. }
  144137. }
  144138. declare module BABYLON {
  144139. /**
  144140. * Block used to compute arc tangent of 2 values
  144141. */
  144142. export class ArcTan2Block extends NodeMaterialBlock {
  144143. /**
  144144. * Creates a new ArcTan2Block
  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 x operand input component
  144155. */
  144156. get x(): NodeMaterialConnectionPoint;
  144157. /**
  144158. * Gets the y operand input component
  144159. */
  144160. get y(): NodeMaterialConnectionPoint;
  144161. /**
  144162. * Gets the output component
  144163. */
  144164. get output(): NodeMaterialConnectionPoint;
  144165. protected _buildBlock(state: NodeMaterialBuildState): this;
  144166. }
  144167. }
  144168. declare module BABYLON {
  144169. /**
  144170. * Block used to smooth step a value
  144171. */
  144172. export class SmoothStepBlock extends NodeMaterialBlock {
  144173. /**
  144174. * Creates a new SmoothStepBlock
  144175. * @param name defines the block name
  144176. */
  144177. constructor(name: string);
  144178. /**
  144179. * Gets the current class name
  144180. * @returns the class name
  144181. */
  144182. getClassName(): string;
  144183. /**
  144184. * Gets the value operand input component
  144185. */
  144186. get value(): NodeMaterialConnectionPoint;
  144187. /**
  144188. * Gets the first edge operand input component
  144189. */
  144190. get edge0(): NodeMaterialConnectionPoint;
  144191. /**
  144192. * Gets the second edge operand input component
  144193. */
  144194. get edge1(): NodeMaterialConnectionPoint;
  144195. /**
  144196. * Gets the output component
  144197. */
  144198. get output(): NodeMaterialConnectionPoint;
  144199. protected _buildBlock(state: NodeMaterialBuildState): this;
  144200. }
  144201. }
  144202. declare module BABYLON {
  144203. /**
  144204. * Block used to get the reciprocal (1 / x) of a value
  144205. */
  144206. export class ReciprocalBlock extends NodeMaterialBlock {
  144207. /**
  144208. * Creates a new ReciprocalBlock
  144209. * @param name defines the block name
  144210. */
  144211. constructor(name: string);
  144212. /**
  144213. * Gets the current class name
  144214. * @returns the class name
  144215. */
  144216. getClassName(): string;
  144217. /**
  144218. * Gets the input component
  144219. */
  144220. get input(): NodeMaterialConnectionPoint;
  144221. /**
  144222. * Gets the output component
  144223. */
  144224. get output(): NodeMaterialConnectionPoint;
  144225. protected _buildBlock(state: NodeMaterialBuildState): this;
  144226. }
  144227. }
  144228. declare module BABYLON {
  144229. /**
  144230. * Block used to replace a color by another one
  144231. */
  144232. export class ReplaceColorBlock extends NodeMaterialBlock {
  144233. /**
  144234. * Creates a new ReplaceColorBlock
  144235. * @param name defines the block name
  144236. */
  144237. constructor(name: string);
  144238. /**
  144239. * Gets the current class name
  144240. * @returns the class name
  144241. */
  144242. getClassName(): string;
  144243. /**
  144244. * Gets the value input component
  144245. */
  144246. get value(): NodeMaterialConnectionPoint;
  144247. /**
  144248. * Gets the reference input component
  144249. */
  144250. get reference(): NodeMaterialConnectionPoint;
  144251. /**
  144252. * Gets the distance input component
  144253. */
  144254. get distance(): NodeMaterialConnectionPoint;
  144255. /**
  144256. * Gets the replacement input component
  144257. */
  144258. get replacement(): NodeMaterialConnectionPoint;
  144259. /**
  144260. * Gets the output component
  144261. */
  144262. get output(): NodeMaterialConnectionPoint;
  144263. protected _buildBlock(state: NodeMaterialBuildState): this;
  144264. }
  144265. }
  144266. declare module BABYLON {
  144267. /**
  144268. * Block used to posterize a value
  144269. * @see https://en.wikipedia.org/wiki/Posterization
  144270. */
  144271. export class PosterizeBlock extends NodeMaterialBlock {
  144272. /**
  144273. * Creates a new PosterizeBlock
  144274. * @param name defines the block name
  144275. */
  144276. constructor(name: string);
  144277. /**
  144278. * Gets the current class name
  144279. * @returns the class name
  144280. */
  144281. getClassName(): string;
  144282. /**
  144283. * Gets the value input component
  144284. */
  144285. get value(): NodeMaterialConnectionPoint;
  144286. /**
  144287. * Gets the steps input component
  144288. */
  144289. get steps(): NodeMaterialConnectionPoint;
  144290. /**
  144291. * Gets the output component
  144292. */
  144293. get output(): NodeMaterialConnectionPoint;
  144294. protected _buildBlock(state: NodeMaterialBuildState): this;
  144295. }
  144296. }
  144297. declare module BABYLON {
  144298. /**
  144299. * Operations supported by the Wave block
  144300. */
  144301. export enum WaveBlockKind {
  144302. /** SawTooth */
  144303. SawTooth = 0,
  144304. /** Square */
  144305. Square = 1,
  144306. /** Triangle */
  144307. Triangle = 2
  144308. }
  144309. /**
  144310. * Block used to apply wave operation to floats
  144311. */
  144312. export class WaveBlock extends NodeMaterialBlock {
  144313. /**
  144314. * Gets or sets the kibnd of wave to be applied by the block
  144315. */
  144316. kind: WaveBlockKind;
  144317. /**
  144318. * Creates a new WaveBlock
  144319. * @param name defines the block name
  144320. */
  144321. constructor(name: string);
  144322. /**
  144323. * Gets the current class name
  144324. * @returns the class name
  144325. */
  144326. getClassName(): string;
  144327. /**
  144328. * Gets the input component
  144329. */
  144330. get input(): NodeMaterialConnectionPoint;
  144331. /**
  144332. * Gets the output component
  144333. */
  144334. get output(): NodeMaterialConnectionPoint;
  144335. protected _buildBlock(state: NodeMaterialBuildState): this;
  144336. serialize(): any;
  144337. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144338. }
  144339. }
  144340. declare module BABYLON {
  144341. /**
  144342. * Class used to store a color step for the GradientBlock
  144343. */
  144344. export class GradientBlockColorStep {
  144345. private _step;
  144346. /**
  144347. * Gets value indicating which step this color is associated with (between 0 and 1)
  144348. */
  144349. get step(): number;
  144350. /**
  144351. * Sets a value indicating which step this color is associated with (between 0 and 1)
  144352. */
  144353. set step(val: number);
  144354. private _color;
  144355. /**
  144356. * Gets the color associated with this step
  144357. */
  144358. get color(): Color3;
  144359. /**
  144360. * Sets the color associated with this step
  144361. */
  144362. set color(val: Color3);
  144363. /**
  144364. * Creates a new GradientBlockColorStep
  144365. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  144366. * @param color defines the color associated with this step
  144367. */
  144368. constructor(step: number, color: Color3);
  144369. }
  144370. /**
  144371. * Block used to return a color from a gradient based on an input value between 0 and 1
  144372. */
  144373. export class GradientBlock extends NodeMaterialBlock {
  144374. /**
  144375. * Gets or sets the list of color steps
  144376. */
  144377. colorSteps: GradientBlockColorStep[];
  144378. /** Gets an observable raised when the value is changed */
  144379. onValueChangedObservable: Observable<GradientBlock>;
  144380. /** calls observable when the value is changed*/
  144381. colorStepsUpdated(): void;
  144382. /**
  144383. * Creates a new GradientBlock
  144384. * @param name defines the block name
  144385. */
  144386. constructor(name: string);
  144387. /**
  144388. * Gets the current class name
  144389. * @returns the class name
  144390. */
  144391. getClassName(): string;
  144392. /**
  144393. * Gets the gradient input component
  144394. */
  144395. get gradient(): NodeMaterialConnectionPoint;
  144396. /**
  144397. * Gets the output component
  144398. */
  144399. get output(): NodeMaterialConnectionPoint;
  144400. private _writeColorConstant;
  144401. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144402. serialize(): any;
  144403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144404. protected _dumpPropertiesCode(): string;
  144405. }
  144406. }
  144407. declare module BABYLON {
  144408. /**
  144409. * Block used to normalize lerp between 2 values
  144410. */
  144411. export class NLerpBlock extends NodeMaterialBlock {
  144412. /**
  144413. * Creates a new NLerpBlock
  144414. * @param name defines the block name
  144415. */
  144416. constructor(name: string);
  144417. /**
  144418. * Gets the current class name
  144419. * @returns the class name
  144420. */
  144421. getClassName(): string;
  144422. /**
  144423. * Gets the left operand input component
  144424. */
  144425. get left(): NodeMaterialConnectionPoint;
  144426. /**
  144427. * Gets the right operand input component
  144428. */
  144429. get right(): NodeMaterialConnectionPoint;
  144430. /**
  144431. * Gets the gradient operand input component
  144432. */
  144433. get gradient(): NodeMaterialConnectionPoint;
  144434. /**
  144435. * Gets the output component
  144436. */
  144437. get output(): NodeMaterialConnectionPoint;
  144438. protected _buildBlock(state: NodeMaterialBuildState): this;
  144439. }
  144440. }
  144441. declare module BABYLON {
  144442. /**
  144443. * block used to Generate a Worley Noise 3D Noise Pattern
  144444. */
  144445. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  144446. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144447. manhattanDistance: boolean;
  144448. /**
  144449. * Creates a new WorleyNoise3DBlock
  144450. * @param name defines the block name
  144451. */
  144452. constructor(name: string);
  144453. /**
  144454. * Gets the current class name
  144455. * @returns the class name
  144456. */
  144457. getClassName(): string;
  144458. /**
  144459. * Gets the seed input component
  144460. */
  144461. get seed(): NodeMaterialConnectionPoint;
  144462. /**
  144463. * Gets the jitter input component
  144464. */
  144465. get jitter(): NodeMaterialConnectionPoint;
  144466. /**
  144467. * Gets the output component
  144468. */
  144469. get output(): NodeMaterialConnectionPoint;
  144470. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144471. /**
  144472. * Exposes the properties to the UI?
  144473. */
  144474. protected _dumpPropertiesCode(): string;
  144475. /**
  144476. * Exposes the properties to the Seralize?
  144477. */
  144478. serialize(): any;
  144479. /**
  144480. * Exposes the properties to the deseralize?
  144481. */
  144482. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144483. }
  144484. }
  144485. declare module BABYLON {
  144486. /**
  144487. * block used to Generate a Simplex Perlin 3d Noise Pattern
  144488. */
  144489. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  144490. /**
  144491. * Creates a new SimplexPerlin3DBlock
  144492. * @param name defines the block name
  144493. */
  144494. constructor(name: string);
  144495. /**
  144496. * Gets the current class name
  144497. * @returns the class name
  144498. */
  144499. getClassName(): string;
  144500. /**
  144501. * Gets the seed operand input component
  144502. */
  144503. get seed(): NodeMaterialConnectionPoint;
  144504. /**
  144505. * Gets the output component
  144506. */
  144507. get output(): NodeMaterialConnectionPoint;
  144508. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144509. }
  144510. }
  144511. declare module BABYLON {
  144512. /**
  144513. * Block used to blend normals
  144514. */
  144515. export class NormalBlendBlock extends NodeMaterialBlock {
  144516. /**
  144517. * Creates a new NormalBlendBlock
  144518. * @param name defines the block name
  144519. */
  144520. constructor(name: string);
  144521. /**
  144522. * Gets the current class name
  144523. * @returns the class name
  144524. */
  144525. getClassName(): string;
  144526. /**
  144527. * Gets the first input component
  144528. */
  144529. get normalMap0(): NodeMaterialConnectionPoint;
  144530. /**
  144531. * Gets the second input component
  144532. */
  144533. get normalMap1(): NodeMaterialConnectionPoint;
  144534. /**
  144535. * Gets the output component
  144536. */
  144537. get output(): NodeMaterialConnectionPoint;
  144538. protected _buildBlock(state: NodeMaterialBuildState): this;
  144539. }
  144540. }
  144541. declare module BABYLON {
  144542. /**
  144543. * Block used to rotate a 2d vector by a given angle
  144544. */
  144545. export class Rotate2dBlock extends NodeMaterialBlock {
  144546. /**
  144547. * Creates a new Rotate2dBlock
  144548. * @param name defines the block name
  144549. */
  144550. constructor(name: string);
  144551. /**
  144552. * Gets the current class name
  144553. * @returns the class name
  144554. */
  144555. getClassName(): string;
  144556. /**
  144557. * Gets the input vector
  144558. */
  144559. get input(): NodeMaterialConnectionPoint;
  144560. /**
  144561. * Gets the input angle
  144562. */
  144563. get angle(): NodeMaterialConnectionPoint;
  144564. /**
  144565. * Gets the output component
  144566. */
  144567. get output(): NodeMaterialConnectionPoint;
  144568. autoConfigure(material: NodeMaterial): void;
  144569. protected _buildBlock(state: NodeMaterialBuildState): this;
  144570. }
  144571. }
  144572. declare module BABYLON {
  144573. /**
  144574. * Block used to get the reflected vector from a direction and a normal
  144575. */
  144576. export class ReflectBlock extends NodeMaterialBlock {
  144577. /**
  144578. * Creates a new ReflectBlock
  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 incident component
  144589. */
  144590. get incident(): NodeMaterialConnectionPoint;
  144591. /**
  144592. * Gets the normal component
  144593. */
  144594. get normal(): 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 get the refracted vector from a direction and a normal
  144605. */
  144606. export class RefractBlock extends NodeMaterialBlock {
  144607. /**
  144608. * Creates a new RefractBlock
  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 incident component
  144619. */
  144620. get incident(): NodeMaterialConnectionPoint;
  144621. /**
  144622. * Gets the normal component
  144623. */
  144624. get normal(): NodeMaterialConnectionPoint;
  144625. /**
  144626. * Gets the index of refraction component
  144627. */
  144628. get ior(): NodeMaterialConnectionPoint;
  144629. /**
  144630. * Gets the output component
  144631. */
  144632. get output(): NodeMaterialConnectionPoint;
  144633. protected _buildBlock(state: NodeMaterialBuildState): this;
  144634. }
  144635. }
  144636. declare module BABYLON {
  144637. /**
  144638. * Block used to desaturate a color
  144639. */
  144640. export class DesaturateBlock extends NodeMaterialBlock {
  144641. /**
  144642. * Creates a new DesaturateBlock
  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 color operand input component
  144653. */
  144654. get color(): NodeMaterialConnectionPoint;
  144655. /**
  144656. * Gets the level operand input component
  144657. */
  144658. get level(): NodeMaterialConnectionPoint;
  144659. /**
  144660. * Gets the output component
  144661. */
  144662. get output(): NodeMaterialConnectionPoint;
  144663. protected _buildBlock(state: NodeMaterialBuildState): this;
  144664. }
  144665. }
  144666. declare module BABYLON {
  144667. /**
  144668. * Block used to implement the ambient occlusion module of the PBR material
  144669. */
  144670. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  144671. /**
  144672. * Create a new AmbientOcclusionBlock
  144673. * @param name defines the block name
  144674. */
  144675. constructor(name: string);
  144676. /**
  144677. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  144678. */
  144679. useAmbientInGrayScale: boolean;
  144680. /**
  144681. * Initialize the block and prepare the context for build
  144682. * @param state defines the state that will be used for the build
  144683. */
  144684. initialize(state: NodeMaterialBuildState): void;
  144685. /**
  144686. * Gets the current class name
  144687. * @returns the class name
  144688. */
  144689. getClassName(): string;
  144690. /**
  144691. * Gets the texture input component
  144692. */
  144693. get texture(): NodeMaterialConnectionPoint;
  144694. /**
  144695. * Gets the texture intensity component
  144696. */
  144697. get intensity(): NodeMaterialConnectionPoint;
  144698. /**
  144699. * Gets the direct light intensity input component
  144700. */
  144701. get directLightIntensity(): NodeMaterialConnectionPoint;
  144702. /**
  144703. * Gets the ambient occlusion object output component
  144704. */
  144705. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144706. /**
  144707. * Gets the main code of the block (fragment side)
  144708. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  144709. * @returns the shader code
  144710. */
  144711. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  144712. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144713. protected _buildBlock(state: NodeMaterialBuildState): this;
  144714. protected _dumpPropertiesCode(): string;
  144715. serialize(): any;
  144716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144717. }
  144718. }
  144719. declare module BABYLON {
  144720. /**
  144721. * Block used to implement the reflection module of the PBR material
  144722. */
  144723. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  144724. /** @hidden */
  144725. _defineLODReflectionAlpha: string;
  144726. /** @hidden */
  144727. _defineLinearSpecularReflection: string;
  144728. private _vEnvironmentIrradianceName;
  144729. /** @hidden */
  144730. _vReflectionMicrosurfaceInfosName: string;
  144731. /** @hidden */
  144732. _vReflectionInfosName: string;
  144733. /** @hidden */
  144734. _vReflectionFilteringInfoName: string;
  144735. private _scene;
  144736. /**
  144737. * The three properties below are set by the main PBR block prior to calling methods of this class.
  144738. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144739. * It's less burden on the user side in the editor part.
  144740. */
  144741. /** @hidden */
  144742. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144743. /** @hidden */
  144744. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144745. /** @hidden */
  144746. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  144747. /**
  144748. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  144749. * diffuse part of the IBL.
  144750. */
  144751. useSphericalHarmonics: boolean;
  144752. /**
  144753. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  144754. */
  144755. forceIrradianceInFragment: boolean;
  144756. /**
  144757. * Create a new ReflectionBlock
  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 position input component
  144768. */
  144769. get position(): NodeMaterialConnectionPoint;
  144770. /**
  144771. * Gets the world position input component
  144772. */
  144773. get worldPosition(): NodeMaterialConnectionPoint;
  144774. /**
  144775. * Gets the world normal input component
  144776. */
  144777. get worldNormal(): NodeMaterialConnectionPoint;
  144778. /**
  144779. * Gets the world input component
  144780. */
  144781. get world(): NodeMaterialConnectionPoint;
  144782. /**
  144783. * Gets the camera (or eye) position component
  144784. */
  144785. get cameraPosition(): NodeMaterialConnectionPoint;
  144786. /**
  144787. * Gets the view input component
  144788. */
  144789. get view(): NodeMaterialConnectionPoint;
  144790. /**
  144791. * Gets the color input component
  144792. */
  144793. get color(): NodeMaterialConnectionPoint;
  144794. /**
  144795. * Gets the reflection object output component
  144796. */
  144797. get reflection(): NodeMaterialConnectionPoint;
  144798. /**
  144799. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  144800. */
  144801. get hasTexture(): boolean;
  144802. /**
  144803. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  144804. */
  144805. get reflectionColor(): string;
  144806. protected _getTexture(): Nullable<BaseTexture>;
  144807. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144808. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144809. /**
  144810. * Gets the code to inject in the vertex shader
  144811. * @param state current state of the node material building
  144812. * @returns the shader code
  144813. */
  144814. handleVertexSide(state: NodeMaterialBuildState): string;
  144815. /**
  144816. * Gets the main code of the block (fragment side)
  144817. * @param state current state of the node material building
  144818. * @param normalVarName name of the existing variable corresponding to the normal
  144819. * @returns the shader code
  144820. */
  144821. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  144822. protected _buildBlock(state: NodeMaterialBuildState): this;
  144823. protected _dumpPropertiesCode(): string;
  144824. serialize(): any;
  144825. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144826. }
  144827. }
  144828. declare module BABYLON {
  144829. /**
  144830. * Block used to implement the sheen module of the PBR material
  144831. */
  144832. export class SheenBlock extends NodeMaterialBlock {
  144833. /**
  144834. * Create a new SheenBlock
  144835. * @param name defines the block name
  144836. */
  144837. constructor(name: string);
  144838. /**
  144839. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  144840. * It allows the strength of the sheen effect to not depend on the base color of the material,
  144841. * making it easier to setup and tweak the effect
  144842. */
  144843. albedoScaling: boolean;
  144844. /**
  144845. * Defines if the sheen is linked to the sheen color.
  144846. */
  144847. linkSheenWithAlbedo: boolean;
  144848. /**
  144849. * Initialize the block and prepare the context for build
  144850. * @param state defines the state that will be used for the build
  144851. */
  144852. initialize(state: NodeMaterialBuildState): void;
  144853. /**
  144854. * Gets the current class name
  144855. * @returns the class name
  144856. */
  144857. getClassName(): string;
  144858. /**
  144859. * Gets the intensity input component
  144860. */
  144861. get intensity(): NodeMaterialConnectionPoint;
  144862. /**
  144863. * Gets the color input component
  144864. */
  144865. get color(): NodeMaterialConnectionPoint;
  144866. /**
  144867. * Gets the roughness input component
  144868. */
  144869. get roughness(): NodeMaterialConnectionPoint;
  144870. /**
  144871. * Gets the sheen object output component
  144872. */
  144873. get sheen(): NodeMaterialConnectionPoint;
  144874. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144875. /**
  144876. * Gets the main code of the block (fragment side)
  144877. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144878. * @returns the shader code
  144879. */
  144880. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144881. protected _buildBlock(state: NodeMaterialBuildState): this;
  144882. protected _dumpPropertiesCode(): string;
  144883. serialize(): any;
  144884. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144885. }
  144886. }
  144887. declare module BABYLON {
  144888. /**
  144889. * Block used to implement the reflectivity module of the PBR material
  144890. */
  144891. export class ReflectivityBlock extends NodeMaterialBlock {
  144892. private _metallicReflectanceColor;
  144893. private _metallicF0Factor;
  144894. /** @hidden */
  144895. _vMetallicReflectanceFactorsName: string;
  144896. /**
  144897. * The property below is set by the main PBR block prior to calling methods of this class.
  144898. */
  144899. /** @hidden */
  144900. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144901. /**
  144902. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144903. */
  144904. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144905. /**
  144906. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144907. */
  144908. useMetallnessFromMetallicTextureBlue: boolean;
  144909. /**
  144910. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144911. */
  144912. useRoughnessFromMetallicTextureAlpha: boolean;
  144913. /**
  144914. * Specifies if the metallic texture contains the roughness information in its green channel.
  144915. */
  144916. useRoughnessFromMetallicTextureGreen: boolean;
  144917. /**
  144918. * Create a new ReflectivityBlock
  144919. * @param name defines the block name
  144920. */
  144921. constructor(name: string);
  144922. /**
  144923. * Initialize the block and prepare the context for build
  144924. * @param state defines the state that will be used for the build
  144925. */
  144926. initialize(state: NodeMaterialBuildState): void;
  144927. /**
  144928. * Gets the current class name
  144929. * @returns the class name
  144930. */
  144931. getClassName(): string;
  144932. /**
  144933. * Gets the metallic input component
  144934. */
  144935. get metallic(): NodeMaterialConnectionPoint;
  144936. /**
  144937. * Gets the roughness input component
  144938. */
  144939. get roughness(): NodeMaterialConnectionPoint;
  144940. /**
  144941. * Gets the texture input component
  144942. */
  144943. get texture(): NodeMaterialConnectionPoint;
  144944. /**
  144945. * Gets the reflectivity object output component
  144946. */
  144947. get reflectivity(): NodeMaterialConnectionPoint;
  144948. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144949. /**
  144950. * Gets the main code of the block (fragment side)
  144951. * @param state current state of the node material building
  144952. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  144953. * @returns the shader code
  144954. */
  144955. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  144956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144957. protected _buildBlock(state: NodeMaterialBuildState): this;
  144958. protected _dumpPropertiesCode(): string;
  144959. serialize(): any;
  144960. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144961. }
  144962. }
  144963. declare module BABYLON {
  144964. /**
  144965. * Block used to implement the anisotropy module of the PBR material
  144966. */
  144967. export class AnisotropyBlock extends NodeMaterialBlock {
  144968. /**
  144969. * The two properties below are set by the main PBR block prior to calling methods of this class.
  144970. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144971. * It's less burden on the user side in the editor part.
  144972. */
  144973. /** @hidden */
  144974. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144975. /** @hidden */
  144976. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144977. /**
  144978. * Create a new AnisotropyBlock
  144979. * @param name defines the block name
  144980. */
  144981. constructor(name: string);
  144982. /**
  144983. * Initialize the block and prepare the context for build
  144984. * @param state defines the state that will be used for the build
  144985. */
  144986. initialize(state: NodeMaterialBuildState): void;
  144987. /**
  144988. * Gets the current class name
  144989. * @returns the class name
  144990. */
  144991. getClassName(): string;
  144992. /**
  144993. * Gets the intensity input component
  144994. */
  144995. get intensity(): NodeMaterialConnectionPoint;
  144996. /**
  144997. * Gets the direction input component
  144998. */
  144999. get direction(): NodeMaterialConnectionPoint;
  145000. /**
  145001. * Gets the texture input component
  145002. */
  145003. get texture(): NodeMaterialConnectionPoint;
  145004. /**
  145005. * Gets the uv input component
  145006. */
  145007. get uv(): NodeMaterialConnectionPoint;
  145008. /**
  145009. * Gets the worldTangent input component
  145010. */
  145011. get worldTangent(): NodeMaterialConnectionPoint;
  145012. /**
  145013. * Gets the anisotropy object output component
  145014. */
  145015. get anisotropy(): NodeMaterialConnectionPoint;
  145016. private _generateTBNSpace;
  145017. /**
  145018. * Gets the main code of the block (fragment side)
  145019. * @param state current state of the node material building
  145020. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145021. * @returns the shader code
  145022. */
  145023. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145024. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145025. protected _buildBlock(state: NodeMaterialBuildState): this;
  145026. }
  145027. }
  145028. declare module BABYLON {
  145029. /**
  145030. * Block used to implement the clear coat module of the PBR material
  145031. */
  145032. export class ClearCoatBlock extends NodeMaterialBlock {
  145033. private _scene;
  145034. /**
  145035. * Create a new ClearCoatBlock
  145036. * @param name defines the block name
  145037. */
  145038. constructor(name: string);
  145039. /**
  145040. * Initialize the block and prepare the context for build
  145041. * @param state defines the state that will be used for the build
  145042. */
  145043. initialize(state: NodeMaterialBuildState): void;
  145044. /**
  145045. * Gets the current class name
  145046. * @returns the class name
  145047. */
  145048. getClassName(): string;
  145049. /**
  145050. * Gets the intensity input component
  145051. */
  145052. get intensity(): NodeMaterialConnectionPoint;
  145053. /**
  145054. * Gets the roughness input component
  145055. */
  145056. get roughness(): NodeMaterialConnectionPoint;
  145057. /**
  145058. * Gets the ior input component
  145059. */
  145060. get ior(): NodeMaterialConnectionPoint;
  145061. /**
  145062. * Gets the texture input component
  145063. */
  145064. get texture(): NodeMaterialConnectionPoint;
  145065. /**
  145066. * Gets the bump texture input component
  145067. */
  145068. get bumpTexture(): NodeMaterialConnectionPoint;
  145069. /**
  145070. * Gets the uv input component
  145071. */
  145072. get uv(): NodeMaterialConnectionPoint;
  145073. /**
  145074. * Gets the tint color input component
  145075. */
  145076. get tintColor(): NodeMaterialConnectionPoint;
  145077. /**
  145078. * Gets the tint "at distance" input component
  145079. */
  145080. get tintAtDistance(): NodeMaterialConnectionPoint;
  145081. /**
  145082. * Gets the tint thickness input component
  145083. */
  145084. get tintThickness(): NodeMaterialConnectionPoint;
  145085. /**
  145086. * Gets the world tangent input component
  145087. */
  145088. get worldTangent(): NodeMaterialConnectionPoint;
  145089. /**
  145090. * Gets the clear coat object output component
  145091. */
  145092. get clearcoat(): NodeMaterialConnectionPoint;
  145093. autoConfigure(material: NodeMaterial): void;
  145094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145095. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145096. private _generateTBNSpace;
  145097. /**
  145098. * Gets the main code of the block (fragment side)
  145099. * @param state current state of the node material building
  145100. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  145101. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145102. * @param worldPosVarName name of the variable holding the world position
  145103. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145104. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145105. * @param worldNormalVarName name of the variable holding the world normal
  145106. * @returns the shader code
  145107. */
  145108. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145109. protected _buildBlock(state: NodeMaterialBuildState): this;
  145110. }
  145111. }
  145112. declare module BABYLON {
  145113. /**
  145114. * Block used to implement the sub surface module of the PBR material
  145115. */
  145116. export class SubSurfaceBlock extends NodeMaterialBlock {
  145117. /**
  145118. * Create a new SubSurfaceBlock
  145119. * @param name defines the block name
  145120. */
  145121. constructor(name: string);
  145122. /**
  145123. * Stores the intensity of the different subsurface effects in the thickness texture.
  145124. * * the green channel is the translucency intensity.
  145125. * * the blue channel is the scattering intensity.
  145126. * * the alpha channel is the refraction intensity.
  145127. */
  145128. useMaskFromThicknessTexture: boolean;
  145129. /**
  145130. * Initialize the block and prepare the context for build
  145131. * @param state defines the state that will be used for the build
  145132. */
  145133. initialize(state: NodeMaterialBuildState): void;
  145134. /**
  145135. * Gets the current class name
  145136. * @returns the class name
  145137. */
  145138. getClassName(): string;
  145139. /**
  145140. * Gets the min thickness input component
  145141. */
  145142. get minThickness(): NodeMaterialConnectionPoint;
  145143. /**
  145144. * Gets the max thickness input component
  145145. */
  145146. get maxThickness(): NodeMaterialConnectionPoint;
  145147. /**
  145148. * Gets the thickness texture component
  145149. */
  145150. get thicknessTexture(): NodeMaterialConnectionPoint;
  145151. /**
  145152. * Gets the tint color input component
  145153. */
  145154. get tintColor(): NodeMaterialConnectionPoint;
  145155. /**
  145156. * Gets the translucency intensity input component
  145157. */
  145158. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145159. /**
  145160. * Gets the translucency diffusion distance input component
  145161. */
  145162. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145163. /**
  145164. * Gets the refraction object parameters
  145165. */
  145166. get refraction(): NodeMaterialConnectionPoint;
  145167. /**
  145168. * Gets the sub surface object output component
  145169. */
  145170. get subsurface(): NodeMaterialConnectionPoint;
  145171. autoConfigure(material: NodeMaterial): void;
  145172. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145173. /**
  145174. * Gets the main code of the block (fragment side)
  145175. * @param state current state of the node material building
  145176. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145177. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145178. * @param worldPosVarName name of the variable holding the world position
  145179. * @returns the shader code
  145180. */
  145181. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145182. protected _buildBlock(state: NodeMaterialBuildState): this;
  145183. }
  145184. }
  145185. declare module BABYLON {
  145186. /**
  145187. * Block used to implement the PBR metallic/roughness model
  145188. */
  145189. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  145190. /**
  145191. * Gets or sets the light associated with this block
  145192. */
  145193. light: Nullable<Light>;
  145194. private _lightId;
  145195. private _scene;
  145196. private _environmentBRDFTexture;
  145197. private _environmentBrdfSamplerName;
  145198. private _vNormalWName;
  145199. private _invertNormalName;
  145200. /**
  145201. * Create a new ReflectionBlock
  145202. * @param name defines the block name
  145203. */
  145204. constructor(name: string);
  145205. /**
  145206. * Intensity of the direct lights e.g. the four lights available in your scene.
  145207. * This impacts both the direct diffuse and specular highlights.
  145208. */
  145209. directIntensity: number;
  145210. /**
  145211. * Intensity of the environment e.g. how much the environment will light the object
  145212. * either through harmonics for rough material or through the refelction for shiny ones.
  145213. */
  145214. environmentIntensity: number;
  145215. /**
  145216. * This is a special control allowing the reduction of the specular highlights coming from the
  145217. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  145218. */
  145219. specularIntensity: number;
  145220. /**
  145221. * Defines the falloff type used in this material.
  145222. * It by default is Physical.
  145223. */
  145224. lightFalloff: number;
  145225. /**
  145226. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  145227. */
  145228. useAlphaFromAlbedoTexture: boolean;
  145229. /**
  145230. * Specifies that alpha test should be used
  145231. */
  145232. useAlphaTest: boolean;
  145233. /**
  145234. * Defines the alpha limits in alpha test mode.
  145235. */
  145236. alphaTestCutoff: number;
  145237. /**
  145238. * Specifies that alpha blending should be used
  145239. */
  145240. useAlphaBlending: boolean;
  145241. /**
  145242. * Defines if the alpha value should be determined via the rgb values.
  145243. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  145244. */
  145245. opacityRGB: boolean;
  145246. /**
  145247. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  145248. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  145249. */
  145250. useRadianceOverAlpha: boolean;
  145251. /**
  145252. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  145253. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  145254. */
  145255. useSpecularOverAlpha: boolean;
  145256. /**
  145257. * Enables specular anti aliasing in the PBR shader.
  145258. * It will both interacts on the Geometry for analytical and IBL lighting.
  145259. * It also prefilter the roughness map based on the bump values.
  145260. */
  145261. enableSpecularAntiAliasing: boolean;
  145262. /**
  145263. * Enables realtime filtering on the texture.
  145264. */
  145265. realTimeFiltering: boolean;
  145266. /**
  145267. * Quality switch for realtime filtering
  145268. */
  145269. realTimeFilteringQuality: number;
  145270. /**
  145271. * Defines if the material uses energy conservation.
  145272. */
  145273. useEnergyConservation: boolean;
  145274. /**
  145275. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  145276. * too much the area relying on ambient texture to define their ambient occlusion.
  145277. */
  145278. useRadianceOcclusion: boolean;
  145279. /**
  145280. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  145281. * makes the reflect vector face the model (under horizon).
  145282. */
  145283. useHorizonOcclusion: boolean;
  145284. /**
  145285. * If set to true, no lighting calculations will be applied.
  145286. */
  145287. unlit: boolean;
  145288. /**
  145289. * Force normal to face away from face.
  145290. */
  145291. forceNormalForward: boolean;
  145292. /**
  145293. * Defines the material debug mode.
  145294. * It helps seeing only some components of the material while troubleshooting.
  145295. */
  145296. debugMode: number;
  145297. /**
  145298. * Specify from where on screen the debug mode should start.
  145299. * The value goes from -1 (full screen) to 1 (not visible)
  145300. * It helps with side by side comparison against the final render
  145301. * This defaults to 0
  145302. */
  145303. debugLimit: number;
  145304. /**
  145305. * As the default viewing range might not be enough (if the ambient is really small for instance)
  145306. * You can use the factor to better multiply the final value.
  145307. */
  145308. debugFactor: number;
  145309. /**
  145310. * Initialize the block and prepare the context for build
  145311. * @param state defines the state that will be used for the build
  145312. */
  145313. initialize(state: NodeMaterialBuildState): void;
  145314. /**
  145315. * Gets the current class name
  145316. * @returns the class name
  145317. */
  145318. getClassName(): string;
  145319. /**
  145320. * Gets the world position input component
  145321. */
  145322. get worldPosition(): NodeMaterialConnectionPoint;
  145323. /**
  145324. * Gets the world normal input component
  145325. */
  145326. get worldNormal(): NodeMaterialConnectionPoint;
  145327. /**
  145328. * Gets the perturbed normal input component
  145329. */
  145330. get perturbedNormal(): NodeMaterialConnectionPoint;
  145331. /**
  145332. * Gets the camera position input component
  145333. */
  145334. get cameraPosition(): NodeMaterialConnectionPoint;
  145335. /**
  145336. * Gets the base color input component
  145337. */
  145338. get baseColor(): NodeMaterialConnectionPoint;
  145339. /**
  145340. * Gets the opacity texture input component
  145341. */
  145342. get opacityTexture(): NodeMaterialConnectionPoint;
  145343. /**
  145344. * Gets the ambient color input component
  145345. */
  145346. get ambientColor(): NodeMaterialConnectionPoint;
  145347. /**
  145348. * Gets the reflectivity object parameters
  145349. */
  145350. get reflectivity(): NodeMaterialConnectionPoint;
  145351. /**
  145352. * Gets the ambient occlusion object parameters
  145353. */
  145354. get ambientOcclusion(): NodeMaterialConnectionPoint;
  145355. /**
  145356. * Gets the reflection object parameters
  145357. */
  145358. get reflection(): NodeMaterialConnectionPoint;
  145359. /**
  145360. * Gets the sheen object parameters
  145361. */
  145362. get sheen(): NodeMaterialConnectionPoint;
  145363. /**
  145364. * Gets the clear coat object parameters
  145365. */
  145366. get clearcoat(): NodeMaterialConnectionPoint;
  145367. /**
  145368. * Gets the sub surface object parameters
  145369. */
  145370. get subsurface(): NodeMaterialConnectionPoint;
  145371. /**
  145372. * Gets the anisotropy object parameters
  145373. */
  145374. get anisotropy(): NodeMaterialConnectionPoint;
  145375. /**
  145376. * Gets the ambient output component
  145377. */
  145378. get ambient(): NodeMaterialConnectionPoint;
  145379. /**
  145380. * Gets the diffuse output component
  145381. */
  145382. get diffuse(): NodeMaterialConnectionPoint;
  145383. /**
  145384. * Gets the specular output component
  145385. */
  145386. get specular(): NodeMaterialConnectionPoint;
  145387. /**
  145388. * Gets the sheen output component
  145389. */
  145390. get sheenDir(): NodeMaterialConnectionPoint;
  145391. /**
  145392. * Gets the clear coat output component
  145393. */
  145394. get clearcoatDir(): NodeMaterialConnectionPoint;
  145395. /**
  145396. * Gets the indirect diffuse output component
  145397. */
  145398. get diffuseIndirect(): NodeMaterialConnectionPoint;
  145399. /**
  145400. * Gets the indirect specular output component
  145401. */
  145402. get specularIndirect(): NodeMaterialConnectionPoint;
  145403. /**
  145404. * Gets the indirect sheen output component
  145405. */
  145406. get sheenIndirect(): NodeMaterialConnectionPoint;
  145407. /**
  145408. * Gets the indirect clear coat output component
  145409. */
  145410. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  145411. /**
  145412. * Gets the refraction output component
  145413. */
  145414. get refraction(): NodeMaterialConnectionPoint;
  145415. /**
  145416. * Gets the global lighting output component
  145417. */
  145418. get lighting(): NodeMaterialConnectionPoint;
  145419. /**
  145420. * Gets the shadow output component
  145421. */
  145422. get shadow(): NodeMaterialConnectionPoint;
  145423. /**
  145424. * Gets the alpha output component
  145425. */
  145426. get alpha(): NodeMaterialConnectionPoint;
  145427. autoConfigure(material: NodeMaterial): void;
  145428. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145429. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145430. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145431. private _injectVertexCode;
  145432. /**
  145433. * Gets the code corresponding to the albedo/opacity module
  145434. * @returns the shader code
  145435. */
  145436. getAlbedoOpacityCode(): string;
  145437. protected _buildBlock(state: NodeMaterialBuildState): this;
  145438. protected _dumpPropertiesCode(): string;
  145439. serialize(): any;
  145440. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145441. }
  145442. }
  145443. declare module BABYLON {
  145444. /**
  145445. * Block used to compute value of one parameter modulo another
  145446. */
  145447. export class ModBlock extends NodeMaterialBlock {
  145448. /**
  145449. * Creates a new ModBlock
  145450. * @param name defines the block name
  145451. */
  145452. constructor(name: string);
  145453. /**
  145454. * Gets the current class name
  145455. * @returns the class name
  145456. */
  145457. getClassName(): string;
  145458. /**
  145459. * Gets the left operand input component
  145460. */
  145461. get left(): NodeMaterialConnectionPoint;
  145462. /**
  145463. * Gets the right operand input component
  145464. */
  145465. get right(): NodeMaterialConnectionPoint;
  145466. /**
  145467. * Gets the output component
  145468. */
  145469. get output(): NodeMaterialConnectionPoint;
  145470. protected _buildBlock(state: NodeMaterialBuildState): this;
  145471. }
  145472. }
  145473. declare module BABYLON {
  145474. /**
  145475. * Configuration for Draco compression
  145476. */
  145477. export interface IDracoCompressionConfiguration {
  145478. /**
  145479. * Configuration for the decoder.
  145480. */
  145481. decoder: {
  145482. /**
  145483. * The url to the WebAssembly module.
  145484. */
  145485. wasmUrl?: string;
  145486. /**
  145487. * The url to the WebAssembly binary.
  145488. */
  145489. wasmBinaryUrl?: string;
  145490. /**
  145491. * The url to the fallback JavaScript module.
  145492. */
  145493. fallbackUrl?: string;
  145494. };
  145495. }
  145496. /**
  145497. * Draco compression (https://google.github.io/draco/)
  145498. *
  145499. * This class wraps the Draco module.
  145500. *
  145501. * **Encoder**
  145502. *
  145503. * The encoder is not currently implemented.
  145504. *
  145505. * **Decoder**
  145506. *
  145507. * 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.
  145508. *
  145509. * To update the configuration, use the following code:
  145510. * ```javascript
  145511. * DracoCompression.Configuration = {
  145512. * decoder: {
  145513. * wasmUrl: "<url to the WebAssembly library>",
  145514. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145515. * fallbackUrl: "<url to the fallback JavaScript library>",
  145516. * }
  145517. * };
  145518. * ```
  145519. *
  145520. * 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.
  145521. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145522. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145523. *
  145524. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145525. * ```javascript
  145526. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145527. * ```
  145528. *
  145529. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145530. */
  145531. export class DracoCompression implements IDisposable {
  145532. private _workerPoolPromise?;
  145533. private _decoderModulePromise?;
  145534. /**
  145535. * The configuration. Defaults to the following urls:
  145536. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145537. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145538. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145539. */
  145540. static Configuration: IDracoCompressionConfiguration;
  145541. /**
  145542. * Returns true if the decoder configuration is available.
  145543. */
  145544. static get DecoderAvailable(): boolean;
  145545. /**
  145546. * Default number of workers to create when creating the draco compression object.
  145547. */
  145548. static DefaultNumWorkers: number;
  145549. private static GetDefaultNumWorkers;
  145550. private static _Default;
  145551. /**
  145552. * Default instance for the draco compression object.
  145553. */
  145554. static get Default(): DracoCompression;
  145555. /**
  145556. * Constructor
  145557. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145558. */
  145559. constructor(numWorkers?: number);
  145560. /**
  145561. * Stop all async operations and release resources.
  145562. */
  145563. dispose(): void;
  145564. /**
  145565. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145566. * @returns a promise that resolves when ready
  145567. */
  145568. whenReadyAsync(): Promise<void>;
  145569. /**
  145570. * Decode Draco compressed mesh data to vertex data.
  145571. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145572. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145573. * @returns A promise that resolves with the decoded vertex data
  145574. */
  145575. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145576. [kind: string]: number;
  145577. }): Promise<VertexData>;
  145578. }
  145579. }
  145580. declare module BABYLON {
  145581. /**
  145582. * Class for building Constructive Solid Geometry
  145583. */
  145584. export class CSG {
  145585. private polygons;
  145586. /**
  145587. * The world matrix
  145588. */
  145589. matrix: Matrix;
  145590. /**
  145591. * Stores the position
  145592. */
  145593. position: Vector3;
  145594. /**
  145595. * Stores the rotation
  145596. */
  145597. rotation: Vector3;
  145598. /**
  145599. * Stores the rotation quaternion
  145600. */
  145601. rotationQuaternion: Nullable<Quaternion>;
  145602. /**
  145603. * Stores the scaling vector
  145604. */
  145605. scaling: Vector3;
  145606. /**
  145607. * Convert the Mesh to CSG
  145608. * @param mesh The Mesh to convert to CSG
  145609. * @returns A new CSG from the Mesh
  145610. */
  145611. static FromMesh(mesh: Mesh): CSG;
  145612. /**
  145613. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145614. * @param polygons Polygons used to construct a CSG solid
  145615. */
  145616. private static FromPolygons;
  145617. /**
  145618. * Clones, or makes a deep copy, of the CSG
  145619. * @returns A new CSG
  145620. */
  145621. clone(): CSG;
  145622. /**
  145623. * Unions this CSG with another CSG
  145624. * @param csg The CSG to union against this CSG
  145625. * @returns The unioned CSG
  145626. */
  145627. union(csg: CSG): CSG;
  145628. /**
  145629. * Unions this CSG with another CSG in place
  145630. * @param csg The CSG to union against this CSG
  145631. */
  145632. unionInPlace(csg: CSG): void;
  145633. /**
  145634. * Subtracts this CSG with another CSG
  145635. * @param csg The CSG to subtract against this CSG
  145636. * @returns A new CSG
  145637. */
  145638. subtract(csg: CSG): CSG;
  145639. /**
  145640. * Subtracts this CSG with another CSG in place
  145641. * @param csg The CSG to subtact against this CSG
  145642. */
  145643. subtractInPlace(csg: CSG): void;
  145644. /**
  145645. * Intersect this CSG with another CSG
  145646. * @param csg The CSG to intersect against this CSG
  145647. * @returns A new CSG
  145648. */
  145649. intersect(csg: CSG): CSG;
  145650. /**
  145651. * Intersects this CSG with another CSG in place
  145652. * @param csg The CSG to intersect against this CSG
  145653. */
  145654. intersectInPlace(csg: CSG): void;
  145655. /**
  145656. * Return a new CSG solid with solid and empty space switched. This solid is
  145657. * not modified.
  145658. * @returns A new CSG solid with solid and empty space switched
  145659. */
  145660. inverse(): CSG;
  145661. /**
  145662. * Inverses the CSG in place
  145663. */
  145664. inverseInPlace(): void;
  145665. /**
  145666. * This is used to keep meshes transformations so they can be restored
  145667. * when we build back a Babylon Mesh
  145668. * NB : All CSG operations are performed in world coordinates
  145669. * @param csg The CSG to copy the transform attributes from
  145670. * @returns This CSG
  145671. */
  145672. copyTransformAttributes(csg: CSG): CSG;
  145673. /**
  145674. * Build Raw mesh from CSG
  145675. * Coordinates here are in world space
  145676. * @param name The name of the mesh geometry
  145677. * @param scene The Scene
  145678. * @param keepSubMeshes Specifies if the submeshes should be kept
  145679. * @returns A new Mesh
  145680. */
  145681. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145682. /**
  145683. * Build Mesh from CSG taking material and transforms into account
  145684. * @param name The name of the Mesh
  145685. * @param material The material of the Mesh
  145686. * @param scene The Scene
  145687. * @param keepSubMeshes Specifies if submeshes should be kept
  145688. * @returns The new Mesh
  145689. */
  145690. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145691. }
  145692. }
  145693. declare module BABYLON {
  145694. /**
  145695. * Class used to create a trail following a mesh
  145696. */
  145697. export class TrailMesh extends Mesh {
  145698. private _generator;
  145699. private _autoStart;
  145700. private _running;
  145701. private _diameter;
  145702. private _length;
  145703. private _sectionPolygonPointsCount;
  145704. private _sectionVectors;
  145705. private _sectionNormalVectors;
  145706. private _beforeRenderObserver;
  145707. /**
  145708. * @constructor
  145709. * @param name The value used by scene.getMeshByName() to do a lookup.
  145710. * @param generator The mesh or transform node to generate a trail.
  145711. * @param scene The scene to add this mesh to.
  145712. * @param diameter Diameter of trailing mesh. Default is 1.
  145713. * @param length Length of trailing mesh. Default is 60.
  145714. * @param autoStart Automatically start trailing mesh. Default true.
  145715. */
  145716. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  145717. /**
  145718. * "TrailMesh"
  145719. * @returns "TrailMesh"
  145720. */
  145721. getClassName(): string;
  145722. private _createMesh;
  145723. /**
  145724. * Start trailing mesh.
  145725. */
  145726. start(): void;
  145727. /**
  145728. * Stop trailing mesh.
  145729. */
  145730. stop(): void;
  145731. /**
  145732. * Update trailing mesh geometry.
  145733. */
  145734. update(): void;
  145735. /**
  145736. * Returns a new TrailMesh object.
  145737. * @param name is a string, the name given to the new mesh
  145738. * @param newGenerator use new generator object for cloned trail mesh
  145739. * @returns a new mesh
  145740. */
  145741. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  145742. /**
  145743. * Serializes this trail mesh
  145744. * @param serializationObject object to write serialization to
  145745. */
  145746. serialize(serializationObject: any): void;
  145747. /**
  145748. * Parses a serialized trail mesh
  145749. * @param parsedMesh the serialized mesh
  145750. * @param scene the scene to create the trail mesh in
  145751. * @returns the created trail mesh
  145752. */
  145753. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  145754. }
  145755. }
  145756. declare module BABYLON {
  145757. /**
  145758. * Class containing static functions to help procedurally build meshes
  145759. */
  145760. export class TiledBoxBuilder {
  145761. /**
  145762. * Creates a box mesh
  145763. * 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)
  145764. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145768. * @param name defines the name of the mesh
  145769. * @param options defines the options used to create the mesh
  145770. * @param scene defines the hosting scene
  145771. * @returns the box mesh
  145772. */
  145773. static CreateTiledBox(name: string, options: {
  145774. pattern?: number;
  145775. width?: number;
  145776. height?: number;
  145777. depth?: number;
  145778. tileSize?: number;
  145779. tileWidth?: number;
  145780. tileHeight?: number;
  145781. alignHorizontal?: number;
  145782. alignVertical?: number;
  145783. faceUV?: Vector4[];
  145784. faceColors?: Color4[];
  145785. sideOrientation?: number;
  145786. updatable?: boolean;
  145787. }, scene?: Nullable<Scene>): Mesh;
  145788. }
  145789. }
  145790. declare module BABYLON {
  145791. /**
  145792. * Class containing static functions to help procedurally build meshes
  145793. */
  145794. export class TorusKnotBuilder {
  145795. /**
  145796. * Creates a torus knot mesh
  145797. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145798. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145799. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145800. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145804. * @param name defines the name of the mesh
  145805. * @param options defines the options used to create the mesh
  145806. * @param scene defines the hosting scene
  145807. * @returns the torus knot mesh
  145808. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145809. */
  145810. static CreateTorusKnot(name: string, options: {
  145811. radius?: number;
  145812. tube?: number;
  145813. radialSegments?: number;
  145814. tubularSegments?: number;
  145815. p?: number;
  145816. q?: number;
  145817. updatable?: boolean;
  145818. sideOrientation?: number;
  145819. frontUVs?: Vector4;
  145820. backUVs?: Vector4;
  145821. }, scene: any): Mesh;
  145822. }
  145823. }
  145824. declare module BABYLON {
  145825. /**
  145826. * Polygon
  145827. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  145828. */
  145829. export class Polygon {
  145830. /**
  145831. * Creates a rectangle
  145832. * @param xmin bottom X coord
  145833. * @param ymin bottom Y coord
  145834. * @param xmax top X coord
  145835. * @param ymax top Y coord
  145836. * @returns points that make the resulting rectation
  145837. */
  145838. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145839. /**
  145840. * Creates a circle
  145841. * @param radius radius of circle
  145842. * @param cx scale in x
  145843. * @param cy scale in y
  145844. * @param numberOfSides number of sides that make up the circle
  145845. * @returns points that make the resulting circle
  145846. */
  145847. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145848. /**
  145849. * Creates a polygon from input string
  145850. * @param input Input polygon data
  145851. * @returns the parsed points
  145852. */
  145853. static Parse(input: string): Vector2[];
  145854. /**
  145855. * Starts building a polygon from x and y coordinates
  145856. * @param x x coordinate
  145857. * @param y y coordinate
  145858. * @returns the started path2
  145859. */
  145860. static StartingAt(x: number, y: number): Path2;
  145861. }
  145862. /**
  145863. * Builds a polygon
  145864. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145865. */
  145866. export class PolygonMeshBuilder {
  145867. private _points;
  145868. private _outlinepoints;
  145869. private _holes;
  145870. private _name;
  145871. private _scene;
  145872. private _epoints;
  145873. private _eholes;
  145874. private _addToepoint;
  145875. /**
  145876. * Babylon reference to the earcut plugin.
  145877. */
  145878. bjsEarcut: any;
  145879. /**
  145880. * Creates a PolygonMeshBuilder
  145881. * @param name name of the builder
  145882. * @param contours Path of the polygon
  145883. * @param scene scene to add to when creating the mesh
  145884. * @param earcutInjection can be used to inject your own earcut reference
  145885. */
  145886. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145887. /**
  145888. * Adds a whole within the polygon
  145889. * @param hole Array of points defining the hole
  145890. * @returns this
  145891. */
  145892. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145893. /**
  145894. * Creates the polygon
  145895. * @param updatable If the mesh should be updatable
  145896. * @param depth The depth of the mesh created
  145897. * @returns the created mesh
  145898. */
  145899. build(updatable?: boolean, depth?: number): Mesh;
  145900. /**
  145901. * Creates the polygon
  145902. * @param depth The depth of the mesh created
  145903. * @returns the created VertexData
  145904. */
  145905. buildVertexData(depth?: number): VertexData;
  145906. /**
  145907. * Adds a side to the polygon
  145908. * @param positions points that make the polygon
  145909. * @param normals normals of the polygon
  145910. * @param uvs uvs of the polygon
  145911. * @param indices indices of the polygon
  145912. * @param bounds bounds of the polygon
  145913. * @param points points of the polygon
  145914. * @param depth depth of the polygon
  145915. * @param flip flip of the polygon
  145916. */
  145917. private addSide;
  145918. }
  145919. }
  145920. declare module BABYLON {
  145921. /**
  145922. * Class containing static functions to help procedurally build meshes
  145923. */
  145924. export class PolygonBuilder {
  145925. /**
  145926. * Creates a polygon mesh
  145927. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145928. * * 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
  145929. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145932. * * Remember you can only change the shape positions, not their number when updating a polygon
  145933. * @param name defines the name of the mesh
  145934. * @param options defines the options used to create the mesh
  145935. * @param scene defines the hosting scene
  145936. * @param earcutInjection can be used to inject your own earcut reference
  145937. * @returns the polygon mesh
  145938. */
  145939. static CreatePolygon(name: string, options: {
  145940. shape: Vector3[];
  145941. holes?: Vector3[][];
  145942. depth?: number;
  145943. faceUV?: Vector4[];
  145944. faceColors?: Color4[];
  145945. updatable?: boolean;
  145946. sideOrientation?: number;
  145947. frontUVs?: Vector4;
  145948. backUVs?: Vector4;
  145949. wrap?: boolean;
  145950. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145951. /**
  145952. * Creates an extruded polygon mesh, with depth in the Y direction.
  145953. * * 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)
  145954. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145955. * @param name defines the name of the mesh
  145956. * @param options defines the options used to create the mesh
  145957. * @param scene defines the hosting scene
  145958. * @param earcutInjection can be used to inject your own earcut reference
  145959. * @returns the polygon mesh
  145960. */
  145961. static ExtrudePolygon(name: string, options: {
  145962. shape: Vector3[];
  145963. holes?: Vector3[][];
  145964. depth?: number;
  145965. faceUV?: Vector4[];
  145966. faceColors?: Color4[];
  145967. updatable?: boolean;
  145968. sideOrientation?: number;
  145969. frontUVs?: Vector4;
  145970. backUVs?: Vector4;
  145971. wrap?: boolean;
  145972. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145973. }
  145974. }
  145975. declare module BABYLON {
  145976. /**
  145977. * Class containing static functions to help procedurally build meshes
  145978. */
  145979. export class LatheBuilder {
  145980. /**
  145981. * Creates lathe mesh.
  145982. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145983. * * 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
  145984. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145985. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145986. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145987. * * 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
  145988. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145989. * * 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
  145990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145992. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145994. * @param name defines the name of the mesh
  145995. * @param options defines the options used to create the mesh
  145996. * @param scene defines the hosting scene
  145997. * @returns the lathe mesh
  145998. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145999. */
  146000. static CreateLathe(name: string, options: {
  146001. shape: Vector3[];
  146002. radius?: number;
  146003. tessellation?: number;
  146004. clip?: number;
  146005. arc?: number;
  146006. closed?: boolean;
  146007. updatable?: boolean;
  146008. sideOrientation?: number;
  146009. frontUVs?: Vector4;
  146010. backUVs?: Vector4;
  146011. cap?: number;
  146012. invertUV?: boolean;
  146013. }, scene?: Nullable<Scene>): Mesh;
  146014. }
  146015. }
  146016. declare module BABYLON {
  146017. /**
  146018. * Class containing static functions to help procedurally build meshes
  146019. */
  146020. export class TiledPlaneBuilder {
  146021. /**
  146022. * Creates a tiled plane mesh
  146023. * * The parameter `pattern` will, depending on value, do nothing or
  146024. * * * flip (reflect about central vertical) alternate tiles across and up
  146025. * * * flip every tile on alternate rows
  146026. * * * rotate (180 degs) alternate tiles across and up
  146027. * * * rotate every tile on alternate rows
  146028. * * * flip and rotate alternate tiles across and up
  146029. * * * flip and rotate every tile on alternate rows
  146030. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146031. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146033. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146034. * * 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)
  146035. * * 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)
  146036. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146037. * @param name defines the name of the mesh
  146038. * @param options defines the options used to create the mesh
  146039. * @param scene defines the hosting scene
  146040. * @returns the box mesh
  146041. */
  146042. static CreateTiledPlane(name: string, options: {
  146043. pattern?: number;
  146044. tileSize?: number;
  146045. tileWidth?: number;
  146046. tileHeight?: number;
  146047. size?: number;
  146048. width?: number;
  146049. height?: number;
  146050. alignHorizontal?: number;
  146051. alignVertical?: number;
  146052. sideOrientation?: number;
  146053. frontUVs?: Vector4;
  146054. backUVs?: Vector4;
  146055. updatable?: boolean;
  146056. }, scene?: Nullable<Scene>): Mesh;
  146057. }
  146058. }
  146059. declare module BABYLON {
  146060. /**
  146061. * Class containing static functions to help procedurally build meshes
  146062. */
  146063. export class TubeBuilder {
  146064. /**
  146065. * Creates a tube mesh.
  146066. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146067. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146068. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146069. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146070. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146071. * * 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)
  146072. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146073. * * 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
  146074. * * 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
  146075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146077. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146079. * @param name defines the name of the mesh
  146080. * @param options defines the options used to create the mesh
  146081. * @param scene defines the hosting scene
  146082. * @returns the tube mesh
  146083. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146084. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146085. */
  146086. static CreateTube(name: string, options: {
  146087. path: Vector3[];
  146088. radius?: number;
  146089. tessellation?: number;
  146090. radiusFunction?: {
  146091. (i: number, distance: number): number;
  146092. };
  146093. cap?: number;
  146094. arc?: number;
  146095. updatable?: boolean;
  146096. sideOrientation?: number;
  146097. frontUVs?: Vector4;
  146098. backUVs?: Vector4;
  146099. instance?: Mesh;
  146100. invertUV?: boolean;
  146101. }, scene?: Nullable<Scene>): Mesh;
  146102. }
  146103. }
  146104. declare module BABYLON {
  146105. /**
  146106. * Class containing static functions to help procedurally build meshes
  146107. */
  146108. export class IcoSphereBuilder {
  146109. /**
  146110. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146111. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146112. * * 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`)
  146113. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146114. * * 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
  146115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146118. * @param name defines the name of the mesh
  146119. * @param options defines the options used to create the mesh
  146120. * @param scene defines the hosting scene
  146121. * @returns the icosahedron mesh
  146122. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146123. */
  146124. static CreateIcoSphere(name: string, options: {
  146125. radius?: number;
  146126. radiusX?: number;
  146127. radiusY?: number;
  146128. radiusZ?: number;
  146129. flat?: boolean;
  146130. subdivisions?: number;
  146131. sideOrientation?: number;
  146132. frontUVs?: Vector4;
  146133. backUVs?: Vector4;
  146134. updatable?: boolean;
  146135. }, scene?: Nullable<Scene>): Mesh;
  146136. }
  146137. }
  146138. declare module BABYLON {
  146139. /**
  146140. * Class containing static functions to help procedurally build meshes
  146141. */
  146142. export class DecalBuilder {
  146143. /**
  146144. * Creates a decal mesh.
  146145. * 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
  146146. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146147. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146148. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146149. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146150. * @param name defines the name of the mesh
  146151. * @param sourceMesh defines the mesh where the decal must be applied
  146152. * @param options defines the options used to create the mesh
  146153. * @param scene defines the hosting scene
  146154. * @returns the decal mesh
  146155. * @see https://doc.babylonjs.com/how_to/decals
  146156. */
  146157. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146158. position?: Vector3;
  146159. normal?: Vector3;
  146160. size?: Vector3;
  146161. angle?: number;
  146162. }): Mesh;
  146163. }
  146164. }
  146165. declare module BABYLON {
  146166. /**
  146167. * Class containing static functions to help procedurally build meshes
  146168. */
  146169. export class MeshBuilder {
  146170. /**
  146171. * Creates a box mesh
  146172. * * The parameter `size` sets the size (float) of each box side (default 1)
  146173. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146174. * * 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)
  146175. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146179. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146180. * @param name defines the name of the mesh
  146181. * @param options defines the options used to create the mesh
  146182. * @param scene defines the hosting scene
  146183. * @returns the box mesh
  146184. */
  146185. static CreateBox(name: string, options: {
  146186. size?: number;
  146187. width?: number;
  146188. height?: number;
  146189. depth?: number;
  146190. faceUV?: Vector4[];
  146191. faceColors?: Color4[];
  146192. sideOrientation?: number;
  146193. frontUVs?: Vector4;
  146194. backUVs?: Vector4;
  146195. wrap?: boolean;
  146196. topBaseAt?: number;
  146197. bottomBaseAt?: number;
  146198. updatable?: boolean;
  146199. }, scene?: Nullable<Scene>): Mesh;
  146200. /**
  146201. * Creates a tiled box mesh
  146202. * * faceTiles sets the pattern, tile size and number of tiles for a face
  146203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146204. * @param name defines the name of the mesh
  146205. * @param options defines the options used to create the mesh
  146206. * @param scene defines the hosting scene
  146207. * @returns the tiled box mesh
  146208. */
  146209. static CreateTiledBox(name: string, options: {
  146210. pattern?: number;
  146211. size?: number;
  146212. width?: number;
  146213. height?: number;
  146214. depth: number;
  146215. tileSize?: number;
  146216. tileWidth?: number;
  146217. tileHeight?: number;
  146218. faceUV?: Vector4[];
  146219. faceColors?: Color4[];
  146220. alignHorizontal?: number;
  146221. alignVertical?: number;
  146222. sideOrientation?: number;
  146223. updatable?: boolean;
  146224. }, scene?: Nullable<Scene>): Mesh;
  146225. /**
  146226. * Creates a sphere mesh
  146227. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  146228. * * 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`)
  146229. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  146230. * * 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
  146231. * * 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)
  146232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146235. * @param name defines the name of the mesh
  146236. * @param options defines the options used to create the mesh
  146237. * @param scene defines the hosting scene
  146238. * @returns the sphere mesh
  146239. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  146240. */
  146241. static CreateSphere(name: string, options: {
  146242. segments?: number;
  146243. diameter?: number;
  146244. diameterX?: number;
  146245. diameterY?: number;
  146246. diameterZ?: number;
  146247. arc?: number;
  146248. slice?: number;
  146249. sideOrientation?: number;
  146250. frontUVs?: Vector4;
  146251. backUVs?: Vector4;
  146252. updatable?: boolean;
  146253. }, scene?: Nullable<Scene>): Mesh;
  146254. /**
  146255. * Creates a plane polygonal mesh. By default, this is a disc
  146256. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  146257. * * 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
  146258. * * 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
  146259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146262. * @param name defines the name of the mesh
  146263. * @param options defines the options used to create the mesh
  146264. * @param scene defines the hosting scene
  146265. * @returns the plane polygonal mesh
  146266. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  146267. */
  146268. static CreateDisc(name: string, options: {
  146269. radius?: number;
  146270. tessellation?: number;
  146271. arc?: number;
  146272. updatable?: boolean;
  146273. sideOrientation?: number;
  146274. frontUVs?: Vector4;
  146275. backUVs?: Vector4;
  146276. }, scene?: Nullable<Scene>): Mesh;
  146277. /**
  146278. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146279. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146280. * * 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`)
  146281. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146282. * * 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
  146283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146286. * @param name defines the name of the mesh
  146287. * @param options defines the options used to create the mesh
  146288. * @param scene defines the hosting scene
  146289. * @returns the icosahedron mesh
  146290. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146291. */
  146292. static CreateIcoSphere(name: string, options: {
  146293. radius?: number;
  146294. radiusX?: number;
  146295. radiusY?: number;
  146296. radiusZ?: number;
  146297. flat?: boolean;
  146298. subdivisions?: number;
  146299. sideOrientation?: number;
  146300. frontUVs?: Vector4;
  146301. backUVs?: Vector4;
  146302. updatable?: boolean;
  146303. }, scene?: Nullable<Scene>): Mesh;
  146304. /**
  146305. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146306. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  146307. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  146308. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  146309. * * 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
  146310. * * 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
  146311. * * 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
  146312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146314. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146315. * * 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
  146316. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  146317. * * 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
  146318. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  146319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146320. * @param name defines the name of the mesh
  146321. * @param options defines the options used to create the mesh
  146322. * @param scene defines the hosting scene
  146323. * @returns the ribbon mesh
  146324. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  146325. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146326. */
  146327. static CreateRibbon(name: string, options: {
  146328. pathArray: Vector3[][];
  146329. closeArray?: boolean;
  146330. closePath?: boolean;
  146331. offset?: number;
  146332. updatable?: boolean;
  146333. sideOrientation?: number;
  146334. frontUVs?: Vector4;
  146335. backUVs?: Vector4;
  146336. instance?: Mesh;
  146337. invertUV?: boolean;
  146338. uvs?: Vector2[];
  146339. colors?: Color4[];
  146340. }, scene?: Nullable<Scene>): Mesh;
  146341. /**
  146342. * Creates a cylinder or a cone mesh
  146343. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  146344. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  146345. * * 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.
  146346. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  146347. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  146348. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  146349. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  146350. * * 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).
  146351. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  146352. * * 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).
  146353. * * 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
  146354. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  146355. * * 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
  146356. * * 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.
  146357. * * If `enclose` is false, a ring surface is one element.
  146358. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  146359. * * 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
  146360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146363. * @param name defines the name of the mesh
  146364. * @param options defines the options used to create the mesh
  146365. * @param scene defines the hosting scene
  146366. * @returns the cylinder mesh
  146367. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  146368. */
  146369. static CreateCylinder(name: string, options: {
  146370. height?: number;
  146371. diameterTop?: number;
  146372. diameterBottom?: number;
  146373. diameter?: number;
  146374. tessellation?: number;
  146375. subdivisions?: number;
  146376. arc?: number;
  146377. faceColors?: Color4[];
  146378. faceUV?: Vector4[];
  146379. updatable?: boolean;
  146380. hasRings?: boolean;
  146381. enclose?: boolean;
  146382. cap?: number;
  146383. sideOrientation?: number;
  146384. frontUVs?: Vector4;
  146385. backUVs?: Vector4;
  146386. }, scene?: Nullable<Scene>): Mesh;
  146387. /**
  146388. * Creates a torus mesh
  146389. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  146390. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  146391. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  146392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146395. * @param name defines the name of the mesh
  146396. * @param options defines the options used to create the mesh
  146397. * @param scene defines the hosting scene
  146398. * @returns the torus mesh
  146399. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  146400. */
  146401. static CreateTorus(name: string, options: {
  146402. diameter?: number;
  146403. thickness?: number;
  146404. tessellation?: number;
  146405. updatable?: boolean;
  146406. sideOrientation?: number;
  146407. frontUVs?: Vector4;
  146408. backUVs?: Vector4;
  146409. }, scene?: Nullable<Scene>): Mesh;
  146410. /**
  146411. * Creates a torus knot mesh
  146412. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146413. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146414. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146415. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146419. * @param name defines the name of the mesh
  146420. * @param options defines the options used to create the mesh
  146421. * @param scene defines the hosting scene
  146422. * @returns the torus knot mesh
  146423. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146424. */
  146425. static CreateTorusKnot(name: string, options: {
  146426. radius?: number;
  146427. tube?: number;
  146428. radialSegments?: number;
  146429. tubularSegments?: number;
  146430. p?: number;
  146431. q?: number;
  146432. updatable?: boolean;
  146433. sideOrientation?: number;
  146434. frontUVs?: Vector4;
  146435. backUVs?: Vector4;
  146436. }, scene?: Nullable<Scene>): Mesh;
  146437. /**
  146438. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  146439. * * 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
  146440. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  146441. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  146442. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  146443. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  146444. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  146445. * * 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
  146446. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  146447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146448. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  146449. * @param name defines the name of the new line system
  146450. * @param options defines the options used to create the line system
  146451. * @param scene defines the hosting scene
  146452. * @returns a new line system mesh
  146453. */
  146454. static CreateLineSystem(name: string, options: {
  146455. lines: Vector3[][];
  146456. updatable?: boolean;
  146457. instance?: Nullable<LinesMesh>;
  146458. colors?: Nullable<Color4[][]>;
  146459. useVertexAlpha?: boolean;
  146460. }, scene: Nullable<Scene>): LinesMesh;
  146461. /**
  146462. * Creates a line mesh
  146463. * 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
  146464. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146465. * * The parameter `points` is an array successive Vector3
  146466. * * 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
  146467. * * The optional parameter `colors` is an array of successive Color4, one per line point
  146468. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  146469. * * When updating an instance, remember that only point positions can change, not the number of points
  146470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  146472. * @param name defines the name of the new line system
  146473. * @param options defines the options used to create the line system
  146474. * @param scene defines the hosting scene
  146475. * @returns a new line mesh
  146476. */
  146477. static CreateLines(name: string, options: {
  146478. points: Vector3[];
  146479. updatable?: boolean;
  146480. instance?: Nullable<LinesMesh>;
  146481. colors?: Color4[];
  146482. useVertexAlpha?: boolean;
  146483. }, scene?: Nullable<Scene>): LinesMesh;
  146484. /**
  146485. * Creates a dashed line mesh
  146486. * * 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
  146487. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146488. * * The parameter `points` is an array successive Vector3
  146489. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  146490. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  146491. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  146492. * * 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
  146493. * * When updating an instance, remember that only point positions can change, not the number of points
  146494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146495. * @param name defines the name of the mesh
  146496. * @param options defines the options used to create the mesh
  146497. * @param scene defines the hosting scene
  146498. * @returns the dashed line mesh
  146499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146500. */
  146501. static CreateDashedLines(name: string, options: {
  146502. points: Vector3[];
  146503. dashSize?: number;
  146504. gapSize?: number;
  146505. dashNb?: number;
  146506. updatable?: boolean;
  146507. instance?: LinesMesh;
  146508. }, scene?: Nullable<Scene>): LinesMesh;
  146509. /**
  146510. * 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.
  146511. * * 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.
  146512. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146513. * * 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.
  146514. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146515. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  146516. * * 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
  146517. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146520. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146522. * @param name defines the name of the mesh
  146523. * @param options defines the options used to create the mesh
  146524. * @param scene defines the hosting scene
  146525. * @returns the extruded shape mesh
  146526. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146527. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146528. */
  146529. static ExtrudeShape(name: string, options: {
  146530. shape: Vector3[];
  146531. path: Vector3[];
  146532. scale?: number;
  146533. rotation?: number;
  146534. cap?: number;
  146535. updatable?: boolean;
  146536. sideOrientation?: number;
  146537. frontUVs?: Vector4;
  146538. backUVs?: Vector4;
  146539. instance?: Mesh;
  146540. invertUV?: boolean;
  146541. }, scene?: Nullable<Scene>): Mesh;
  146542. /**
  146543. * Creates an custom extruded shape mesh.
  146544. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146545. * * 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.
  146546. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146547. * * 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
  146548. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146549. * * 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
  146550. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146551. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146552. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146553. * * 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
  146554. * * 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
  146555. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146558. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146560. * @param name defines the name of the mesh
  146561. * @param options defines the options used to create the mesh
  146562. * @param scene defines the hosting scene
  146563. * @returns the custom extruded shape mesh
  146564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146565. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146566. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146567. */
  146568. static ExtrudeShapeCustom(name: string, options: {
  146569. shape: Vector3[];
  146570. path: Vector3[];
  146571. scaleFunction?: any;
  146572. rotationFunction?: any;
  146573. ribbonCloseArray?: boolean;
  146574. ribbonClosePath?: boolean;
  146575. cap?: number;
  146576. updatable?: boolean;
  146577. sideOrientation?: number;
  146578. frontUVs?: Vector4;
  146579. backUVs?: Vector4;
  146580. instance?: Mesh;
  146581. invertUV?: boolean;
  146582. }, scene?: Nullable<Scene>): Mesh;
  146583. /**
  146584. * Creates lathe mesh.
  146585. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146586. * * 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
  146587. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146588. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146589. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146590. * * 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
  146591. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146592. * * 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
  146593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146595. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146597. * @param name defines the name of the mesh
  146598. * @param options defines the options used to create the mesh
  146599. * @param scene defines the hosting scene
  146600. * @returns the lathe mesh
  146601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146602. */
  146603. static CreateLathe(name: string, options: {
  146604. shape: Vector3[];
  146605. radius?: number;
  146606. tessellation?: number;
  146607. clip?: number;
  146608. arc?: number;
  146609. closed?: boolean;
  146610. updatable?: boolean;
  146611. sideOrientation?: number;
  146612. frontUVs?: Vector4;
  146613. backUVs?: Vector4;
  146614. cap?: number;
  146615. invertUV?: boolean;
  146616. }, scene?: Nullable<Scene>): Mesh;
  146617. /**
  146618. * Creates a tiled plane mesh
  146619. * * You can set a limited pattern arrangement with the tiles
  146620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146623. * @param name defines the name of the mesh
  146624. * @param options defines the options used to create the mesh
  146625. * @param scene defines the hosting scene
  146626. * @returns the plane mesh
  146627. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146628. */
  146629. static CreateTiledPlane(name: string, options: {
  146630. pattern?: number;
  146631. tileSize?: number;
  146632. tileWidth?: number;
  146633. tileHeight?: number;
  146634. size?: number;
  146635. width?: number;
  146636. height?: number;
  146637. alignHorizontal?: number;
  146638. alignVertical?: number;
  146639. sideOrientation?: number;
  146640. frontUVs?: Vector4;
  146641. backUVs?: Vector4;
  146642. updatable?: boolean;
  146643. }, scene?: Nullable<Scene>): Mesh;
  146644. /**
  146645. * Creates a plane mesh
  146646. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146647. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146648. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146652. * @param name defines the name of the mesh
  146653. * @param options defines the options used to create the mesh
  146654. * @param scene defines the hosting scene
  146655. * @returns the plane mesh
  146656. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146657. */
  146658. static CreatePlane(name: string, options: {
  146659. size?: number;
  146660. width?: number;
  146661. height?: number;
  146662. sideOrientation?: number;
  146663. frontUVs?: Vector4;
  146664. backUVs?: Vector4;
  146665. updatable?: boolean;
  146666. sourcePlane?: Plane;
  146667. }, scene?: Nullable<Scene>): Mesh;
  146668. /**
  146669. * Creates a ground mesh
  146670. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  146671. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  146672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146673. * @param name defines the name of the mesh
  146674. * @param options defines the options used to create the mesh
  146675. * @param scene defines the hosting scene
  146676. * @returns the ground mesh
  146677. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  146678. */
  146679. static CreateGround(name: string, options: {
  146680. width?: number;
  146681. height?: number;
  146682. subdivisions?: number;
  146683. subdivisionsX?: number;
  146684. subdivisionsY?: number;
  146685. updatable?: boolean;
  146686. }, scene?: Nullable<Scene>): Mesh;
  146687. /**
  146688. * Creates a tiled ground mesh
  146689. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  146690. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  146691. * * 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
  146692. * * 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
  146693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146694. * @param name defines the name of the mesh
  146695. * @param options defines the options used to create the mesh
  146696. * @param scene defines the hosting scene
  146697. * @returns the tiled ground mesh
  146698. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  146699. */
  146700. static CreateTiledGround(name: string, options: {
  146701. xmin: number;
  146702. zmin: number;
  146703. xmax: number;
  146704. zmax: number;
  146705. subdivisions?: {
  146706. w: number;
  146707. h: number;
  146708. };
  146709. precision?: {
  146710. w: number;
  146711. h: number;
  146712. };
  146713. updatable?: boolean;
  146714. }, scene?: Nullable<Scene>): Mesh;
  146715. /**
  146716. * Creates a ground mesh from a height map
  146717. * * The parameter `url` sets the URL of the height map image resource.
  146718. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  146719. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  146720. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  146721. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  146722. * * 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.
  146723. * * 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).
  146724. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  146725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146726. * @param name defines the name of the mesh
  146727. * @param url defines the url to the height map
  146728. * @param options defines the options used to create the mesh
  146729. * @param scene defines the hosting scene
  146730. * @returns the ground mesh
  146731. * @see https://doc.babylonjs.com/babylon101/height_map
  146732. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  146733. */
  146734. static CreateGroundFromHeightMap(name: string, url: string, options: {
  146735. width?: number;
  146736. height?: number;
  146737. subdivisions?: number;
  146738. minHeight?: number;
  146739. maxHeight?: number;
  146740. colorFilter?: Color3;
  146741. alphaFilter?: number;
  146742. updatable?: boolean;
  146743. onReady?: (mesh: GroundMesh) => void;
  146744. }, scene?: Nullable<Scene>): GroundMesh;
  146745. /**
  146746. * Creates a polygon mesh
  146747. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146748. * * 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
  146749. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146752. * * Remember you can only change the shape positions, not their number when updating a polygon
  146753. * @param name defines the name of the mesh
  146754. * @param options defines the options used to create the mesh
  146755. * @param scene defines the hosting scene
  146756. * @param earcutInjection can be used to inject your own earcut reference
  146757. * @returns the polygon mesh
  146758. */
  146759. static CreatePolygon(name: string, options: {
  146760. shape: Vector3[];
  146761. holes?: Vector3[][];
  146762. depth?: number;
  146763. faceUV?: Vector4[];
  146764. faceColors?: Color4[];
  146765. updatable?: boolean;
  146766. sideOrientation?: number;
  146767. frontUVs?: Vector4;
  146768. backUVs?: Vector4;
  146769. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146770. /**
  146771. * Creates an extruded polygon mesh, with depth in the Y direction.
  146772. * * 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)
  146773. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146774. * @param name defines the name of the mesh
  146775. * @param options defines the options used to create the mesh
  146776. * @param scene defines the hosting scene
  146777. * @param earcutInjection can be used to inject your own earcut reference
  146778. * @returns the polygon mesh
  146779. */
  146780. static ExtrudePolygon(name: string, options: {
  146781. shape: Vector3[];
  146782. holes?: Vector3[][];
  146783. depth?: number;
  146784. faceUV?: Vector4[];
  146785. faceColors?: Color4[];
  146786. updatable?: boolean;
  146787. sideOrientation?: number;
  146788. frontUVs?: Vector4;
  146789. backUVs?: Vector4;
  146790. wrap?: boolean;
  146791. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146792. /**
  146793. * Creates a tube mesh.
  146794. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146795. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146796. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146797. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146798. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146799. * * 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)
  146800. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146801. * * 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
  146802. * * 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
  146803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146805. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146807. * @param name defines the name of the mesh
  146808. * @param options defines the options used to create the mesh
  146809. * @param scene defines the hosting scene
  146810. * @returns the tube mesh
  146811. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146812. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146813. */
  146814. static CreateTube(name: string, options: {
  146815. path: Vector3[];
  146816. radius?: number;
  146817. tessellation?: number;
  146818. radiusFunction?: {
  146819. (i: number, distance: number): number;
  146820. };
  146821. cap?: number;
  146822. arc?: number;
  146823. updatable?: boolean;
  146824. sideOrientation?: number;
  146825. frontUVs?: Vector4;
  146826. backUVs?: Vector4;
  146827. instance?: Mesh;
  146828. invertUV?: boolean;
  146829. }, scene?: Nullable<Scene>): Mesh;
  146830. /**
  146831. * Creates a polyhedron mesh
  146832. * * 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
  146833. * * The parameter `size` (positive float, default 1) sets the polygon size
  146834. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  146835. * * 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`
  146836. * * 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
  146837. * * 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)`)
  146838. * * 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
  146839. * * 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
  146840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146843. * @param name defines the name of the mesh
  146844. * @param options defines the options used to create the mesh
  146845. * @param scene defines the hosting scene
  146846. * @returns the polyhedron mesh
  146847. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146848. */
  146849. static CreatePolyhedron(name: string, options: {
  146850. type?: number;
  146851. size?: number;
  146852. sizeX?: number;
  146853. sizeY?: number;
  146854. sizeZ?: number;
  146855. custom?: any;
  146856. faceUV?: Vector4[];
  146857. faceColors?: Color4[];
  146858. flat?: boolean;
  146859. updatable?: boolean;
  146860. sideOrientation?: number;
  146861. frontUVs?: Vector4;
  146862. backUVs?: Vector4;
  146863. }, scene?: Nullable<Scene>): Mesh;
  146864. /**
  146865. * Creates a decal mesh.
  146866. * 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
  146867. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146868. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146869. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146870. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146871. * @param name defines the name of the mesh
  146872. * @param sourceMesh defines the mesh where the decal must be applied
  146873. * @param options defines the options used to create the mesh
  146874. * @param scene defines the hosting scene
  146875. * @returns the decal mesh
  146876. * @see https://doc.babylonjs.com/how_to/decals
  146877. */
  146878. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146879. position?: Vector3;
  146880. normal?: Vector3;
  146881. size?: Vector3;
  146882. angle?: number;
  146883. }): Mesh;
  146884. /**
  146885. * Creates a Capsule Mesh
  146886. * @param name defines the name of the mesh.
  146887. * @param options the constructors options used to shape the mesh.
  146888. * @param scene defines the scene the mesh is scoped to.
  146889. * @returns the capsule mesh
  146890. * @see https://doc.babylonjs.com/how_to/capsule_shape
  146891. */
  146892. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  146893. }
  146894. }
  146895. declare module BABYLON {
  146896. /**
  146897. * A simplifier interface for future simplification implementations
  146898. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146899. */
  146900. export interface ISimplifier {
  146901. /**
  146902. * Simplification of a given mesh according to the given settings.
  146903. * Since this requires computation, it is assumed that the function runs async.
  146904. * @param settings The settings of the simplification, including quality and distance
  146905. * @param successCallback A callback that will be called after the mesh was simplified.
  146906. * @param errorCallback in case of an error, this callback will be called. optional.
  146907. */
  146908. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146909. }
  146910. /**
  146911. * Expected simplification settings.
  146912. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146913. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146914. */
  146915. export interface ISimplificationSettings {
  146916. /**
  146917. * Gets or sets the expected quality
  146918. */
  146919. quality: number;
  146920. /**
  146921. * Gets or sets the distance when this optimized version should be used
  146922. */
  146923. distance: number;
  146924. /**
  146925. * Gets an already optimized mesh
  146926. */
  146927. optimizeMesh?: boolean;
  146928. }
  146929. /**
  146930. * Class used to specify simplification options
  146931. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146932. */
  146933. export class SimplificationSettings implements ISimplificationSettings {
  146934. /** expected quality */
  146935. quality: number;
  146936. /** distance when this optimized version should be used */
  146937. distance: number;
  146938. /** already optimized mesh */
  146939. optimizeMesh?: boolean | undefined;
  146940. /**
  146941. * Creates a SimplificationSettings
  146942. * @param quality expected quality
  146943. * @param distance distance when this optimized version should be used
  146944. * @param optimizeMesh already optimized mesh
  146945. */
  146946. constructor(
  146947. /** expected quality */
  146948. quality: number,
  146949. /** distance when this optimized version should be used */
  146950. distance: number,
  146951. /** already optimized mesh */
  146952. optimizeMesh?: boolean | undefined);
  146953. }
  146954. /**
  146955. * Interface used to define a simplification task
  146956. */
  146957. export interface ISimplificationTask {
  146958. /**
  146959. * Array of settings
  146960. */
  146961. settings: Array<ISimplificationSettings>;
  146962. /**
  146963. * Simplification type
  146964. */
  146965. simplificationType: SimplificationType;
  146966. /**
  146967. * Mesh to simplify
  146968. */
  146969. mesh: Mesh;
  146970. /**
  146971. * Callback called on success
  146972. */
  146973. successCallback?: () => void;
  146974. /**
  146975. * Defines if parallel processing can be used
  146976. */
  146977. parallelProcessing: boolean;
  146978. }
  146979. /**
  146980. * Queue used to order the simplification tasks
  146981. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146982. */
  146983. export class SimplificationQueue {
  146984. private _simplificationArray;
  146985. /**
  146986. * Gets a boolean indicating that the process is still running
  146987. */
  146988. running: boolean;
  146989. /**
  146990. * Creates a new queue
  146991. */
  146992. constructor();
  146993. /**
  146994. * Adds a new simplification task
  146995. * @param task defines a task to add
  146996. */
  146997. addTask(task: ISimplificationTask): void;
  146998. /**
  146999. * Execute next task
  147000. */
  147001. executeNext(): void;
  147002. /**
  147003. * Execute a simplification task
  147004. * @param task defines the task to run
  147005. */
  147006. runSimplification(task: ISimplificationTask): void;
  147007. private getSimplifier;
  147008. }
  147009. /**
  147010. * The implemented types of simplification
  147011. * At the moment only Quadratic Error Decimation is implemented
  147012. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147013. */
  147014. export enum SimplificationType {
  147015. /** Quadratic error decimation */
  147016. QUADRATIC = 0
  147017. }
  147018. /**
  147019. * An implementation of the Quadratic Error simplification algorithm.
  147020. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147021. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147022. * @author RaananW
  147023. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147024. */
  147025. export class QuadraticErrorSimplification implements ISimplifier {
  147026. private _mesh;
  147027. private triangles;
  147028. private vertices;
  147029. private references;
  147030. private _reconstructedMesh;
  147031. /** Gets or sets the number pf sync interations */
  147032. syncIterations: number;
  147033. /** Gets or sets the aggressiveness of the simplifier */
  147034. aggressiveness: number;
  147035. /** Gets or sets the number of allowed iterations for decimation */
  147036. decimationIterations: number;
  147037. /** Gets or sets the espilon to use for bounding box computation */
  147038. boundingBoxEpsilon: number;
  147039. /**
  147040. * Creates a new QuadraticErrorSimplification
  147041. * @param _mesh defines the target mesh
  147042. */
  147043. constructor(_mesh: Mesh);
  147044. /**
  147045. * Simplification of a given mesh according to the given settings.
  147046. * Since this requires computation, it is assumed that the function runs async.
  147047. * @param settings The settings of the simplification, including quality and distance
  147048. * @param successCallback A callback that will be called after the mesh was simplified.
  147049. */
  147050. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147051. private runDecimation;
  147052. private initWithMesh;
  147053. private init;
  147054. private reconstructMesh;
  147055. private initDecimatedMesh;
  147056. private isFlipped;
  147057. private updateTriangles;
  147058. private identifyBorder;
  147059. private updateMesh;
  147060. private vertexError;
  147061. private calculateError;
  147062. }
  147063. }
  147064. declare module BABYLON {
  147065. interface Scene {
  147066. /** @hidden (Backing field) */
  147067. _simplificationQueue: SimplificationQueue;
  147068. /**
  147069. * Gets or sets the simplification queue attached to the scene
  147070. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147071. */
  147072. simplificationQueue: SimplificationQueue;
  147073. }
  147074. interface Mesh {
  147075. /**
  147076. * Simplify the mesh according to the given array of settings.
  147077. * Function will return immediately and will simplify async
  147078. * @param settings a collection of simplification settings
  147079. * @param parallelProcessing should all levels calculate parallel or one after the other
  147080. * @param simplificationType the type of simplification to run
  147081. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  147082. * @returns the current mesh
  147083. */
  147084. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  147085. }
  147086. /**
  147087. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  147088. * created in a scene
  147089. */
  147090. export class SimplicationQueueSceneComponent implements ISceneComponent {
  147091. /**
  147092. * The component name helpfull to identify the component in the list of scene components.
  147093. */
  147094. readonly name: string;
  147095. /**
  147096. * The scene the component belongs to.
  147097. */
  147098. scene: Scene;
  147099. /**
  147100. * Creates a new instance of the component for the given scene
  147101. * @param scene Defines the scene to register the component in
  147102. */
  147103. constructor(scene: Scene);
  147104. /**
  147105. * Registers the component in a given scene
  147106. */
  147107. register(): void;
  147108. /**
  147109. * Rebuilds the elements related to this component in case of
  147110. * context lost for instance.
  147111. */
  147112. rebuild(): void;
  147113. /**
  147114. * Disposes the component and the associated ressources
  147115. */
  147116. dispose(): void;
  147117. private _beforeCameraUpdate;
  147118. }
  147119. }
  147120. declare module BABYLON {
  147121. interface Mesh {
  147122. /**
  147123. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147124. */
  147125. thinInstanceEnablePicking: boolean;
  147126. /**
  147127. * Creates a new thin instance
  147128. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147129. * @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
  147130. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147131. */
  147132. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147133. /**
  147134. * Adds the transformation (matrix) of the current mesh as a thin instance
  147135. * @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
  147136. * @returns the thin instance index number
  147137. */
  147138. thinInstanceAddSelf(refresh: boolean): number;
  147139. /**
  147140. * Registers a custom attribute to be used with thin instances
  147141. * @param kind name of the attribute
  147142. * @param stride size in floats of the attribute
  147143. */
  147144. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147145. /**
  147146. * Sets the matrix of a thin instance
  147147. * @param index index of the thin instance
  147148. * @param matrix matrix to set
  147149. * @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
  147150. */
  147151. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147152. /**
  147153. * Sets the value of a custom attribute for a thin instance
  147154. * @param kind name of the attribute
  147155. * @param index index of the thin instance
  147156. * @param value value to set
  147157. * @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
  147158. */
  147159. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147160. /**
  147161. * 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.
  147162. */
  147163. thinInstanceCount: number;
  147164. /**
  147165. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147166. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147167. * @param buffer buffer to set
  147168. * @param stride size in floats of each value of the buffer
  147169. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147170. */
  147171. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147172. /**
  147173. * Gets the list of world matrices
  147174. * @return an array containing all the world matrices from the thin instances
  147175. */
  147176. thinInstanceGetWorldMatrices(): Matrix[];
  147177. /**
  147178. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147179. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147180. */
  147181. thinInstanceBufferUpdated(kind: string): void;
  147182. /**
  147183. * Applies a partial update to a buffer directly on the GPU
  147184. * 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
  147185. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147186. * @param data the data to set in the GPU buffer
  147187. * @param offset the offset in the GPU buffer where to update the data
  147188. */
  147189. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  147190. /**
  147191. * Refreshes the bounding info, taking into account all the thin instances defined
  147192. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  147193. */
  147194. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  147195. /** @hidden */
  147196. _thinInstanceInitializeUserStorage(): void;
  147197. /** @hidden */
  147198. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  147199. /** @hidden */
  147200. _userThinInstanceBuffersStorage: {
  147201. data: {
  147202. [key: string]: Float32Array;
  147203. };
  147204. sizes: {
  147205. [key: string]: number;
  147206. };
  147207. vertexBuffers: {
  147208. [key: string]: Nullable<VertexBuffer>;
  147209. };
  147210. strides: {
  147211. [key: string]: number;
  147212. };
  147213. };
  147214. }
  147215. }
  147216. declare module BABYLON {
  147217. /**
  147218. * Navigation plugin interface to add navigation constrained by a navigation mesh
  147219. */
  147220. export interface INavigationEnginePlugin {
  147221. /**
  147222. * plugin name
  147223. */
  147224. name: string;
  147225. /**
  147226. * Creates a navigation mesh
  147227. * @param meshes array of all the geometry used to compute the navigatio mesh
  147228. * @param parameters bunch of parameters used to filter geometry
  147229. */
  147230. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147231. /**
  147232. * Create a navigation mesh debug mesh
  147233. * @param scene is where the mesh will be added
  147234. * @returns debug display mesh
  147235. */
  147236. createDebugNavMesh(scene: Scene): Mesh;
  147237. /**
  147238. * Get a navigation mesh constrained position, closest to the parameter position
  147239. * @param position world position
  147240. * @returns the closest point to position constrained by the navigation mesh
  147241. */
  147242. getClosestPoint(position: Vector3): Vector3;
  147243. /**
  147244. * Get a navigation mesh constrained position, closest to the parameter position
  147245. * @param position world position
  147246. * @param result output the closest point to position constrained by the navigation mesh
  147247. */
  147248. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147249. /**
  147250. * Get a navigation mesh constrained position, within a particular radius
  147251. * @param position world position
  147252. * @param maxRadius the maximum distance to the constrained world position
  147253. * @returns the closest point to position constrained by the navigation mesh
  147254. */
  147255. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147256. /**
  147257. * Get a navigation mesh constrained position, within a particular radius
  147258. * @param position world position
  147259. * @param maxRadius the maximum distance to the constrained world position
  147260. * @param result output the closest point to position constrained by the navigation mesh
  147261. */
  147262. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147263. /**
  147264. * Compute the final position from a segment made of destination-position
  147265. * @param position world position
  147266. * @param destination world position
  147267. * @returns the resulting point along the navmesh
  147268. */
  147269. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147270. /**
  147271. * Compute the final position from a segment made of destination-position
  147272. * @param position world position
  147273. * @param destination world position
  147274. * @param result output the resulting point along the navmesh
  147275. */
  147276. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147277. /**
  147278. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147279. * @param start world position
  147280. * @param end world position
  147281. * @returns array containing world position composing the path
  147282. */
  147283. computePath(start: Vector3, end: Vector3): Vector3[];
  147284. /**
  147285. * If this plugin is supported
  147286. * @returns true if plugin is supported
  147287. */
  147288. isSupported(): boolean;
  147289. /**
  147290. * Create a new Crowd so you can add agents
  147291. * @param maxAgents the maximum agent count in the crowd
  147292. * @param maxAgentRadius the maximum radius an agent can have
  147293. * @param scene to attach the crowd to
  147294. * @returns the crowd you can add agents to
  147295. */
  147296. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147297. /**
  147298. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147299. * The queries will try to find a solution within those bounds
  147300. * default is (1,1,1)
  147301. * @param extent x,y,z value that define the extent around the queries point of reference
  147302. */
  147303. setDefaultQueryExtent(extent: Vector3): void;
  147304. /**
  147305. * Get the Bounding box extent specified by setDefaultQueryExtent
  147306. * @returns the box extent values
  147307. */
  147308. getDefaultQueryExtent(): Vector3;
  147309. /**
  147310. * build the navmesh from a previously saved state using getNavmeshData
  147311. * @param data the Uint8Array returned by getNavmeshData
  147312. */
  147313. buildFromNavmeshData(data: Uint8Array): void;
  147314. /**
  147315. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147316. * @returns data the Uint8Array that can be saved and reused
  147317. */
  147318. getNavmeshData(): Uint8Array;
  147319. /**
  147320. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147321. * @param result output the box extent values
  147322. */
  147323. getDefaultQueryExtentToRef(result: Vector3): void;
  147324. /**
  147325. * Release all resources
  147326. */
  147327. dispose(): void;
  147328. }
  147329. /**
  147330. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  147331. */
  147332. export interface ICrowd {
  147333. /**
  147334. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147335. * You can attach anything to that node. The node position is updated in the scene update tick.
  147336. * @param pos world position that will be constrained by the navigation mesh
  147337. * @param parameters agent parameters
  147338. * @param transform hooked to the agent that will be update by the scene
  147339. * @returns agent index
  147340. */
  147341. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147342. /**
  147343. * Returns the agent position in world space
  147344. * @param index agent index returned by addAgent
  147345. * @returns world space position
  147346. */
  147347. getAgentPosition(index: number): Vector3;
  147348. /**
  147349. * Gets the agent position result in world space
  147350. * @param index agent index returned by addAgent
  147351. * @param result output world space position
  147352. */
  147353. getAgentPositionToRef(index: number, result: Vector3): void;
  147354. /**
  147355. * Gets the agent velocity in world space
  147356. * @param index agent index returned by addAgent
  147357. * @returns world space velocity
  147358. */
  147359. getAgentVelocity(index: number): Vector3;
  147360. /**
  147361. * Gets the agent velocity result in world space
  147362. * @param index agent index returned by addAgent
  147363. * @param result output world space velocity
  147364. */
  147365. getAgentVelocityToRef(index: number, result: Vector3): void;
  147366. /**
  147367. * remove a particular agent previously created
  147368. * @param index agent index returned by addAgent
  147369. */
  147370. removeAgent(index: number): void;
  147371. /**
  147372. * get the list of all agents attached to this crowd
  147373. * @returns list of agent indices
  147374. */
  147375. getAgents(): number[];
  147376. /**
  147377. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147378. * @param deltaTime in seconds
  147379. */
  147380. update(deltaTime: number): void;
  147381. /**
  147382. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147383. * @param index agent index returned by addAgent
  147384. * @param destination targeted world position
  147385. */
  147386. agentGoto(index: number, destination: Vector3): void;
  147387. /**
  147388. * Teleport the agent to a new position
  147389. * @param index agent index returned by addAgent
  147390. * @param destination targeted world position
  147391. */
  147392. agentTeleport(index: number, destination: Vector3): void;
  147393. /**
  147394. * Update agent parameters
  147395. * @param index agent index returned by addAgent
  147396. * @param parameters agent parameters
  147397. */
  147398. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147399. /**
  147400. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147401. * The queries will try to find a solution within those bounds
  147402. * default is (1,1,1)
  147403. * @param extent x,y,z value that define the extent around the queries point of reference
  147404. */
  147405. setDefaultQueryExtent(extent: Vector3): void;
  147406. /**
  147407. * Get the Bounding box extent specified by setDefaultQueryExtent
  147408. * @returns the box extent values
  147409. */
  147410. getDefaultQueryExtent(): Vector3;
  147411. /**
  147412. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147413. * @param result output the box extent values
  147414. */
  147415. getDefaultQueryExtentToRef(result: Vector3): void;
  147416. /**
  147417. * Release all resources
  147418. */
  147419. dispose(): void;
  147420. }
  147421. /**
  147422. * Configures an agent
  147423. */
  147424. export interface IAgentParameters {
  147425. /**
  147426. * Agent radius. [Limit: >= 0]
  147427. */
  147428. radius: number;
  147429. /**
  147430. * Agent height. [Limit: > 0]
  147431. */
  147432. height: number;
  147433. /**
  147434. * Maximum allowed acceleration. [Limit: >= 0]
  147435. */
  147436. maxAcceleration: number;
  147437. /**
  147438. * Maximum allowed speed. [Limit: >= 0]
  147439. */
  147440. maxSpeed: number;
  147441. /**
  147442. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  147443. */
  147444. collisionQueryRange: number;
  147445. /**
  147446. * The path visibility optimization range. [Limit: > 0]
  147447. */
  147448. pathOptimizationRange: number;
  147449. /**
  147450. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  147451. */
  147452. separationWeight: number;
  147453. }
  147454. /**
  147455. * Configures the navigation mesh creation
  147456. */
  147457. export interface INavMeshParameters {
  147458. /**
  147459. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  147460. */
  147461. cs: number;
  147462. /**
  147463. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  147464. */
  147465. ch: number;
  147466. /**
  147467. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  147468. */
  147469. walkableSlopeAngle: number;
  147470. /**
  147471. * Minimum floor to 'ceiling' height that will still allow the floor area to
  147472. * be considered walkable. [Limit: >= 3] [Units: vx]
  147473. */
  147474. walkableHeight: number;
  147475. /**
  147476. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  147477. */
  147478. walkableClimb: number;
  147479. /**
  147480. * The distance to erode/shrink the walkable area of the heightfield away from
  147481. * obstructions. [Limit: >=0] [Units: vx]
  147482. */
  147483. walkableRadius: number;
  147484. /**
  147485. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  147486. */
  147487. maxEdgeLen: number;
  147488. /**
  147489. * The maximum distance a simplfied contour's border edges should deviate
  147490. * the original raw contour. [Limit: >=0] [Units: vx]
  147491. */
  147492. maxSimplificationError: number;
  147493. /**
  147494. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147495. */
  147496. minRegionArea: number;
  147497. /**
  147498. * Any regions with a span count smaller than this value will, if possible,
  147499. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147500. */
  147501. mergeRegionArea: number;
  147502. /**
  147503. * The maximum number of vertices allowed for polygons generated during the
  147504. * contour to polygon conversion process. [Limit: >= 3]
  147505. */
  147506. maxVertsPerPoly: number;
  147507. /**
  147508. * Sets the sampling distance to use when generating the detail mesh.
  147509. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147510. */
  147511. detailSampleDist: number;
  147512. /**
  147513. * The maximum distance the detail mesh surface should deviate from heightfield
  147514. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147515. */
  147516. detailSampleMaxError: number;
  147517. }
  147518. }
  147519. declare module BABYLON {
  147520. /**
  147521. * RecastJS navigation plugin
  147522. */
  147523. export class RecastJSPlugin implements INavigationEnginePlugin {
  147524. /**
  147525. * Reference to the Recast library
  147526. */
  147527. bjsRECAST: any;
  147528. /**
  147529. * plugin name
  147530. */
  147531. name: string;
  147532. /**
  147533. * the first navmesh created. We might extend this to support multiple navmeshes
  147534. */
  147535. navMesh: any;
  147536. /**
  147537. * Initializes the recastJS plugin
  147538. * @param recastInjection can be used to inject your own recast reference
  147539. */
  147540. constructor(recastInjection?: any);
  147541. /**
  147542. * Creates a navigation mesh
  147543. * @param meshes array of all the geometry used to compute the navigatio mesh
  147544. * @param parameters bunch of parameters used to filter geometry
  147545. */
  147546. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147547. /**
  147548. * Create a navigation mesh debug mesh
  147549. * @param scene is where the mesh will be added
  147550. * @returns debug display mesh
  147551. */
  147552. createDebugNavMesh(scene: Scene): Mesh;
  147553. /**
  147554. * Get a navigation mesh constrained position, closest to the parameter position
  147555. * @param position world position
  147556. * @returns the closest point to position constrained by the navigation mesh
  147557. */
  147558. getClosestPoint(position: Vector3): Vector3;
  147559. /**
  147560. * Get a navigation mesh constrained position, closest to the parameter position
  147561. * @param position world position
  147562. * @param result output the closest point to position constrained by the navigation mesh
  147563. */
  147564. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147565. /**
  147566. * Get a navigation mesh constrained position, within a particular radius
  147567. * @param position world position
  147568. * @param maxRadius the maximum distance to the constrained world position
  147569. * @returns the closest point to position constrained by the navigation mesh
  147570. */
  147571. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147572. /**
  147573. * Get a navigation mesh constrained position, within a particular radius
  147574. * @param position world position
  147575. * @param maxRadius the maximum distance to the constrained world position
  147576. * @param result output the closest point to position constrained by the navigation mesh
  147577. */
  147578. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147579. /**
  147580. * Compute the final position from a segment made of destination-position
  147581. * @param position world position
  147582. * @param destination world position
  147583. * @returns the resulting point along the navmesh
  147584. */
  147585. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147586. /**
  147587. * Compute the final position from a segment made of destination-position
  147588. * @param position world position
  147589. * @param destination world position
  147590. * @param result output the resulting point along the navmesh
  147591. */
  147592. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147593. /**
  147594. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147595. * @param start world position
  147596. * @param end world position
  147597. * @returns array containing world position composing the path
  147598. */
  147599. computePath(start: Vector3, end: Vector3): Vector3[];
  147600. /**
  147601. * Create a new Crowd so you can add agents
  147602. * @param maxAgents the maximum agent count in the crowd
  147603. * @param maxAgentRadius the maximum radius an agent can have
  147604. * @param scene to attach the crowd to
  147605. * @returns the crowd you can add agents to
  147606. */
  147607. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147608. /**
  147609. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147610. * The queries will try to find a solution within those bounds
  147611. * default is (1,1,1)
  147612. * @param extent x,y,z value that define the extent around the queries point of reference
  147613. */
  147614. setDefaultQueryExtent(extent: Vector3): void;
  147615. /**
  147616. * Get the Bounding box extent specified by setDefaultQueryExtent
  147617. * @returns the box extent values
  147618. */
  147619. getDefaultQueryExtent(): Vector3;
  147620. /**
  147621. * build the navmesh from a previously saved state using getNavmeshData
  147622. * @param data the Uint8Array returned by getNavmeshData
  147623. */
  147624. buildFromNavmeshData(data: Uint8Array): void;
  147625. /**
  147626. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147627. * @returns data the Uint8Array that can be saved and reused
  147628. */
  147629. getNavmeshData(): Uint8Array;
  147630. /**
  147631. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147632. * @param result output the box extent values
  147633. */
  147634. getDefaultQueryExtentToRef(result: Vector3): void;
  147635. /**
  147636. * Disposes
  147637. */
  147638. dispose(): void;
  147639. /**
  147640. * If this plugin is supported
  147641. * @returns true if plugin is supported
  147642. */
  147643. isSupported(): boolean;
  147644. }
  147645. /**
  147646. * Recast detour crowd implementation
  147647. */
  147648. export class RecastJSCrowd implements ICrowd {
  147649. /**
  147650. * Recast/detour plugin
  147651. */
  147652. bjsRECASTPlugin: RecastJSPlugin;
  147653. /**
  147654. * Link to the detour crowd
  147655. */
  147656. recastCrowd: any;
  147657. /**
  147658. * One transform per agent
  147659. */
  147660. transforms: TransformNode[];
  147661. /**
  147662. * All agents created
  147663. */
  147664. agents: number[];
  147665. /**
  147666. * Link to the scene is kept to unregister the crowd from the scene
  147667. */
  147668. private _scene;
  147669. /**
  147670. * Observer for crowd updates
  147671. */
  147672. private _onBeforeAnimationsObserver;
  147673. /**
  147674. * Constructor
  147675. * @param plugin recastJS plugin
  147676. * @param maxAgents the maximum agent count in the crowd
  147677. * @param maxAgentRadius the maximum radius an agent can have
  147678. * @param scene to attach the crowd to
  147679. * @returns the crowd you can add agents to
  147680. */
  147681. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  147682. /**
  147683. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147684. * You can attach anything to that node. The node position is updated in the scene update tick.
  147685. * @param pos world position that will be constrained by the navigation mesh
  147686. * @param parameters agent parameters
  147687. * @param transform hooked to the agent that will be update by the scene
  147688. * @returns agent index
  147689. */
  147690. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147691. /**
  147692. * Returns the agent position in world space
  147693. * @param index agent index returned by addAgent
  147694. * @returns world space position
  147695. */
  147696. getAgentPosition(index: number): Vector3;
  147697. /**
  147698. * Returns the agent position result in world space
  147699. * @param index agent index returned by addAgent
  147700. * @param result output world space position
  147701. */
  147702. getAgentPositionToRef(index: number, result: Vector3): void;
  147703. /**
  147704. * Returns the agent velocity in world space
  147705. * @param index agent index returned by addAgent
  147706. * @returns world space velocity
  147707. */
  147708. getAgentVelocity(index: number): Vector3;
  147709. /**
  147710. * Returns the agent velocity result in world space
  147711. * @param index agent index returned by addAgent
  147712. * @param result output world space velocity
  147713. */
  147714. getAgentVelocityToRef(index: number, result: Vector3): void;
  147715. /**
  147716. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147717. * @param index agent index returned by addAgent
  147718. * @param destination targeted world position
  147719. */
  147720. agentGoto(index: number, destination: Vector3): void;
  147721. /**
  147722. * Teleport the agent to a new position
  147723. * @param index agent index returned by addAgent
  147724. * @param destination targeted world position
  147725. */
  147726. agentTeleport(index: number, destination: Vector3): void;
  147727. /**
  147728. * Update agent parameters
  147729. * @param index agent index returned by addAgent
  147730. * @param parameters agent parameters
  147731. */
  147732. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147733. /**
  147734. * remove a particular agent previously created
  147735. * @param index agent index returned by addAgent
  147736. */
  147737. removeAgent(index: number): void;
  147738. /**
  147739. * get the list of all agents attached to this crowd
  147740. * @returns list of agent indices
  147741. */
  147742. getAgents(): number[];
  147743. /**
  147744. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147745. * @param deltaTime in seconds
  147746. */
  147747. update(deltaTime: number): void;
  147748. /**
  147749. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147750. * The queries will try to find a solution within those bounds
  147751. * default is (1,1,1)
  147752. * @param extent x,y,z value that define the extent around the queries point of reference
  147753. */
  147754. setDefaultQueryExtent(extent: Vector3): void;
  147755. /**
  147756. * Get the Bounding box extent specified by setDefaultQueryExtent
  147757. * @returns the box extent values
  147758. */
  147759. getDefaultQueryExtent(): Vector3;
  147760. /**
  147761. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147762. * @param result output the box extent values
  147763. */
  147764. getDefaultQueryExtentToRef(result: Vector3): void;
  147765. /**
  147766. * Release all resources
  147767. */
  147768. dispose(): void;
  147769. }
  147770. }
  147771. declare module BABYLON {
  147772. /**
  147773. * Class used to enable access to IndexedDB
  147774. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  147775. */
  147776. export class Database implements IOfflineProvider {
  147777. private _callbackManifestChecked;
  147778. private _currentSceneUrl;
  147779. private _db;
  147780. private _enableSceneOffline;
  147781. private _enableTexturesOffline;
  147782. private _manifestVersionFound;
  147783. private _mustUpdateRessources;
  147784. private _hasReachedQuota;
  147785. private _isSupported;
  147786. private _idbFactory;
  147787. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  147788. private static IsUASupportingBlobStorage;
  147789. /**
  147790. * Gets a boolean indicating if Database storate is enabled (off by default)
  147791. */
  147792. static IDBStorageEnabled: boolean;
  147793. /**
  147794. * Gets a boolean indicating if scene must be saved in the database
  147795. */
  147796. get enableSceneOffline(): boolean;
  147797. /**
  147798. * Gets a boolean indicating if textures must be saved in the database
  147799. */
  147800. get enableTexturesOffline(): boolean;
  147801. /**
  147802. * Creates a new Database
  147803. * @param urlToScene defines the url to load the scene
  147804. * @param callbackManifestChecked defines the callback to use when manifest is checked
  147805. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  147806. */
  147807. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  147808. private static _ParseURL;
  147809. private static _ReturnFullUrlLocation;
  147810. private _checkManifestFile;
  147811. /**
  147812. * Open the database and make it available
  147813. * @param successCallback defines the callback to call on success
  147814. * @param errorCallback defines the callback to call on error
  147815. */
  147816. open(successCallback: () => void, errorCallback: () => void): void;
  147817. /**
  147818. * Loads an image from the database
  147819. * @param url defines the url to load from
  147820. * @param image defines the target DOM image
  147821. */
  147822. loadImage(url: string, image: HTMLImageElement): void;
  147823. private _loadImageFromDBAsync;
  147824. private _saveImageIntoDBAsync;
  147825. private _checkVersionFromDB;
  147826. private _loadVersionFromDBAsync;
  147827. private _saveVersionIntoDBAsync;
  147828. /**
  147829. * Loads a file from database
  147830. * @param url defines the URL to load from
  147831. * @param sceneLoaded defines a callback to call on success
  147832. * @param progressCallBack defines a callback to call when progress changed
  147833. * @param errorCallback defines a callback to call on error
  147834. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  147835. */
  147836. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  147837. private _loadFileAsync;
  147838. private _saveFileAsync;
  147839. /**
  147840. * Validates if xhr data is correct
  147841. * @param xhr defines the request to validate
  147842. * @param dataType defines the expected data type
  147843. * @returns true if data is correct
  147844. */
  147845. private static _ValidateXHRData;
  147846. }
  147847. }
  147848. declare module BABYLON {
  147849. /** @hidden */
  147850. export var gpuUpdateParticlesPixelShader: {
  147851. name: string;
  147852. shader: string;
  147853. };
  147854. }
  147855. declare module BABYLON {
  147856. /** @hidden */
  147857. export var gpuUpdateParticlesVertexShader: {
  147858. name: string;
  147859. shader: string;
  147860. };
  147861. }
  147862. declare module BABYLON {
  147863. /** @hidden */
  147864. export var clipPlaneFragmentDeclaration2: {
  147865. name: string;
  147866. shader: string;
  147867. };
  147868. }
  147869. declare module BABYLON {
  147870. /** @hidden */
  147871. export var gpuRenderParticlesPixelShader: {
  147872. name: string;
  147873. shader: string;
  147874. };
  147875. }
  147876. declare module BABYLON {
  147877. /** @hidden */
  147878. export var clipPlaneVertexDeclaration2: {
  147879. name: string;
  147880. shader: string;
  147881. };
  147882. }
  147883. declare module BABYLON {
  147884. /** @hidden */
  147885. export var gpuRenderParticlesVertexShader: {
  147886. name: string;
  147887. shader: string;
  147888. };
  147889. }
  147890. declare module BABYLON {
  147891. /**
  147892. * This represents a GPU particle system in Babylon
  147893. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147894. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147895. */
  147896. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147897. /**
  147898. * The layer mask we are rendering the particles through.
  147899. */
  147900. layerMask: number;
  147901. private _capacity;
  147902. private _activeCount;
  147903. private _currentActiveCount;
  147904. private _accumulatedCount;
  147905. private _renderEffect;
  147906. private _updateEffect;
  147907. private _buffer0;
  147908. private _buffer1;
  147909. private _spriteBuffer;
  147910. private _updateVAO;
  147911. private _renderVAO;
  147912. private _targetIndex;
  147913. private _sourceBuffer;
  147914. private _targetBuffer;
  147915. private _currentRenderId;
  147916. private _started;
  147917. private _stopped;
  147918. private _timeDelta;
  147919. private _randomTexture;
  147920. private _randomTexture2;
  147921. private _attributesStrideSize;
  147922. private _updateEffectOptions;
  147923. private _randomTextureSize;
  147924. private _actualFrame;
  147925. private _customEffect;
  147926. private readonly _rawTextureWidth;
  147927. /**
  147928. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  147929. */
  147930. static get IsSupported(): boolean;
  147931. /**
  147932. * An event triggered when the system is disposed.
  147933. */
  147934. onDisposeObservable: Observable<IParticleSystem>;
  147935. /**
  147936. * Gets the maximum number of particles active at the same time.
  147937. * @returns The max number of active particles.
  147938. */
  147939. getCapacity(): number;
  147940. /**
  147941. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  147942. * to override the particles.
  147943. */
  147944. forceDepthWrite: boolean;
  147945. /**
  147946. * Gets or set the number of active particles
  147947. */
  147948. get activeParticleCount(): number;
  147949. set activeParticleCount(value: number);
  147950. private _preWarmDone;
  147951. /**
  147952. * Specifies if the particles are updated in emitter local space or world space.
  147953. */
  147954. isLocal: boolean;
  147955. /** Gets or sets a matrix to use to compute projection */
  147956. defaultProjectionMatrix: Matrix;
  147957. /**
  147958. * Is this system ready to be used/rendered
  147959. * @return true if the system is ready
  147960. */
  147961. isReady(): boolean;
  147962. /**
  147963. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147964. * @returns True if it has been started, otherwise false.
  147965. */
  147966. isStarted(): boolean;
  147967. /**
  147968. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147969. * @returns True if it has been stopped, otherwise false.
  147970. */
  147971. isStopped(): boolean;
  147972. /**
  147973. * Gets a boolean indicating that the system is stopping
  147974. * @returns true if the system is currently stopping
  147975. */
  147976. isStopping(): boolean;
  147977. /**
  147978. * Gets the number of particles active at the same time.
  147979. * @returns The number of active particles.
  147980. */
  147981. getActiveCount(): number;
  147982. /**
  147983. * Starts the particle system and begins to emit
  147984. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147985. */
  147986. start(delay?: number): void;
  147987. /**
  147988. * Stops the particle system.
  147989. */
  147990. stop(): void;
  147991. /**
  147992. * Remove all active particles
  147993. */
  147994. reset(): void;
  147995. /**
  147996. * Returns the string "GPUParticleSystem"
  147997. * @returns a string containing the class name
  147998. */
  147999. getClassName(): string;
  148000. /**
  148001. * Gets the custom effect used to render the particles
  148002. * @param blendMode Blend mode for which the effect should be retrieved
  148003. * @returns The effect
  148004. */
  148005. getCustomEffect(blendMode?: number): Nullable<Effect>;
  148006. /**
  148007. * Sets the custom effect used to render the particles
  148008. * @param effect The effect to set
  148009. * @param blendMode Blend mode for which the effect should be set
  148010. */
  148011. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  148012. /** @hidden */
  148013. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  148014. /**
  148015. * Observable that will be called just before the particles are drawn
  148016. */
  148017. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  148018. /**
  148019. * Gets the name of the particle vertex shader
  148020. */
  148021. get vertexShaderName(): string;
  148022. private _colorGradientsTexture;
  148023. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148024. /**
  148025. * Adds a new color gradient
  148026. * @param gradient defines the gradient to use (between 0 and 1)
  148027. * @param color1 defines the color to affect to the specified gradient
  148028. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148029. * @returns the current particle system
  148030. */
  148031. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148032. private _refreshColorGradient;
  148033. /** Force the system to rebuild all gradients that need to be resync */
  148034. forceRefreshGradients(): void;
  148035. /**
  148036. * Remove a specific color gradient
  148037. * @param gradient defines the gradient to remove
  148038. * @returns the current particle system
  148039. */
  148040. removeColorGradient(gradient: number): GPUParticleSystem;
  148041. private _angularSpeedGradientsTexture;
  148042. private _sizeGradientsTexture;
  148043. private _velocityGradientsTexture;
  148044. private _limitVelocityGradientsTexture;
  148045. private _dragGradientsTexture;
  148046. private _addFactorGradient;
  148047. /**
  148048. * Adds a new size gradient
  148049. * @param gradient defines the gradient to use (between 0 and 1)
  148050. * @param factor defines the size factor to affect to the specified gradient
  148051. * @returns the current particle system
  148052. */
  148053. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148054. /**
  148055. * Remove a specific size gradient
  148056. * @param gradient defines the gradient to remove
  148057. * @returns the current particle system
  148058. */
  148059. removeSizeGradient(gradient: number): GPUParticleSystem;
  148060. private _refreshFactorGradient;
  148061. /**
  148062. * Adds a new angular speed gradient
  148063. * @param gradient defines the gradient to use (between 0 and 1)
  148064. * @param factor defines the angular speed to affect to the specified gradient
  148065. * @returns the current particle system
  148066. */
  148067. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  148068. /**
  148069. * Remove a specific angular speed gradient
  148070. * @param gradient defines the gradient to remove
  148071. * @returns the current particle system
  148072. */
  148073. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  148074. /**
  148075. * Adds a new velocity gradient
  148076. * @param gradient defines the gradient to use (between 0 and 1)
  148077. * @param factor defines the velocity to affect to the specified gradient
  148078. * @returns the current particle system
  148079. */
  148080. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148081. /**
  148082. * Remove a specific velocity gradient
  148083. * @param gradient defines the gradient to remove
  148084. * @returns the current particle system
  148085. */
  148086. removeVelocityGradient(gradient: number): GPUParticleSystem;
  148087. /**
  148088. * Adds a new limit velocity gradient
  148089. * @param gradient defines the gradient to use (between 0 and 1)
  148090. * @param factor defines the limit velocity value to affect to the specified gradient
  148091. * @returns the current particle system
  148092. */
  148093. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148094. /**
  148095. * Remove a specific limit velocity gradient
  148096. * @param gradient defines the gradient to remove
  148097. * @returns the current particle system
  148098. */
  148099. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  148100. /**
  148101. * Adds a new drag gradient
  148102. * @param gradient defines the gradient to use (between 0 and 1)
  148103. * @param factor defines the drag value to affect to the specified gradient
  148104. * @returns the current particle system
  148105. */
  148106. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148107. /**
  148108. * Remove a specific drag gradient
  148109. * @param gradient defines the gradient to remove
  148110. * @returns the current particle system
  148111. */
  148112. removeDragGradient(gradient: number): GPUParticleSystem;
  148113. /**
  148114. * Not supported by GPUParticleSystem
  148115. * @param gradient defines the gradient to use (between 0 and 1)
  148116. * @param factor defines the emit rate value to affect to the specified gradient
  148117. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148118. * @returns the current particle system
  148119. */
  148120. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148121. /**
  148122. * Not supported by GPUParticleSystem
  148123. * @param gradient defines the gradient to remove
  148124. * @returns the current particle system
  148125. */
  148126. removeEmitRateGradient(gradient: number): IParticleSystem;
  148127. /**
  148128. * Not supported by GPUParticleSystem
  148129. * @param gradient defines the gradient to use (between 0 and 1)
  148130. * @param factor defines the start size value to affect to the specified gradient
  148131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148132. * @returns the current particle system
  148133. */
  148134. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148135. /**
  148136. * Not supported by GPUParticleSystem
  148137. * @param gradient defines the gradient to remove
  148138. * @returns the current particle system
  148139. */
  148140. removeStartSizeGradient(gradient: number): IParticleSystem;
  148141. /**
  148142. * Not supported by GPUParticleSystem
  148143. * @param gradient defines the gradient to use (between 0 and 1)
  148144. * @param min defines the color remap minimal range
  148145. * @param max defines the color remap maximal range
  148146. * @returns the current particle system
  148147. */
  148148. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148149. /**
  148150. * Not supported by GPUParticleSystem
  148151. * @param gradient defines the gradient to remove
  148152. * @returns the current particle system
  148153. */
  148154. removeColorRemapGradient(): IParticleSystem;
  148155. /**
  148156. * Not supported by GPUParticleSystem
  148157. * @param gradient defines the gradient to use (between 0 and 1)
  148158. * @param min defines the alpha remap minimal range
  148159. * @param max defines the alpha remap maximal range
  148160. * @returns the current particle system
  148161. */
  148162. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148163. /**
  148164. * Not supported by GPUParticleSystem
  148165. * @param gradient defines the gradient to remove
  148166. * @returns the current particle system
  148167. */
  148168. removeAlphaRemapGradient(): IParticleSystem;
  148169. /**
  148170. * Not supported by GPUParticleSystem
  148171. * @param gradient defines the gradient to use (between 0 and 1)
  148172. * @param color defines the color to affect to the specified gradient
  148173. * @returns the current particle system
  148174. */
  148175. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148176. /**
  148177. * Not supported by GPUParticleSystem
  148178. * @param gradient defines the gradient to remove
  148179. * @returns the current particle system
  148180. */
  148181. removeRampGradient(): IParticleSystem;
  148182. /**
  148183. * Not supported by GPUParticleSystem
  148184. * @returns the list of ramp gradients
  148185. */
  148186. getRampGradients(): Nullable<Array<Color3Gradient>>;
  148187. /**
  148188. * Not supported by GPUParticleSystem
  148189. * Gets or sets a boolean indicating that ramp gradients must be used
  148190. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  148191. */
  148192. get useRampGradients(): boolean;
  148193. set useRampGradients(value: boolean);
  148194. /**
  148195. * Not supported by GPUParticleSystem
  148196. * @param gradient defines the gradient to use (between 0 and 1)
  148197. * @param factor defines the life time factor to affect to the specified gradient
  148198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148199. * @returns the current particle system
  148200. */
  148201. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148202. /**
  148203. * Not supported by GPUParticleSystem
  148204. * @param gradient defines the gradient to remove
  148205. * @returns the current particle system
  148206. */
  148207. removeLifeTimeGradient(gradient: number): IParticleSystem;
  148208. /**
  148209. * Instantiates a GPU particle system.
  148210. * 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.
  148211. * @param name The name of the particle system
  148212. * @param options The options used to create the system
  148213. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  148214. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  148215. * @param customEffect a custom effect used to change the way particles are rendered by default
  148216. */
  148217. constructor(name: string, options: Partial<{
  148218. capacity: number;
  148219. randomTextureSize: number;
  148220. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  148221. protected _reset(): void;
  148222. private _createUpdateVAO;
  148223. private _createRenderVAO;
  148224. private _initialize;
  148225. /** @hidden */
  148226. _recreateUpdateEffect(): void;
  148227. private _getEffect;
  148228. /**
  148229. * Fill the defines array according to the current settings of the particle system
  148230. * @param defines Array to be updated
  148231. * @param blendMode blend mode to take into account when updating the array
  148232. */
  148233. fillDefines(defines: Array<string>, blendMode?: number): void;
  148234. /**
  148235. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  148236. * @param uniforms Uniforms array to fill
  148237. * @param attributes Attributes array to fill
  148238. * @param samplers Samplers array to fill
  148239. */
  148240. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  148241. /** @hidden */
  148242. _recreateRenderEffect(): Effect;
  148243. /**
  148244. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  148245. * @param preWarm defines if we are in the pre-warmimg phase
  148246. */
  148247. animate(preWarm?: boolean): void;
  148248. private _createFactorGradientTexture;
  148249. private _createSizeGradientTexture;
  148250. private _createAngularSpeedGradientTexture;
  148251. private _createVelocityGradientTexture;
  148252. private _createLimitVelocityGradientTexture;
  148253. private _createDragGradientTexture;
  148254. private _createColorGradientTexture;
  148255. /**
  148256. * Renders the particle system in its current state
  148257. * @param preWarm defines if the system should only update the particles but not render them
  148258. * @returns the current number of particles
  148259. */
  148260. render(preWarm?: boolean): number;
  148261. /**
  148262. * Rebuilds the particle system
  148263. */
  148264. rebuild(): void;
  148265. private _releaseBuffers;
  148266. private _releaseVAOs;
  148267. /**
  148268. * Disposes the particle system and free the associated resources
  148269. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  148270. */
  148271. dispose(disposeTexture?: boolean): void;
  148272. /**
  148273. * Clones the particle system.
  148274. * @param name The name of the cloned object
  148275. * @param newEmitter The new emitter to use
  148276. * @returns the cloned particle system
  148277. */
  148278. clone(name: string, newEmitter: any): GPUParticleSystem;
  148279. /**
  148280. * Serializes the particle system to a JSON object
  148281. * @param serializeTexture defines if the texture must be serialized as well
  148282. * @returns the JSON object
  148283. */
  148284. serialize(serializeTexture?: boolean): any;
  148285. /**
  148286. * Parses a JSON object to create a GPU particle system.
  148287. * @param parsedParticleSystem The JSON object to parse
  148288. * @param sceneOrEngine The scene or the engine to create the particle system in
  148289. * @param rootUrl The root url to use to load external dependencies like texture
  148290. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  148291. * @returns the parsed GPU particle system
  148292. */
  148293. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  148294. }
  148295. }
  148296. declare module BABYLON {
  148297. /**
  148298. * Represents a set of particle systems working together to create a specific effect
  148299. */
  148300. export class ParticleSystemSet implements IDisposable {
  148301. /**
  148302. * Gets or sets base Assets URL
  148303. */
  148304. static BaseAssetsUrl: string;
  148305. private _emitterCreationOptions;
  148306. private _emitterNode;
  148307. /**
  148308. * Gets the particle system list
  148309. */
  148310. systems: IParticleSystem[];
  148311. /**
  148312. * Gets the emitter node used with this set
  148313. */
  148314. get emitterNode(): Nullable<TransformNode>;
  148315. /**
  148316. * Creates a new emitter mesh as a sphere
  148317. * @param options defines the options used to create the sphere
  148318. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  148319. * @param scene defines the hosting scene
  148320. */
  148321. setEmitterAsSphere(options: {
  148322. diameter: number;
  148323. segments: number;
  148324. color: Color3;
  148325. }, renderingGroupId: number, scene: Scene): void;
  148326. /**
  148327. * Starts all particle systems of the set
  148328. * @param emitter defines an optional mesh to use as emitter for the particle systems
  148329. */
  148330. start(emitter?: AbstractMesh): void;
  148331. /**
  148332. * Release all associated resources
  148333. */
  148334. dispose(): void;
  148335. /**
  148336. * Serialize the set into a JSON compatible object
  148337. * @param serializeTexture defines if the texture must be serialized as well
  148338. * @returns a JSON compatible representation of the set
  148339. */
  148340. serialize(serializeTexture?: boolean): any;
  148341. /**
  148342. * Parse a new ParticleSystemSet from a serialized source
  148343. * @param data defines a JSON compatible representation of the set
  148344. * @param scene defines the hosting scene
  148345. * @param gpu defines if we want GPU particles or CPU particles
  148346. * @returns a new ParticleSystemSet
  148347. */
  148348. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  148349. }
  148350. }
  148351. declare module BABYLON {
  148352. /**
  148353. * This class is made for on one-liner static method to help creating particle system set.
  148354. */
  148355. export class ParticleHelper {
  148356. /**
  148357. * Gets or sets base Assets URL
  148358. */
  148359. static BaseAssetsUrl: string;
  148360. /** Define the Url to load snippets */
  148361. static SnippetUrl: string;
  148362. /**
  148363. * Create a default particle system that you can tweak
  148364. * @param emitter defines the emitter to use
  148365. * @param capacity defines the system capacity (default is 500 particles)
  148366. * @param scene defines the hosting scene
  148367. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  148368. * @returns the new Particle system
  148369. */
  148370. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  148371. /**
  148372. * This is the main static method (one-liner) of this helper to create different particle systems
  148373. * @param type This string represents the type to the particle system to create
  148374. * @param scene The scene where the particle system should live
  148375. * @param gpu If the system will use gpu
  148376. * @returns the ParticleSystemSet created
  148377. */
  148378. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  148379. /**
  148380. * Static function used to export a particle system to a ParticleSystemSet variable.
  148381. * Please note that the emitter shape is not exported
  148382. * @param systems defines the particle systems to export
  148383. * @returns the created particle system set
  148384. */
  148385. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  148386. /**
  148387. * Creates a particle system from a snippet saved in a remote file
  148388. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  148389. * @param url defines the url to load from
  148390. * @param scene defines the hosting scene
  148391. * @param gpu If the system will use gpu
  148392. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148393. * @returns a promise that will resolve to the new particle system
  148394. */
  148395. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148396. /**
  148397. * Creates a particle system from a snippet saved by the particle system editor
  148398. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  148399. * @param scene defines the hosting scene
  148400. * @param gpu If the system will use gpu
  148401. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148402. * @returns a promise that will resolve to the new particle system
  148403. */
  148404. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148405. }
  148406. }
  148407. declare module BABYLON {
  148408. interface Engine {
  148409. /**
  148410. * Create an effect to use with particle systems.
  148411. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  148412. * the particle system for which you want to create a custom effect in the last parameter
  148413. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  148414. * @param uniformsNames defines a list of attribute names
  148415. * @param samplers defines an array of string used to represent textures
  148416. * @param defines defines the string containing the defines to use to compile the shaders
  148417. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  148418. * @param onCompiled defines a function to call when the effect creation is successful
  148419. * @param onError defines a function to call when the effect creation has failed
  148420. * @param particleSystem the particle system you want to create the effect for
  148421. * @returns the new Effect
  148422. */
  148423. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  148424. }
  148425. interface Mesh {
  148426. /**
  148427. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  148428. * @returns an array of IParticleSystem
  148429. */
  148430. getEmittedParticleSystems(): IParticleSystem[];
  148431. /**
  148432. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  148433. * @returns an array of IParticleSystem
  148434. */
  148435. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  148436. }
  148437. }
  148438. declare module BABYLON {
  148439. /** Defines the 4 color options */
  148440. export enum PointColor {
  148441. /** color value */
  148442. Color = 2,
  148443. /** uv value */
  148444. UV = 1,
  148445. /** random value */
  148446. Random = 0,
  148447. /** stated value */
  148448. Stated = 3
  148449. }
  148450. /**
  148451. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  148452. * 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.
  148453. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  148454. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  148455. *
  148456. * Full documentation here : TO BE ENTERED
  148457. */
  148458. export class PointsCloudSystem implements IDisposable {
  148459. /**
  148460. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  148461. * Example : var p = SPS.particles[i];
  148462. */
  148463. particles: CloudPoint[];
  148464. /**
  148465. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  148466. */
  148467. nbParticles: number;
  148468. /**
  148469. * This a counter for your own usage. It's not set by any SPS functions.
  148470. */
  148471. counter: number;
  148472. /**
  148473. * The PCS name. This name is also given to the underlying mesh.
  148474. */
  148475. name: string;
  148476. /**
  148477. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  148478. */
  148479. mesh: Mesh;
  148480. /**
  148481. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  148482. * Please read :
  148483. */
  148484. vars: any;
  148485. /**
  148486. * @hidden
  148487. */
  148488. _size: number;
  148489. private _scene;
  148490. private _promises;
  148491. private _positions;
  148492. private _indices;
  148493. private _normals;
  148494. private _colors;
  148495. private _uvs;
  148496. private _indices32;
  148497. private _positions32;
  148498. private _colors32;
  148499. private _uvs32;
  148500. private _updatable;
  148501. private _isVisibilityBoxLocked;
  148502. private _alwaysVisible;
  148503. private _groups;
  148504. private _groupCounter;
  148505. private _computeParticleColor;
  148506. private _computeParticleTexture;
  148507. private _computeParticleRotation;
  148508. private _computeBoundingBox;
  148509. private _isReady;
  148510. /**
  148511. * Creates a PCS (Points Cloud System) object
  148512. * @param name (String) is the PCS name, this will be the underlying mesh name
  148513. * @param pointSize (number) is the size for each point
  148514. * @param scene (Scene) is the scene in which the PCS is added
  148515. * @param options defines the options of the PCS e.g.
  148516. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148517. */
  148518. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148519. updatable?: boolean;
  148520. });
  148521. /**
  148522. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148523. * If no points were added to the PCS, the returned mesh is just a single point.
  148524. * @returns a promise for the created mesh
  148525. */
  148526. buildMeshAsync(): Promise<Mesh>;
  148527. /**
  148528. * @hidden
  148529. */
  148530. private _buildMesh;
  148531. private _addParticle;
  148532. private _randomUnitVector;
  148533. private _getColorIndicesForCoord;
  148534. private _setPointsColorOrUV;
  148535. private _colorFromTexture;
  148536. private _calculateDensity;
  148537. /**
  148538. * Adds points to the PCS in random positions within a unit sphere
  148539. * @param nb (positive integer) the number of particles to be created from this model
  148540. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148541. * @returns the number of groups in the system
  148542. */
  148543. addPoints(nb: number, pointFunction?: any): number;
  148544. /**
  148545. * Adds points to the PCS from the surface of the model shape
  148546. * @param mesh is any Mesh object that will be used as a surface model for the points
  148547. * @param nb (positive integer) the number of particles to be created from this model
  148548. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148549. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148550. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148551. * @returns the number of groups in the system
  148552. */
  148553. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148554. /**
  148555. * Adds points to the PCS inside the model shape
  148556. * @param mesh is any Mesh object that will be used as a surface model for the points
  148557. * @param nb (positive integer) the number of particles to be created from this model
  148558. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148559. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148560. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148561. * @returns the number of groups in the system
  148562. */
  148563. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148564. /**
  148565. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148566. * This method calls `updateParticle()` for each particle of the SPS.
  148567. * For an animated SPS, it is usually called within the render loop.
  148568. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148569. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148570. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148571. * @returns the PCS.
  148572. */
  148573. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148574. /**
  148575. * Disposes the PCS.
  148576. */
  148577. dispose(): void;
  148578. /**
  148579. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148580. * doc :
  148581. * @returns the PCS.
  148582. */
  148583. refreshVisibleSize(): PointsCloudSystem;
  148584. /**
  148585. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148586. * @param size the size (float) of the visibility box
  148587. * note : this doesn't lock the PCS mesh bounding box.
  148588. * doc :
  148589. */
  148590. setVisibilityBox(size: number): void;
  148591. /**
  148592. * Gets whether the PCS is always visible or not
  148593. * doc :
  148594. */
  148595. get isAlwaysVisible(): boolean;
  148596. /**
  148597. * Sets the PCS as always visible or not
  148598. * doc :
  148599. */
  148600. set isAlwaysVisible(val: boolean);
  148601. /**
  148602. * Tells to `setParticles()` to compute the particle rotations or not
  148603. * Default value : false. The PCS is faster when it's set to false
  148604. * Note : particle rotations are only applied to parent particles
  148605. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148606. */
  148607. set computeParticleRotation(val: boolean);
  148608. /**
  148609. * Tells to `setParticles()` to compute the particle colors or not.
  148610. * Default value : true. The PCS is faster when it's set to false.
  148611. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148612. */
  148613. set computeParticleColor(val: boolean);
  148614. set computeParticleTexture(val: boolean);
  148615. /**
  148616. * Gets if `setParticles()` computes the particle colors or not.
  148617. * Default value : false. The PCS is faster when it's set to false.
  148618. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148619. */
  148620. get computeParticleColor(): boolean;
  148621. /**
  148622. * Gets if `setParticles()` computes the particle textures or not.
  148623. * Default value : false. The PCS is faster when it's set to false.
  148624. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148625. */
  148626. get computeParticleTexture(): boolean;
  148627. /**
  148628. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148629. */
  148630. set computeBoundingBox(val: boolean);
  148631. /**
  148632. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148633. */
  148634. get computeBoundingBox(): boolean;
  148635. /**
  148636. * This function does nothing. It may be overwritten to set all the particle first values.
  148637. * The PCS doesn't call this function, you may have to call it by your own.
  148638. * doc :
  148639. */
  148640. initParticles(): void;
  148641. /**
  148642. * This function does nothing. It may be overwritten to recycle a particle
  148643. * The PCS doesn't call this function, you can to call it
  148644. * doc :
  148645. * @param particle The particle to recycle
  148646. * @returns the recycled particle
  148647. */
  148648. recycleParticle(particle: CloudPoint): CloudPoint;
  148649. /**
  148650. * Updates a particle : this function should be overwritten by the user.
  148651. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148652. * doc :
  148653. * @example : just set a particle position or velocity and recycle conditions
  148654. * @param particle The particle to update
  148655. * @returns the updated particle
  148656. */
  148657. updateParticle(particle: CloudPoint): CloudPoint;
  148658. /**
  148659. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148660. * This does nothing and may be overwritten by the user.
  148661. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148662. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148663. * @param update the boolean update value actually passed to setParticles()
  148664. */
  148665. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148666. /**
  148667. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  148668. * This will be passed three parameters.
  148669. * This does nothing and may be overwritten by the user.
  148670. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148671. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148672. * @param update the boolean update value actually passed to setParticles()
  148673. */
  148674. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148675. }
  148676. }
  148677. declare module BABYLON {
  148678. /**
  148679. * Represents one particle of a points cloud system.
  148680. */
  148681. export class CloudPoint {
  148682. /**
  148683. * particle global index
  148684. */
  148685. idx: number;
  148686. /**
  148687. * The color of the particle
  148688. */
  148689. color: Nullable<Color4>;
  148690. /**
  148691. * The world space position of the particle.
  148692. */
  148693. position: Vector3;
  148694. /**
  148695. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  148696. */
  148697. rotation: Vector3;
  148698. /**
  148699. * The world space rotation quaternion of the particle.
  148700. */
  148701. rotationQuaternion: Nullable<Quaternion>;
  148702. /**
  148703. * The uv of the particle.
  148704. */
  148705. uv: Nullable<Vector2>;
  148706. /**
  148707. * The current speed of the particle.
  148708. */
  148709. velocity: Vector3;
  148710. /**
  148711. * The pivot point in the particle local space.
  148712. */
  148713. pivot: Vector3;
  148714. /**
  148715. * Must the particle be translated from its pivot point in its local space ?
  148716. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  148717. * Default : false
  148718. */
  148719. translateFromPivot: boolean;
  148720. /**
  148721. * Index of this particle in the global "positions" array (Internal use)
  148722. * @hidden
  148723. */
  148724. _pos: number;
  148725. /**
  148726. * @hidden Index of this particle in the global "indices" array (Internal use)
  148727. */
  148728. _ind: number;
  148729. /**
  148730. * Group this particle belongs to
  148731. */
  148732. _group: PointsGroup;
  148733. /**
  148734. * Group id of this particle
  148735. */
  148736. groupId: number;
  148737. /**
  148738. * Index of the particle in its group id (Internal use)
  148739. */
  148740. idxInGroup: number;
  148741. /**
  148742. * @hidden Particle BoundingInfo object (Internal use)
  148743. */
  148744. _boundingInfo: BoundingInfo;
  148745. /**
  148746. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  148747. */
  148748. _pcs: PointsCloudSystem;
  148749. /**
  148750. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  148751. */
  148752. _stillInvisible: boolean;
  148753. /**
  148754. * @hidden Last computed particle rotation matrix
  148755. */
  148756. _rotationMatrix: number[];
  148757. /**
  148758. * Parent particle Id, if any.
  148759. * Default null.
  148760. */
  148761. parentId: Nullable<number>;
  148762. /**
  148763. * @hidden Internal global position in the PCS.
  148764. */
  148765. _globalPosition: Vector3;
  148766. /**
  148767. * Creates a Point Cloud object.
  148768. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  148769. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  148770. * @param group (PointsGroup) is the group the particle belongs to
  148771. * @param groupId (integer) is the group identifier in the PCS.
  148772. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  148773. * @param pcs defines the PCS it is associated to
  148774. */
  148775. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  148776. /**
  148777. * get point size
  148778. */
  148779. get size(): Vector3;
  148780. /**
  148781. * Set point size
  148782. */
  148783. set size(scale: Vector3);
  148784. /**
  148785. * Legacy support, changed quaternion to rotationQuaternion
  148786. */
  148787. get quaternion(): Nullable<Quaternion>;
  148788. /**
  148789. * Legacy support, changed quaternion to rotationQuaternion
  148790. */
  148791. set quaternion(q: Nullable<Quaternion>);
  148792. /**
  148793. * Returns a boolean. True if the particle intersects a mesh, else false
  148794. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  148795. * @param target is the object (point or mesh) what the intersection is computed against
  148796. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  148797. * @returns true if it intersects
  148798. */
  148799. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  148800. /**
  148801. * get the rotation matrix of the particle
  148802. * @hidden
  148803. */
  148804. getRotationMatrix(m: Matrix): void;
  148805. }
  148806. /**
  148807. * Represents a group of points in a points cloud system
  148808. * * PCS internal tool, don't use it manually.
  148809. */
  148810. export class PointsGroup {
  148811. /**
  148812. * The group id
  148813. * @hidden
  148814. */
  148815. groupID: number;
  148816. /**
  148817. * image data for group (internal use)
  148818. * @hidden
  148819. */
  148820. _groupImageData: Nullable<ArrayBufferView>;
  148821. /**
  148822. * Image Width (internal use)
  148823. * @hidden
  148824. */
  148825. _groupImgWidth: number;
  148826. /**
  148827. * Image Height (internal use)
  148828. * @hidden
  148829. */
  148830. _groupImgHeight: number;
  148831. /**
  148832. * Custom position function (internal use)
  148833. * @hidden
  148834. */
  148835. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  148836. /**
  148837. * density per facet for surface points
  148838. * @hidden
  148839. */
  148840. _groupDensity: number[];
  148841. /**
  148842. * Only when points are colored by texture carries pointer to texture list array
  148843. * @hidden
  148844. */
  148845. _textureNb: number;
  148846. /**
  148847. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148848. * PCS internal tool, don't use it manually.
  148849. * @hidden
  148850. */
  148851. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148852. }
  148853. }
  148854. declare module BABYLON {
  148855. interface Scene {
  148856. /** @hidden (Backing field) */
  148857. _physicsEngine: Nullable<IPhysicsEngine>;
  148858. /** @hidden */
  148859. _physicsTimeAccumulator: number;
  148860. /**
  148861. * Gets the current physics engine
  148862. * @returns a IPhysicsEngine or null if none attached
  148863. */
  148864. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148865. /**
  148866. * Enables physics to the current scene
  148867. * @param gravity defines the scene's gravity for the physics engine
  148868. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148869. * @return a boolean indicating if the physics engine was initialized
  148870. */
  148871. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148872. /**
  148873. * Disables and disposes the physics engine associated with the scene
  148874. */
  148875. disablePhysicsEngine(): void;
  148876. /**
  148877. * Gets a boolean indicating if there is an active physics engine
  148878. * @returns a boolean indicating if there is an active physics engine
  148879. */
  148880. isPhysicsEnabled(): boolean;
  148881. /**
  148882. * Deletes a physics compound impostor
  148883. * @param compound defines the compound to delete
  148884. */
  148885. deleteCompoundImpostor(compound: any): void;
  148886. /**
  148887. * An event triggered when physic simulation is about to be run
  148888. */
  148889. onBeforePhysicsObservable: Observable<Scene>;
  148890. /**
  148891. * An event triggered when physic simulation has been done
  148892. */
  148893. onAfterPhysicsObservable: Observable<Scene>;
  148894. }
  148895. interface AbstractMesh {
  148896. /** @hidden */
  148897. _physicsImpostor: Nullable<PhysicsImpostor>;
  148898. /**
  148899. * Gets or sets impostor used for physic simulation
  148900. * @see https://doc.babylonjs.com/features/physics_engine
  148901. */
  148902. physicsImpostor: Nullable<PhysicsImpostor>;
  148903. /**
  148904. * Gets the current physics impostor
  148905. * @see https://doc.babylonjs.com/features/physics_engine
  148906. * @returns a physics impostor or null
  148907. */
  148908. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148909. /** Apply a physic impulse to the mesh
  148910. * @param force defines the force to apply
  148911. * @param contactPoint defines where to apply the force
  148912. * @returns the current mesh
  148913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148914. */
  148915. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148916. /**
  148917. * Creates a physic joint between two meshes
  148918. * @param otherMesh defines the other mesh to use
  148919. * @param pivot1 defines the pivot to use on this mesh
  148920. * @param pivot2 defines the pivot to use on the other mesh
  148921. * @param options defines additional options (can be plugin dependent)
  148922. * @returns the current mesh
  148923. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  148924. */
  148925. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  148926. /** @hidden */
  148927. _disposePhysicsObserver: Nullable<Observer<Node>>;
  148928. }
  148929. /**
  148930. * Defines the physics engine scene component responsible to manage a physics engine
  148931. */
  148932. export class PhysicsEngineSceneComponent implements ISceneComponent {
  148933. /**
  148934. * The component name helpful to identify the component in the list of scene components.
  148935. */
  148936. readonly name: string;
  148937. /**
  148938. * The scene the component belongs to.
  148939. */
  148940. scene: Scene;
  148941. /**
  148942. * Creates a new instance of the component for the given scene
  148943. * @param scene Defines the scene to register the component in
  148944. */
  148945. constructor(scene: Scene);
  148946. /**
  148947. * Registers the component in a given scene
  148948. */
  148949. register(): void;
  148950. /**
  148951. * Rebuilds the elements related to this component in case of
  148952. * context lost for instance.
  148953. */
  148954. rebuild(): void;
  148955. /**
  148956. * Disposes the component and the associated ressources
  148957. */
  148958. dispose(): void;
  148959. }
  148960. }
  148961. declare module BABYLON {
  148962. /**
  148963. * A helper for physics simulations
  148964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148965. */
  148966. export class PhysicsHelper {
  148967. private _scene;
  148968. private _physicsEngine;
  148969. /**
  148970. * Initializes the Physics helper
  148971. * @param scene Babylon.js scene
  148972. */
  148973. constructor(scene: Scene);
  148974. /**
  148975. * Applies a radial explosion impulse
  148976. * @param origin the origin of the explosion
  148977. * @param radiusOrEventOptions the radius or the options of radial explosion
  148978. * @param strength the explosion strength
  148979. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148980. * @returns A physics radial explosion event, or null
  148981. */
  148982. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148983. /**
  148984. * Applies a radial explosion force
  148985. * @param origin the origin of the explosion
  148986. * @param radiusOrEventOptions the radius or the options of radial explosion
  148987. * @param strength the explosion strength
  148988. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148989. * @returns A physics radial explosion event, or null
  148990. */
  148991. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148992. /**
  148993. * Creates a gravitational field
  148994. * @param origin the origin of the explosion
  148995. * @param radiusOrEventOptions the radius or the options of radial explosion
  148996. * @param strength the explosion strength
  148997. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148998. * @returns A physics gravitational field event, or null
  148999. */
  149000. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  149001. /**
  149002. * Creates a physics updraft event
  149003. * @param origin the origin of the updraft
  149004. * @param radiusOrEventOptions the radius or the options of the updraft
  149005. * @param strength the strength of the updraft
  149006. * @param height the height of the updraft
  149007. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  149008. * @returns A physics updraft event, or null
  149009. */
  149010. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  149011. /**
  149012. * Creates a physics vortex event
  149013. * @param origin the of the vortex
  149014. * @param radiusOrEventOptions the radius or the options of the vortex
  149015. * @param strength the strength of the vortex
  149016. * @param height the height of the vortex
  149017. * @returns a Physics vortex event, or null
  149018. * A physics vortex event or null
  149019. */
  149020. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149021. }
  149022. /**
  149023. * Represents a physics radial explosion event
  149024. */
  149025. class PhysicsRadialExplosionEvent {
  149026. private _scene;
  149027. private _options;
  149028. private _sphere;
  149029. private _dataFetched;
  149030. /**
  149031. * Initializes a radial explosioin event
  149032. * @param _scene BabylonJS scene
  149033. * @param _options The options for the vortex event
  149034. */
  149035. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149036. /**
  149037. * Returns the data related to the radial explosion event (sphere).
  149038. * @returns The radial explosion event data
  149039. */
  149040. getData(): PhysicsRadialExplosionEventData;
  149041. /**
  149042. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149043. * @param impostor A physics imposter
  149044. * @param origin the origin of the explosion
  149045. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149046. */
  149047. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149048. /**
  149049. * Triggers affecterd impostors callbacks
  149050. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149051. */
  149052. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149053. /**
  149054. * Disposes the sphere.
  149055. * @param force Specifies if the sphere should be disposed by force
  149056. */
  149057. dispose(force?: boolean): void;
  149058. /*** Helpers ***/
  149059. private _prepareSphere;
  149060. private _intersectsWithSphere;
  149061. }
  149062. /**
  149063. * Represents a gravitational field event
  149064. */
  149065. class PhysicsGravitationalFieldEvent {
  149066. private _physicsHelper;
  149067. private _scene;
  149068. private _origin;
  149069. private _options;
  149070. private _tickCallback;
  149071. private _sphere;
  149072. private _dataFetched;
  149073. /**
  149074. * Initializes the physics gravitational field event
  149075. * @param _physicsHelper A physics helper
  149076. * @param _scene BabylonJS scene
  149077. * @param _origin The origin position of the gravitational field event
  149078. * @param _options The options for the vortex event
  149079. */
  149080. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  149081. /**
  149082. * Returns the data related to the gravitational field event (sphere).
  149083. * @returns A gravitational field event
  149084. */
  149085. getData(): PhysicsGravitationalFieldEventData;
  149086. /**
  149087. * Enables the gravitational field.
  149088. */
  149089. enable(): void;
  149090. /**
  149091. * Disables the gravitational field.
  149092. */
  149093. disable(): void;
  149094. /**
  149095. * Disposes the sphere.
  149096. * @param force The force to dispose from the gravitational field event
  149097. */
  149098. dispose(force?: boolean): void;
  149099. private _tick;
  149100. }
  149101. /**
  149102. * Represents a physics updraft event
  149103. */
  149104. class PhysicsUpdraftEvent {
  149105. private _scene;
  149106. private _origin;
  149107. private _options;
  149108. private _physicsEngine;
  149109. private _originTop;
  149110. private _originDirection;
  149111. private _tickCallback;
  149112. private _cylinder;
  149113. private _cylinderPosition;
  149114. private _dataFetched;
  149115. /**
  149116. * Initializes the physics updraft event
  149117. * @param _scene BabylonJS scene
  149118. * @param _origin The origin position of the updraft
  149119. * @param _options The options for the updraft event
  149120. */
  149121. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149122. /**
  149123. * Returns the data related to the updraft event (cylinder).
  149124. * @returns A physics updraft event
  149125. */
  149126. getData(): PhysicsUpdraftEventData;
  149127. /**
  149128. * Enables the updraft.
  149129. */
  149130. enable(): void;
  149131. /**
  149132. * Disables the updraft.
  149133. */
  149134. disable(): void;
  149135. /**
  149136. * Disposes the cylinder.
  149137. * @param force Specifies if the updraft should be disposed by force
  149138. */
  149139. dispose(force?: boolean): void;
  149140. private getImpostorHitData;
  149141. private _tick;
  149142. /*** Helpers ***/
  149143. private _prepareCylinder;
  149144. private _intersectsWithCylinder;
  149145. }
  149146. /**
  149147. * Represents a physics vortex event
  149148. */
  149149. class PhysicsVortexEvent {
  149150. private _scene;
  149151. private _origin;
  149152. private _options;
  149153. private _physicsEngine;
  149154. private _originTop;
  149155. private _tickCallback;
  149156. private _cylinder;
  149157. private _cylinderPosition;
  149158. private _dataFetched;
  149159. /**
  149160. * Initializes the physics vortex event
  149161. * @param _scene The BabylonJS scene
  149162. * @param _origin The origin position of the vortex
  149163. * @param _options The options for the vortex event
  149164. */
  149165. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149166. /**
  149167. * Returns the data related to the vortex event (cylinder).
  149168. * @returns The physics vortex event data
  149169. */
  149170. getData(): PhysicsVortexEventData;
  149171. /**
  149172. * Enables the vortex.
  149173. */
  149174. enable(): void;
  149175. /**
  149176. * Disables the cortex.
  149177. */
  149178. disable(): void;
  149179. /**
  149180. * Disposes the sphere.
  149181. * @param force
  149182. */
  149183. dispose(force?: boolean): void;
  149184. private getImpostorHitData;
  149185. private _tick;
  149186. /*** Helpers ***/
  149187. private _prepareCylinder;
  149188. private _intersectsWithCylinder;
  149189. }
  149190. /**
  149191. * Options fot the radial explosion event
  149192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149193. */
  149194. export class PhysicsRadialExplosionEventOptions {
  149195. /**
  149196. * The radius of the sphere for the radial explosion.
  149197. */
  149198. radius: number;
  149199. /**
  149200. * The strenth of the explosion.
  149201. */
  149202. strength: number;
  149203. /**
  149204. * The strenght of the force in correspondence to the distance of the affected object
  149205. */
  149206. falloff: PhysicsRadialImpulseFalloff;
  149207. /**
  149208. * Sphere options for the radial explosion.
  149209. */
  149210. sphere: {
  149211. segments: number;
  149212. diameter: number;
  149213. };
  149214. /**
  149215. * Sphere options for the radial explosion.
  149216. */
  149217. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  149218. }
  149219. /**
  149220. * Options fot the updraft event
  149221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149222. */
  149223. export class PhysicsUpdraftEventOptions {
  149224. /**
  149225. * The radius of the cylinder for the vortex
  149226. */
  149227. radius: number;
  149228. /**
  149229. * The strenth of the updraft.
  149230. */
  149231. strength: number;
  149232. /**
  149233. * The height of the cylinder for the updraft.
  149234. */
  149235. height: number;
  149236. /**
  149237. * The mode for the the updraft.
  149238. */
  149239. updraftMode: PhysicsUpdraftMode;
  149240. }
  149241. /**
  149242. * Options fot the vortex event
  149243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149244. */
  149245. export class PhysicsVortexEventOptions {
  149246. /**
  149247. * The radius of the cylinder for the vortex
  149248. */
  149249. radius: number;
  149250. /**
  149251. * The strenth of the vortex.
  149252. */
  149253. strength: number;
  149254. /**
  149255. * The height of the cylinder for the vortex.
  149256. */
  149257. height: number;
  149258. /**
  149259. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  149260. */
  149261. centripetalForceThreshold: number;
  149262. /**
  149263. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  149264. */
  149265. centripetalForceMultiplier: number;
  149266. /**
  149267. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  149268. */
  149269. centrifugalForceMultiplier: number;
  149270. /**
  149271. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  149272. */
  149273. updraftForceMultiplier: number;
  149274. }
  149275. /**
  149276. * The strenght of the force in correspondence to the distance of the affected object
  149277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149278. */
  149279. export enum PhysicsRadialImpulseFalloff {
  149280. /** Defines that impulse is constant in strength across it's whole radius */
  149281. Constant = 0,
  149282. /** Defines that impulse gets weaker if it's further from the origin */
  149283. Linear = 1
  149284. }
  149285. /**
  149286. * The strength of the force in correspondence to the distance of the affected object
  149287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149288. */
  149289. export enum PhysicsUpdraftMode {
  149290. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  149291. Center = 0,
  149292. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  149293. Perpendicular = 1
  149294. }
  149295. /**
  149296. * Interface for a physics hit data
  149297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149298. */
  149299. export interface PhysicsHitData {
  149300. /**
  149301. * The force applied at the contact point
  149302. */
  149303. force: Vector3;
  149304. /**
  149305. * The contact point
  149306. */
  149307. contactPoint: Vector3;
  149308. /**
  149309. * The distance from the origin to the contact point
  149310. */
  149311. distanceFromOrigin: number;
  149312. }
  149313. /**
  149314. * Interface for radial explosion event data
  149315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149316. */
  149317. export interface PhysicsRadialExplosionEventData {
  149318. /**
  149319. * A sphere used for the radial explosion event
  149320. */
  149321. sphere: Mesh;
  149322. }
  149323. /**
  149324. * Interface for gravitational field event data
  149325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149326. */
  149327. export interface PhysicsGravitationalFieldEventData {
  149328. /**
  149329. * A sphere mesh used for the gravitational field event
  149330. */
  149331. sphere: Mesh;
  149332. }
  149333. /**
  149334. * Interface for updraft event data
  149335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149336. */
  149337. export interface PhysicsUpdraftEventData {
  149338. /**
  149339. * A cylinder used for the updraft event
  149340. */
  149341. cylinder: Mesh;
  149342. }
  149343. /**
  149344. * Interface for vortex event data
  149345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149346. */
  149347. export interface PhysicsVortexEventData {
  149348. /**
  149349. * A cylinder used for the vortex event
  149350. */
  149351. cylinder: Mesh;
  149352. }
  149353. /**
  149354. * Interface for an affected physics impostor
  149355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149356. */
  149357. export interface PhysicsAffectedImpostorWithData {
  149358. /**
  149359. * The impostor affected by the effect
  149360. */
  149361. impostor: PhysicsImpostor;
  149362. /**
  149363. * The data about the hit/horce from the explosion
  149364. */
  149365. hitData: PhysicsHitData;
  149366. }
  149367. }
  149368. declare module BABYLON {
  149369. /** @hidden */
  149370. export var blackAndWhitePixelShader: {
  149371. name: string;
  149372. shader: string;
  149373. };
  149374. }
  149375. declare module BABYLON {
  149376. /**
  149377. * Post process used to render in black and white
  149378. */
  149379. export class BlackAndWhitePostProcess extends PostProcess {
  149380. /**
  149381. * Linear about to convert he result to black and white (default: 1)
  149382. */
  149383. degree: number;
  149384. /**
  149385. * Gets a string identifying the name of the class
  149386. * @returns "BlackAndWhitePostProcess" string
  149387. */
  149388. getClassName(): string;
  149389. /**
  149390. * Creates a black and white post process
  149391. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  149392. * @param name The name of the effect.
  149393. * @param options The required width/height ratio to downsize to before computing the render pass.
  149394. * @param camera The camera to apply the render pass to.
  149395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149396. * @param engine The engine which the post process will be applied. (default: current engine)
  149397. * @param reusable If the post process can be reused on the same frame. (default: false)
  149398. */
  149399. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149400. /** @hidden */
  149401. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  149402. }
  149403. }
  149404. declare module BABYLON {
  149405. /**
  149406. * This represents a set of one or more post processes in Babylon.
  149407. * A post process can be used to apply a shader to a texture after it is rendered.
  149408. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149409. */
  149410. export class PostProcessRenderEffect {
  149411. private _postProcesses;
  149412. private _getPostProcesses;
  149413. private _singleInstance;
  149414. private _cameras;
  149415. private _indicesForCamera;
  149416. /**
  149417. * Name of the effect
  149418. * @hidden
  149419. */
  149420. _name: string;
  149421. /**
  149422. * Instantiates a post process render effect.
  149423. * A post process can be used to apply a shader to a texture after it is rendered.
  149424. * @param engine The engine the effect is tied to
  149425. * @param name The name of the effect
  149426. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  149427. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  149428. */
  149429. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  149430. /**
  149431. * Checks if all the post processes in the effect are supported.
  149432. */
  149433. get isSupported(): boolean;
  149434. /**
  149435. * Updates the current state of the effect
  149436. * @hidden
  149437. */
  149438. _update(): void;
  149439. /**
  149440. * Attaches the effect on cameras
  149441. * @param cameras The camera to attach to.
  149442. * @hidden
  149443. */
  149444. _attachCameras(cameras: Camera): void;
  149445. /**
  149446. * Attaches the effect on cameras
  149447. * @param cameras The camera to attach to.
  149448. * @hidden
  149449. */
  149450. _attachCameras(cameras: Camera[]): void;
  149451. /**
  149452. * Detaches the effect on cameras
  149453. * @param cameras The camera to detatch from.
  149454. * @hidden
  149455. */
  149456. _detachCameras(cameras: Camera): void;
  149457. /**
  149458. * Detatches the effect on cameras
  149459. * @param cameras The camera to detatch from.
  149460. * @hidden
  149461. */
  149462. _detachCameras(cameras: Camera[]): void;
  149463. /**
  149464. * Enables the effect on given cameras
  149465. * @param cameras The camera to enable.
  149466. * @hidden
  149467. */
  149468. _enable(cameras: Camera): void;
  149469. /**
  149470. * Enables the effect on given cameras
  149471. * @param cameras The camera to enable.
  149472. * @hidden
  149473. */
  149474. _enable(cameras: Nullable<Camera[]>): void;
  149475. /**
  149476. * Disables the effect on the given cameras
  149477. * @param cameras The camera to disable.
  149478. * @hidden
  149479. */
  149480. _disable(cameras: Camera): void;
  149481. /**
  149482. * Disables the effect on the given cameras
  149483. * @param cameras The camera to disable.
  149484. * @hidden
  149485. */
  149486. _disable(cameras: Nullable<Camera[]>): void;
  149487. /**
  149488. * Gets a list of the post processes contained in the effect.
  149489. * @param camera The camera to get the post processes on.
  149490. * @returns The list of the post processes in the effect.
  149491. */
  149492. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  149493. }
  149494. }
  149495. declare module BABYLON {
  149496. /** @hidden */
  149497. export var extractHighlightsPixelShader: {
  149498. name: string;
  149499. shader: string;
  149500. };
  149501. }
  149502. declare module BABYLON {
  149503. /**
  149504. * 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.
  149505. */
  149506. export class ExtractHighlightsPostProcess extends PostProcess {
  149507. /**
  149508. * The luminance threshold, pixels below this value will be set to black.
  149509. */
  149510. threshold: number;
  149511. /** @hidden */
  149512. _exposure: number;
  149513. /**
  149514. * Post process which has the input texture to be used when performing highlight extraction
  149515. * @hidden
  149516. */
  149517. _inputPostProcess: Nullable<PostProcess>;
  149518. /**
  149519. * Gets a string identifying the name of the class
  149520. * @returns "ExtractHighlightsPostProcess" string
  149521. */
  149522. getClassName(): string;
  149523. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149524. }
  149525. }
  149526. declare module BABYLON {
  149527. /** @hidden */
  149528. export var bloomMergePixelShader: {
  149529. name: string;
  149530. shader: string;
  149531. };
  149532. }
  149533. declare module BABYLON {
  149534. /**
  149535. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149536. */
  149537. export class BloomMergePostProcess extends PostProcess {
  149538. /** Weight of the bloom to be added to the original input. */
  149539. weight: number;
  149540. /**
  149541. * Gets a string identifying the name of the class
  149542. * @returns "BloomMergePostProcess" string
  149543. */
  149544. getClassName(): string;
  149545. /**
  149546. * Creates a new instance of @see BloomMergePostProcess
  149547. * @param name The name of the effect.
  149548. * @param originalFromInput Post process which's input will be used for the merge.
  149549. * @param blurred Blurred highlights post process which's output will be used.
  149550. * @param weight Weight of the bloom to be added to the original input.
  149551. * @param options The required width/height ratio to downsize to before computing the render pass.
  149552. * @param camera The camera to apply the render pass to.
  149553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149554. * @param engine The engine which the post process will be applied. (default: current engine)
  149555. * @param reusable If the post process can be reused on the same frame. (default: false)
  149556. * @param textureType Type of textures used when performing the post process. (default: 0)
  149557. * @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)
  149558. */
  149559. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149560. /** Weight of the bloom to be added to the original input. */
  149561. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149562. }
  149563. }
  149564. declare module BABYLON {
  149565. /**
  149566. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149567. */
  149568. export class BloomEffect extends PostProcessRenderEffect {
  149569. private bloomScale;
  149570. /**
  149571. * @hidden Internal
  149572. */
  149573. _effects: Array<PostProcess>;
  149574. /**
  149575. * @hidden Internal
  149576. */
  149577. _downscale: ExtractHighlightsPostProcess;
  149578. private _blurX;
  149579. private _blurY;
  149580. private _merge;
  149581. /**
  149582. * The luminance threshold to find bright areas of the image to bloom.
  149583. */
  149584. get threshold(): number;
  149585. set threshold(value: number);
  149586. /**
  149587. * The strength of the bloom.
  149588. */
  149589. get weight(): number;
  149590. set weight(value: number);
  149591. /**
  149592. * Specifies the size of the bloom blur kernel, relative to the final output size
  149593. */
  149594. get kernel(): number;
  149595. set kernel(value: number);
  149596. /**
  149597. * Creates a new instance of @see BloomEffect
  149598. * @param scene The scene the effect belongs to.
  149599. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149600. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149601. * @param bloomWeight The the strength of bloom.
  149602. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149603. * @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)
  149604. */
  149605. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149606. /**
  149607. * Disposes each of the internal effects for a given camera.
  149608. * @param camera The camera to dispose the effect on.
  149609. */
  149610. disposeEffects(camera: Camera): void;
  149611. /**
  149612. * @hidden Internal
  149613. */
  149614. _updateEffects(): void;
  149615. /**
  149616. * Internal
  149617. * @returns if all the contained post processes are ready.
  149618. * @hidden
  149619. */
  149620. _isReady(): boolean;
  149621. }
  149622. }
  149623. declare module BABYLON {
  149624. /** @hidden */
  149625. export var chromaticAberrationPixelShader: {
  149626. name: string;
  149627. shader: string;
  149628. };
  149629. }
  149630. declare module BABYLON {
  149631. /**
  149632. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149633. */
  149634. export class ChromaticAberrationPostProcess extends PostProcess {
  149635. /**
  149636. * The amount of seperation of rgb channels (default: 30)
  149637. */
  149638. aberrationAmount: number;
  149639. /**
  149640. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149641. */
  149642. radialIntensity: number;
  149643. /**
  149644. * 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))
  149645. */
  149646. direction: Vector2;
  149647. /**
  149648. * 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))
  149649. */
  149650. centerPosition: Vector2;
  149651. /** The width of the screen to apply the effect on */
  149652. screenWidth: number;
  149653. /** The height of the screen to apply the effect on */
  149654. screenHeight: number;
  149655. /**
  149656. * Gets a string identifying the name of the class
  149657. * @returns "ChromaticAberrationPostProcess" string
  149658. */
  149659. getClassName(): string;
  149660. /**
  149661. * Creates a new instance ChromaticAberrationPostProcess
  149662. * @param name The name of the effect.
  149663. * @param screenWidth The width of the screen to apply the effect on.
  149664. * @param screenHeight The height of the screen to apply the effect on.
  149665. * @param options The required width/height ratio to downsize to before computing the render pass.
  149666. * @param camera The camera to apply the render pass to.
  149667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149668. * @param engine The engine which the post process will be applied. (default: current engine)
  149669. * @param reusable If the post process can be reused on the same frame. (default: false)
  149670. * @param textureType Type of textures used when performing the post process. (default: 0)
  149671. * @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)
  149672. */
  149673. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149674. /** @hidden */
  149675. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  149676. }
  149677. }
  149678. declare module BABYLON {
  149679. /** @hidden */
  149680. export var circleOfConfusionPixelShader: {
  149681. name: string;
  149682. shader: string;
  149683. };
  149684. }
  149685. declare module BABYLON {
  149686. /**
  149687. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  149688. */
  149689. export class CircleOfConfusionPostProcess extends PostProcess {
  149690. /**
  149691. * 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.
  149692. */
  149693. lensSize: number;
  149694. /**
  149695. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149696. */
  149697. fStop: number;
  149698. /**
  149699. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149700. */
  149701. focusDistance: number;
  149702. /**
  149703. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  149704. */
  149705. focalLength: number;
  149706. /**
  149707. * Gets a string identifying the name of the class
  149708. * @returns "CircleOfConfusionPostProcess" string
  149709. */
  149710. getClassName(): string;
  149711. private _depthTexture;
  149712. /**
  149713. * Creates a new instance CircleOfConfusionPostProcess
  149714. * @param name The name of the effect.
  149715. * @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.
  149716. * @param options The required width/height ratio to downsize to before computing the render pass.
  149717. * @param camera The camera to apply the render pass to.
  149718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149719. * @param engine The engine which the post process will be applied. (default: current engine)
  149720. * @param reusable If the post process can be reused on the same frame. (default: false)
  149721. * @param textureType Type of textures used when performing the post process. (default: 0)
  149722. * @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)
  149723. */
  149724. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149725. /**
  149726. * 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.
  149727. */
  149728. set depthTexture(value: RenderTargetTexture);
  149729. }
  149730. }
  149731. declare module BABYLON {
  149732. /** @hidden */
  149733. export var colorCorrectionPixelShader: {
  149734. name: string;
  149735. shader: string;
  149736. };
  149737. }
  149738. declare module BABYLON {
  149739. /**
  149740. *
  149741. * This post-process allows the modification of rendered colors by using
  149742. * a 'look-up table' (LUT). This effect is also called Color Grading.
  149743. *
  149744. * The object needs to be provided an url to a texture containing the color
  149745. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  149746. * Use an image editing software to tweak the LUT to match your needs.
  149747. *
  149748. * For an example of a color LUT, see here:
  149749. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  149750. * For explanations on color grading, see here:
  149751. * @see http://udn.epicgames.com/Three/ColorGrading.html
  149752. *
  149753. */
  149754. export class ColorCorrectionPostProcess extends PostProcess {
  149755. private _colorTableTexture;
  149756. /**
  149757. * Gets the color table url used to create the LUT texture
  149758. */
  149759. colorTableUrl: string;
  149760. /**
  149761. * Gets a string identifying the name of the class
  149762. * @returns "ColorCorrectionPostProcess" string
  149763. */
  149764. getClassName(): string;
  149765. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149766. /** @hidden */
  149767. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  149768. }
  149769. }
  149770. declare module BABYLON {
  149771. /** @hidden */
  149772. export var convolutionPixelShader: {
  149773. name: string;
  149774. shader: string;
  149775. };
  149776. }
  149777. declare module BABYLON {
  149778. /**
  149779. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  149780. * input texture to perform effects such as edge detection or sharpening
  149781. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149782. */
  149783. export class ConvolutionPostProcess extends PostProcess {
  149784. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  149785. kernel: number[];
  149786. /**
  149787. * Gets a string identifying the name of the class
  149788. * @returns "ConvolutionPostProcess" string
  149789. */
  149790. getClassName(): string;
  149791. /**
  149792. * Creates a new instance ConvolutionPostProcess
  149793. * @param name The name of the effect.
  149794. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  149795. * @param options The required width/height ratio to downsize to before computing the render pass.
  149796. * @param camera The camera to apply the render pass to.
  149797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149798. * @param engine The engine which the post process will be applied. (default: current engine)
  149799. * @param reusable If the post process can be reused on the same frame. (default: false)
  149800. * @param textureType Type of textures used when performing the post process. (default: 0)
  149801. */
  149802. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149803. /** @hidden */
  149804. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  149805. /**
  149806. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149807. */
  149808. static EdgeDetect0Kernel: number[];
  149809. /**
  149810. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149811. */
  149812. static EdgeDetect1Kernel: number[];
  149813. /**
  149814. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149815. */
  149816. static EdgeDetect2Kernel: number[];
  149817. /**
  149818. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149819. */
  149820. static SharpenKernel: number[];
  149821. /**
  149822. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149823. */
  149824. static EmbossKernel: number[];
  149825. /**
  149826. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149827. */
  149828. static GaussianKernel: number[];
  149829. }
  149830. }
  149831. declare module BABYLON {
  149832. /**
  149833. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  149834. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  149835. * based on samples that have a large difference in distance than the center pixel.
  149836. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  149837. */
  149838. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  149839. /**
  149840. * The direction the blur should be applied
  149841. */
  149842. direction: Vector2;
  149843. /**
  149844. * Gets a string identifying the name of the class
  149845. * @returns "DepthOfFieldBlurPostProcess" string
  149846. */
  149847. getClassName(): string;
  149848. /**
  149849. * Creates a new instance CircleOfConfusionPostProcess
  149850. * @param name The name of the effect.
  149851. * @param scene The scene the effect belongs to.
  149852. * @param direction The direction the blur should be applied.
  149853. * @param kernel The size of the kernel used to blur.
  149854. * @param options The required width/height ratio to downsize to before computing the render pass.
  149855. * @param camera The camera to apply the render pass to.
  149856. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149857. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149859. * @param engine The engine which the post process will be applied. (default: current engine)
  149860. * @param reusable If the post process can be reused on the same frame. (default: false)
  149861. * @param textureType Type of textures used when performing the post process. (default: 0)
  149862. * @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)
  149863. */
  149864. 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);
  149865. }
  149866. }
  149867. declare module BABYLON {
  149868. /** @hidden */
  149869. export var depthOfFieldMergePixelShader: {
  149870. name: string;
  149871. shader: string;
  149872. };
  149873. }
  149874. declare module BABYLON {
  149875. /**
  149876. * Options to be set when merging outputs from the default pipeline.
  149877. */
  149878. export class DepthOfFieldMergePostProcessOptions {
  149879. /**
  149880. * The original image to merge on top of
  149881. */
  149882. originalFromInput: PostProcess;
  149883. /**
  149884. * Parameters to perform the merge of the depth of field effect
  149885. */
  149886. depthOfField?: {
  149887. circleOfConfusion: PostProcess;
  149888. blurSteps: Array<PostProcess>;
  149889. };
  149890. /**
  149891. * Parameters to perform the merge of bloom effect
  149892. */
  149893. bloom?: {
  149894. blurred: PostProcess;
  149895. weight: number;
  149896. };
  149897. }
  149898. /**
  149899. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149900. */
  149901. export class DepthOfFieldMergePostProcess extends PostProcess {
  149902. private blurSteps;
  149903. /**
  149904. * Gets a string identifying the name of the class
  149905. * @returns "DepthOfFieldMergePostProcess" string
  149906. */
  149907. getClassName(): string;
  149908. /**
  149909. * Creates a new instance of DepthOfFieldMergePostProcess
  149910. * @param name The name of the effect.
  149911. * @param originalFromInput Post process which's input will be used for the merge.
  149912. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149913. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149914. * @param options The required width/height ratio to downsize to before computing the render pass.
  149915. * @param camera The camera to apply the render pass to.
  149916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149917. * @param engine The engine which the post process will be applied. (default: current engine)
  149918. * @param reusable If the post process can be reused on the same frame. (default: false)
  149919. * @param textureType Type of textures used when performing the post process. (default: 0)
  149920. * @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)
  149921. */
  149922. 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);
  149923. /**
  149924. * Updates the effect with the current post process compile time values and recompiles the shader.
  149925. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  149926. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  149927. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  149928. * @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
  149929. * @param onCompiled Called when the shader has been compiled.
  149930. * @param onError Called if there is an error when compiling a shader.
  149931. */
  149932. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  149933. }
  149934. }
  149935. declare module BABYLON {
  149936. /**
  149937. * Specifies the level of max blur that should be applied when using the depth of field effect
  149938. */
  149939. export enum DepthOfFieldEffectBlurLevel {
  149940. /**
  149941. * Subtle blur
  149942. */
  149943. Low = 0,
  149944. /**
  149945. * Medium blur
  149946. */
  149947. Medium = 1,
  149948. /**
  149949. * Large blur
  149950. */
  149951. High = 2
  149952. }
  149953. /**
  149954. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  149955. */
  149956. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  149957. private _circleOfConfusion;
  149958. /**
  149959. * @hidden Internal, blurs from high to low
  149960. */
  149961. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  149962. private _depthOfFieldBlurY;
  149963. private _dofMerge;
  149964. /**
  149965. * @hidden Internal post processes in depth of field effect
  149966. */
  149967. _effects: Array<PostProcess>;
  149968. /**
  149969. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149970. */
  149971. set focalLength(value: number);
  149972. get focalLength(): number;
  149973. /**
  149974. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149975. */
  149976. set fStop(value: number);
  149977. get fStop(): number;
  149978. /**
  149979. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149980. */
  149981. set focusDistance(value: number);
  149982. get focusDistance(): number;
  149983. /**
  149984. * 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.
  149985. */
  149986. set lensSize(value: number);
  149987. get lensSize(): number;
  149988. /**
  149989. * Creates a new instance DepthOfFieldEffect
  149990. * @param scene The scene the effect belongs to.
  149991. * @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.
  149992. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149993. * @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)
  149994. */
  149995. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149996. /**
  149997. * Get the current class name of the current effet
  149998. * @returns "DepthOfFieldEffect"
  149999. */
  150000. getClassName(): string;
  150001. /**
  150002. * 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.
  150003. */
  150004. set depthTexture(value: RenderTargetTexture);
  150005. /**
  150006. * Disposes each of the internal effects for a given camera.
  150007. * @param camera The camera to dispose the effect on.
  150008. */
  150009. disposeEffects(camera: Camera): void;
  150010. /**
  150011. * @hidden Internal
  150012. */
  150013. _updateEffects(): void;
  150014. /**
  150015. * Internal
  150016. * @returns if all the contained post processes are ready.
  150017. * @hidden
  150018. */
  150019. _isReady(): boolean;
  150020. }
  150021. }
  150022. declare module BABYLON {
  150023. /** @hidden */
  150024. export var displayPassPixelShader: {
  150025. name: string;
  150026. shader: string;
  150027. };
  150028. }
  150029. declare module BABYLON {
  150030. /**
  150031. * DisplayPassPostProcess which produces an output the same as it's input
  150032. */
  150033. export class DisplayPassPostProcess extends PostProcess {
  150034. /**
  150035. * Gets a string identifying the name of the class
  150036. * @returns "DisplayPassPostProcess" string
  150037. */
  150038. getClassName(): string;
  150039. /**
  150040. * Creates the DisplayPassPostProcess
  150041. * @param name The name of the effect.
  150042. * @param options The required width/height ratio to downsize to before computing the render pass.
  150043. * @param camera The camera to apply the render pass to.
  150044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150045. * @param engine The engine which the post process will be applied. (default: current engine)
  150046. * @param reusable If the post process can be reused on the same frame. (default: false)
  150047. */
  150048. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150049. /** @hidden */
  150050. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150051. }
  150052. }
  150053. declare module BABYLON {
  150054. /** @hidden */
  150055. export var filterPixelShader: {
  150056. name: string;
  150057. shader: string;
  150058. };
  150059. }
  150060. declare module BABYLON {
  150061. /**
  150062. * Applies a kernel filter to the image
  150063. */
  150064. export class FilterPostProcess extends PostProcess {
  150065. /** The matrix to be applied to the image */
  150066. kernelMatrix: Matrix;
  150067. /**
  150068. * Gets a string identifying the name of the class
  150069. * @returns "FilterPostProcess" string
  150070. */
  150071. getClassName(): string;
  150072. /**
  150073. *
  150074. * @param name The name of the effect.
  150075. * @param kernelMatrix The matrix to be applied to the image
  150076. * @param options The required width/height ratio to downsize to before computing the render pass.
  150077. * @param camera The camera to apply the render pass to.
  150078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150079. * @param engine The engine which the post process will be applied. (default: current engine)
  150080. * @param reusable If the post process can be reused on the same frame. (default: false)
  150081. */
  150082. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150083. /** @hidden */
  150084. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  150085. }
  150086. }
  150087. declare module BABYLON {
  150088. /** @hidden */
  150089. export var fxaaPixelShader: {
  150090. name: string;
  150091. shader: string;
  150092. };
  150093. }
  150094. declare module BABYLON {
  150095. /** @hidden */
  150096. export var fxaaVertexShader: {
  150097. name: string;
  150098. shader: string;
  150099. };
  150100. }
  150101. declare module BABYLON {
  150102. /**
  150103. * Fxaa post process
  150104. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150105. */
  150106. export class FxaaPostProcess extends PostProcess {
  150107. /**
  150108. * Gets a string identifying the name of the class
  150109. * @returns "FxaaPostProcess" string
  150110. */
  150111. getClassName(): string;
  150112. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150113. private _getDefines;
  150114. /** @hidden */
  150115. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150116. }
  150117. }
  150118. declare module BABYLON {
  150119. /** @hidden */
  150120. export var grainPixelShader: {
  150121. name: string;
  150122. shader: string;
  150123. };
  150124. }
  150125. declare module BABYLON {
  150126. /**
  150127. * The GrainPostProcess adds noise to the image at mid luminance levels
  150128. */
  150129. export class GrainPostProcess extends PostProcess {
  150130. /**
  150131. * The intensity of the grain added (default: 30)
  150132. */
  150133. intensity: number;
  150134. /**
  150135. * If the grain should be randomized on every frame
  150136. */
  150137. animated: boolean;
  150138. /**
  150139. * Gets a string identifying the name of the class
  150140. * @returns "GrainPostProcess" string
  150141. */
  150142. getClassName(): string;
  150143. /**
  150144. * Creates a new instance of @see GrainPostProcess
  150145. * @param name The name of the effect.
  150146. * @param options The required width/height ratio to downsize to before computing the render pass.
  150147. * @param camera The camera to apply the render pass to.
  150148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150149. * @param engine The engine which the post process will be applied. (default: current engine)
  150150. * @param reusable If the post process can be reused on the same frame. (default: false)
  150151. * @param textureType Type of textures used when performing the post process. (default: 0)
  150152. * @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)
  150153. */
  150154. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150155. /** @hidden */
  150156. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150157. }
  150158. }
  150159. declare module BABYLON {
  150160. /** @hidden */
  150161. export var highlightsPixelShader: {
  150162. name: string;
  150163. shader: string;
  150164. };
  150165. }
  150166. declare module BABYLON {
  150167. /**
  150168. * Extracts highlights from the image
  150169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150170. */
  150171. export class HighlightsPostProcess extends PostProcess {
  150172. /**
  150173. * Gets a string identifying the name of the class
  150174. * @returns "HighlightsPostProcess" string
  150175. */
  150176. getClassName(): string;
  150177. /**
  150178. * Extracts highlights from the image
  150179. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150180. * @param name The name of the effect.
  150181. * @param options The required width/height ratio to downsize to before computing the render pass.
  150182. * @param camera The camera to apply the render pass to.
  150183. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150184. * @param engine The engine which the post process will be applied. (default: current engine)
  150185. * @param reusable If the post process can be reused on the same frame. (default: false)
  150186. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  150187. */
  150188. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150189. }
  150190. }
  150191. declare module BABYLON {
  150192. /** @hidden */
  150193. export var mrtFragmentDeclaration: {
  150194. name: string;
  150195. shader: string;
  150196. };
  150197. }
  150198. declare module BABYLON {
  150199. /** @hidden */
  150200. export var geometryPixelShader: {
  150201. name: string;
  150202. shader: string;
  150203. };
  150204. }
  150205. declare module BABYLON {
  150206. /** @hidden */
  150207. export var geometryVertexShader: {
  150208. name: string;
  150209. shader: string;
  150210. };
  150211. }
  150212. declare module BABYLON {
  150213. /** @hidden */
  150214. interface ISavedTransformationMatrix {
  150215. world: Matrix;
  150216. viewProjection: Matrix;
  150217. }
  150218. /**
  150219. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  150220. */
  150221. export class GeometryBufferRenderer {
  150222. /**
  150223. * Constant used to retrieve the position texture index in the G-Buffer textures array
  150224. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  150225. */
  150226. static readonly POSITION_TEXTURE_TYPE: number;
  150227. /**
  150228. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  150229. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  150230. */
  150231. static readonly VELOCITY_TEXTURE_TYPE: number;
  150232. /**
  150233. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  150234. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  150235. */
  150236. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  150237. /**
  150238. * Dictionary used to store the previous transformation matrices of each rendered mesh
  150239. * in order to compute objects velocities when enableVelocity is set to "true"
  150240. * @hidden
  150241. */
  150242. _previousTransformationMatrices: {
  150243. [index: number]: ISavedTransformationMatrix;
  150244. };
  150245. /**
  150246. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  150247. * in order to compute objects velocities when enableVelocity is set to "true"
  150248. * @hidden
  150249. */
  150250. _previousBonesTransformationMatrices: {
  150251. [index: number]: Float32Array;
  150252. };
  150253. /**
  150254. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  150255. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  150256. */
  150257. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  150258. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  150259. renderTransparentMeshes: boolean;
  150260. private _scene;
  150261. private _resizeObserver;
  150262. private _multiRenderTarget;
  150263. private _ratio;
  150264. private _enablePosition;
  150265. private _enableVelocity;
  150266. private _enableReflectivity;
  150267. private _positionIndex;
  150268. private _velocityIndex;
  150269. private _reflectivityIndex;
  150270. protected _effect: Effect;
  150271. protected _cachedDefines: string;
  150272. /**
  150273. * Set the render list (meshes to be rendered) used in the G buffer.
  150274. */
  150275. set renderList(meshes: Mesh[]);
  150276. /**
  150277. * Gets wether or not G buffer are supported by the running hardware.
  150278. * This requires draw buffer supports
  150279. */
  150280. get isSupported(): boolean;
  150281. /**
  150282. * Returns the index of the given texture type in the G-Buffer textures array
  150283. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  150284. * @returns the index of the given texture type in the G-Buffer textures array
  150285. */
  150286. getTextureIndex(textureType: number): number;
  150287. /**
  150288. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  150289. */
  150290. get enablePosition(): boolean;
  150291. /**
  150292. * Sets whether or not objects positions are enabled for the G buffer.
  150293. */
  150294. set enablePosition(enable: boolean);
  150295. /**
  150296. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  150297. */
  150298. get enableVelocity(): boolean;
  150299. /**
  150300. * Sets wether or not objects velocities are enabled for the G buffer.
  150301. */
  150302. set enableVelocity(enable: boolean);
  150303. /**
  150304. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  150305. */
  150306. get enableReflectivity(): boolean;
  150307. /**
  150308. * Sets wether or not objects roughness are enabled for the G buffer.
  150309. */
  150310. set enableReflectivity(enable: boolean);
  150311. /**
  150312. * Gets the scene associated with the buffer.
  150313. */
  150314. get scene(): Scene;
  150315. /**
  150316. * Gets the ratio used by the buffer during its creation.
  150317. * How big is the buffer related to the main canvas.
  150318. */
  150319. get ratio(): number;
  150320. /** @hidden */
  150321. static _SceneComponentInitialization: (scene: Scene) => void;
  150322. /**
  150323. * Creates a new G Buffer for the scene
  150324. * @param scene The scene the buffer belongs to
  150325. * @param ratio How big is the buffer related to the main canvas.
  150326. */
  150327. constructor(scene: Scene, ratio?: number);
  150328. /**
  150329. * Checks wether everything is ready to render a submesh to the G buffer.
  150330. * @param subMesh the submesh to check readiness for
  150331. * @param useInstances is the mesh drawn using instance or not
  150332. * @returns true if ready otherwise false
  150333. */
  150334. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150335. /**
  150336. * Gets the current underlying G Buffer.
  150337. * @returns the buffer
  150338. */
  150339. getGBuffer(): MultiRenderTarget;
  150340. /**
  150341. * Gets the number of samples used to render the buffer (anti aliasing).
  150342. */
  150343. get samples(): number;
  150344. /**
  150345. * Sets the number of samples used to render the buffer (anti aliasing).
  150346. */
  150347. set samples(value: number);
  150348. /**
  150349. * Disposes the renderer and frees up associated resources.
  150350. */
  150351. dispose(): void;
  150352. protected _createRenderTargets(): void;
  150353. private _copyBonesTransformationMatrices;
  150354. }
  150355. }
  150356. declare module BABYLON {
  150357. interface Scene {
  150358. /** @hidden (Backing field) */
  150359. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150360. /**
  150361. * Gets or Sets the current geometry buffer associated to the scene.
  150362. */
  150363. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150364. /**
  150365. * Enables a GeometryBufferRender and associates it with the scene
  150366. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  150367. * @returns the GeometryBufferRenderer
  150368. */
  150369. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  150370. /**
  150371. * Disables the GeometryBufferRender associated with the scene
  150372. */
  150373. disableGeometryBufferRenderer(): void;
  150374. }
  150375. /**
  150376. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150377. * in several rendering techniques.
  150378. */
  150379. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  150380. /**
  150381. * The component name helpful to identify the component in the list of scene components.
  150382. */
  150383. readonly name: string;
  150384. /**
  150385. * The scene the component belongs to.
  150386. */
  150387. scene: Scene;
  150388. /**
  150389. * Creates a new instance of the component for the given scene
  150390. * @param scene Defines the scene to register the component in
  150391. */
  150392. constructor(scene: Scene);
  150393. /**
  150394. * Registers the component in a given scene
  150395. */
  150396. register(): void;
  150397. /**
  150398. * Rebuilds the elements related to this component in case of
  150399. * context lost for instance.
  150400. */
  150401. rebuild(): void;
  150402. /**
  150403. * Disposes the component and the associated ressources
  150404. */
  150405. dispose(): void;
  150406. private _gatherRenderTargets;
  150407. }
  150408. }
  150409. declare module BABYLON {
  150410. /** @hidden */
  150411. export var motionBlurPixelShader: {
  150412. name: string;
  150413. shader: string;
  150414. };
  150415. }
  150416. declare module BABYLON {
  150417. /**
  150418. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  150419. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  150420. * As an example, all you have to do is to create the post-process:
  150421. * var mb = new BABYLON.MotionBlurPostProcess(
  150422. * 'mb', // The name of the effect.
  150423. * scene, // The scene containing the objects to blur according to their velocity.
  150424. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  150425. * camera // The camera to apply the render pass to.
  150426. * );
  150427. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  150428. */
  150429. export class MotionBlurPostProcess extends PostProcess {
  150430. /**
  150431. * Defines how much the image is blurred by the movement. Default value is equal to 1
  150432. */
  150433. motionStrength: number;
  150434. /**
  150435. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  150436. */
  150437. get motionBlurSamples(): number;
  150438. /**
  150439. * Sets the number of iterations to be used for motion blur quality
  150440. */
  150441. set motionBlurSamples(samples: number);
  150442. private _motionBlurSamples;
  150443. private _geometryBufferRenderer;
  150444. /**
  150445. * Gets a string identifying the name of the class
  150446. * @returns "MotionBlurPostProcess" string
  150447. */
  150448. getClassName(): string;
  150449. /**
  150450. * Creates a new instance MotionBlurPostProcess
  150451. * @param name The name of the effect.
  150452. * @param scene The scene containing the objects to blur according to their velocity.
  150453. * @param options The required width/height ratio to downsize to before computing the render pass.
  150454. * @param camera The camera to apply the render pass to.
  150455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150456. * @param engine The engine which the post process will be applied. (default: current engine)
  150457. * @param reusable If the post process can be reused on the same frame. (default: false)
  150458. * @param textureType Type of textures used when performing the post process. (default: 0)
  150459. * @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)
  150460. */
  150461. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150462. /**
  150463. * Excludes the given skinned mesh from computing bones velocities.
  150464. * 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.
  150465. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  150466. */
  150467. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150468. /**
  150469. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  150470. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  150471. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  150472. */
  150473. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150474. /**
  150475. * Disposes the post process.
  150476. * @param camera The camera to dispose the post process on.
  150477. */
  150478. dispose(camera?: Camera): void;
  150479. /** @hidden */
  150480. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  150481. }
  150482. }
  150483. declare module BABYLON {
  150484. /** @hidden */
  150485. export var refractionPixelShader: {
  150486. name: string;
  150487. shader: string;
  150488. };
  150489. }
  150490. declare module BABYLON {
  150491. /**
  150492. * Post process which applies a refractin texture
  150493. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150494. */
  150495. export class RefractionPostProcess extends PostProcess {
  150496. private _refTexture;
  150497. private _ownRefractionTexture;
  150498. /** the base color of the refraction (used to taint the rendering) */
  150499. color: Color3;
  150500. /** simulated refraction depth */
  150501. depth: number;
  150502. /** the coefficient of the base color (0 to remove base color tainting) */
  150503. colorLevel: number;
  150504. /** Gets the url used to load the refraction texture */
  150505. refractionTextureUrl: string;
  150506. /**
  150507. * Gets or sets the refraction texture
  150508. * Please note that you are responsible for disposing the texture if you set it manually
  150509. */
  150510. get refractionTexture(): Texture;
  150511. set refractionTexture(value: Texture);
  150512. /**
  150513. * Gets a string identifying the name of the class
  150514. * @returns "RefractionPostProcess" string
  150515. */
  150516. getClassName(): string;
  150517. /**
  150518. * Initializes the RefractionPostProcess
  150519. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150520. * @param name The name of the effect.
  150521. * @param refractionTextureUrl Url of the refraction texture to use
  150522. * @param color the base color of the refraction (used to taint the rendering)
  150523. * @param depth simulated refraction depth
  150524. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150525. * @param camera The camera to apply the render pass to.
  150526. * @param options The required width/height ratio to downsize to before computing the render pass.
  150527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150528. * @param engine The engine which the post process will be applied. (default: current engine)
  150529. * @param reusable If the post process can be reused on the same frame. (default: false)
  150530. */
  150531. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150532. /**
  150533. * Disposes of the post process
  150534. * @param camera Camera to dispose post process on
  150535. */
  150536. dispose(camera: Camera): void;
  150537. /** @hidden */
  150538. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150539. }
  150540. }
  150541. declare module BABYLON {
  150542. /** @hidden */
  150543. export var sharpenPixelShader: {
  150544. name: string;
  150545. shader: string;
  150546. };
  150547. }
  150548. declare module BABYLON {
  150549. /**
  150550. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150551. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150552. */
  150553. export class SharpenPostProcess extends PostProcess {
  150554. /**
  150555. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150556. */
  150557. colorAmount: number;
  150558. /**
  150559. * How much sharpness should be applied (default: 0.3)
  150560. */
  150561. edgeAmount: number;
  150562. /**
  150563. * Gets a string identifying the name of the class
  150564. * @returns "SharpenPostProcess" string
  150565. */
  150566. getClassName(): string;
  150567. /**
  150568. * Creates a new instance ConvolutionPostProcess
  150569. * @param name The name of the effect.
  150570. * @param options The required width/height ratio to downsize to before computing the render pass.
  150571. * @param camera The camera to apply the render pass to.
  150572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150573. * @param engine The engine which the post process will be applied. (default: current engine)
  150574. * @param reusable If the post process can be reused on the same frame. (default: false)
  150575. * @param textureType Type of textures used when performing the post process. (default: 0)
  150576. * @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)
  150577. */
  150578. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150579. /** @hidden */
  150580. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150581. }
  150582. }
  150583. declare module BABYLON {
  150584. /**
  150585. * PostProcessRenderPipeline
  150586. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150587. */
  150588. export class PostProcessRenderPipeline {
  150589. private engine;
  150590. private _renderEffects;
  150591. private _renderEffectsForIsolatedPass;
  150592. /**
  150593. * List of inspectable custom properties (used by the Inspector)
  150594. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  150595. */
  150596. inspectableCustomProperties: IInspectable[];
  150597. /**
  150598. * @hidden
  150599. */
  150600. protected _cameras: Camera[];
  150601. /** @hidden */
  150602. _name: string;
  150603. /**
  150604. * Gets pipeline name
  150605. */
  150606. get name(): string;
  150607. /** Gets the list of attached cameras */
  150608. get cameras(): Camera[];
  150609. /**
  150610. * Initializes a PostProcessRenderPipeline
  150611. * @param engine engine to add the pipeline to
  150612. * @param name name of the pipeline
  150613. */
  150614. constructor(engine: Engine, name: string);
  150615. /**
  150616. * Gets the class name
  150617. * @returns "PostProcessRenderPipeline"
  150618. */
  150619. getClassName(): string;
  150620. /**
  150621. * If all the render effects in the pipeline are supported
  150622. */
  150623. get isSupported(): boolean;
  150624. /**
  150625. * Adds an effect to the pipeline
  150626. * @param renderEffect the effect to add
  150627. */
  150628. addEffect(renderEffect: PostProcessRenderEffect): void;
  150629. /** @hidden */
  150630. _rebuild(): void;
  150631. /** @hidden */
  150632. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150633. /** @hidden */
  150634. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  150635. /** @hidden */
  150636. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150637. /** @hidden */
  150638. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150639. /** @hidden */
  150640. _attachCameras(cameras: Camera, unique: boolean): void;
  150641. /** @hidden */
  150642. _attachCameras(cameras: Camera[], unique: boolean): void;
  150643. /** @hidden */
  150644. _detachCameras(cameras: Camera): void;
  150645. /** @hidden */
  150646. _detachCameras(cameras: Nullable<Camera[]>): void;
  150647. /** @hidden */
  150648. _update(): void;
  150649. /** @hidden */
  150650. _reset(): void;
  150651. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  150652. /**
  150653. * Sets the required values to the prepass renderer.
  150654. * @param prePassRenderer defines the prepass renderer to setup.
  150655. * @returns true if the pre pass is needed.
  150656. */
  150657. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150658. /**
  150659. * Disposes of the pipeline
  150660. */
  150661. dispose(): void;
  150662. }
  150663. }
  150664. declare module BABYLON {
  150665. /**
  150666. * PostProcessRenderPipelineManager class
  150667. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150668. */
  150669. export class PostProcessRenderPipelineManager {
  150670. private _renderPipelines;
  150671. /**
  150672. * Initializes a PostProcessRenderPipelineManager
  150673. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150674. */
  150675. constructor();
  150676. /**
  150677. * Gets the list of supported render pipelines
  150678. */
  150679. get supportedPipelines(): PostProcessRenderPipeline[];
  150680. /**
  150681. * Adds a pipeline to the manager
  150682. * @param renderPipeline The pipeline to add
  150683. */
  150684. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  150685. /**
  150686. * Attaches a camera to the pipeline
  150687. * @param renderPipelineName The name of the pipeline to attach to
  150688. * @param cameras the camera to attach
  150689. * @param unique if the camera can be attached multiple times to the pipeline
  150690. */
  150691. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  150692. /**
  150693. * Detaches a camera from the pipeline
  150694. * @param renderPipelineName The name of the pipeline to detach from
  150695. * @param cameras the camera to detach
  150696. */
  150697. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  150698. /**
  150699. * Enables an effect by name on a pipeline
  150700. * @param renderPipelineName the name of the pipeline to enable the effect in
  150701. * @param renderEffectName the name of the effect to enable
  150702. * @param cameras the cameras that the effect should be enabled on
  150703. */
  150704. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150705. /**
  150706. * Disables an effect by name on a pipeline
  150707. * @param renderPipelineName the name of the pipeline to disable the effect in
  150708. * @param renderEffectName the name of the effect to disable
  150709. * @param cameras the cameras that the effect should be disabled on
  150710. */
  150711. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150712. /**
  150713. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  150714. */
  150715. update(): void;
  150716. /** @hidden */
  150717. _rebuild(): void;
  150718. /**
  150719. * Disposes of the manager and pipelines
  150720. */
  150721. dispose(): void;
  150722. }
  150723. }
  150724. declare module BABYLON {
  150725. interface Scene {
  150726. /** @hidden (Backing field) */
  150727. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150728. /**
  150729. * Gets the postprocess render pipeline manager
  150730. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150731. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150732. */
  150733. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150734. }
  150735. /**
  150736. * Defines the Render Pipeline scene component responsible to rendering pipelines
  150737. */
  150738. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  150739. /**
  150740. * The component name helpfull to identify the component in the list of scene components.
  150741. */
  150742. readonly name: string;
  150743. /**
  150744. * The scene the component belongs to.
  150745. */
  150746. scene: Scene;
  150747. /**
  150748. * Creates a new instance of the component for the given scene
  150749. * @param scene Defines the scene to register the component in
  150750. */
  150751. constructor(scene: Scene);
  150752. /**
  150753. * Registers the component in a given scene
  150754. */
  150755. register(): void;
  150756. /**
  150757. * Rebuilds the elements related to this component in case of
  150758. * context lost for instance.
  150759. */
  150760. rebuild(): void;
  150761. /**
  150762. * Disposes the component and the associated ressources
  150763. */
  150764. dispose(): void;
  150765. private _gatherRenderTargets;
  150766. }
  150767. }
  150768. declare module BABYLON {
  150769. /**
  150770. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  150771. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150772. */
  150773. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150774. private _scene;
  150775. private _camerasToBeAttached;
  150776. /**
  150777. * ID of the sharpen post process,
  150778. */
  150779. private readonly SharpenPostProcessId;
  150780. /**
  150781. * @ignore
  150782. * ID of the image processing post process;
  150783. */
  150784. readonly ImageProcessingPostProcessId: string;
  150785. /**
  150786. * @ignore
  150787. * ID of the Fast Approximate Anti-Aliasing post process;
  150788. */
  150789. readonly FxaaPostProcessId: string;
  150790. /**
  150791. * ID of the chromatic aberration post process,
  150792. */
  150793. private readonly ChromaticAberrationPostProcessId;
  150794. /**
  150795. * ID of the grain post process
  150796. */
  150797. private readonly GrainPostProcessId;
  150798. /**
  150799. * Sharpen post process which will apply a sharpen convolution to enhance edges
  150800. */
  150801. sharpen: SharpenPostProcess;
  150802. private _sharpenEffect;
  150803. private bloom;
  150804. /**
  150805. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  150806. */
  150807. depthOfField: DepthOfFieldEffect;
  150808. /**
  150809. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150810. */
  150811. fxaa: FxaaPostProcess;
  150812. /**
  150813. * Image post processing pass used to perform operations such as tone mapping or color grading.
  150814. */
  150815. imageProcessing: ImageProcessingPostProcess;
  150816. /**
  150817. * Chromatic aberration post process which will shift rgb colors in the image
  150818. */
  150819. chromaticAberration: ChromaticAberrationPostProcess;
  150820. private _chromaticAberrationEffect;
  150821. /**
  150822. * Grain post process which add noise to the image
  150823. */
  150824. grain: GrainPostProcess;
  150825. private _grainEffect;
  150826. /**
  150827. * Glow post process which adds a glow to emissive areas of the image
  150828. */
  150829. private _glowLayer;
  150830. /**
  150831. * Animations which can be used to tweak settings over a period of time
  150832. */
  150833. animations: Animation[];
  150834. private _imageProcessingConfigurationObserver;
  150835. private _sharpenEnabled;
  150836. private _bloomEnabled;
  150837. private _depthOfFieldEnabled;
  150838. private _depthOfFieldBlurLevel;
  150839. private _fxaaEnabled;
  150840. private _imageProcessingEnabled;
  150841. private _defaultPipelineTextureType;
  150842. private _bloomScale;
  150843. private _chromaticAberrationEnabled;
  150844. private _grainEnabled;
  150845. private _buildAllowed;
  150846. /**
  150847. * Gets active scene
  150848. */
  150849. get scene(): Scene;
  150850. /**
  150851. * Enable or disable the sharpen process from the pipeline
  150852. */
  150853. set sharpenEnabled(enabled: boolean);
  150854. get sharpenEnabled(): boolean;
  150855. private _resizeObserver;
  150856. private _hardwareScaleLevel;
  150857. private _bloomKernel;
  150858. /**
  150859. * Specifies the size of the bloom blur kernel, relative to the final output size
  150860. */
  150861. get bloomKernel(): number;
  150862. set bloomKernel(value: number);
  150863. /**
  150864. * Specifies the weight of the bloom in the final rendering
  150865. */
  150866. private _bloomWeight;
  150867. /**
  150868. * Specifies the luma threshold for the area that will be blurred by the bloom
  150869. */
  150870. private _bloomThreshold;
  150871. private _hdr;
  150872. /**
  150873. * The strength of the bloom.
  150874. */
  150875. set bloomWeight(value: number);
  150876. get bloomWeight(): number;
  150877. /**
  150878. * The strength of the bloom.
  150879. */
  150880. set bloomThreshold(value: number);
  150881. get bloomThreshold(): number;
  150882. /**
  150883. * The scale of the bloom, lower value will provide better performance.
  150884. */
  150885. set bloomScale(value: number);
  150886. get bloomScale(): number;
  150887. /**
  150888. * Enable or disable the bloom from the pipeline
  150889. */
  150890. set bloomEnabled(enabled: boolean);
  150891. get bloomEnabled(): boolean;
  150892. private _rebuildBloom;
  150893. /**
  150894. * If the depth of field is enabled.
  150895. */
  150896. get depthOfFieldEnabled(): boolean;
  150897. set depthOfFieldEnabled(enabled: boolean);
  150898. /**
  150899. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150900. */
  150901. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150902. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150903. /**
  150904. * If the anti aliasing is enabled.
  150905. */
  150906. set fxaaEnabled(enabled: boolean);
  150907. get fxaaEnabled(): boolean;
  150908. private _samples;
  150909. /**
  150910. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150911. */
  150912. set samples(sampleCount: number);
  150913. get samples(): number;
  150914. /**
  150915. * If image processing is enabled.
  150916. */
  150917. set imageProcessingEnabled(enabled: boolean);
  150918. get imageProcessingEnabled(): boolean;
  150919. /**
  150920. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150921. */
  150922. set glowLayerEnabled(enabled: boolean);
  150923. get glowLayerEnabled(): boolean;
  150924. /**
  150925. * Gets the glow layer (or null if not defined)
  150926. */
  150927. get glowLayer(): Nullable<GlowLayer>;
  150928. /**
  150929. * Enable or disable the chromaticAberration process from the pipeline
  150930. */
  150931. set chromaticAberrationEnabled(enabled: boolean);
  150932. get chromaticAberrationEnabled(): boolean;
  150933. /**
  150934. * Enable or disable the grain process from the pipeline
  150935. */
  150936. set grainEnabled(enabled: boolean);
  150937. get grainEnabled(): boolean;
  150938. /**
  150939. * @constructor
  150940. * @param name - The rendering pipeline name (default: "")
  150941. * @param hdr - If high dynamic range textures should be used (default: true)
  150942. * @param scene - The scene linked to this pipeline (default: the last created scene)
  150943. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  150944. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  150945. */
  150946. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  150947. /**
  150948. * Get the class name
  150949. * @returns "DefaultRenderingPipeline"
  150950. */
  150951. getClassName(): string;
  150952. /**
  150953. * Force the compilation of the entire pipeline.
  150954. */
  150955. prepare(): void;
  150956. private _hasCleared;
  150957. private _prevPostProcess;
  150958. private _prevPrevPostProcess;
  150959. private _setAutoClearAndTextureSharing;
  150960. private _depthOfFieldSceneObserver;
  150961. private _buildPipeline;
  150962. private _disposePostProcesses;
  150963. /**
  150964. * Adds a camera to the pipeline
  150965. * @param camera the camera to be added
  150966. */
  150967. addCamera(camera: Camera): void;
  150968. /**
  150969. * Removes a camera from the pipeline
  150970. * @param camera the camera to remove
  150971. */
  150972. removeCamera(camera: Camera): void;
  150973. /**
  150974. * Dispose of the pipeline and stop all post processes
  150975. */
  150976. dispose(): void;
  150977. /**
  150978. * Serialize the rendering pipeline (Used when exporting)
  150979. * @returns the serialized object
  150980. */
  150981. serialize(): any;
  150982. /**
  150983. * Parse the serialized pipeline
  150984. * @param source Source pipeline.
  150985. * @param scene The scene to load the pipeline to.
  150986. * @param rootUrl The URL of the serialized pipeline.
  150987. * @returns An instantiated pipeline from the serialized object.
  150988. */
  150989. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150990. }
  150991. }
  150992. declare module BABYLON {
  150993. /** @hidden */
  150994. export var lensHighlightsPixelShader: {
  150995. name: string;
  150996. shader: string;
  150997. };
  150998. }
  150999. declare module BABYLON {
  151000. /** @hidden */
  151001. export var depthOfFieldPixelShader: {
  151002. name: string;
  151003. shader: string;
  151004. };
  151005. }
  151006. declare module BABYLON {
  151007. /**
  151008. * BABYLON.JS Chromatic Aberration GLSL Shader
  151009. * Author: Olivier Guyot
  151010. * Separates very slightly R, G and B colors on the edges of the screen
  151011. * Inspired by Francois Tarlier & Martins Upitis
  151012. */
  151013. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151014. /**
  151015. * @ignore
  151016. * The chromatic aberration PostProcess id in the pipeline
  151017. */
  151018. LensChromaticAberrationEffect: string;
  151019. /**
  151020. * @ignore
  151021. * The highlights enhancing PostProcess id in the pipeline
  151022. */
  151023. HighlightsEnhancingEffect: string;
  151024. /**
  151025. * @ignore
  151026. * The depth-of-field PostProcess id in the pipeline
  151027. */
  151028. LensDepthOfFieldEffect: string;
  151029. private _scene;
  151030. private _depthTexture;
  151031. private _grainTexture;
  151032. private _chromaticAberrationPostProcess;
  151033. private _highlightsPostProcess;
  151034. private _depthOfFieldPostProcess;
  151035. private _edgeBlur;
  151036. private _grainAmount;
  151037. private _chromaticAberration;
  151038. private _distortion;
  151039. private _highlightsGain;
  151040. private _highlightsThreshold;
  151041. private _dofDistance;
  151042. private _dofAperture;
  151043. private _dofDarken;
  151044. private _dofPentagon;
  151045. private _blurNoise;
  151046. /**
  151047. * @constructor
  151048. *
  151049. * Effect parameters are as follow:
  151050. * {
  151051. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151052. * edge_blur: number; // from 0 to x (1 for realism)
  151053. * distortion: number; // from 0 to x (1 for realism)
  151054. * grain_amount: number; // from 0 to 1
  151055. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151056. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151057. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151058. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151059. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151060. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151061. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151062. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151063. * }
  151064. * Note: if an effect parameter is unset, effect is disabled
  151065. *
  151066. * @param name The rendering pipeline name
  151067. * @param parameters - An object containing all parameters (see above)
  151068. * @param scene The scene linked to this pipeline
  151069. * @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)
  151070. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151071. */
  151072. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151073. /**
  151074. * Get the class name
  151075. * @returns "LensRenderingPipeline"
  151076. */
  151077. getClassName(): string;
  151078. /**
  151079. * Gets associated scene
  151080. */
  151081. get scene(): Scene;
  151082. /**
  151083. * Gets or sets the edge blur
  151084. */
  151085. get edgeBlur(): number;
  151086. set edgeBlur(value: number);
  151087. /**
  151088. * Gets or sets the grain amount
  151089. */
  151090. get grainAmount(): number;
  151091. set grainAmount(value: number);
  151092. /**
  151093. * Gets or sets the chromatic aberration amount
  151094. */
  151095. get chromaticAberration(): number;
  151096. set chromaticAberration(value: number);
  151097. /**
  151098. * Gets or sets the depth of field aperture
  151099. */
  151100. get dofAperture(): number;
  151101. set dofAperture(value: number);
  151102. /**
  151103. * Gets or sets the edge distortion
  151104. */
  151105. get edgeDistortion(): number;
  151106. set edgeDistortion(value: number);
  151107. /**
  151108. * Gets or sets the depth of field distortion
  151109. */
  151110. get dofDistortion(): number;
  151111. set dofDistortion(value: number);
  151112. /**
  151113. * Gets or sets the darken out of focus amount
  151114. */
  151115. get darkenOutOfFocus(): number;
  151116. set darkenOutOfFocus(value: number);
  151117. /**
  151118. * Gets or sets a boolean indicating if blur noise is enabled
  151119. */
  151120. get blurNoise(): boolean;
  151121. set blurNoise(value: boolean);
  151122. /**
  151123. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151124. */
  151125. get pentagonBokeh(): boolean;
  151126. set pentagonBokeh(value: boolean);
  151127. /**
  151128. * Gets or sets the highlight grain amount
  151129. */
  151130. get highlightsGain(): number;
  151131. set highlightsGain(value: number);
  151132. /**
  151133. * Gets or sets the highlight threshold
  151134. */
  151135. get highlightsThreshold(): number;
  151136. set highlightsThreshold(value: number);
  151137. /**
  151138. * Sets the amount of blur at the edges
  151139. * @param amount blur amount
  151140. */
  151141. setEdgeBlur(amount: number): void;
  151142. /**
  151143. * Sets edge blur to 0
  151144. */
  151145. disableEdgeBlur(): void;
  151146. /**
  151147. * Sets the amout of grain
  151148. * @param amount Amount of grain
  151149. */
  151150. setGrainAmount(amount: number): void;
  151151. /**
  151152. * Set grain amount to 0
  151153. */
  151154. disableGrain(): void;
  151155. /**
  151156. * Sets the chromatic aberration amount
  151157. * @param amount amount of chromatic aberration
  151158. */
  151159. setChromaticAberration(amount: number): void;
  151160. /**
  151161. * Sets chromatic aberration amount to 0
  151162. */
  151163. disableChromaticAberration(): void;
  151164. /**
  151165. * Sets the EdgeDistortion amount
  151166. * @param amount amount of EdgeDistortion
  151167. */
  151168. setEdgeDistortion(amount: number): void;
  151169. /**
  151170. * Sets edge distortion to 0
  151171. */
  151172. disableEdgeDistortion(): void;
  151173. /**
  151174. * Sets the FocusDistance amount
  151175. * @param amount amount of FocusDistance
  151176. */
  151177. setFocusDistance(amount: number): void;
  151178. /**
  151179. * Disables depth of field
  151180. */
  151181. disableDepthOfField(): void;
  151182. /**
  151183. * Sets the Aperture amount
  151184. * @param amount amount of Aperture
  151185. */
  151186. setAperture(amount: number): void;
  151187. /**
  151188. * Sets the DarkenOutOfFocus amount
  151189. * @param amount amount of DarkenOutOfFocus
  151190. */
  151191. setDarkenOutOfFocus(amount: number): void;
  151192. private _pentagonBokehIsEnabled;
  151193. /**
  151194. * Creates a pentagon bokeh effect
  151195. */
  151196. enablePentagonBokeh(): void;
  151197. /**
  151198. * Disables the pentagon bokeh effect
  151199. */
  151200. disablePentagonBokeh(): void;
  151201. /**
  151202. * Enables noise blur
  151203. */
  151204. enableNoiseBlur(): void;
  151205. /**
  151206. * Disables noise blur
  151207. */
  151208. disableNoiseBlur(): void;
  151209. /**
  151210. * Sets the HighlightsGain amount
  151211. * @param amount amount of HighlightsGain
  151212. */
  151213. setHighlightsGain(amount: number): void;
  151214. /**
  151215. * Sets the HighlightsThreshold amount
  151216. * @param amount amount of HighlightsThreshold
  151217. */
  151218. setHighlightsThreshold(amount: number): void;
  151219. /**
  151220. * Disables highlights
  151221. */
  151222. disableHighlights(): void;
  151223. /**
  151224. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151225. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151226. */
  151227. dispose(disableDepthRender?: boolean): void;
  151228. private _createChromaticAberrationPostProcess;
  151229. private _createHighlightsPostProcess;
  151230. private _createDepthOfFieldPostProcess;
  151231. private _createGrainTexture;
  151232. }
  151233. }
  151234. declare module BABYLON {
  151235. /**
  151236. * Contains all parameters needed for the prepass to perform
  151237. * screen space subsurface scattering
  151238. */
  151239. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151240. /**
  151241. * Is subsurface enabled
  151242. */
  151243. enabled: boolean;
  151244. /**
  151245. * Name of the configuration
  151246. */
  151247. name: string;
  151248. /**
  151249. * Textures that should be present in the MRT for this effect to work
  151250. */
  151251. readonly texturesRequired: number[];
  151252. /**
  151253. * Builds a ssao2 configuration object
  151254. * @param scene The scene
  151255. */
  151256. constructor();
  151257. /**
  151258. * Disposes the configuration
  151259. */
  151260. dispose(): void;
  151261. }
  151262. }
  151263. declare module BABYLON {
  151264. /** @hidden */
  151265. export var ssao2PixelShader: {
  151266. name: string;
  151267. shader: string;
  151268. };
  151269. }
  151270. declare module BABYLON {
  151271. /** @hidden */
  151272. export var ssaoCombinePixelShader: {
  151273. name: string;
  151274. shader: string;
  151275. };
  151276. }
  151277. declare module BABYLON {
  151278. /**
  151279. * Render pipeline to produce ssao effect
  151280. */
  151281. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151282. /**
  151283. * @ignore
  151284. * The PassPostProcess id in the pipeline that contains the original scene color
  151285. */
  151286. SSAOOriginalSceneColorEffect: string;
  151287. /**
  151288. * @ignore
  151289. * The SSAO PostProcess id in the pipeline
  151290. */
  151291. SSAORenderEffect: string;
  151292. /**
  151293. * @ignore
  151294. * The horizontal blur PostProcess id in the pipeline
  151295. */
  151296. SSAOBlurHRenderEffect: string;
  151297. /**
  151298. * @ignore
  151299. * The vertical blur PostProcess id in the pipeline
  151300. */
  151301. SSAOBlurVRenderEffect: string;
  151302. /**
  151303. * @ignore
  151304. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151305. */
  151306. SSAOCombineRenderEffect: string;
  151307. /**
  151308. * The output strength of the SSAO post-process. Default value is 1.0.
  151309. */
  151310. totalStrength: number;
  151311. /**
  151312. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151313. */
  151314. maxZ: number;
  151315. /**
  151316. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151317. */
  151318. minZAspect: number;
  151319. private _samples;
  151320. /**
  151321. * Number of samples used for the SSAO calculations. Default value is 8
  151322. */
  151323. set samples(n: number);
  151324. get samples(): number;
  151325. private _textureSamples;
  151326. /**
  151327. * Number of samples to use for antialiasing
  151328. */
  151329. set textureSamples(n: number);
  151330. get textureSamples(): number;
  151331. /**
  151332. * Force rendering the geometry through geometry buffer
  151333. */
  151334. private _forceGeometryBuffer;
  151335. /**
  151336. * Ratio object used for SSAO ratio and blur ratio
  151337. */
  151338. private _ratio;
  151339. /**
  151340. * Dynamically generated sphere sampler.
  151341. */
  151342. private _sampleSphere;
  151343. private _ssao2PrePassConfiguration;
  151344. /**
  151345. * Blur filter offsets
  151346. */
  151347. private _samplerOffsets;
  151348. private _expensiveBlur;
  151349. /**
  151350. * If bilateral blur should be used
  151351. */
  151352. set expensiveBlur(b: boolean);
  151353. get expensiveBlur(): boolean;
  151354. /**
  151355. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  151356. */
  151357. radius: number;
  151358. /**
  151359. * The base color of the SSAO post-process
  151360. * The final result is "base + ssao" between [0, 1]
  151361. */
  151362. base: number;
  151363. /**
  151364. * Support test.
  151365. */
  151366. static get IsSupported(): boolean;
  151367. private _scene;
  151368. private _randomTexture;
  151369. private _originalColorPostProcess;
  151370. private _ssaoPostProcess;
  151371. private _blurHPostProcess;
  151372. private _blurVPostProcess;
  151373. private _ssaoCombinePostProcess;
  151374. private _prePassRenderer;
  151375. /**
  151376. * Gets active scene
  151377. */
  151378. get scene(): Scene;
  151379. /**
  151380. * @constructor
  151381. * @param name The rendering pipeline name
  151382. * @param scene The scene linked to this pipeline
  151383. * @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 }
  151384. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151385. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  151386. */
  151387. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  151388. /**
  151389. * Get the class name
  151390. * @returns "SSAO2RenderingPipeline"
  151391. */
  151392. getClassName(): string;
  151393. /**
  151394. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151395. */
  151396. dispose(disableGeometryBufferRenderer?: boolean): void;
  151397. private _createBlurPostProcess;
  151398. /** @hidden */
  151399. _rebuild(): void;
  151400. private _bits;
  151401. private _radicalInverse_VdC;
  151402. private _hammersley;
  151403. private _hemisphereSample_uniform;
  151404. private _generateHemisphere;
  151405. private _getDefinesForSSAO;
  151406. private _createSSAOPostProcess;
  151407. private _createSSAOCombinePostProcess;
  151408. private _createRandomTexture;
  151409. /**
  151410. * Serialize the rendering pipeline (Used when exporting)
  151411. * @returns the serialized object
  151412. */
  151413. serialize(): any;
  151414. /**
  151415. * Parse the serialized pipeline
  151416. * @param source Source pipeline.
  151417. * @param scene The scene to load the pipeline to.
  151418. * @param rootUrl The URL of the serialized pipeline.
  151419. * @returns An instantiated pipeline from the serialized object.
  151420. */
  151421. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  151422. /**
  151423. * Sets the required values to the prepass renderer.
  151424. * @param prePassRenderer defines the prepass renderer to setup
  151425. * @returns true if the pre pass is needed.
  151426. */
  151427. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151428. }
  151429. }
  151430. declare module BABYLON {
  151431. /** @hidden */
  151432. export var ssaoPixelShader: {
  151433. name: string;
  151434. shader: string;
  151435. };
  151436. }
  151437. declare module BABYLON {
  151438. /**
  151439. * Render pipeline to produce ssao effect
  151440. */
  151441. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  151442. /**
  151443. * @ignore
  151444. * The PassPostProcess id in the pipeline that contains the original scene color
  151445. */
  151446. SSAOOriginalSceneColorEffect: string;
  151447. /**
  151448. * @ignore
  151449. * The SSAO PostProcess id in the pipeline
  151450. */
  151451. SSAORenderEffect: string;
  151452. /**
  151453. * @ignore
  151454. * The horizontal blur PostProcess id in the pipeline
  151455. */
  151456. SSAOBlurHRenderEffect: string;
  151457. /**
  151458. * @ignore
  151459. * The vertical blur PostProcess id in the pipeline
  151460. */
  151461. SSAOBlurVRenderEffect: string;
  151462. /**
  151463. * @ignore
  151464. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151465. */
  151466. SSAOCombineRenderEffect: string;
  151467. /**
  151468. * The output strength of the SSAO post-process. Default value is 1.0.
  151469. */
  151470. totalStrength: number;
  151471. /**
  151472. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  151473. */
  151474. radius: number;
  151475. /**
  151476. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  151477. * Must not be equal to fallOff and superior to fallOff.
  151478. * Default value is 0.0075
  151479. */
  151480. area: number;
  151481. /**
  151482. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  151483. * Must not be equal to area and inferior to area.
  151484. * Default value is 0.000001
  151485. */
  151486. fallOff: number;
  151487. /**
  151488. * The base color of the SSAO post-process
  151489. * The final result is "base + ssao" between [0, 1]
  151490. */
  151491. base: number;
  151492. private _scene;
  151493. private _depthTexture;
  151494. private _randomTexture;
  151495. private _originalColorPostProcess;
  151496. private _ssaoPostProcess;
  151497. private _blurHPostProcess;
  151498. private _blurVPostProcess;
  151499. private _ssaoCombinePostProcess;
  151500. private _firstUpdate;
  151501. /**
  151502. * Gets active scene
  151503. */
  151504. get scene(): Scene;
  151505. /**
  151506. * @constructor
  151507. * @param name - The rendering pipeline name
  151508. * @param scene - The scene linked to this pipeline
  151509. * @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 }
  151510. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  151511. */
  151512. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  151513. /**
  151514. * Get the class name
  151515. * @returns "SSAORenderingPipeline"
  151516. */
  151517. getClassName(): string;
  151518. /**
  151519. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151520. */
  151521. dispose(disableDepthRender?: boolean): void;
  151522. private _createBlurPostProcess;
  151523. /** @hidden */
  151524. _rebuild(): void;
  151525. private _createSSAOPostProcess;
  151526. private _createSSAOCombinePostProcess;
  151527. private _createRandomTexture;
  151528. }
  151529. }
  151530. declare module BABYLON {
  151531. /** @hidden */
  151532. export var screenSpaceReflectionPixelShader: {
  151533. name: string;
  151534. shader: string;
  151535. };
  151536. }
  151537. declare module BABYLON {
  151538. /**
  151539. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151540. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151541. */
  151542. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151543. /**
  151544. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151545. */
  151546. threshold: number;
  151547. /**
  151548. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151549. */
  151550. strength: number;
  151551. /**
  151552. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151553. */
  151554. reflectionSpecularFalloffExponent: number;
  151555. /**
  151556. * 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]
  151557. */
  151558. step: number;
  151559. /**
  151560. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151561. */
  151562. roughnessFactor: number;
  151563. private _geometryBufferRenderer;
  151564. private _enableSmoothReflections;
  151565. private _reflectionSamples;
  151566. private _smoothSteps;
  151567. /**
  151568. * Gets a string identifying the name of the class
  151569. * @returns "ScreenSpaceReflectionPostProcess" string
  151570. */
  151571. getClassName(): string;
  151572. /**
  151573. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151574. * @param name The name of the effect.
  151575. * @param scene The scene containing the objects to calculate reflections.
  151576. * @param options The required width/height ratio to downsize to before computing the render pass.
  151577. * @param camera The camera to apply the render pass to.
  151578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151579. * @param engine The engine which the post process will be applied. (default: current engine)
  151580. * @param reusable If the post process can be reused on the same frame. (default: false)
  151581. * @param textureType Type of textures used when performing the post process. (default: 0)
  151582. * @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)
  151583. */
  151584. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151585. /**
  151586. * Gets wether or not smoothing reflections is enabled.
  151587. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151588. */
  151589. get enableSmoothReflections(): boolean;
  151590. /**
  151591. * Sets wether or not smoothing reflections is enabled.
  151592. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151593. */
  151594. set enableSmoothReflections(enabled: boolean);
  151595. /**
  151596. * Gets the number of samples taken while computing reflections. More samples count is high,
  151597. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151598. */
  151599. get reflectionSamples(): number;
  151600. /**
  151601. * Sets the number of samples taken while computing reflections. More samples count is high,
  151602. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151603. */
  151604. set reflectionSamples(samples: number);
  151605. /**
  151606. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  151607. * more the post-process will require GPU power and can generate a drop in FPS.
  151608. * Default value (5.0) work pretty well in all cases but can be adjusted.
  151609. */
  151610. get smoothSteps(): number;
  151611. set smoothSteps(steps: number);
  151612. private _updateEffectDefines;
  151613. /** @hidden */
  151614. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  151615. }
  151616. }
  151617. declare module BABYLON {
  151618. /** @hidden */
  151619. export var standardPixelShader: {
  151620. name: string;
  151621. shader: string;
  151622. };
  151623. }
  151624. declare module BABYLON {
  151625. /**
  151626. * Standard rendering pipeline
  151627. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151628. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  151629. */
  151630. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151631. /**
  151632. * Public members
  151633. */
  151634. /**
  151635. * Post-process which contains the original scene color before the pipeline applies all the effects
  151636. */
  151637. originalPostProcess: Nullable<PostProcess>;
  151638. /**
  151639. * Post-process used to down scale an image x4
  151640. */
  151641. downSampleX4PostProcess: Nullable<PostProcess>;
  151642. /**
  151643. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  151644. */
  151645. brightPassPostProcess: Nullable<PostProcess>;
  151646. /**
  151647. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  151648. */
  151649. blurHPostProcesses: PostProcess[];
  151650. /**
  151651. * Post-process array storing all the vertical blur post-processes used by the pipeline
  151652. */
  151653. blurVPostProcesses: PostProcess[];
  151654. /**
  151655. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  151656. */
  151657. textureAdderPostProcess: Nullable<PostProcess>;
  151658. /**
  151659. * Post-process used to create volumetric lighting effect
  151660. */
  151661. volumetricLightPostProcess: Nullable<PostProcess>;
  151662. /**
  151663. * Post-process used to smooth the previous volumetric light post-process on the X axis
  151664. */
  151665. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  151666. /**
  151667. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  151668. */
  151669. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  151670. /**
  151671. * Post-process used to merge the volumetric light effect and the real scene color
  151672. */
  151673. volumetricLightMergePostProces: Nullable<PostProcess>;
  151674. /**
  151675. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  151676. */
  151677. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  151678. /**
  151679. * Base post-process used to calculate the average luminance of the final image for HDR
  151680. */
  151681. luminancePostProcess: Nullable<PostProcess>;
  151682. /**
  151683. * Post-processes used to create down sample post-processes in order to get
  151684. * the average luminance of the final image for HDR
  151685. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  151686. */
  151687. luminanceDownSamplePostProcesses: PostProcess[];
  151688. /**
  151689. * Post-process used to create a HDR effect (light adaptation)
  151690. */
  151691. hdrPostProcess: Nullable<PostProcess>;
  151692. /**
  151693. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  151694. */
  151695. textureAdderFinalPostProcess: Nullable<PostProcess>;
  151696. /**
  151697. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  151698. */
  151699. lensFlareFinalPostProcess: Nullable<PostProcess>;
  151700. /**
  151701. * Post-process used to merge the final HDR post-process and the real scene color
  151702. */
  151703. hdrFinalPostProcess: Nullable<PostProcess>;
  151704. /**
  151705. * Post-process used to create a lens flare effect
  151706. */
  151707. lensFlarePostProcess: Nullable<PostProcess>;
  151708. /**
  151709. * Post-process that merges the result of the lens flare post-process and the real scene color
  151710. */
  151711. lensFlareComposePostProcess: Nullable<PostProcess>;
  151712. /**
  151713. * Post-process used to create a motion blur effect
  151714. */
  151715. motionBlurPostProcess: Nullable<PostProcess>;
  151716. /**
  151717. * Post-process used to create a depth of field effect
  151718. */
  151719. depthOfFieldPostProcess: Nullable<PostProcess>;
  151720. /**
  151721. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151722. */
  151723. fxaaPostProcess: Nullable<FxaaPostProcess>;
  151724. /**
  151725. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  151726. */
  151727. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  151728. /**
  151729. * Represents the brightness threshold in order to configure the illuminated surfaces
  151730. */
  151731. brightThreshold: number;
  151732. /**
  151733. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  151734. */
  151735. blurWidth: number;
  151736. /**
  151737. * Sets if the blur for highlighted surfaces must be only horizontal
  151738. */
  151739. horizontalBlur: boolean;
  151740. /**
  151741. * Gets the overall exposure used by the pipeline
  151742. */
  151743. get exposure(): number;
  151744. /**
  151745. * Sets the overall exposure used by the pipeline
  151746. */
  151747. set exposure(value: number);
  151748. /**
  151749. * Texture used typically to simulate "dirty" on camera lens
  151750. */
  151751. lensTexture: Nullable<Texture>;
  151752. /**
  151753. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  151754. */
  151755. volumetricLightCoefficient: number;
  151756. /**
  151757. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  151758. */
  151759. volumetricLightPower: number;
  151760. /**
  151761. * Used the set the blur intensity to smooth the volumetric lights
  151762. */
  151763. volumetricLightBlurScale: number;
  151764. /**
  151765. * Light (spot or directional) used to generate the volumetric lights rays
  151766. * The source light must have a shadow generate so the pipeline can get its
  151767. * depth map
  151768. */
  151769. sourceLight: Nullable<SpotLight | DirectionalLight>;
  151770. /**
  151771. * For eye adaptation, represents the minimum luminance the eye can see
  151772. */
  151773. hdrMinimumLuminance: number;
  151774. /**
  151775. * For eye adaptation, represents the decrease luminance speed
  151776. */
  151777. hdrDecreaseRate: number;
  151778. /**
  151779. * For eye adaptation, represents the increase luminance speed
  151780. */
  151781. hdrIncreaseRate: number;
  151782. /**
  151783. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151784. */
  151785. get hdrAutoExposure(): boolean;
  151786. /**
  151787. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151788. */
  151789. set hdrAutoExposure(value: boolean);
  151790. /**
  151791. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  151792. */
  151793. lensColorTexture: Nullable<Texture>;
  151794. /**
  151795. * The overall strengh for the lens flare effect
  151796. */
  151797. lensFlareStrength: number;
  151798. /**
  151799. * Dispersion coefficient for lens flare ghosts
  151800. */
  151801. lensFlareGhostDispersal: number;
  151802. /**
  151803. * Main lens flare halo width
  151804. */
  151805. lensFlareHaloWidth: number;
  151806. /**
  151807. * Based on the lens distortion effect, defines how much the lens flare result
  151808. * is distorted
  151809. */
  151810. lensFlareDistortionStrength: number;
  151811. /**
  151812. * Configures the blur intensity used for for lens flare (halo)
  151813. */
  151814. lensFlareBlurWidth: number;
  151815. /**
  151816. * Lens star texture must be used to simulate rays on the flares and is available
  151817. * in the documentation
  151818. */
  151819. lensStarTexture: Nullable<Texture>;
  151820. /**
  151821. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  151822. * flare effect by taking account of the dirt texture
  151823. */
  151824. lensFlareDirtTexture: Nullable<Texture>;
  151825. /**
  151826. * Represents the focal length for the depth of field effect
  151827. */
  151828. depthOfFieldDistance: number;
  151829. /**
  151830. * Represents the blur intensity for the blurred part of the depth of field effect
  151831. */
  151832. depthOfFieldBlurWidth: number;
  151833. /**
  151834. * Gets how much the image is blurred by the movement while using the motion blur post-process
  151835. */
  151836. get motionStrength(): number;
  151837. /**
  151838. * Sets how much the image is blurred by the movement while using the motion blur post-process
  151839. */
  151840. set motionStrength(strength: number);
  151841. /**
  151842. * Gets wether or not the motion blur post-process is object based or screen based.
  151843. */
  151844. get objectBasedMotionBlur(): boolean;
  151845. /**
  151846. * Sets wether or not the motion blur post-process should be object based or screen based
  151847. */
  151848. set objectBasedMotionBlur(value: boolean);
  151849. /**
  151850. * List of animations for the pipeline (IAnimatable implementation)
  151851. */
  151852. animations: Animation[];
  151853. /**
  151854. * Private members
  151855. */
  151856. private _scene;
  151857. private _currentDepthOfFieldSource;
  151858. private _basePostProcess;
  151859. private _fixedExposure;
  151860. private _currentExposure;
  151861. private _hdrAutoExposure;
  151862. private _hdrCurrentLuminance;
  151863. private _motionStrength;
  151864. private _isObjectBasedMotionBlur;
  151865. private _floatTextureType;
  151866. private _camerasToBeAttached;
  151867. private _ratio;
  151868. private _bloomEnabled;
  151869. private _depthOfFieldEnabled;
  151870. private _vlsEnabled;
  151871. private _lensFlareEnabled;
  151872. private _hdrEnabled;
  151873. private _motionBlurEnabled;
  151874. private _fxaaEnabled;
  151875. private _screenSpaceReflectionsEnabled;
  151876. private _motionBlurSamples;
  151877. private _volumetricLightStepsCount;
  151878. private _samples;
  151879. /**
  151880. * @ignore
  151881. * Specifies if the bloom pipeline is enabled
  151882. */
  151883. get BloomEnabled(): boolean;
  151884. set BloomEnabled(enabled: boolean);
  151885. /**
  151886. * @ignore
  151887. * Specifies if the depth of field pipeline is enabed
  151888. */
  151889. get DepthOfFieldEnabled(): boolean;
  151890. set DepthOfFieldEnabled(enabled: boolean);
  151891. /**
  151892. * @ignore
  151893. * Specifies if the lens flare pipeline is enabed
  151894. */
  151895. get LensFlareEnabled(): boolean;
  151896. set LensFlareEnabled(enabled: boolean);
  151897. /**
  151898. * @ignore
  151899. * Specifies if the HDR pipeline is enabled
  151900. */
  151901. get HDREnabled(): boolean;
  151902. set HDREnabled(enabled: boolean);
  151903. /**
  151904. * @ignore
  151905. * Specifies if the volumetric lights scattering effect is enabled
  151906. */
  151907. get VLSEnabled(): boolean;
  151908. set VLSEnabled(enabled: boolean);
  151909. /**
  151910. * @ignore
  151911. * Specifies if the motion blur effect is enabled
  151912. */
  151913. get MotionBlurEnabled(): boolean;
  151914. set MotionBlurEnabled(enabled: boolean);
  151915. /**
  151916. * Specifies if anti-aliasing is enabled
  151917. */
  151918. get fxaaEnabled(): boolean;
  151919. set fxaaEnabled(enabled: boolean);
  151920. /**
  151921. * Specifies if screen space reflections are enabled.
  151922. */
  151923. get screenSpaceReflectionsEnabled(): boolean;
  151924. set screenSpaceReflectionsEnabled(enabled: boolean);
  151925. /**
  151926. * Specifies the number of steps used to calculate the volumetric lights
  151927. * Typically in interval [50, 200]
  151928. */
  151929. get volumetricLightStepsCount(): number;
  151930. set volumetricLightStepsCount(count: number);
  151931. /**
  151932. * Specifies the number of samples used for the motion blur effect
  151933. * Typically in interval [16, 64]
  151934. */
  151935. get motionBlurSamples(): number;
  151936. set motionBlurSamples(samples: number);
  151937. /**
  151938. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151939. */
  151940. get samples(): number;
  151941. set samples(sampleCount: number);
  151942. /**
  151943. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151944. * @constructor
  151945. * @param name The rendering pipeline name
  151946. * @param scene The scene linked to this pipeline
  151947. * @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)
  151948. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  151949. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151950. */
  151951. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  151952. private _buildPipeline;
  151953. private _createDownSampleX4PostProcess;
  151954. private _createBrightPassPostProcess;
  151955. private _createBlurPostProcesses;
  151956. private _createTextureAdderPostProcess;
  151957. private _createVolumetricLightPostProcess;
  151958. private _createLuminancePostProcesses;
  151959. private _createHdrPostProcess;
  151960. private _createLensFlarePostProcess;
  151961. private _createDepthOfFieldPostProcess;
  151962. private _createMotionBlurPostProcess;
  151963. private _getDepthTexture;
  151964. private _disposePostProcesses;
  151965. /**
  151966. * Dispose of the pipeline and stop all post processes
  151967. */
  151968. dispose(): void;
  151969. /**
  151970. * Serialize the rendering pipeline (Used when exporting)
  151971. * @returns the serialized object
  151972. */
  151973. serialize(): any;
  151974. /**
  151975. * Parse the serialized pipeline
  151976. * @param source Source pipeline.
  151977. * @param scene The scene to load the pipeline to.
  151978. * @param rootUrl The URL of the serialized pipeline.
  151979. * @returns An instantiated pipeline from the serialized object.
  151980. */
  151981. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  151982. /**
  151983. * Luminance steps
  151984. */
  151985. static LuminanceSteps: number;
  151986. }
  151987. }
  151988. declare module BABYLON {
  151989. /** @hidden */
  151990. export var stereoscopicInterlacePixelShader: {
  151991. name: string;
  151992. shader: string;
  151993. };
  151994. }
  151995. declare module BABYLON {
  151996. /**
  151997. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151998. */
  151999. export class StereoscopicInterlacePostProcessI extends PostProcess {
  152000. private _stepSize;
  152001. private _passedProcess;
  152002. /**
  152003. * Gets a string identifying the name of the class
  152004. * @returns "StereoscopicInterlacePostProcessI" string
  152005. */
  152006. getClassName(): string;
  152007. /**
  152008. * Initializes a StereoscopicInterlacePostProcessI
  152009. * @param name The name of the effect.
  152010. * @param rigCameras The rig cameras to be appled to the post process
  152011. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152012. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152014. * @param engine The engine which the post process will be applied. (default: current engine)
  152015. * @param reusable If the post process can be reused on the same frame. (default: false)
  152016. */
  152017. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152018. }
  152019. /**
  152020. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152021. */
  152022. export class StereoscopicInterlacePostProcess extends PostProcess {
  152023. private _stepSize;
  152024. private _passedProcess;
  152025. /**
  152026. * Gets a string identifying the name of the class
  152027. * @returns "StereoscopicInterlacePostProcess" string
  152028. */
  152029. getClassName(): string;
  152030. /**
  152031. * Initializes a StereoscopicInterlacePostProcess
  152032. * @param name The name of the effect.
  152033. * @param rigCameras The rig cameras to be appled to the post process
  152034. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152035. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152036. * @param engine The engine which the post process will be applied. (default: current engine)
  152037. * @param reusable If the post process can be reused on the same frame. (default: false)
  152038. */
  152039. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152040. }
  152041. }
  152042. declare module BABYLON {
  152043. /** @hidden */
  152044. export var tonemapPixelShader: {
  152045. name: string;
  152046. shader: string;
  152047. };
  152048. }
  152049. declare module BABYLON {
  152050. /** Defines operator used for tonemapping */
  152051. export enum TonemappingOperator {
  152052. /** Hable */
  152053. Hable = 0,
  152054. /** Reinhard */
  152055. Reinhard = 1,
  152056. /** HejiDawson */
  152057. HejiDawson = 2,
  152058. /** Photographic */
  152059. Photographic = 3
  152060. }
  152061. /**
  152062. * Defines a post process to apply tone mapping
  152063. */
  152064. export class TonemapPostProcess extends PostProcess {
  152065. private _operator;
  152066. /** Defines the required exposure adjustement */
  152067. exposureAdjustment: number;
  152068. /**
  152069. * Gets a string identifying the name of the class
  152070. * @returns "TonemapPostProcess" string
  152071. */
  152072. getClassName(): string;
  152073. /**
  152074. * Creates a new TonemapPostProcess
  152075. * @param name defines the name of the postprocess
  152076. * @param _operator defines the operator to use
  152077. * @param exposureAdjustment defines the required exposure adjustement
  152078. * @param camera defines the camera to use (can be null)
  152079. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152080. * @param engine defines the hosting engine (can be ignore if camera is set)
  152081. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152082. */
  152083. constructor(name: string, _operator: TonemappingOperator,
  152084. /** Defines the required exposure adjustement */
  152085. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152086. }
  152087. }
  152088. declare module BABYLON {
  152089. /** @hidden */
  152090. export var volumetricLightScatteringPixelShader: {
  152091. name: string;
  152092. shader: string;
  152093. };
  152094. }
  152095. declare module BABYLON {
  152096. /** @hidden */
  152097. export var volumetricLightScatteringPassVertexShader: {
  152098. name: string;
  152099. shader: string;
  152100. };
  152101. }
  152102. declare module BABYLON {
  152103. /** @hidden */
  152104. export var volumetricLightScatteringPassPixelShader: {
  152105. name: string;
  152106. shader: string;
  152107. };
  152108. }
  152109. declare module BABYLON {
  152110. /**
  152111. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152112. */
  152113. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152114. private _volumetricLightScatteringPass;
  152115. private _volumetricLightScatteringRTT;
  152116. private _viewPort;
  152117. private _screenCoordinates;
  152118. private _cachedDefines;
  152119. /**
  152120. * If not undefined, the mesh position is computed from the attached node position
  152121. */
  152122. attachedNode: {
  152123. position: Vector3;
  152124. };
  152125. /**
  152126. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152127. */
  152128. customMeshPosition: Vector3;
  152129. /**
  152130. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152131. */
  152132. useCustomMeshPosition: boolean;
  152133. /**
  152134. * If the post-process should inverse the light scattering direction
  152135. */
  152136. invert: boolean;
  152137. /**
  152138. * The internal mesh used by the post-process
  152139. */
  152140. mesh: Mesh;
  152141. /**
  152142. * @hidden
  152143. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152144. */
  152145. get useDiffuseColor(): boolean;
  152146. set useDiffuseColor(useDiffuseColor: boolean);
  152147. /**
  152148. * Array containing the excluded meshes not rendered in the internal pass
  152149. */
  152150. excludedMeshes: AbstractMesh[];
  152151. /**
  152152. * Controls the overall intensity of the post-process
  152153. */
  152154. exposure: number;
  152155. /**
  152156. * Dissipates each sample's contribution in range [0, 1]
  152157. */
  152158. decay: number;
  152159. /**
  152160. * Controls the overall intensity of each sample
  152161. */
  152162. weight: number;
  152163. /**
  152164. * Controls the density of each sample
  152165. */
  152166. density: number;
  152167. /**
  152168. * @constructor
  152169. * @param name The post-process name
  152170. * @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)
  152171. * @param camera The camera that the post-process will be attached to
  152172. * @param mesh The mesh used to create the light scattering
  152173. * @param samples The post-process quality, default 100
  152174. * @param samplingModeThe post-process filtering mode
  152175. * @param engine The babylon engine
  152176. * @param reusable If the post-process is reusable
  152177. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152178. */
  152179. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152180. /**
  152181. * Returns the string "VolumetricLightScatteringPostProcess"
  152182. * @returns "VolumetricLightScatteringPostProcess"
  152183. */
  152184. getClassName(): string;
  152185. private _isReady;
  152186. /**
  152187. * Sets the new light position for light scattering effect
  152188. * @param position The new custom light position
  152189. */
  152190. setCustomMeshPosition(position: Vector3): void;
  152191. /**
  152192. * Returns the light position for light scattering effect
  152193. * @return Vector3 The custom light position
  152194. */
  152195. getCustomMeshPosition(): Vector3;
  152196. /**
  152197. * Disposes the internal assets and detaches the post-process from the camera
  152198. */
  152199. dispose(camera: Camera): void;
  152200. /**
  152201. * Returns the render target texture used by the post-process
  152202. * @return the render target texture used by the post-process
  152203. */
  152204. getPass(): RenderTargetTexture;
  152205. private _meshExcluded;
  152206. private _createPass;
  152207. private _updateMeshScreenCoordinates;
  152208. /**
  152209. * Creates a default mesh for the Volumeric Light Scattering post-process
  152210. * @param name The mesh name
  152211. * @param scene The scene where to create the mesh
  152212. * @return the default mesh
  152213. */
  152214. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152215. }
  152216. }
  152217. declare module BABYLON {
  152218. /** @hidden */
  152219. export var screenSpaceCurvaturePixelShader: {
  152220. name: string;
  152221. shader: string;
  152222. };
  152223. }
  152224. declare module BABYLON {
  152225. /**
  152226. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152227. */
  152228. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152229. /**
  152230. * Defines how much ridge the curvature effect displays.
  152231. */
  152232. ridge: number;
  152233. /**
  152234. * Defines how much valley the curvature effect displays.
  152235. */
  152236. valley: number;
  152237. private _geometryBufferRenderer;
  152238. /**
  152239. * Gets a string identifying the name of the class
  152240. * @returns "ScreenSpaceCurvaturePostProcess" string
  152241. */
  152242. getClassName(): string;
  152243. /**
  152244. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152245. * @param name The name of the effect.
  152246. * @param scene The scene containing the objects to blur according to their velocity.
  152247. * @param options The required width/height ratio to downsize to before computing the render pass.
  152248. * @param camera The camera to apply the render pass to.
  152249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152250. * @param engine The engine which the post process will be applied. (default: current engine)
  152251. * @param reusable If the post process can be reused on the same frame. (default: false)
  152252. * @param textureType Type of textures used when performing the post process. (default: 0)
  152253. * @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)
  152254. */
  152255. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152256. /**
  152257. * Support test.
  152258. */
  152259. static get IsSupported(): boolean;
  152260. /** @hidden */
  152261. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152262. }
  152263. }
  152264. declare module BABYLON {
  152265. interface Scene {
  152266. /** @hidden (Backing field) */
  152267. _boundingBoxRenderer: BoundingBoxRenderer;
  152268. /** @hidden (Backing field) */
  152269. _forceShowBoundingBoxes: boolean;
  152270. /**
  152271. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152272. */
  152273. forceShowBoundingBoxes: boolean;
  152274. /**
  152275. * Gets the bounding box renderer associated with the scene
  152276. * @returns a BoundingBoxRenderer
  152277. */
  152278. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152279. }
  152280. interface AbstractMesh {
  152281. /** @hidden (Backing field) */
  152282. _showBoundingBox: boolean;
  152283. /**
  152284. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152285. */
  152286. showBoundingBox: boolean;
  152287. }
  152288. /**
  152289. * Component responsible of rendering the bounding box of the meshes in a scene.
  152290. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152291. */
  152292. export class BoundingBoxRenderer implements ISceneComponent {
  152293. /**
  152294. * The component name helpfull to identify the component in the list of scene components.
  152295. */
  152296. readonly name: string;
  152297. /**
  152298. * The scene the component belongs to.
  152299. */
  152300. scene: Scene;
  152301. /**
  152302. * Color of the bounding box lines placed in front of an object
  152303. */
  152304. frontColor: Color3;
  152305. /**
  152306. * Color of the bounding box lines placed behind an object
  152307. */
  152308. backColor: Color3;
  152309. /**
  152310. * Defines if the renderer should show the back lines or not
  152311. */
  152312. showBackLines: boolean;
  152313. /**
  152314. * Observable raised before rendering a bounding box
  152315. */
  152316. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152317. /**
  152318. * Observable raised after rendering a bounding box
  152319. */
  152320. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  152321. /**
  152322. * @hidden
  152323. */
  152324. renderList: SmartArray<BoundingBox>;
  152325. private _colorShader;
  152326. private _vertexBuffers;
  152327. private _indexBuffer;
  152328. private _fillIndexBuffer;
  152329. private _fillIndexData;
  152330. /**
  152331. * Instantiates a new bounding box renderer in a scene.
  152332. * @param scene the scene the renderer renders in
  152333. */
  152334. constructor(scene: Scene);
  152335. /**
  152336. * Registers the component in a given scene
  152337. */
  152338. register(): void;
  152339. private _evaluateSubMesh;
  152340. private _activeMesh;
  152341. private _prepareRessources;
  152342. private _createIndexBuffer;
  152343. /**
  152344. * Rebuilds the elements related to this component in case of
  152345. * context lost for instance.
  152346. */
  152347. rebuild(): void;
  152348. /**
  152349. * @hidden
  152350. */
  152351. reset(): void;
  152352. /**
  152353. * Render the bounding boxes of a specific rendering group
  152354. * @param renderingGroupId defines the rendering group to render
  152355. */
  152356. render(renderingGroupId: number): void;
  152357. /**
  152358. * In case of occlusion queries, we can render the occlusion bounding box through this method
  152359. * @param mesh Define the mesh to render the occlusion bounding box for
  152360. */
  152361. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  152362. /**
  152363. * Dispose and release the resources attached to this renderer.
  152364. */
  152365. dispose(): void;
  152366. }
  152367. }
  152368. declare module BABYLON {
  152369. interface Scene {
  152370. /** @hidden (Backing field) */
  152371. _depthRenderer: {
  152372. [id: string]: DepthRenderer;
  152373. };
  152374. /**
  152375. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  152376. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  152377. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  152378. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  152379. * @returns the created depth renderer
  152380. */
  152381. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  152382. /**
  152383. * Disables a depth renderer for a given camera
  152384. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  152385. */
  152386. disableDepthRenderer(camera?: Nullable<Camera>): void;
  152387. }
  152388. /**
  152389. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  152390. * in several rendering techniques.
  152391. */
  152392. export class DepthRendererSceneComponent implements ISceneComponent {
  152393. /**
  152394. * The component name helpfull to identify the component in the list of scene components.
  152395. */
  152396. readonly name: string;
  152397. /**
  152398. * The scene the component belongs to.
  152399. */
  152400. scene: Scene;
  152401. /**
  152402. * Creates a new instance of the component for the given scene
  152403. * @param scene Defines the scene to register the component in
  152404. */
  152405. constructor(scene: Scene);
  152406. /**
  152407. * Registers the component in a given scene
  152408. */
  152409. register(): void;
  152410. /**
  152411. * Rebuilds the elements related to this component in case of
  152412. * context lost for instance.
  152413. */
  152414. rebuild(): void;
  152415. /**
  152416. * Disposes the component and the associated ressources
  152417. */
  152418. dispose(): void;
  152419. private _gatherRenderTargets;
  152420. private _gatherActiveCameraRenderTargets;
  152421. }
  152422. }
  152423. declare module BABYLON {
  152424. interface AbstractScene {
  152425. /** @hidden (Backing field) */
  152426. _prePassRenderer: Nullable<PrePassRenderer>;
  152427. /**
  152428. * Gets or Sets the current prepass renderer associated to the scene.
  152429. */
  152430. prePassRenderer: Nullable<PrePassRenderer>;
  152431. /**
  152432. * Enables the prepass and associates it with the scene
  152433. * @returns the PrePassRenderer
  152434. */
  152435. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  152436. /**
  152437. * Disables the prepass associated with the scene
  152438. */
  152439. disablePrePassRenderer(): void;
  152440. }
  152441. /**
  152442. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152443. * in several rendering techniques.
  152444. */
  152445. export class PrePassRendererSceneComponent implements ISceneComponent {
  152446. /**
  152447. * The component name helpful to identify the component in the list of scene components.
  152448. */
  152449. readonly name: string;
  152450. /**
  152451. * The scene the component belongs to.
  152452. */
  152453. scene: Scene;
  152454. /**
  152455. * Creates a new instance of the component for the given scene
  152456. * @param scene Defines the scene to register the component in
  152457. */
  152458. constructor(scene: Scene);
  152459. /**
  152460. * Registers the component in a given scene
  152461. */
  152462. register(): void;
  152463. private _beforeCameraDraw;
  152464. private _afterCameraDraw;
  152465. private _beforeClearStage;
  152466. /**
  152467. * Rebuilds the elements related to this component in case of
  152468. * context lost for instance.
  152469. */
  152470. rebuild(): void;
  152471. /**
  152472. * Disposes the component and the associated ressources
  152473. */
  152474. dispose(): void;
  152475. }
  152476. }
  152477. declare module BABYLON {
  152478. /** @hidden */
  152479. export var fibonacci: {
  152480. name: string;
  152481. shader: string;
  152482. };
  152483. }
  152484. declare module BABYLON {
  152485. /** @hidden */
  152486. export var diffusionProfile: {
  152487. name: string;
  152488. shader: string;
  152489. };
  152490. }
  152491. declare module BABYLON {
  152492. /** @hidden */
  152493. export var subSurfaceScatteringPixelShader: {
  152494. name: string;
  152495. shader: string;
  152496. };
  152497. }
  152498. declare module BABYLON {
  152499. /**
  152500. * Sub surface scattering post process
  152501. */
  152502. export class SubSurfaceScatteringPostProcess extends PostProcess {
  152503. /**
  152504. * Gets a string identifying the name of the class
  152505. * @returns "SubSurfaceScatteringPostProcess" string
  152506. */
  152507. getClassName(): string;
  152508. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152509. }
  152510. }
  152511. declare module BABYLON {
  152512. /**
  152513. * Contains all parameters needed for the prepass to perform
  152514. * screen space subsurface scattering
  152515. */
  152516. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  152517. /** @hidden */
  152518. static _SceneComponentInitialization: (scene: Scene) => void;
  152519. private _ssDiffusionS;
  152520. private _ssFilterRadii;
  152521. private _ssDiffusionD;
  152522. /**
  152523. * Post process to attach for screen space subsurface scattering
  152524. */
  152525. postProcess: SubSurfaceScatteringPostProcess;
  152526. /**
  152527. * Diffusion profile color for subsurface scattering
  152528. */
  152529. get ssDiffusionS(): number[];
  152530. /**
  152531. * Diffusion profile max color channel value for subsurface scattering
  152532. */
  152533. get ssDiffusionD(): number[];
  152534. /**
  152535. * Diffusion profile filter radius for subsurface scattering
  152536. */
  152537. get ssFilterRadii(): number[];
  152538. /**
  152539. * Is subsurface enabled
  152540. */
  152541. enabled: boolean;
  152542. /**
  152543. * Name of the configuration
  152544. */
  152545. name: string;
  152546. /**
  152547. * Diffusion profile colors for subsurface scattering
  152548. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  152549. * See ...
  152550. * Note that you can only store up to 5 of them
  152551. */
  152552. ssDiffusionProfileColors: Color3[];
  152553. /**
  152554. * Defines the ratio real world => scene units.
  152555. * Used for subsurface scattering
  152556. */
  152557. metersPerUnit: number;
  152558. /**
  152559. * Textures that should be present in the MRT for this effect to work
  152560. */
  152561. readonly texturesRequired: number[];
  152562. private _scene;
  152563. /**
  152564. * Builds a subsurface configuration object
  152565. * @param scene The scene
  152566. */
  152567. constructor(scene: Scene);
  152568. /**
  152569. * Adds a new diffusion profile.
  152570. * Useful for more realistic subsurface scattering on diverse materials.
  152571. * @param color The color of the diffusion profile. Should be the average color of the material.
  152572. * @return The index of the diffusion profile for the material subsurface configuration
  152573. */
  152574. addDiffusionProfile(color: Color3): number;
  152575. /**
  152576. * Creates the sss post process
  152577. * @return The created post process
  152578. */
  152579. createPostProcess(): SubSurfaceScatteringPostProcess;
  152580. /**
  152581. * Deletes all diffusion profiles.
  152582. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  152583. */
  152584. clearAllDiffusionProfiles(): void;
  152585. /**
  152586. * Disposes this object
  152587. */
  152588. dispose(): void;
  152589. /**
  152590. * @hidden
  152591. * https://zero-radiance.github.io/post/sampling-diffusion/
  152592. *
  152593. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  152594. * ------------------------------------------------------------------------------------
  152595. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  152596. * PDF[r, phi, s] = r * R[r, phi, s]
  152597. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  152598. * ------------------------------------------------------------------------------------
  152599. * We importance sample the color channel with the widest scattering distance.
  152600. */
  152601. getDiffusionProfileParameters(color: Color3): number;
  152602. /**
  152603. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  152604. * 'u' is the random number (the value of the CDF): [0, 1).
  152605. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  152606. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  152607. */
  152608. private _sampleBurleyDiffusionProfile;
  152609. }
  152610. }
  152611. declare module BABYLON {
  152612. interface AbstractScene {
  152613. /** @hidden (Backing field) */
  152614. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152615. /**
  152616. * Gets or Sets the current prepass renderer associated to the scene.
  152617. */
  152618. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152619. /**
  152620. * Enables the subsurface effect for prepass
  152621. * @returns the SubSurfaceConfiguration
  152622. */
  152623. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  152624. /**
  152625. * Disables the subsurface effect for prepass
  152626. */
  152627. disableSubSurfaceForPrePass(): void;
  152628. }
  152629. /**
  152630. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152631. * in several rendering techniques.
  152632. */
  152633. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  152634. /**
  152635. * The component name helpful to identify the component in the list of scene components.
  152636. */
  152637. readonly name: string;
  152638. /**
  152639. * The scene the component belongs to.
  152640. */
  152641. scene: Scene;
  152642. /**
  152643. * Creates a new instance of the component for the given scene
  152644. * @param scene Defines the scene to register the component in
  152645. */
  152646. constructor(scene: Scene);
  152647. /**
  152648. * Registers the component in a given scene
  152649. */
  152650. register(): void;
  152651. /**
  152652. * Serializes the component data to the specified json object
  152653. * @param serializationObject The object to serialize to
  152654. */
  152655. serialize(serializationObject: any): void;
  152656. /**
  152657. * Adds all the elements from the container to the scene
  152658. * @param container the container holding the elements
  152659. */
  152660. addFromContainer(container: AbstractScene): void;
  152661. /**
  152662. * Removes all the elements in the container from the scene
  152663. * @param container contains the elements to remove
  152664. * @param dispose if the removed element should be disposed (default: false)
  152665. */
  152666. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  152667. /**
  152668. * Rebuilds the elements related to this component in case of
  152669. * context lost for instance.
  152670. */
  152671. rebuild(): void;
  152672. /**
  152673. * Disposes the component and the associated ressources
  152674. */
  152675. dispose(): void;
  152676. }
  152677. }
  152678. declare module BABYLON {
  152679. /** @hidden */
  152680. export var outlinePixelShader: {
  152681. name: string;
  152682. shader: string;
  152683. };
  152684. }
  152685. declare module BABYLON {
  152686. /** @hidden */
  152687. export var outlineVertexShader: {
  152688. name: string;
  152689. shader: string;
  152690. };
  152691. }
  152692. declare module BABYLON {
  152693. interface Scene {
  152694. /** @hidden */
  152695. _outlineRenderer: OutlineRenderer;
  152696. /**
  152697. * Gets the outline renderer associated with the scene
  152698. * @returns a OutlineRenderer
  152699. */
  152700. getOutlineRenderer(): OutlineRenderer;
  152701. }
  152702. interface AbstractMesh {
  152703. /** @hidden (Backing field) */
  152704. _renderOutline: boolean;
  152705. /**
  152706. * Gets or sets a boolean indicating if the outline must be rendered as well
  152707. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  152708. */
  152709. renderOutline: boolean;
  152710. /** @hidden (Backing field) */
  152711. _renderOverlay: boolean;
  152712. /**
  152713. * Gets or sets a boolean indicating if the overlay must be rendered as well
  152714. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  152715. */
  152716. renderOverlay: boolean;
  152717. }
  152718. /**
  152719. * This class is responsible to draw bothe outline/overlay of meshes.
  152720. * It should not be used directly but through the available method on mesh.
  152721. */
  152722. export class OutlineRenderer implements ISceneComponent {
  152723. /**
  152724. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  152725. */
  152726. private static _StencilReference;
  152727. /**
  152728. * The name of the component. Each component must have a unique name.
  152729. */
  152730. name: string;
  152731. /**
  152732. * The scene the component belongs to.
  152733. */
  152734. scene: Scene;
  152735. /**
  152736. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  152737. */
  152738. zOffset: number;
  152739. private _engine;
  152740. private _effect;
  152741. private _cachedDefines;
  152742. private _savedDepthWrite;
  152743. /**
  152744. * Instantiates a new outline renderer. (There could be only one per scene).
  152745. * @param scene Defines the scene it belongs to
  152746. */
  152747. constructor(scene: Scene);
  152748. /**
  152749. * Register the component to one instance of a scene.
  152750. */
  152751. register(): void;
  152752. /**
  152753. * Rebuilds the elements related to this component in case of
  152754. * context lost for instance.
  152755. */
  152756. rebuild(): void;
  152757. /**
  152758. * Disposes the component and the associated ressources.
  152759. */
  152760. dispose(): void;
  152761. /**
  152762. * Renders the outline in the canvas.
  152763. * @param subMesh Defines the sumesh to render
  152764. * @param batch Defines the batch of meshes in case of instances
  152765. * @param useOverlay Defines if the rendering is for the overlay or the outline
  152766. */
  152767. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  152768. /**
  152769. * Returns whether or not the outline renderer is ready for a given submesh.
  152770. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  152771. * @param subMesh Defines the submesh to check readyness for
  152772. * @param useInstances Defines wheter wee are trying to render instances or not
  152773. * @returns true if ready otherwise false
  152774. */
  152775. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  152776. private _beforeRenderingMesh;
  152777. private _afterRenderingMesh;
  152778. }
  152779. }
  152780. declare module BABYLON {
  152781. /**
  152782. * Defines the basic options interface of a Sprite Frame Source Size.
  152783. */
  152784. export interface ISpriteJSONSpriteSourceSize {
  152785. /**
  152786. * number of the original width of the Frame
  152787. */
  152788. w: number;
  152789. /**
  152790. * number of the original height of the Frame
  152791. */
  152792. h: number;
  152793. }
  152794. /**
  152795. * Defines the basic options interface of a Sprite Frame Data.
  152796. */
  152797. export interface ISpriteJSONSpriteFrameData {
  152798. /**
  152799. * number of the x offset of the Frame
  152800. */
  152801. x: number;
  152802. /**
  152803. * number of the y offset of the Frame
  152804. */
  152805. y: number;
  152806. /**
  152807. * number of the width of the Frame
  152808. */
  152809. w: number;
  152810. /**
  152811. * number of the height of the Frame
  152812. */
  152813. h: number;
  152814. }
  152815. /**
  152816. * Defines the basic options interface of a JSON Sprite.
  152817. */
  152818. export interface ISpriteJSONSprite {
  152819. /**
  152820. * string name of the Frame
  152821. */
  152822. filename: string;
  152823. /**
  152824. * ISpriteJSONSpriteFrame basic object of the frame data
  152825. */
  152826. frame: ISpriteJSONSpriteFrameData;
  152827. /**
  152828. * boolean to flag is the frame was rotated.
  152829. */
  152830. rotated: boolean;
  152831. /**
  152832. * boolean to flag is the frame was trimmed.
  152833. */
  152834. trimmed: boolean;
  152835. /**
  152836. * ISpriteJSONSpriteFrame basic object of the source data
  152837. */
  152838. spriteSourceSize: ISpriteJSONSpriteFrameData;
  152839. /**
  152840. * ISpriteJSONSpriteFrame basic object of the source data
  152841. */
  152842. sourceSize: ISpriteJSONSpriteSourceSize;
  152843. }
  152844. /**
  152845. * Defines the basic options interface of a JSON atlas.
  152846. */
  152847. export interface ISpriteJSONAtlas {
  152848. /**
  152849. * Array of objects that contain the frame data.
  152850. */
  152851. frames: Array<ISpriteJSONSprite>;
  152852. /**
  152853. * object basic object containing the sprite meta data.
  152854. */
  152855. meta?: object;
  152856. }
  152857. }
  152858. declare module BABYLON {
  152859. /** @hidden */
  152860. export var spriteMapPixelShader: {
  152861. name: string;
  152862. shader: string;
  152863. };
  152864. }
  152865. declare module BABYLON {
  152866. /** @hidden */
  152867. export var spriteMapVertexShader: {
  152868. name: string;
  152869. shader: string;
  152870. };
  152871. }
  152872. declare module BABYLON {
  152873. /**
  152874. * Defines the basic options interface of a SpriteMap
  152875. */
  152876. export interface ISpriteMapOptions {
  152877. /**
  152878. * Vector2 of the number of cells in the grid.
  152879. */
  152880. stageSize?: Vector2;
  152881. /**
  152882. * Vector2 of the size of the output plane in World Units.
  152883. */
  152884. outputSize?: Vector2;
  152885. /**
  152886. * Vector3 of the position of the output plane in World Units.
  152887. */
  152888. outputPosition?: Vector3;
  152889. /**
  152890. * Vector3 of the rotation of the output plane.
  152891. */
  152892. outputRotation?: Vector3;
  152893. /**
  152894. * number of layers that the system will reserve in resources.
  152895. */
  152896. layerCount?: number;
  152897. /**
  152898. * number of max animation frames a single cell will reserve in resources.
  152899. */
  152900. maxAnimationFrames?: number;
  152901. /**
  152902. * number cell index of the base tile when the system compiles.
  152903. */
  152904. baseTile?: number;
  152905. /**
  152906. * boolean flip the sprite after its been repositioned by the framing data.
  152907. */
  152908. flipU?: boolean;
  152909. /**
  152910. * Vector3 scalar of the global RGB values of the SpriteMap.
  152911. */
  152912. colorMultiply?: Vector3;
  152913. }
  152914. /**
  152915. * Defines the IDisposable interface in order to be cleanable from resources.
  152916. */
  152917. export interface ISpriteMap extends IDisposable {
  152918. /**
  152919. * String name of the SpriteMap.
  152920. */
  152921. name: string;
  152922. /**
  152923. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  152924. */
  152925. atlasJSON: ISpriteJSONAtlas;
  152926. /**
  152927. * Texture of the SpriteMap.
  152928. */
  152929. spriteSheet: Texture;
  152930. /**
  152931. * The parameters to initialize the SpriteMap with.
  152932. */
  152933. options: ISpriteMapOptions;
  152934. }
  152935. /**
  152936. * Class used to manage a grid restricted sprite deployment on an Output plane.
  152937. */
  152938. export class SpriteMap implements ISpriteMap {
  152939. /** The Name of the spriteMap */
  152940. name: string;
  152941. /** The JSON file with the frame and meta data */
  152942. atlasJSON: ISpriteJSONAtlas;
  152943. /** The systems Sprite Sheet Texture */
  152944. spriteSheet: Texture;
  152945. /** Arguments passed with the Constructor */
  152946. options: ISpriteMapOptions;
  152947. /** Public Sprite Storage array, parsed from atlasJSON */
  152948. sprites: Array<ISpriteJSONSprite>;
  152949. /** Returns the Number of Sprites in the System */
  152950. get spriteCount(): number;
  152951. /** Returns the Position of Output Plane*/
  152952. get position(): Vector3;
  152953. /** Returns the Position of Output Plane*/
  152954. set position(v: Vector3);
  152955. /** Returns the Rotation of Output Plane*/
  152956. get rotation(): Vector3;
  152957. /** Returns the Rotation of Output Plane*/
  152958. set rotation(v: Vector3);
  152959. /** Sets the AnimationMap*/
  152960. get animationMap(): RawTexture;
  152961. /** Sets the AnimationMap*/
  152962. set animationMap(v: RawTexture);
  152963. /** Scene that the SpriteMap was created in */
  152964. private _scene;
  152965. /** Texture Buffer of Float32 that holds tile frame data*/
  152966. private _frameMap;
  152967. /** Texture Buffers of Float32 that holds tileMap data*/
  152968. private _tileMaps;
  152969. /** Texture Buffer of Float32 that holds Animation Data*/
  152970. private _animationMap;
  152971. /** Custom ShaderMaterial Central to the System*/
  152972. private _material;
  152973. /** Custom ShaderMaterial Central to the System*/
  152974. private _output;
  152975. /** Systems Time Ticker*/
  152976. private _time;
  152977. /**
  152978. * Creates a new SpriteMap
  152979. * @param name defines the SpriteMaps Name
  152980. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  152981. * @param spriteSheet is the Texture that the Sprites are on.
  152982. * @param options a basic deployment configuration
  152983. * @param scene The Scene that the map is deployed on
  152984. */
  152985. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  152986. /**
  152987. * Returns tileID location
  152988. * @returns Vector2 the cell position ID
  152989. */
  152990. getTileID(): Vector2;
  152991. /**
  152992. * Gets the UV location of the mouse over the SpriteMap.
  152993. * @returns Vector2 the UV position of the mouse interaction
  152994. */
  152995. getMousePosition(): Vector2;
  152996. /**
  152997. * Creates the "frame" texture Buffer
  152998. * -------------------------------------
  152999. * Structure of frames
  153000. * "filename": "Falling-Water-2.png",
  153001. * "frame": {"x":69,"y":103,"w":24,"h":32},
  153002. * "rotated": true,
  153003. * "trimmed": true,
  153004. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  153005. * "sourceSize": {"w":32,"h":32}
  153006. * @returns RawTexture of the frameMap
  153007. */
  153008. private _createFrameBuffer;
  153009. /**
  153010. * Creates the tileMap texture Buffer
  153011. * @param buffer normally and array of numbers, or a false to generate from scratch
  153012. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153013. * @returns RawTexture of the tileMap
  153014. */
  153015. private _createTileBuffer;
  153016. /**
  153017. * Modifies the data of the tileMaps
  153018. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153019. * @param pos is the iVector2 Coordinates of the Tile
  153020. * @param tile The SpriteIndex of the new Tile
  153021. */
  153022. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153023. /**
  153024. * Creates the animationMap texture Buffer
  153025. * @param buffer normally and array of numbers, or a false to generate from scratch
  153026. * @returns RawTexture of the animationMap
  153027. */
  153028. private _createTileAnimationBuffer;
  153029. /**
  153030. * Modifies the data of the animationMap
  153031. * @param cellID is the Index of the Sprite
  153032. * @param _frame is the target Animation frame
  153033. * @param toCell is the Target Index of the next frame of the animation
  153034. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153035. * @param speed is a global scalar of the time variable on the map.
  153036. */
  153037. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153038. /**
  153039. * Exports the .tilemaps file
  153040. */
  153041. saveTileMaps(): void;
  153042. /**
  153043. * Imports the .tilemaps file
  153044. * @param url of the .tilemaps file
  153045. */
  153046. loadTileMaps(url: string): void;
  153047. /**
  153048. * Release associated resources
  153049. */
  153050. dispose(): void;
  153051. }
  153052. }
  153053. declare module BABYLON {
  153054. /**
  153055. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153056. * @see https://doc.babylonjs.com/babylon101/sprites
  153057. */
  153058. export class SpritePackedManager extends SpriteManager {
  153059. /** defines the packed manager's name */
  153060. name: string;
  153061. /**
  153062. * Creates a new sprite manager from a packed sprite sheet
  153063. * @param name defines the manager's name
  153064. * @param imgUrl defines the sprite sheet url
  153065. * @param capacity defines the maximum allowed number of sprites
  153066. * @param scene defines the hosting scene
  153067. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153068. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153069. * @param samplingMode defines the smapling mode to use with spritesheet
  153070. * @param fromPacked set to true; do not alter
  153071. */
  153072. constructor(
  153073. /** defines the packed manager's name */
  153074. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153075. }
  153076. }
  153077. declare module BABYLON {
  153078. /**
  153079. * Defines the list of states available for a task inside a AssetsManager
  153080. */
  153081. export enum AssetTaskState {
  153082. /**
  153083. * Initialization
  153084. */
  153085. INIT = 0,
  153086. /**
  153087. * Running
  153088. */
  153089. RUNNING = 1,
  153090. /**
  153091. * Done
  153092. */
  153093. DONE = 2,
  153094. /**
  153095. * Error
  153096. */
  153097. ERROR = 3
  153098. }
  153099. /**
  153100. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153101. */
  153102. export abstract class AbstractAssetTask {
  153103. /**
  153104. * Task name
  153105. */ name: string;
  153106. /**
  153107. * Callback called when the task is successful
  153108. */
  153109. onSuccess: (task: any) => void;
  153110. /**
  153111. * Callback called when the task is not successful
  153112. */
  153113. onError: (task: any, message?: string, exception?: any) => void;
  153114. /**
  153115. * Creates a new AssetsManager
  153116. * @param name defines the name of the task
  153117. */
  153118. constructor(
  153119. /**
  153120. * Task name
  153121. */ name: string);
  153122. private _isCompleted;
  153123. private _taskState;
  153124. private _errorObject;
  153125. /**
  153126. * Get if the task is completed
  153127. */
  153128. get isCompleted(): boolean;
  153129. /**
  153130. * Gets the current state of the task
  153131. */
  153132. get taskState(): AssetTaskState;
  153133. /**
  153134. * Gets the current error object (if task is in error)
  153135. */
  153136. get errorObject(): {
  153137. message?: string;
  153138. exception?: any;
  153139. };
  153140. /**
  153141. * Internal only
  153142. * @hidden
  153143. */
  153144. _setErrorObject(message?: string, exception?: any): void;
  153145. /**
  153146. * Execute the current task
  153147. * @param scene defines the scene where you want your assets to be loaded
  153148. * @param onSuccess is a callback called when the task is successfully executed
  153149. * @param onError is a callback called if an error occurs
  153150. */
  153151. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153152. /**
  153153. * Execute the current task
  153154. * @param scene defines the scene where you want your assets to be loaded
  153155. * @param onSuccess is a callback called when the task is successfully executed
  153156. * @param onError is a callback called if an error occurs
  153157. */
  153158. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153159. /**
  153160. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153161. * This can be used with failed tasks that have the reason for failure fixed.
  153162. */
  153163. reset(): void;
  153164. private onErrorCallback;
  153165. private onDoneCallback;
  153166. }
  153167. /**
  153168. * Define the interface used by progress events raised during assets loading
  153169. */
  153170. export interface IAssetsProgressEvent {
  153171. /**
  153172. * Defines the number of remaining tasks to process
  153173. */
  153174. remainingCount: number;
  153175. /**
  153176. * Defines the total number of tasks
  153177. */
  153178. totalCount: number;
  153179. /**
  153180. * Defines the task that was just processed
  153181. */
  153182. task: AbstractAssetTask;
  153183. }
  153184. /**
  153185. * Class used to share progress information about assets loading
  153186. */
  153187. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153188. /**
  153189. * Defines the number of remaining tasks to process
  153190. */
  153191. remainingCount: number;
  153192. /**
  153193. * Defines the total number of tasks
  153194. */
  153195. totalCount: number;
  153196. /**
  153197. * Defines the task that was just processed
  153198. */
  153199. task: AbstractAssetTask;
  153200. /**
  153201. * Creates a AssetsProgressEvent
  153202. * @param remainingCount defines the number of remaining tasks to process
  153203. * @param totalCount defines the total number of tasks
  153204. * @param task defines the task that was just processed
  153205. */
  153206. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153207. }
  153208. /**
  153209. * Define a task used by AssetsManager to load assets into a container
  153210. */
  153211. export class ContainerAssetTask extends AbstractAssetTask {
  153212. /**
  153213. * Defines the name of the task
  153214. */
  153215. name: string;
  153216. /**
  153217. * Defines the list of mesh's names you want to load
  153218. */
  153219. meshesNames: any;
  153220. /**
  153221. * Defines the root url to use as a base to load your meshes and associated resources
  153222. */
  153223. rootUrl: string;
  153224. /**
  153225. * Defines the filename or File of the scene to load from
  153226. */
  153227. sceneFilename: string | File;
  153228. /**
  153229. * Get the loaded asset container
  153230. */
  153231. loadedContainer: AssetContainer;
  153232. /**
  153233. * Gets the list of loaded meshes
  153234. */
  153235. loadedMeshes: Array<AbstractMesh>;
  153236. /**
  153237. * Gets the list of loaded particle systems
  153238. */
  153239. loadedParticleSystems: Array<IParticleSystem>;
  153240. /**
  153241. * Gets the list of loaded skeletons
  153242. */
  153243. loadedSkeletons: Array<Skeleton>;
  153244. /**
  153245. * Gets the list of loaded animation groups
  153246. */
  153247. loadedAnimationGroups: Array<AnimationGroup>;
  153248. /**
  153249. * Callback called when the task is successful
  153250. */
  153251. onSuccess: (task: ContainerAssetTask) => void;
  153252. /**
  153253. * Callback called when the task is successful
  153254. */
  153255. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153256. /**
  153257. * Creates a new ContainerAssetTask
  153258. * @param name defines the name of the task
  153259. * @param meshesNames defines the list of mesh's names you want to load
  153260. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153261. * @param sceneFilename defines the filename or File of the scene to load from
  153262. */
  153263. constructor(
  153264. /**
  153265. * Defines the name of the task
  153266. */
  153267. name: string,
  153268. /**
  153269. * Defines the list of mesh's names you want to load
  153270. */
  153271. meshesNames: any,
  153272. /**
  153273. * Defines the root url to use as a base to load your meshes and associated resources
  153274. */
  153275. rootUrl: string,
  153276. /**
  153277. * Defines the filename or File of the scene to load from
  153278. */
  153279. sceneFilename: string | File);
  153280. /**
  153281. * Execute the current task
  153282. * @param scene defines the scene where you want your assets to be loaded
  153283. * @param onSuccess is a callback called when the task is successfully executed
  153284. * @param onError is a callback called if an error occurs
  153285. */
  153286. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153287. }
  153288. /**
  153289. * Define a task used by AssetsManager to load meshes
  153290. */
  153291. export class MeshAssetTask extends AbstractAssetTask {
  153292. /**
  153293. * Defines the name of the task
  153294. */
  153295. name: string;
  153296. /**
  153297. * Defines the list of mesh's names you want to load
  153298. */
  153299. meshesNames: any;
  153300. /**
  153301. * Defines the root url to use as a base to load your meshes and associated resources
  153302. */
  153303. rootUrl: string;
  153304. /**
  153305. * Defines the filename or File of the scene to load from
  153306. */
  153307. sceneFilename: string | File;
  153308. /**
  153309. * Gets the list of loaded meshes
  153310. */
  153311. loadedMeshes: Array<AbstractMesh>;
  153312. /**
  153313. * Gets the list of loaded particle systems
  153314. */
  153315. loadedParticleSystems: Array<IParticleSystem>;
  153316. /**
  153317. * Gets the list of loaded skeletons
  153318. */
  153319. loadedSkeletons: Array<Skeleton>;
  153320. /**
  153321. * Gets the list of loaded animation groups
  153322. */
  153323. loadedAnimationGroups: Array<AnimationGroup>;
  153324. /**
  153325. * Callback called when the task is successful
  153326. */
  153327. onSuccess: (task: MeshAssetTask) => void;
  153328. /**
  153329. * Callback called when the task is successful
  153330. */
  153331. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  153332. /**
  153333. * Creates a new MeshAssetTask
  153334. * @param name defines the name of the task
  153335. * @param meshesNames defines the list of mesh's names you want to load
  153336. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153337. * @param sceneFilename defines the filename or File of the scene to load from
  153338. */
  153339. constructor(
  153340. /**
  153341. * Defines the name of the task
  153342. */
  153343. name: string,
  153344. /**
  153345. * Defines the list of mesh's names you want to load
  153346. */
  153347. meshesNames: any,
  153348. /**
  153349. * Defines the root url to use as a base to load your meshes and associated resources
  153350. */
  153351. rootUrl: string,
  153352. /**
  153353. * Defines the filename or File of the scene to load from
  153354. */
  153355. sceneFilename: string | File);
  153356. /**
  153357. * Execute the current task
  153358. * @param scene defines the scene where you want your assets to be loaded
  153359. * @param onSuccess is a callback called when the task is successfully executed
  153360. * @param onError is a callback called if an error occurs
  153361. */
  153362. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153363. }
  153364. /**
  153365. * Define a task used by AssetsManager to load text content
  153366. */
  153367. export class TextFileAssetTask extends AbstractAssetTask {
  153368. /**
  153369. * Defines the name of the task
  153370. */
  153371. name: string;
  153372. /**
  153373. * Defines the location of the file to load
  153374. */
  153375. url: string;
  153376. /**
  153377. * Gets the loaded text string
  153378. */
  153379. text: string;
  153380. /**
  153381. * Callback called when the task is successful
  153382. */
  153383. onSuccess: (task: TextFileAssetTask) => void;
  153384. /**
  153385. * Callback called when the task is successful
  153386. */
  153387. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  153388. /**
  153389. * Creates a new TextFileAssetTask object
  153390. * @param name defines the name of the task
  153391. * @param url defines the location of the file to load
  153392. */
  153393. constructor(
  153394. /**
  153395. * Defines the name of the task
  153396. */
  153397. name: string,
  153398. /**
  153399. * Defines the location of the file to load
  153400. */
  153401. url: string);
  153402. /**
  153403. * Execute the current task
  153404. * @param scene defines the scene where you want your assets to be loaded
  153405. * @param onSuccess is a callback called when the task is successfully executed
  153406. * @param onError is a callback called if an error occurs
  153407. */
  153408. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153409. }
  153410. /**
  153411. * Define a task used by AssetsManager to load binary data
  153412. */
  153413. export class BinaryFileAssetTask extends AbstractAssetTask {
  153414. /**
  153415. * Defines the name of the task
  153416. */
  153417. name: string;
  153418. /**
  153419. * Defines the location of the file to load
  153420. */
  153421. url: string;
  153422. /**
  153423. * Gets the lodaded data (as an array buffer)
  153424. */
  153425. data: ArrayBuffer;
  153426. /**
  153427. * Callback called when the task is successful
  153428. */
  153429. onSuccess: (task: BinaryFileAssetTask) => void;
  153430. /**
  153431. * Callback called when the task is successful
  153432. */
  153433. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  153434. /**
  153435. * Creates a new BinaryFileAssetTask object
  153436. * @param name defines the name of the new task
  153437. * @param url defines the location of the file to load
  153438. */
  153439. constructor(
  153440. /**
  153441. * Defines the name of the task
  153442. */
  153443. name: string,
  153444. /**
  153445. * Defines the location of the file to load
  153446. */
  153447. url: string);
  153448. /**
  153449. * Execute the current task
  153450. * @param scene defines the scene where you want your assets to be loaded
  153451. * @param onSuccess is a callback called when the task is successfully executed
  153452. * @param onError is a callback called if an error occurs
  153453. */
  153454. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153455. }
  153456. /**
  153457. * Define a task used by AssetsManager to load images
  153458. */
  153459. export class ImageAssetTask extends AbstractAssetTask {
  153460. /**
  153461. * Defines the name of the task
  153462. */
  153463. name: string;
  153464. /**
  153465. * Defines the location of the image to load
  153466. */
  153467. url: string;
  153468. /**
  153469. * Gets the loaded images
  153470. */
  153471. image: HTMLImageElement;
  153472. /**
  153473. * Callback called when the task is successful
  153474. */
  153475. onSuccess: (task: ImageAssetTask) => void;
  153476. /**
  153477. * Callback called when the task is successful
  153478. */
  153479. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  153480. /**
  153481. * Creates a new ImageAssetTask
  153482. * @param name defines the name of the task
  153483. * @param url defines the location of the image to load
  153484. */
  153485. constructor(
  153486. /**
  153487. * Defines the name of the task
  153488. */
  153489. name: string,
  153490. /**
  153491. * Defines the location of the image to load
  153492. */
  153493. url: string);
  153494. /**
  153495. * Execute the current task
  153496. * @param scene defines the scene where you want your assets to be loaded
  153497. * @param onSuccess is a callback called when the task is successfully executed
  153498. * @param onError is a callback called if an error occurs
  153499. */
  153500. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153501. }
  153502. /**
  153503. * Defines the interface used by texture loading tasks
  153504. */
  153505. export interface ITextureAssetTask<TEX extends BaseTexture> {
  153506. /**
  153507. * Gets the loaded texture
  153508. */
  153509. texture: TEX;
  153510. }
  153511. /**
  153512. * Define a task used by AssetsManager to load 2D textures
  153513. */
  153514. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  153515. /**
  153516. * Defines the name of the task
  153517. */
  153518. name: string;
  153519. /**
  153520. * Defines the location of the file to load
  153521. */
  153522. url: string;
  153523. /**
  153524. * Defines if mipmap should not be generated (default is false)
  153525. */
  153526. noMipmap?: boolean | undefined;
  153527. /**
  153528. * Defines if texture must be inverted on Y axis (default is true)
  153529. */
  153530. invertY: boolean;
  153531. /**
  153532. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153533. */
  153534. samplingMode: number;
  153535. /**
  153536. * Gets the loaded texture
  153537. */
  153538. texture: Texture;
  153539. /**
  153540. * Callback called when the task is successful
  153541. */
  153542. onSuccess: (task: TextureAssetTask) => void;
  153543. /**
  153544. * Callback called when the task is successful
  153545. */
  153546. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  153547. /**
  153548. * Creates a new TextureAssetTask object
  153549. * @param name defines the name of the task
  153550. * @param url defines the location of the file to load
  153551. * @param noMipmap defines if mipmap should not be generated (default is false)
  153552. * @param invertY defines if texture must be inverted on Y axis (default is true)
  153553. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153554. */
  153555. constructor(
  153556. /**
  153557. * Defines the name of the task
  153558. */
  153559. name: string,
  153560. /**
  153561. * Defines the location of the file to load
  153562. */
  153563. url: string,
  153564. /**
  153565. * Defines if mipmap should not be generated (default is false)
  153566. */
  153567. noMipmap?: boolean | undefined,
  153568. /**
  153569. * Defines if texture must be inverted on Y axis (default is true)
  153570. */
  153571. invertY?: boolean,
  153572. /**
  153573. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153574. */
  153575. samplingMode?: number);
  153576. /**
  153577. * Execute the current task
  153578. * @param scene defines the scene where you want your assets to be loaded
  153579. * @param onSuccess is a callback called when the task is successfully executed
  153580. * @param onError is a callback called if an error occurs
  153581. */
  153582. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153583. }
  153584. /**
  153585. * Define a task used by AssetsManager to load cube textures
  153586. */
  153587. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  153588. /**
  153589. * Defines the name of the task
  153590. */
  153591. name: string;
  153592. /**
  153593. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153594. */
  153595. url: string;
  153596. /**
  153597. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153598. */
  153599. extensions?: string[] | undefined;
  153600. /**
  153601. * Defines if mipmaps should not be generated (default is false)
  153602. */
  153603. noMipmap?: boolean | undefined;
  153604. /**
  153605. * Defines the explicit list of files (undefined by default)
  153606. */
  153607. files?: string[] | undefined;
  153608. /**
  153609. * Gets the loaded texture
  153610. */
  153611. texture: CubeTexture;
  153612. /**
  153613. * Callback called when the task is successful
  153614. */
  153615. onSuccess: (task: CubeTextureAssetTask) => void;
  153616. /**
  153617. * Callback called when the task is successful
  153618. */
  153619. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  153620. /**
  153621. * Creates a new CubeTextureAssetTask
  153622. * @param name defines the name of the task
  153623. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153624. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153625. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153626. * @param files defines the explicit list of files (undefined by default)
  153627. */
  153628. constructor(
  153629. /**
  153630. * Defines the name of the task
  153631. */
  153632. name: string,
  153633. /**
  153634. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153635. */
  153636. url: string,
  153637. /**
  153638. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153639. */
  153640. extensions?: string[] | undefined,
  153641. /**
  153642. * Defines if mipmaps should not be generated (default is false)
  153643. */
  153644. noMipmap?: boolean | undefined,
  153645. /**
  153646. * Defines the explicit list of files (undefined by default)
  153647. */
  153648. files?: string[] | undefined);
  153649. /**
  153650. * Execute the current task
  153651. * @param scene defines the scene where you want your assets to be loaded
  153652. * @param onSuccess is a callback called when the task is successfully executed
  153653. * @param onError is a callback called if an error occurs
  153654. */
  153655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153656. }
  153657. /**
  153658. * Define a task used by AssetsManager to load HDR cube textures
  153659. */
  153660. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  153661. /**
  153662. * Defines the name of the task
  153663. */
  153664. name: string;
  153665. /**
  153666. * Defines the location of the file to load
  153667. */
  153668. url: string;
  153669. /**
  153670. * Defines the desired size (the more it increases the longer the generation will be)
  153671. */
  153672. size: number;
  153673. /**
  153674. * Defines if mipmaps should not be generated (default is false)
  153675. */
  153676. noMipmap: boolean;
  153677. /**
  153678. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153679. */
  153680. generateHarmonics: boolean;
  153681. /**
  153682. * 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)
  153683. */
  153684. gammaSpace: boolean;
  153685. /**
  153686. * Internal Use Only
  153687. */
  153688. reserved: boolean;
  153689. /**
  153690. * Gets the loaded texture
  153691. */
  153692. texture: HDRCubeTexture;
  153693. /**
  153694. * Callback called when the task is successful
  153695. */
  153696. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  153697. /**
  153698. * Callback called when the task is successful
  153699. */
  153700. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  153701. /**
  153702. * Creates a new HDRCubeTextureAssetTask object
  153703. * @param name defines the name of the task
  153704. * @param url defines the location of the file to load
  153705. * @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.
  153706. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153707. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153708. * @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)
  153709. * @param reserved Internal use only
  153710. */
  153711. constructor(
  153712. /**
  153713. * Defines the name of the task
  153714. */
  153715. name: string,
  153716. /**
  153717. * Defines the location of the file to load
  153718. */
  153719. url: string,
  153720. /**
  153721. * Defines the desired size (the more it increases the longer the generation will be)
  153722. */
  153723. size: number,
  153724. /**
  153725. * Defines if mipmaps should not be generated (default is false)
  153726. */
  153727. noMipmap?: boolean,
  153728. /**
  153729. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153730. */
  153731. generateHarmonics?: boolean,
  153732. /**
  153733. * 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)
  153734. */
  153735. gammaSpace?: boolean,
  153736. /**
  153737. * Internal Use Only
  153738. */
  153739. reserved?: boolean);
  153740. /**
  153741. * Execute the current task
  153742. * @param scene defines the scene where you want your assets to be loaded
  153743. * @param onSuccess is a callback called when the task is successfully executed
  153744. * @param onError is a callback called if an error occurs
  153745. */
  153746. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153747. }
  153748. /**
  153749. * Define a task used by AssetsManager to load Equirectangular cube textures
  153750. */
  153751. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  153752. /**
  153753. * Defines the name of the task
  153754. */
  153755. name: string;
  153756. /**
  153757. * Defines the location of the file to load
  153758. */
  153759. url: string;
  153760. /**
  153761. * Defines the desired size (the more it increases the longer the generation will be)
  153762. */
  153763. size: number;
  153764. /**
  153765. * Defines if mipmaps should not be generated (default is false)
  153766. */
  153767. noMipmap: boolean;
  153768. /**
  153769. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153770. * but the standard material would require them in Gamma space) (default is true)
  153771. */
  153772. gammaSpace: boolean;
  153773. /**
  153774. * Gets the loaded texture
  153775. */
  153776. texture: EquiRectangularCubeTexture;
  153777. /**
  153778. * Callback called when the task is successful
  153779. */
  153780. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  153781. /**
  153782. * Callback called when the task is successful
  153783. */
  153784. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  153785. /**
  153786. * Creates a new EquiRectangularCubeTextureAssetTask object
  153787. * @param name defines the name of the task
  153788. * @param url defines the location of the file to load
  153789. * @param size defines the desired size (the more it increases the longer the generation will be)
  153790. * If the size is omitted this implies you are using a preprocessed cubemap.
  153791. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153792. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  153793. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  153794. * (default is true)
  153795. */
  153796. constructor(
  153797. /**
  153798. * Defines the name of the task
  153799. */
  153800. name: string,
  153801. /**
  153802. * Defines the location of the file to load
  153803. */
  153804. url: string,
  153805. /**
  153806. * Defines the desired size (the more it increases the longer the generation will be)
  153807. */
  153808. size: number,
  153809. /**
  153810. * Defines if mipmaps should not be generated (default is false)
  153811. */
  153812. noMipmap?: boolean,
  153813. /**
  153814. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153815. * but the standard material would require them in Gamma space) (default is true)
  153816. */
  153817. gammaSpace?: boolean);
  153818. /**
  153819. * Execute the current task
  153820. * @param scene defines the scene where you want your assets to be loaded
  153821. * @param onSuccess is a callback called when the task is successfully executed
  153822. * @param onError is a callback called if an error occurs
  153823. */
  153824. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153825. }
  153826. /**
  153827. * This class can be used to easily import assets into a scene
  153828. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  153829. */
  153830. export class AssetsManager {
  153831. private _scene;
  153832. private _isLoading;
  153833. protected _tasks: AbstractAssetTask[];
  153834. protected _waitingTasksCount: number;
  153835. protected _totalTasksCount: number;
  153836. /**
  153837. * Callback called when all tasks are processed
  153838. */
  153839. onFinish: (tasks: AbstractAssetTask[]) => void;
  153840. /**
  153841. * Callback called when a task is successful
  153842. */
  153843. onTaskSuccess: (task: AbstractAssetTask) => void;
  153844. /**
  153845. * Callback called when a task had an error
  153846. */
  153847. onTaskError: (task: AbstractAssetTask) => void;
  153848. /**
  153849. * Callback called when a task is done (whatever the result is)
  153850. */
  153851. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  153852. /**
  153853. * Observable called when all tasks are processed
  153854. */
  153855. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  153856. /**
  153857. * Observable called when a task had an error
  153858. */
  153859. onTaskErrorObservable: Observable<AbstractAssetTask>;
  153860. /**
  153861. * Observable called when all tasks were executed
  153862. */
  153863. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  153864. /**
  153865. * Observable called when a task is done (whatever the result is)
  153866. */
  153867. onProgressObservable: Observable<IAssetsProgressEvent>;
  153868. /**
  153869. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  153870. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  153871. */
  153872. useDefaultLoadingScreen: boolean;
  153873. /**
  153874. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  153875. * when all assets have been downloaded.
  153876. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  153877. */
  153878. autoHideLoadingUI: boolean;
  153879. /**
  153880. * Creates a new AssetsManager
  153881. * @param scene defines the scene to work on
  153882. */
  153883. constructor(scene: Scene);
  153884. /**
  153885. * Add a ContainerAssetTask to the list of active tasks
  153886. * @param taskName defines the name of the new task
  153887. * @param meshesNames defines the name of meshes to load
  153888. * @param rootUrl defines the root url to use to locate files
  153889. * @param sceneFilename defines the filename of the scene file
  153890. * @returns a new ContainerAssetTask object
  153891. */
  153892. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  153893. /**
  153894. * Add a MeshAssetTask to the list of active tasks
  153895. * @param taskName defines the name of the new task
  153896. * @param meshesNames defines the name of meshes to load
  153897. * @param rootUrl defines the root url to use to locate files
  153898. * @param sceneFilename defines the filename of the scene file
  153899. * @returns a new MeshAssetTask object
  153900. */
  153901. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  153902. /**
  153903. * Add a TextFileAssetTask to the list of active tasks
  153904. * @param taskName defines the name of the new task
  153905. * @param url defines the url of the file to load
  153906. * @returns a new TextFileAssetTask object
  153907. */
  153908. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  153909. /**
  153910. * Add a BinaryFileAssetTask to the list of active tasks
  153911. * @param taskName defines the name of the new task
  153912. * @param url defines the url of the file to load
  153913. * @returns a new BinaryFileAssetTask object
  153914. */
  153915. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  153916. /**
  153917. * Add a ImageAssetTask to the list of active tasks
  153918. * @param taskName defines the name of the new task
  153919. * @param url defines the url of the file to load
  153920. * @returns a new ImageAssetTask object
  153921. */
  153922. addImageTask(taskName: string, url: string): ImageAssetTask;
  153923. /**
  153924. * Add a TextureAssetTask to the list of active tasks
  153925. * @param taskName defines the name of the new task
  153926. * @param url defines the url of the file to load
  153927. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153928. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  153929. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  153930. * @returns a new TextureAssetTask object
  153931. */
  153932. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  153933. /**
  153934. * Add a CubeTextureAssetTask to the list of active tasks
  153935. * @param taskName defines the name of the new task
  153936. * @param url defines the url of the file to load
  153937. * @param extensions defines the extension to use to load the cube map (can be null)
  153938. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153939. * @param files defines the list of files to load (can be null)
  153940. * @returns a new CubeTextureAssetTask object
  153941. */
  153942. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  153943. /**
  153944. *
  153945. * Add a HDRCubeTextureAssetTask to the list of active tasks
  153946. * @param taskName defines the name of the new task
  153947. * @param url defines the url of the file to load
  153948. * @param size defines the size you want for the cubemap (can be null)
  153949. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153950. * @param generateHarmonics defines if you want to automatically generate (true by default)
  153951. * @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)
  153952. * @param reserved Internal use only
  153953. * @returns a new HDRCubeTextureAssetTask object
  153954. */
  153955. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  153956. /**
  153957. *
  153958. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  153959. * @param taskName defines the name of the new task
  153960. * @param url defines the url of the file to load
  153961. * @param size defines the size you want for the cubemap (can be null)
  153962. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153963. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  153964. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  153965. * @returns a new EquiRectangularCubeTextureAssetTask object
  153966. */
  153967. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  153968. /**
  153969. * Remove a task from the assets manager.
  153970. * @param task the task to remove
  153971. */
  153972. removeTask(task: AbstractAssetTask): void;
  153973. private _decreaseWaitingTasksCount;
  153974. private _runTask;
  153975. /**
  153976. * Reset the AssetsManager and remove all tasks
  153977. * @return the current instance of the AssetsManager
  153978. */
  153979. reset(): AssetsManager;
  153980. /**
  153981. * Start the loading process
  153982. * @return the current instance of the AssetsManager
  153983. */
  153984. load(): AssetsManager;
  153985. /**
  153986. * Start the loading process as an async operation
  153987. * @return a promise returning the list of failed tasks
  153988. */
  153989. loadAsync(): Promise<void>;
  153990. }
  153991. }
  153992. declare module BABYLON {
  153993. /**
  153994. * Wrapper class for promise with external resolve and reject.
  153995. */
  153996. export class Deferred<T> {
  153997. /**
  153998. * The promise associated with this deferred object.
  153999. */
  154000. readonly promise: Promise<T>;
  154001. private _resolve;
  154002. private _reject;
  154003. /**
  154004. * The resolve method of the promise associated with this deferred object.
  154005. */
  154006. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  154007. /**
  154008. * The reject method of the promise associated with this deferred object.
  154009. */
  154010. get reject(): (reason?: any) => void;
  154011. /**
  154012. * Constructor for this deferred object.
  154013. */
  154014. constructor();
  154015. }
  154016. }
  154017. declare module BABYLON {
  154018. /**
  154019. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154020. */
  154021. export class MeshExploder {
  154022. private _centerMesh;
  154023. private _meshes;
  154024. private _meshesOrigins;
  154025. private _toCenterVectors;
  154026. private _scaledDirection;
  154027. private _newPosition;
  154028. private _centerPosition;
  154029. /**
  154030. * Explodes meshes from a center mesh.
  154031. * @param meshes The meshes to explode.
  154032. * @param centerMesh The mesh to be center of explosion.
  154033. */
  154034. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154035. private _setCenterMesh;
  154036. /**
  154037. * Get class name
  154038. * @returns "MeshExploder"
  154039. */
  154040. getClassName(): string;
  154041. /**
  154042. * "Exploded meshes"
  154043. * @returns Array of meshes with the centerMesh at index 0.
  154044. */
  154045. getMeshes(): Array<Mesh>;
  154046. /**
  154047. * Explodes meshes giving a specific direction
  154048. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154049. */
  154050. explode(direction?: number): void;
  154051. }
  154052. }
  154053. declare module BABYLON {
  154054. /**
  154055. * Class used to help managing file picking and drag'n'drop
  154056. */
  154057. export class FilesInput {
  154058. /**
  154059. * List of files ready to be loaded
  154060. */
  154061. static get FilesToLoad(): {
  154062. [key: string]: File;
  154063. };
  154064. /**
  154065. * Callback called when a file is processed
  154066. */
  154067. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154068. private _engine;
  154069. private _currentScene;
  154070. private _sceneLoadedCallback;
  154071. private _progressCallback;
  154072. private _additionalRenderLoopLogicCallback;
  154073. private _textureLoadingCallback;
  154074. private _startingProcessingFilesCallback;
  154075. private _onReloadCallback;
  154076. private _errorCallback;
  154077. private _elementToMonitor;
  154078. private _sceneFileToLoad;
  154079. private _filesToLoad;
  154080. /**
  154081. * Creates a new FilesInput
  154082. * @param engine defines the rendering engine
  154083. * @param scene defines the hosting scene
  154084. * @param sceneLoadedCallback callback called when scene is loaded
  154085. * @param progressCallback callback called to track progress
  154086. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154087. * @param textureLoadingCallback callback called when a texture is loading
  154088. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154089. * @param onReloadCallback callback called when a reload is requested
  154090. * @param errorCallback callback call if an error occurs
  154091. */
  154092. 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>);
  154093. private _dragEnterHandler;
  154094. private _dragOverHandler;
  154095. private _dropHandler;
  154096. /**
  154097. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154098. * @param elementToMonitor defines the DOM element to track
  154099. */
  154100. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154101. /** Gets the current list of files to load */
  154102. get filesToLoad(): File[];
  154103. /**
  154104. * Release all associated resources
  154105. */
  154106. dispose(): void;
  154107. private renderFunction;
  154108. private drag;
  154109. private drop;
  154110. private _traverseFolder;
  154111. private _processFiles;
  154112. /**
  154113. * Load files from a drop event
  154114. * @param event defines the drop event to use as source
  154115. */
  154116. loadFiles(event: any): void;
  154117. private _processReload;
  154118. /**
  154119. * Reload the current scene from the loaded files
  154120. */
  154121. reload(): void;
  154122. }
  154123. }
  154124. declare module BABYLON {
  154125. /**
  154126. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154127. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154128. */
  154129. export class SceneOptimization {
  154130. /**
  154131. * Defines the priority of this optimization (0 by default which means first in the list)
  154132. */
  154133. priority: number;
  154134. /**
  154135. * Gets a string describing the action executed by the current optimization
  154136. * @returns description string
  154137. */
  154138. getDescription(): string;
  154139. /**
  154140. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154141. * @param scene defines the current scene where to apply this optimization
  154142. * @param optimizer defines the current optimizer
  154143. * @returns true if everything that can be done was applied
  154144. */
  154145. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154146. /**
  154147. * Creates the SceneOptimization object
  154148. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154149. * @param desc defines the description associated with the optimization
  154150. */
  154151. constructor(
  154152. /**
  154153. * Defines the priority of this optimization (0 by default which means first in the list)
  154154. */
  154155. priority?: number);
  154156. }
  154157. /**
  154158. * Defines an optimization used to reduce the size of render target textures
  154159. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154160. */
  154161. export class TextureOptimization extends SceneOptimization {
  154162. /**
  154163. * Defines the priority of this optimization (0 by default which means first in the list)
  154164. */
  154165. priority: number;
  154166. /**
  154167. * 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
  154168. */
  154169. maximumSize: number;
  154170. /**
  154171. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154172. */
  154173. step: number;
  154174. /**
  154175. * Gets a string describing the action executed by the current optimization
  154176. * @returns description string
  154177. */
  154178. getDescription(): string;
  154179. /**
  154180. * Creates the TextureOptimization object
  154181. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154182. * @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
  154183. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154184. */
  154185. constructor(
  154186. /**
  154187. * Defines the priority of this optimization (0 by default which means first in the list)
  154188. */
  154189. priority?: number,
  154190. /**
  154191. * 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
  154192. */
  154193. maximumSize?: number,
  154194. /**
  154195. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154196. */
  154197. step?: number);
  154198. /**
  154199. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154200. * @param scene defines the current scene where to apply this optimization
  154201. * @param optimizer defines the current optimizer
  154202. * @returns true if everything that can be done was applied
  154203. */
  154204. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154205. }
  154206. /**
  154207. * Defines an optimization used to increase or decrease the rendering resolution
  154208. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154209. */
  154210. export class HardwareScalingOptimization extends SceneOptimization {
  154211. /**
  154212. * Defines the priority of this optimization (0 by default which means first in the list)
  154213. */
  154214. priority: number;
  154215. /**
  154216. * Defines the maximum scale to use (2 by default)
  154217. */
  154218. maximumScale: number;
  154219. /**
  154220. * Defines the step to use between two passes (0.5 by default)
  154221. */
  154222. step: number;
  154223. private _currentScale;
  154224. private _directionOffset;
  154225. /**
  154226. * Gets a string describing the action executed by the current optimization
  154227. * @return description string
  154228. */
  154229. getDescription(): string;
  154230. /**
  154231. * Creates the HardwareScalingOptimization object
  154232. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154233. * @param maximumScale defines the maximum scale to use (2 by default)
  154234. * @param step defines the step to use between two passes (0.5 by default)
  154235. */
  154236. constructor(
  154237. /**
  154238. * Defines the priority of this optimization (0 by default which means first in the list)
  154239. */
  154240. priority?: number,
  154241. /**
  154242. * Defines the maximum scale to use (2 by default)
  154243. */
  154244. maximumScale?: number,
  154245. /**
  154246. * Defines the step to use between two passes (0.5 by default)
  154247. */
  154248. step?: number);
  154249. /**
  154250. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154251. * @param scene defines the current scene where to apply this optimization
  154252. * @param optimizer defines the current optimizer
  154253. * @returns true if everything that can be done was applied
  154254. */
  154255. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154256. }
  154257. /**
  154258. * Defines an optimization used to remove shadows
  154259. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154260. */
  154261. export class ShadowsOptimization extends SceneOptimization {
  154262. /**
  154263. * Gets a string describing the action executed by the current optimization
  154264. * @return description string
  154265. */
  154266. getDescription(): string;
  154267. /**
  154268. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154269. * @param scene defines the current scene where to apply this optimization
  154270. * @param optimizer defines the current optimizer
  154271. * @returns true if everything that can be done was applied
  154272. */
  154273. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154274. }
  154275. /**
  154276. * Defines an optimization used to turn post-processes off
  154277. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154278. */
  154279. export class PostProcessesOptimization extends SceneOptimization {
  154280. /**
  154281. * Gets a string describing the action executed by the current optimization
  154282. * @return description string
  154283. */
  154284. getDescription(): string;
  154285. /**
  154286. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154287. * @param scene defines the current scene where to apply this optimization
  154288. * @param optimizer defines the current optimizer
  154289. * @returns true if everything that can be done was applied
  154290. */
  154291. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154292. }
  154293. /**
  154294. * Defines an optimization used to turn lens flares off
  154295. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154296. */
  154297. export class LensFlaresOptimization extends SceneOptimization {
  154298. /**
  154299. * Gets a string describing the action executed by the current optimization
  154300. * @return description string
  154301. */
  154302. getDescription(): string;
  154303. /**
  154304. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154305. * @param scene defines the current scene where to apply this optimization
  154306. * @param optimizer defines the current optimizer
  154307. * @returns true if everything that can be done was applied
  154308. */
  154309. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154310. }
  154311. /**
  154312. * Defines an optimization based on user defined callback.
  154313. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154314. */
  154315. export class CustomOptimization extends SceneOptimization {
  154316. /**
  154317. * Callback called to apply the custom optimization.
  154318. */
  154319. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  154320. /**
  154321. * Callback called to get custom description
  154322. */
  154323. onGetDescription: () => string;
  154324. /**
  154325. * Gets a string describing the action executed by the current optimization
  154326. * @returns description string
  154327. */
  154328. getDescription(): string;
  154329. /**
  154330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154331. * @param scene defines the current scene where to apply this optimization
  154332. * @param optimizer defines the current optimizer
  154333. * @returns true if everything that can be done was applied
  154334. */
  154335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154336. }
  154337. /**
  154338. * Defines an optimization used to turn particles off
  154339. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154340. */
  154341. export class ParticlesOptimization extends SceneOptimization {
  154342. /**
  154343. * Gets a string describing the action executed by the current optimization
  154344. * @return description string
  154345. */
  154346. getDescription(): string;
  154347. /**
  154348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154349. * @param scene defines the current scene where to apply this optimization
  154350. * @param optimizer defines the current optimizer
  154351. * @returns true if everything that can be done was applied
  154352. */
  154353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154354. }
  154355. /**
  154356. * Defines an optimization used to turn render targets off
  154357. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154358. */
  154359. export class RenderTargetsOptimization extends SceneOptimization {
  154360. /**
  154361. * Gets a string describing the action executed by the current optimization
  154362. * @return description string
  154363. */
  154364. getDescription(): string;
  154365. /**
  154366. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154367. * @param scene defines the current scene where to apply this optimization
  154368. * @param optimizer defines the current optimizer
  154369. * @returns true if everything that can be done was applied
  154370. */
  154371. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154372. }
  154373. /**
  154374. * Defines an optimization used to merge meshes with compatible materials
  154375. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154376. */
  154377. export class MergeMeshesOptimization extends SceneOptimization {
  154378. private static _UpdateSelectionTree;
  154379. /**
  154380. * Gets or sets a boolean which defines if optimization octree has to be updated
  154381. */
  154382. static get UpdateSelectionTree(): boolean;
  154383. /**
  154384. * Gets or sets a boolean which defines if optimization octree has to be updated
  154385. */
  154386. static set UpdateSelectionTree(value: boolean);
  154387. /**
  154388. * Gets a string describing the action executed by the current optimization
  154389. * @return description string
  154390. */
  154391. getDescription(): string;
  154392. private _canBeMerged;
  154393. /**
  154394. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154395. * @param scene defines the current scene where to apply this optimization
  154396. * @param optimizer defines the current optimizer
  154397. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  154398. * @returns true if everything that can be done was applied
  154399. */
  154400. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  154401. }
  154402. /**
  154403. * Defines a list of options used by SceneOptimizer
  154404. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154405. */
  154406. export class SceneOptimizerOptions {
  154407. /**
  154408. * Defines the target frame rate to reach (60 by default)
  154409. */
  154410. targetFrameRate: number;
  154411. /**
  154412. * Defines the interval between two checkes (2000ms by default)
  154413. */
  154414. trackerDuration: number;
  154415. /**
  154416. * Gets the list of optimizations to apply
  154417. */
  154418. optimizations: SceneOptimization[];
  154419. /**
  154420. * Creates a new list of options used by SceneOptimizer
  154421. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  154422. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  154423. */
  154424. constructor(
  154425. /**
  154426. * Defines the target frame rate to reach (60 by default)
  154427. */
  154428. targetFrameRate?: number,
  154429. /**
  154430. * Defines the interval between two checkes (2000ms by default)
  154431. */
  154432. trackerDuration?: number);
  154433. /**
  154434. * Add a new optimization
  154435. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  154436. * @returns the current SceneOptimizerOptions
  154437. */
  154438. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  154439. /**
  154440. * Add a new custom optimization
  154441. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  154442. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  154443. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154444. * @returns the current SceneOptimizerOptions
  154445. */
  154446. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  154447. /**
  154448. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  154449. * @param targetFrameRate defines the target frame rate (60 by default)
  154450. * @returns a SceneOptimizerOptions object
  154451. */
  154452. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154453. /**
  154454. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  154455. * @param targetFrameRate defines the target frame rate (60 by default)
  154456. * @returns a SceneOptimizerOptions object
  154457. */
  154458. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154459. /**
  154460. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  154461. * @param targetFrameRate defines the target frame rate (60 by default)
  154462. * @returns a SceneOptimizerOptions object
  154463. */
  154464. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154465. }
  154466. /**
  154467. * Class used to run optimizations in order to reach a target frame rate
  154468. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154469. */
  154470. export class SceneOptimizer implements IDisposable {
  154471. private _isRunning;
  154472. private _options;
  154473. private _scene;
  154474. private _currentPriorityLevel;
  154475. private _targetFrameRate;
  154476. private _trackerDuration;
  154477. private _currentFrameRate;
  154478. private _sceneDisposeObserver;
  154479. private _improvementMode;
  154480. /**
  154481. * Defines an observable called when the optimizer reaches the target frame rate
  154482. */
  154483. onSuccessObservable: Observable<SceneOptimizer>;
  154484. /**
  154485. * Defines an observable called when the optimizer enables an optimization
  154486. */
  154487. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  154488. /**
  154489. * Defines an observable called when the optimizer is not able to reach the target frame rate
  154490. */
  154491. onFailureObservable: Observable<SceneOptimizer>;
  154492. /**
  154493. * Gets a boolean indicating if the optimizer is in improvement mode
  154494. */
  154495. get isInImprovementMode(): boolean;
  154496. /**
  154497. * Gets the current priority level (0 at start)
  154498. */
  154499. get currentPriorityLevel(): number;
  154500. /**
  154501. * Gets the current frame rate checked by the SceneOptimizer
  154502. */
  154503. get currentFrameRate(): number;
  154504. /**
  154505. * Gets or sets the current target frame rate (60 by default)
  154506. */
  154507. get targetFrameRate(): number;
  154508. /**
  154509. * Gets or sets the current target frame rate (60 by default)
  154510. */
  154511. set targetFrameRate(value: number);
  154512. /**
  154513. * Gets or sets the current interval between two checks (every 2000ms by default)
  154514. */
  154515. get trackerDuration(): number;
  154516. /**
  154517. * Gets or sets the current interval between two checks (every 2000ms by default)
  154518. */
  154519. set trackerDuration(value: number);
  154520. /**
  154521. * Gets the list of active optimizations
  154522. */
  154523. get optimizations(): SceneOptimization[];
  154524. /**
  154525. * Creates a new SceneOptimizer
  154526. * @param scene defines the scene to work on
  154527. * @param options defines the options to use with the SceneOptimizer
  154528. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  154529. * @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)
  154530. */
  154531. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  154532. /**
  154533. * Stops the current optimizer
  154534. */
  154535. stop(): void;
  154536. /**
  154537. * Reset the optimizer to initial step (current priority level = 0)
  154538. */
  154539. reset(): void;
  154540. /**
  154541. * Start the optimizer. By default it will try to reach a specific framerate
  154542. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  154543. */
  154544. start(): void;
  154545. private _checkCurrentState;
  154546. /**
  154547. * Release all resources
  154548. */
  154549. dispose(): void;
  154550. /**
  154551. * Helper function to create a SceneOptimizer with one single line of code
  154552. * @param scene defines the scene to work on
  154553. * @param options defines the options to use with the SceneOptimizer
  154554. * @param onSuccess defines a callback to call on success
  154555. * @param onFailure defines a callback to call on failure
  154556. * @returns the new SceneOptimizer object
  154557. */
  154558. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  154559. }
  154560. }
  154561. declare module BABYLON {
  154562. /**
  154563. * Class used to serialize a scene into a string
  154564. */
  154565. export class SceneSerializer {
  154566. /**
  154567. * Clear cache used by a previous serialization
  154568. */
  154569. static ClearCache(): void;
  154570. /**
  154571. * Serialize a scene into a JSON compatible object
  154572. * @param scene defines the scene to serialize
  154573. * @returns a JSON compatible object
  154574. */
  154575. static Serialize(scene: Scene): any;
  154576. /**
  154577. * Serialize a mesh into a JSON compatible object
  154578. * @param toSerialize defines the mesh to serialize
  154579. * @param withParents defines if parents must be serialized as well
  154580. * @param withChildren defines if children must be serialized as well
  154581. * @returns a JSON compatible object
  154582. */
  154583. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  154584. }
  154585. }
  154586. declare module BABYLON {
  154587. /**
  154588. * Class used to host texture specific utilities
  154589. */
  154590. export class TextureTools {
  154591. /**
  154592. * Uses the GPU to create a copy texture rescaled at a given size
  154593. * @param texture Texture to copy from
  154594. * @param width defines the desired width
  154595. * @param height defines the desired height
  154596. * @param useBilinearMode defines if bilinear mode has to be used
  154597. * @return the generated texture
  154598. */
  154599. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  154600. }
  154601. }
  154602. declare module BABYLON {
  154603. /**
  154604. * This represents the different options available for the video capture.
  154605. */
  154606. export interface VideoRecorderOptions {
  154607. /** Defines the mime type of the video. */
  154608. mimeType: string;
  154609. /** Defines the FPS the video should be recorded at. */
  154610. fps: number;
  154611. /** Defines the chunk size for the recording data. */
  154612. recordChunckSize: number;
  154613. /** The audio tracks to attach to the recording. */
  154614. audioTracks?: MediaStreamTrack[];
  154615. }
  154616. /**
  154617. * This can help with recording videos from BabylonJS.
  154618. * This is based on the available WebRTC functionalities of the browser.
  154619. *
  154620. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  154621. */
  154622. export class VideoRecorder {
  154623. private static readonly _defaultOptions;
  154624. /**
  154625. * Returns whether or not the VideoRecorder is available in your browser.
  154626. * @param engine Defines the Babylon Engine.
  154627. * @returns true if supported otherwise false.
  154628. */
  154629. static IsSupported(engine: Engine): boolean;
  154630. private readonly _options;
  154631. private _canvas;
  154632. private _mediaRecorder;
  154633. private _recordedChunks;
  154634. private _fileName;
  154635. private _resolve;
  154636. private _reject;
  154637. /**
  154638. * True when a recording is already in progress.
  154639. */
  154640. get isRecording(): boolean;
  154641. /**
  154642. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  154643. * @param engine Defines the BabylonJS Engine you wish to record.
  154644. * @param options Defines options that can be used to customize the capture.
  154645. */
  154646. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  154647. /**
  154648. * Stops the current recording before the default capture timeout passed in the startRecording function.
  154649. */
  154650. stopRecording(): void;
  154651. /**
  154652. * Starts recording the canvas for a max duration specified in parameters.
  154653. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  154654. * If null no automatic download will start and you can rely on the promise to get the data back.
  154655. * @param maxDuration Defines the maximum recording time in seconds.
  154656. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  154657. * @return A promise callback at the end of the recording with the video data in Blob.
  154658. */
  154659. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  154660. /**
  154661. * Releases internal resources used during the recording.
  154662. */
  154663. dispose(): void;
  154664. private _handleDataAvailable;
  154665. private _handleError;
  154666. private _handleStop;
  154667. }
  154668. }
  154669. declare module BABYLON {
  154670. /**
  154671. * Class containing a set of static utilities functions for screenshots
  154672. */
  154673. export class ScreenshotTools {
  154674. /**
  154675. * Captures a screenshot of the current rendering
  154676. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154677. * @param engine defines the rendering engine
  154678. * @param camera defines the source camera
  154679. * @param size This parameter can be set to a single number or to an object with the
  154680. * following (optional) properties: precision, width, height. If a single number is passed,
  154681. * it will be used for both width and height. If an object is passed, the screenshot size
  154682. * will be derived from the parameters. The precision property is a multiplier allowing
  154683. * rendering at a higher or lower resolution
  154684. * @param successCallback defines the callback receives a single parameter which contains the
  154685. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154686. * src parameter of an <img> to display it
  154687. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154688. * Check your browser for supported MIME types
  154689. */
  154690. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  154691. /**
  154692. * Captures a screenshot of the current rendering
  154693. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154694. * @param engine defines the rendering engine
  154695. * @param camera defines the source camera
  154696. * @param size This parameter can be set to a single number or to an object with the
  154697. * following (optional) properties: precision, width, height. If a single number is passed,
  154698. * it will be used for both width and height. If an object is passed, the screenshot size
  154699. * will be derived from the parameters. The precision property is a multiplier allowing
  154700. * rendering at a higher or lower resolution
  154701. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154702. * Check your browser for supported MIME types
  154703. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154704. * to the src parameter of an <img> to display it
  154705. */
  154706. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  154707. /**
  154708. * Generates an image screenshot from the specified camera.
  154709. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154710. * @param engine The engine to use for rendering
  154711. * @param camera The camera to use for rendering
  154712. * @param size This parameter can be set to a single number or to an object with the
  154713. * following (optional) properties: precision, width, height. If a single number is passed,
  154714. * it will be used for both width and height. If an object is passed, the screenshot size
  154715. * will be derived from the parameters. The precision property is a multiplier allowing
  154716. * rendering at a higher or lower resolution
  154717. * @param successCallback The callback receives a single parameter which contains the
  154718. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154719. * src parameter of an <img> to display it
  154720. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154721. * Check your browser for supported MIME types
  154722. * @param samples Texture samples (default: 1)
  154723. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154724. * @param fileName A name for for the downloaded file.
  154725. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154726. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  154727. */
  154728. 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;
  154729. /**
  154730. * Generates an image screenshot from the specified camera.
  154731. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154732. * @param engine The engine to use for rendering
  154733. * @param camera The camera to use for rendering
  154734. * @param size This parameter can be set to a single number or to an object with the
  154735. * following (optional) properties: precision, width, height. If a single number is passed,
  154736. * it will be used for both width and height. If an object is passed, the screenshot size
  154737. * will be derived from the parameters. The precision property is a multiplier allowing
  154738. * rendering at a higher or lower resolution
  154739. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154740. * Check your browser for supported MIME types
  154741. * @param samples Texture samples (default: 1)
  154742. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154743. * @param fileName A name for for the downloaded file.
  154744. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154745. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154746. * to the src parameter of an <img> to display it
  154747. */
  154748. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  154749. /**
  154750. * Gets height and width for screenshot size
  154751. * @private
  154752. */
  154753. private static _getScreenshotSize;
  154754. }
  154755. }
  154756. declare module BABYLON {
  154757. /**
  154758. * Interface for a data buffer
  154759. */
  154760. export interface IDataBuffer {
  154761. /**
  154762. * Reads bytes from the data buffer.
  154763. * @param byteOffset The byte offset to read
  154764. * @param byteLength The byte length to read
  154765. * @returns A promise that resolves when the bytes are read
  154766. */
  154767. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  154768. /**
  154769. * The byte length of the buffer.
  154770. */
  154771. readonly byteLength: number;
  154772. }
  154773. /**
  154774. * Utility class for reading from a data buffer
  154775. */
  154776. export class DataReader {
  154777. /**
  154778. * The data buffer associated with this data reader.
  154779. */
  154780. readonly buffer: IDataBuffer;
  154781. /**
  154782. * The current byte offset from the beginning of the data buffer.
  154783. */
  154784. byteOffset: number;
  154785. private _dataView;
  154786. private _dataByteOffset;
  154787. /**
  154788. * Constructor
  154789. * @param buffer The buffer to read
  154790. */
  154791. constructor(buffer: IDataBuffer);
  154792. /**
  154793. * Loads the given byte length.
  154794. * @param byteLength The byte length to load
  154795. * @returns A promise that resolves when the load is complete
  154796. */
  154797. loadAsync(byteLength: number): Promise<void>;
  154798. /**
  154799. * Read a unsigned 32-bit integer from the currently loaded data range.
  154800. * @returns The 32-bit integer read
  154801. */
  154802. readUint32(): number;
  154803. /**
  154804. * Read a byte array from the currently loaded data range.
  154805. * @param byteLength The byte length to read
  154806. * @returns The byte array read
  154807. */
  154808. readUint8Array(byteLength: number): Uint8Array;
  154809. /**
  154810. * Read a string from the currently loaded data range.
  154811. * @param byteLength The byte length to read
  154812. * @returns The string read
  154813. */
  154814. readString(byteLength: number): string;
  154815. /**
  154816. * Skips the given byte length the currently loaded data range.
  154817. * @param byteLength The byte length to skip
  154818. */
  154819. skipBytes(byteLength: number): void;
  154820. }
  154821. }
  154822. declare module BABYLON {
  154823. /**
  154824. * Class for storing data to local storage if available or in-memory storage otherwise
  154825. */
  154826. export class DataStorage {
  154827. private static _Storage;
  154828. private static _GetStorage;
  154829. /**
  154830. * Reads a string from the data storage
  154831. * @param key The key to read
  154832. * @param defaultValue The value if the key doesn't exist
  154833. * @returns The string value
  154834. */
  154835. static ReadString(key: string, defaultValue: string): string;
  154836. /**
  154837. * Writes a string to the data storage
  154838. * @param key The key to write
  154839. * @param value The value to write
  154840. */
  154841. static WriteString(key: string, value: string): void;
  154842. /**
  154843. * Reads a boolean from the data storage
  154844. * @param key The key to read
  154845. * @param defaultValue The value if the key doesn't exist
  154846. * @returns The boolean value
  154847. */
  154848. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  154849. /**
  154850. * Writes a boolean to the data storage
  154851. * @param key The key to write
  154852. * @param value The value to write
  154853. */
  154854. static WriteBoolean(key: string, value: boolean): void;
  154855. /**
  154856. * Reads a number from the data storage
  154857. * @param key The key to read
  154858. * @param defaultValue The value if the key doesn't exist
  154859. * @returns The number value
  154860. */
  154861. static ReadNumber(key: string, defaultValue: number): number;
  154862. /**
  154863. * Writes a number to the data storage
  154864. * @param key The key to write
  154865. * @param value The value to write
  154866. */
  154867. static WriteNumber(key: string, value: number): void;
  154868. }
  154869. }
  154870. declare module BABYLON {
  154871. /**
  154872. * Class used to record delta files between 2 scene states
  154873. */
  154874. export class SceneRecorder {
  154875. private _trackedScene;
  154876. private _savedJSON;
  154877. /**
  154878. * Track a given scene. This means the current scene state will be considered the original state
  154879. * @param scene defines the scene to track
  154880. */
  154881. track(scene: Scene): void;
  154882. /**
  154883. * Get the delta between current state and original state
  154884. * @returns a string containing the delta
  154885. */
  154886. getDelta(): any;
  154887. private _compareArray;
  154888. private _compareObjects;
  154889. private _compareCollections;
  154890. private static GetShadowGeneratorById;
  154891. /**
  154892. * Apply a given delta to a given scene
  154893. * @param deltaJSON defines the JSON containing the delta
  154894. * @param scene defines the scene to apply the delta to
  154895. */
  154896. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  154897. private static _ApplyPropertiesToEntity;
  154898. private static _ApplyDeltaForEntity;
  154899. }
  154900. }
  154901. declare module BABYLON {
  154902. /**
  154903. * A 3D trajectory consisting of an order list of vectors describing a
  154904. * path of motion through 3D space.
  154905. */
  154906. export class Trajectory {
  154907. private _points;
  154908. private readonly _segmentLength;
  154909. /**
  154910. * Serialize to JSON.
  154911. * @returns serialized JSON string
  154912. */
  154913. serialize(): string;
  154914. /**
  154915. * Deserialize from JSON.
  154916. * @param json serialized JSON string
  154917. * @returns deserialized Trajectory
  154918. */
  154919. static Deserialize(json: string): Trajectory;
  154920. /**
  154921. * Create a new empty Trajectory.
  154922. * @param segmentLength radius of discretization for Trajectory points
  154923. */
  154924. constructor(segmentLength?: number);
  154925. /**
  154926. * Get the length of the Trajectory.
  154927. * @returns length of the Trajectory
  154928. */
  154929. getLength(): number;
  154930. /**
  154931. * Append a new point to the Trajectory.
  154932. * NOTE: This implementation has many allocations.
  154933. * @param point point to append to the Trajectory
  154934. */
  154935. add(point: DeepImmutable<Vector3>): void;
  154936. /**
  154937. * Create a new Trajectory with a segment length chosen to make it
  154938. * probable that the new Trajectory will have a specified number of
  154939. * segments. This operation is imprecise.
  154940. * @param targetResolution number of segments desired
  154941. * @returns new Trajectory with approximately the requested number of segments
  154942. */
  154943. resampleAtTargetResolution(targetResolution: number): Trajectory;
  154944. /**
  154945. * Convert Trajectory segments into tokenized representation. This
  154946. * representation is an array of numbers where each nth number is the
  154947. * index of the token which is most similar to the nth segment of the
  154948. * Trajectory.
  154949. * @param tokens list of vectors which serve as discrete tokens
  154950. * @returns list of indices of most similar token per segment
  154951. */
  154952. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  154953. private static _forwardDir;
  154954. private static _inverseFromVec;
  154955. private static _upDir;
  154956. private static _fromToVec;
  154957. private static _lookMatrix;
  154958. /**
  154959. * Transform the rotation (i.e., direction) of a segment to isolate
  154960. * the relative transformation represented by the segment. This operation
  154961. * may or may not succeed due to singularities in the equations that define
  154962. * motion relativity in this context.
  154963. * @param priorVec the origin of the prior segment
  154964. * @param fromVec the origin of the current segment
  154965. * @param toVec the destination of the current segment
  154966. * @param result reference to output variable
  154967. * @returns whether or not transformation was successful
  154968. */
  154969. private static _transformSegmentDirToRef;
  154970. private static _bestMatch;
  154971. private static _score;
  154972. private static _bestScore;
  154973. /**
  154974. * Determine which token vector is most similar to the
  154975. * segment vector.
  154976. * @param segment segment vector
  154977. * @param tokens token vector list
  154978. * @returns index of the most similar token to the segment
  154979. */
  154980. private static _tokenizeSegment;
  154981. }
  154982. /**
  154983. * Class representing a set of known, named trajectories to which Trajectories can be
  154984. * added and using which Trajectories can be recognized.
  154985. */
  154986. export class TrajectoryClassifier {
  154987. private _maximumAllowableMatchCost;
  154988. private _vector3Alphabet;
  154989. private _levenshteinAlphabet;
  154990. private _nameToDescribedTrajectory;
  154991. /**
  154992. * Serialize to JSON.
  154993. * @returns JSON serialization
  154994. */
  154995. serialize(): string;
  154996. /**
  154997. * Deserialize from JSON.
  154998. * @param json JSON serialization
  154999. * @returns deserialized TrajectorySet
  155000. */
  155001. static Deserialize(json: string): TrajectoryClassifier;
  155002. /**
  155003. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  155004. * VERY naive, need to be generating these things from known
  155005. * sets. Better version later, probably eliminating this one.
  155006. * @returns auto-generated TrajectorySet
  155007. */
  155008. static Generate(): TrajectoryClassifier;
  155009. private constructor();
  155010. /**
  155011. * Add a new Trajectory to the set with a given name.
  155012. * @param trajectory new Trajectory to be added
  155013. * @param classification name to which to add the Trajectory
  155014. */
  155015. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155016. /**
  155017. * Remove a known named trajectory and all Trajectories associated with it.
  155018. * @param classification name to remove
  155019. * @returns whether anything was removed
  155020. */
  155021. deleteClassification(classification: string): boolean;
  155022. /**
  155023. * Attempt to recognize a Trajectory from among all the classifications
  155024. * already known to the classifier.
  155025. * @param trajectory Trajectory to be recognized
  155026. * @returns classification of Trajectory if recognized, null otherwise
  155027. */
  155028. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155029. }
  155030. }
  155031. declare module BABYLON {
  155032. /**
  155033. * An interface for all Hit test features
  155034. */
  155035. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155036. /**
  155037. * Triggered when new babylon (transformed) hit test results are available
  155038. */
  155039. onHitTestResultObservable: Observable<T[]>;
  155040. }
  155041. /**
  155042. * Options used for hit testing
  155043. */
  155044. export interface IWebXRLegacyHitTestOptions {
  155045. /**
  155046. * Only test when user interacted with the scene. Default - hit test every frame
  155047. */
  155048. testOnPointerDownOnly?: boolean;
  155049. /**
  155050. * The node to use to transform the local results to world coordinates
  155051. */
  155052. worldParentNode?: TransformNode;
  155053. }
  155054. /**
  155055. * Interface defining the babylon result of raycasting/hit-test
  155056. */
  155057. export interface IWebXRLegacyHitResult {
  155058. /**
  155059. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155060. */
  155061. transformationMatrix: Matrix;
  155062. /**
  155063. * The native hit test result
  155064. */
  155065. xrHitResult: XRHitResult | XRHitTestResult;
  155066. }
  155067. /**
  155068. * The currently-working hit-test module.
  155069. * Hit test (or Ray-casting) is used to interact with the real world.
  155070. * For further information read here - https://github.com/immersive-web/hit-test
  155071. */
  155072. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155073. /**
  155074. * options to use when constructing this feature
  155075. */
  155076. readonly options: IWebXRLegacyHitTestOptions;
  155077. private _direction;
  155078. private _mat;
  155079. private _onSelectEnabled;
  155080. private _origin;
  155081. /**
  155082. * The module's name
  155083. */
  155084. static readonly Name: string;
  155085. /**
  155086. * The (Babylon) version of this module.
  155087. * This is an integer representing the implementation version.
  155088. * This number does not correspond to the WebXR specs version
  155089. */
  155090. static readonly Version: number;
  155091. /**
  155092. * Populated with the last native XR Hit Results
  155093. */
  155094. lastNativeXRHitResults: XRHitResult[];
  155095. /**
  155096. * Triggered when new babylon (transformed) hit test results are available
  155097. */
  155098. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155099. /**
  155100. * Creates a new instance of the (legacy version) hit test feature
  155101. * @param _xrSessionManager an instance of WebXRSessionManager
  155102. * @param options options to use when constructing this feature
  155103. */
  155104. constructor(_xrSessionManager: WebXRSessionManager,
  155105. /**
  155106. * options to use when constructing this feature
  155107. */
  155108. options?: IWebXRLegacyHitTestOptions);
  155109. /**
  155110. * execute a hit test with an XR Ray
  155111. *
  155112. * @param xrSession a native xrSession that will execute this hit test
  155113. * @param xrRay the ray (position and direction) to use for ray-casting
  155114. * @param referenceSpace native XR reference space to use for the hit-test
  155115. * @param filter filter function that will filter the results
  155116. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155117. */
  155118. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155119. /**
  155120. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155121. * @param event the (select) event to use to select with
  155122. * @param referenceSpace the reference space to use for this hit test
  155123. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155124. */
  155125. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155126. /**
  155127. * attach this feature
  155128. * Will usually be called by the features manager
  155129. *
  155130. * @returns true if successful.
  155131. */
  155132. attach(): boolean;
  155133. /**
  155134. * detach this feature.
  155135. * Will usually be called by the features manager
  155136. *
  155137. * @returns true if successful.
  155138. */
  155139. detach(): boolean;
  155140. /**
  155141. * Dispose this feature and all of the resources attached
  155142. */
  155143. dispose(): void;
  155144. protected _onXRFrame(frame: XRFrame): void;
  155145. private _onHitTestResults;
  155146. private _onSelect;
  155147. }
  155148. }
  155149. declare module BABYLON {
  155150. /**
  155151. * Options used for hit testing (version 2)
  155152. */
  155153. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155154. /**
  155155. * Do not create a permanent hit test. Will usually be used when only
  155156. * transient inputs are needed.
  155157. */
  155158. disablePermanentHitTest?: boolean;
  155159. /**
  155160. * Enable transient (for example touch-based) hit test inspections
  155161. */
  155162. enableTransientHitTest?: boolean;
  155163. /**
  155164. * Offset ray for the permanent hit test
  155165. */
  155166. offsetRay?: Vector3;
  155167. /**
  155168. * Offset ray for the transient hit test
  155169. */
  155170. transientOffsetRay?: Vector3;
  155171. /**
  155172. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155173. */
  155174. useReferenceSpace?: boolean;
  155175. /**
  155176. * Override the default entity type(s) of the hit-test result
  155177. */
  155178. entityTypes?: XRHitTestTrackableType[];
  155179. }
  155180. /**
  155181. * Interface defining the babylon result of hit-test
  155182. */
  155183. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155184. /**
  155185. * The input source that generated this hit test (if transient)
  155186. */
  155187. inputSource?: XRInputSource;
  155188. /**
  155189. * Is this a transient hit test
  155190. */
  155191. isTransient?: boolean;
  155192. /**
  155193. * Position of the hit test result
  155194. */
  155195. position: Vector3;
  155196. /**
  155197. * Rotation of the hit test result
  155198. */
  155199. rotationQuaternion: Quaternion;
  155200. /**
  155201. * The native hit test result
  155202. */
  155203. xrHitResult: XRHitTestResult;
  155204. }
  155205. /**
  155206. * The currently-working hit-test module.
  155207. * Hit test (or Ray-casting) is used to interact with the real world.
  155208. * For further information read here - https://github.com/immersive-web/hit-test
  155209. *
  155210. * Tested on chrome (mobile) 80.
  155211. */
  155212. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155213. /**
  155214. * options to use when constructing this feature
  155215. */
  155216. readonly options: IWebXRHitTestOptions;
  155217. private _tmpMat;
  155218. private _tmpPos;
  155219. private _tmpQuat;
  155220. private _transientXrHitTestSource;
  155221. private _xrHitTestSource;
  155222. private initHitTestSource;
  155223. /**
  155224. * The module's name
  155225. */
  155226. static readonly Name: string;
  155227. /**
  155228. * The (Babylon) version of this module.
  155229. * This is an integer representing the implementation version.
  155230. * This number does not correspond to the WebXR specs version
  155231. */
  155232. static readonly Version: number;
  155233. /**
  155234. * When set to true, each hit test will have its own position/rotation objects
  155235. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155236. * the developers will clone them or copy them as they see fit.
  155237. */
  155238. autoCloneTransformation: boolean;
  155239. /**
  155240. * Triggered when new babylon (transformed) hit test results are available
  155241. * Note - this will be called when results come back from the device. It can be an empty array!!
  155242. */
  155243. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155244. /**
  155245. * Use this to temporarily pause hit test checks.
  155246. */
  155247. paused: boolean;
  155248. /**
  155249. * Creates a new instance of the hit test feature
  155250. * @param _xrSessionManager an instance of WebXRSessionManager
  155251. * @param options options to use when constructing this feature
  155252. */
  155253. constructor(_xrSessionManager: WebXRSessionManager,
  155254. /**
  155255. * options to use when constructing this feature
  155256. */
  155257. options?: IWebXRHitTestOptions);
  155258. /**
  155259. * attach this feature
  155260. * Will usually be called by the features manager
  155261. *
  155262. * @returns true if successful.
  155263. */
  155264. attach(): boolean;
  155265. /**
  155266. * detach this feature.
  155267. * Will usually be called by the features manager
  155268. *
  155269. * @returns true if successful.
  155270. */
  155271. detach(): boolean;
  155272. /**
  155273. * Dispose this feature and all of the resources attached
  155274. */
  155275. dispose(): void;
  155276. protected _onXRFrame(frame: XRFrame): void;
  155277. private _processWebXRHitTestResult;
  155278. }
  155279. }
  155280. declare module BABYLON {
  155281. /**
  155282. * Configuration options of the anchor system
  155283. */
  155284. export interface IWebXRAnchorSystemOptions {
  155285. /**
  155286. * a node that will be used to convert local to world coordinates
  155287. */
  155288. worldParentNode?: TransformNode;
  155289. /**
  155290. * If set to true a reference of the created anchors will be kept until the next session starts
  155291. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155292. */
  155293. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155294. }
  155295. /**
  155296. * A babylon container for an XR Anchor
  155297. */
  155298. export interface IWebXRAnchor {
  155299. /**
  155300. * A babylon-assigned ID for this anchor
  155301. */
  155302. id: number;
  155303. /**
  155304. * Transformation matrix to apply to an object attached to this anchor
  155305. */
  155306. transformationMatrix: Matrix;
  155307. /**
  155308. * The native anchor object
  155309. */
  155310. xrAnchor: XRAnchor;
  155311. /**
  155312. * if defined, this object will be constantly updated by the anchor's position and rotation
  155313. */
  155314. attachedNode?: TransformNode;
  155315. }
  155316. /**
  155317. * An implementation of the anchor system for WebXR.
  155318. * For further information see https://github.com/immersive-web/anchors/
  155319. */
  155320. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  155321. private _options;
  155322. private _lastFrameDetected;
  155323. private _trackedAnchors;
  155324. private _referenceSpaceForFrameAnchors;
  155325. private _futureAnchors;
  155326. /**
  155327. * The module's name
  155328. */
  155329. static readonly Name: string;
  155330. /**
  155331. * The (Babylon) version of this module.
  155332. * This is an integer representing the implementation version.
  155333. * This number does not correspond to the WebXR specs version
  155334. */
  155335. static readonly Version: number;
  155336. /**
  155337. * Observers registered here will be executed when a new anchor was added to the session
  155338. */
  155339. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  155340. /**
  155341. * Observers registered here will be executed when an anchor was removed from the session
  155342. */
  155343. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  155344. /**
  155345. * Observers registered here will be executed when an existing anchor updates
  155346. * This can execute N times every frame
  155347. */
  155348. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  155349. /**
  155350. * Set the reference space to use for anchor creation, when not using a hit test.
  155351. * Will default to the session's reference space if not defined
  155352. */
  155353. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  155354. /**
  155355. * constructs a new anchor system
  155356. * @param _xrSessionManager an instance of WebXRSessionManager
  155357. * @param _options configuration object for this feature
  155358. */
  155359. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  155360. private _tmpVector;
  155361. private _tmpQuaternion;
  155362. private _populateTmpTransformation;
  155363. /**
  155364. * Create a new anchor point using a hit test result at a specific point in the scene
  155365. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155366. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155367. *
  155368. * @param hitTestResult The hit test result to use for this anchor creation
  155369. * @param position an optional position offset for this anchor
  155370. * @param rotationQuaternion an optional rotation offset for this anchor
  155371. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155372. */
  155373. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  155374. /**
  155375. * Add a new anchor at a specific position and rotation
  155376. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  155377. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  155378. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155379. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155380. *
  155381. * @param position the position in which to add an anchor
  155382. * @param rotationQuaternion an optional rotation for the anchor transformation
  155383. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  155384. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155385. */
  155386. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  155387. /**
  155388. * detach this feature.
  155389. * Will usually be called by the features manager
  155390. *
  155391. * @returns true if successful.
  155392. */
  155393. detach(): boolean;
  155394. /**
  155395. * Dispose this feature and all of the resources attached
  155396. */
  155397. dispose(): void;
  155398. protected _onXRFrame(frame: XRFrame): void;
  155399. /**
  155400. * avoiding using Array.find for global support.
  155401. * @param xrAnchor the plane to find in the array
  155402. */
  155403. private _findIndexInAnchorArray;
  155404. private _updateAnchorWithXRFrame;
  155405. private _createAnchorAtTransformation;
  155406. }
  155407. }
  155408. declare module BABYLON {
  155409. /**
  155410. * Options used in the plane detector module
  155411. */
  155412. export interface IWebXRPlaneDetectorOptions {
  155413. /**
  155414. * The node to use to transform the local results to world coordinates
  155415. */
  155416. worldParentNode?: TransformNode;
  155417. /**
  155418. * If set to true a reference of the created planes will be kept until the next session starts
  155419. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  155420. */
  155421. doNotRemovePlanesOnSessionEnded?: boolean;
  155422. }
  155423. /**
  155424. * A babylon interface for a WebXR plane.
  155425. * A Plane is actually a polygon, built from N points in space
  155426. *
  155427. * Supported in chrome 79, not supported in canary 81 ATM
  155428. */
  155429. export interface IWebXRPlane {
  155430. /**
  155431. * a babylon-assigned ID for this polygon
  155432. */
  155433. id: number;
  155434. /**
  155435. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  155436. */
  155437. polygonDefinition: Array<Vector3>;
  155438. /**
  155439. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  155440. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  155441. */
  155442. transformationMatrix: Matrix;
  155443. /**
  155444. * the native xr-plane object
  155445. */
  155446. xrPlane: XRPlane;
  155447. }
  155448. /**
  155449. * The plane detector is used to detect planes in the real world when in AR
  155450. * For more information see https://github.com/immersive-web/real-world-geometry/
  155451. */
  155452. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  155453. private _options;
  155454. private _detectedPlanes;
  155455. private _enabled;
  155456. private _lastFrameDetected;
  155457. /**
  155458. * The module's name
  155459. */
  155460. static readonly Name: string;
  155461. /**
  155462. * The (Babylon) version of this module.
  155463. * This is an integer representing the implementation version.
  155464. * This number does not correspond to the WebXR specs version
  155465. */
  155466. static readonly Version: number;
  155467. /**
  155468. * Observers registered here will be executed when a new plane was added to the session
  155469. */
  155470. onPlaneAddedObservable: Observable<IWebXRPlane>;
  155471. /**
  155472. * Observers registered here will be executed when a plane is no longer detected in the session
  155473. */
  155474. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  155475. /**
  155476. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  155477. * This can execute N times every frame
  155478. */
  155479. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  155480. /**
  155481. * construct a new Plane Detector
  155482. * @param _xrSessionManager an instance of xr Session manager
  155483. * @param _options configuration to use when constructing this feature
  155484. */
  155485. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  155486. /**
  155487. * detach this feature.
  155488. * Will usually be called by the features manager
  155489. *
  155490. * @returns true if successful.
  155491. */
  155492. detach(): boolean;
  155493. /**
  155494. * Dispose this feature and all of the resources attached
  155495. */
  155496. dispose(): void;
  155497. protected _onXRFrame(frame: XRFrame): void;
  155498. private _init;
  155499. private _updatePlaneWithXRPlane;
  155500. /**
  155501. * avoiding using Array.find for global support.
  155502. * @param xrPlane the plane to find in the array
  155503. */
  155504. private findIndexInPlaneArray;
  155505. }
  155506. }
  155507. declare module BABYLON {
  155508. /**
  155509. * Options interface for the background remover plugin
  155510. */
  155511. export interface IWebXRBackgroundRemoverOptions {
  155512. /**
  155513. * Further background meshes to disable when entering AR
  155514. */
  155515. backgroundMeshes?: AbstractMesh[];
  155516. /**
  155517. * flags to configure the removal of the environment helper.
  155518. * If not set, the entire background will be removed. If set, flags should be set as well.
  155519. */
  155520. environmentHelperRemovalFlags?: {
  155521. /**
  155522. * Should the skybox be removed (default false)
  155523. */
  155524. skyBox?: boolean;
  155525. /**
  155526. * Should the ground be removed (default false)
  155527. */
  155528. ground?: boolean;
  155529. };
  155530. /**
  155531. * don't disable the environment helper
  155532. */
  155533. ignoreEnvironmentHelper?: boolean;
  155534. }
  155535. /**
  155536. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  155537. */
  155538. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  155539. /**
  155540. * read-only options to be used in this module
  155541. */
  155542. readonly options: IWebXRBackgroundRemoverOptions;
  155543. /**
  155544. * The module's name
  155545. */
  155546. static readonly Name: string;
  155547. /**
  155548. * The (Babylon) version of this module.
  155549. * This is an integer representing the implementation version.
  155550. * This number does not correspond to the WebXR specs version
  155551. */
  155552. static readonly Version: number;
  155553. /**
  155554. * registered observers will be triggered when the background state changes
  155555. */
  155556. onBackgroundStateChangedObservable: Observable<boolean>;
  155557. /**
  155558. * constructs a new background remover module
  155559. * @param _xrSessionManager the session manager for this module
  155560. * @param options read-only options to be used in this module
  155561. */
  155562. constructor(_xrSessionManager: WebXRSessionManager,
  155563. /**
  155564. * read-only options to be used in this module
  155565. */
  155566. options?: IWebXRBackgroundRemoverOptions);
  155567. /**
  155568. * attach this feature
  155569. * Will usually be called by the features manager
  155570. *
  155571. * @returns true if successful.
  155572. */
  155573. attach(): boolean;
  155574. /**
  155575. * detach this feature.
  155576. * Will usually be called by the features manager
  155577. *
  155578. * @returns true if successful.
  155579. */
  155580. detach(): boolean;
  155581. /**
  155582. * Dispose this feature and all of the resources attached
  155583. */
  155584. dispose(): void;
  155585. protected _onXRFrame(_xrFrame: XRFrame): void;
  155586. private _setBackgroundState;
  155587. }
  155588. }
  155589. declare module BABYLON {
  155590. /**
  155591. * Options for the controller physics feature
  155592. */
  155593. export class IWebXRControllerPhysicsOptions {
  155594. /**
  155595. * Should the headset get its own impostor
  155596. */
  155597. enableHeadsetImpostor?: boolean;
  155598. /**
  155599. * Optional parameters for the headset impostor
  155600. */
  155601. headsetImpostorParams?: {
  155602. /**
  155603. * The type of impostor to create. Default is sphere
  155604. */
  155605. impostorType: number;
  155606. /**
  155607. * the size of the impostor. Defaults to 10cm
  155608. */
  155609. impostorSize?: number | {
  155610. width: number;
  155611. height: number;
  155612. depth: number;
  155613. };
  155614. /**
  155615. * Friction definitions
  155616. */
  155617. friction?: number;
  155618. /**
  155619. * Restitution
  155620. */
  155621. restitution?: number;
  155622. };
  155623. /**
  155624. * The physics properties of the future impostors
  155625. */
  155626. physicsProperties?: {
  155627. /**
  155628. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  155629. * Note that this requires a physics engine that supports mesh impostors!
  155630. */
  155631. useControllerMesh?: boolean;
  155632. /**
  155633. * The type of impostor to create. Default is sphere
  155634. */
  155635. impostorType?: number;
  155636. /**
  155637. * the size of the impostor. Defaults to 10cm
  155638. */
  155639. impostorSize?: number | {
  155640. width: number;
  155641. height: number;
  155642. depth: number;
  155643. };
  155644. /**
  155645. * Friction definitions
  155646. */
  155647. friction?: number;
  155648. /**
  155649. * Restitution
  155650. */
  155651. restitution?: number;
  155652. };
  155653. /**
  155654. * the xr input to use with this pointer selection
  155655. */
  155656. xrInput: WebXRInput;
  155657. }
  155658. /**
  155659. * Add physics impostor to your webxr controllers,
  155660. * including naive calculation of their linear and angular velocity
  155661. */
  155662. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  155663. private readonly _options;
  155664. private _attachController;
  155665. private _controllers;
  155666. private _debugMode;
  155667. private _delta;
  155668. private _headsetImpostor?;
  155669. private _headsetMesh?;
  155670. private _lastTimestamp;
  155671. private _tmpQuaternion;
  155672. private _tmpVector;
  155673. /**
  155674. * The module's name
  155675. */
  155676. static readonly Name: string;
  155677. /**
  155678. * The (Babylon) version of this module.
  155679. * This is an integer representing the implementation version.
  155680. * This number does not correspond to the webxr specs version
  155681. */
  155682. static readonly Version: number;
  155683. /**
  155684. * Construct a new Controller Physics Feature
  155685. * @param _xrSessionManager the corresponding xr session manager
  155686. * @param _options options to create this feature with
  155687. */
  155688. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  155689. /**
  155690. * @hidden
  155691. * enable debugging - will show console outputs and the impostor mesh
  155692. */
  155693. _enablePhysicsDebug(): void;
  155694. /**
  155695. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  155696. * @param xrController the controller to add
  155697. */
  155698. addController(xrController: WebXRInputSource): void;
  155699. /**
  155700. * attach this feature
  155701. * Will usually be called by the features manager
  155702. *
  155703. * @returns true if successful.
  155704. */
  155705. attach(): boolean;
  155706. /**
  155707. * detach this feature.
  155708. * Will usually be called by the features manager
  155709. *
  155710. * @returns true if successful.
  155711. */
  155712. detach(): boolean;
  155713. /**
  155714. * Get the headset impostor, if enabled
  155715. * @returns the impostor
  155716. */
  155717. getHeadsetImpostor(): PhysicsImpostor | undefined;
  155718. /**
  155719. * Get the physics impostor of a specific controller.
  155720. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  155721. * @param controller the controller or the controller id of which to get the impostor
  155722. * @returns the impostor or null
  155723. */
  155724. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  155725. /**
  155726. * Update the physics properties provided in the constructor
  155727. * @param newProperties the new properties object
  155728. */
  155729. setPhysicsProperties(newProperties: {
  155730. impostorType?: number;
  155731. impostorSize?: number | {
  155732. width: number;
  155733. height: number;
  155734. depth: number;
  155735. };
  155736. friction?: number;
  155737. restitution?: number;
  155738. }): void;
  155739. protected _onXRFrame(_xrFrame: any): void;
  155740. private _detachController;
  155741. }
  155742. }
  155743. declare module BABYLON {
  155744. /**
  155745. * A babylon interface for a "WebXR" feature point.
  155746. * Represents the position and confidence value of a given feature point.
  155747. */
  155748. export interface IWebXRFeaturePoint {
  155749. /**
  155750. * Represents the position of the feature point in world space.
  155751. */
  155752. position: Vector3;
  155753. /**
  155754. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  155755. */
  155756. confidenceValue: number;
  155757. }
  155758. /**
  155759. * The feature point system is used to detect feature points from real world geometry.
  155760. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  155761. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  155762. */
  155763. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  155764. private _enabled;
  155765. private _featurePointCloud;
  155766. /**
  155767. * The module's name
  155768. */
  155769. static readonly Name: string;
  155770. /**
  155771. * The (Babylon) version of this module.
  155772. * This is an integer representing the implementation version.
  155773. * This number does not correspond to the WebXR specs version
  155774. */
  155775. static readonly Version: number;
  155776. /**
  155777. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  155778. * Will notify the observers about which feature points have been added.
  155779. */
  155780. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  155781. /**
  155782. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  155783. * Will notify the observers about which feature points have been updated.
  155784. */
  155785. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  155786. /**
  155787. * The current feature point cloud maintained across frames.
  155788. */
  155789. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  155790. /**
  155791. * construct the feature point system
  155792. * @param _xrSessionManager an instance of xr Session manager
  155793. */
  155794. constructor(_xrSessionManager: WebXRSessionManager);
  155795. /**
  155796. * Detach this feature.
  155797. * Will usually be called by the features manager
  155798. *
  155799. * @returns true if successful.
  155800. */
  155801. detach(): boolean;
  155802. /**
  155803. * Dispose this feature and all of the resources attached
  155804. */
  155805. dispose(): void;
  155806. /**
  155807. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  155808. */
  155809. protected _onXRFrame(frame: XRFrame): void;
  155810. /**
  155811. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  155812. */
  155813. private _init;
  155814. }
  155815. }
  155816. declare module BABYLON {
  155817. /**
  155818. * Configuration interface for the hand tracking feature
  155819. */
  155820. export interface IWebXRHandTrackingOptions {
  155821. /**
  155822. * The xrInput that will be used as source for new hands
  155823. */
  155824. xrInput: WebXRInput;
  155825. /**
  155826. * Configuration object for the joint meshes
  155827. */
  155828. jointMeshes?: {
  155829. /**
  155830. * Should the meshes created be invisible (defaults to false)
  155831. */
  155832. invisible?: boolean;
  155833. /**
  155834. * A source mesh to be used to create instances. Defaults to a sphere.
  155835. * This mesh will be the source for all other (25) meshes.
  155836. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  155837. */
  155838. sourceMesh?: Mesh;
  155839. /**
  155840. * Should the source mesh stay visible. Defaults to false
  155841. */
  155842. keepOriginalVisible?: boolean;
  155843. /**
  155844. * Scale factor for all instances (defaults to 2)
  155845. */
  155846. scaleFactor?: number;
  155847. /**
  155848. * Should each instance have its own physics impostor
  155849. */
  155850. enablePhysics?: boolean;
  155851. /**
  155852. * If enabled, override default physics properties
  155853. */
  155854. physicsProps?: {
  155855. friction?: number;
  155856. restitution?: number;
  155857. impostorType?: number;
  155858. };
  155859. /**
  155860. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  155861. */
  155862. handMesh?: AbstractMesh;
  155863. };
  155864. }
  155865. /**
  155866. * Parts of the hands divided to writs and finger names
  155867. */
  155868. export const enum HandPart {
  155869. /**
  155870. * HandPart - Wrist
  155871. */
  155872. WRIST = "wrist",
  155873. /**
  155874. * HandPart - The THumb
  155875. */
  155876. THUMB = "thumb",
  155877. /**
  155878. * HandPart - Index finger
  155879. */
  155880. INDEX = "index",
  155881. /**
  155882. * HandPart - Middle finger
  155883. */
  155884. MIDDLE = "middle",
  155885. /**
  155886. * HandPart - Ring finger
  155887. */
  155888. RING = "ring",
  155889. /**
  155890. * HandPart - Little finger
  155891. */
  155892. LITTLE = "little"
  155893. }
  155894. /**
  155895. * Representing a single hand (with its corresponding native XRHand object)
  155896. */
  155897. export class WebXRHand implements IDisposable {
  155898. /** the controller to which the hand correlates */
  155899. readonly xrController: WebXRInputSource;
  155900. /** the meshes to be used to track the hand joints */
  155901. readonly trackedMeshes: AbstractMesh[];
  155902. /**
  155903. * Hand-parts definition (key is HandPart)
  155904. */
  155905. handPartsDefinition: {
  155906. [key: string]: number[];
  155907. };
  155908. /**
  155909. * Populate the HandPartsDefinition object.
  155910. * This is called as a side effect since certain browsers don't have XRHand defined.
  155911. */
  155912. private generateHandPartsDefinition;
  155913. /**
  155914. * Construct a new hand object
  155915. * @param xrController the controller to which the hand correlates
  155916. * @param trackedMeshes the meshes to be used to track the hand joints
  155917. */
  155918. constructor(
  155919. /** the controller to which the hand correlates */
  155920. xrController: WebXRInputSource,
  155921. /** the meshes to be used to track the hand joints */
  155922. trackedMeshes: AbstractMesh[]);
  155923. /**
  155924. * Update this hand from the latest xr frame
  155925. * @param xrFrame xrFrame to update from
  155926. * @param referenceSpace The current viewer reference space
  155927. * @param scaleFactor optional scale factor for the meshes
  155928. */
  155929. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  155930. /**
  155931. * Get meshes of part of the hand
  155932. * @param part the part of hand to get
  155933. * @returns An array of meshes that correlate to the hand part requested
  155934. */
  155935. getHandPartMeshes(part: HandPart): AbstractMesh[];
  155936. /**
  155937. * Dispose this Hand object
  155938. */
  155939. dispose(): void;
  155940. }
  155941. /**
  155942. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  155943. */
  155944. export class WebXRHandTracking extends WebXRAbstractFeature {
  155945. /**
  155946. * options to use when constructing this feature
  155947. */
  155948. readonly options: IWebXRHandTrackingOptions;
  155949. private static _idCounter;
  155950. /**
  155951. * The module's name
  155952. */
  155953. static readonly Name: string;
  155954. /**
  155955. * The (Babylon) version of this module.
  155956. * This is an integer representing the implementation version.
  155957. * This number does not correspond to the WebXR specs version
  155958. */
  155959. static readonly Version: number;
  155960. /**
  155961. * This observable will notify registered observers when a new hand object was added and initialized
  155962. */
  155963. onHandAddedObservable: Observable<WebXRHand>;
  155964. /**
  155965. * This observable will notify its observers right before the hand object is disposed
  155966. */
  155967. onHandRemovedObservable: Observable<WebXRHand>;
  155968. private _hands;
  155969. /**
  155970. * Creates a new instance of the hit test feature
  155971. * @param _xrSessionManager an instance of WebXRSessionManager
  155972. * @param options options to use when constructing this feature
  155973. */
  155974. constructor(_xrSessionManager: WebXRSessionManager,
  155975. /**
  155976. * options to use when constructing this feature
  155977. */
  155978. options: IWebXRHandTrackingOptions);
  155979. /**
  155980. * Check if the needed objects are defined.
  155981. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  155982. */
  155983. isCompatible(): boolean;
  155984. /**
  155985. * attach this feature
  155986. * Will usually be called by the features manager
  155987. *
  155988. * @returns true if successful.
  155989. */
  155990. attach(): boolean;
  155991. /**
  155992. * detach this feature.
  155993. * Will usually be called by the features manager
  155994. *
  155995. * @returns true if successful.
  155996. */
  155997. detach(): boolean;
  155998. /**
  155999. * Dispose this feature and all of the resources attached
  156000. */
  156001. dispose(): void;
  156002. /**
  156003. * Get the hand object according to the controller id
  156004. * @param controllerId the controller id to which we want to get the hand
  156005. * @returns null if not found or the WebXRHand object if found
  156006. */
  156007. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  156008. /**
  156009. * Get a hand object according to the requested handedness
  156010. * @param handedness the handedness to request
  156011. * @returns null if not found or the WebXRHand object if found
  156012. */
  156013. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156014. protected _onXRFrame(_xrFrame: XRFrame): void;
  156015. private _attachHand;
  156016. private _detachHand;
  156017. }
  156018. }
  156019. declare module BABYLON {
  156020. /**
  156021. * The motion controller class for all microsoft mixed reality controllers
  156022. */
  156023. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156024. protected readonly _mapping: {
  156025. defaultButton: {
  156026. valueNodeName: string;
  156027. unpressedNodeName: string;
  156028. pressedNodeName: string;
  156029. };
  156030. defaultAxis: {
  156031. valueNodeName: string;
  156032. minNodeName: string;
  156033. maxNodeName: string;
  156034. };
  156035. buttons: {
  156036. "xr-standard-trigger": {
  156037. rootNodeName: string;
  156038. componentProperty: string;
  156039. states: string[];
  156040. };
  156041. "xr-standard-squeeze": {
  156042. rootNodeName: string;
  156043. componentProperty: string;
  156044. states: string[];
  156045. };
  156046. "xr-standard-touchpad": {
  156047. rootNodeName: string;
  156048. labelAnchorNodeName: string;
  156049. touchPointNodeName: string;
  156050. };
  156051. "xr-standard-thumbstick": {
  156052. rootNodeName: string;
  156053. componentProperty: string;
  156054. states: string[];
  156055. };
  156056. };
  156057. axes: {
  156058. "xr-standard-touchpad": {
  156059. "x-axis": {
  156060. rootNodeName: string;
  156061. };
  156062. "y-axis": {
  156063. rootNodeName: string;
  156064. };
  156065. };
  156066. "xr-standard-thumbstick": {
  156067. "x-axis": {
  156068. rootNodeName: string;
  156069. };
  156070. "y-axis": {
  156071. rootNodeName: string;
  156072. };
  156073. };
  156074. };
  156075. };
  156076. /**
  156077. * The base url used to load the left and right controller models
  156078. */
  156079. static MODEL_BASE_URL: string;
  156080. /**
  156081. * The name of the left controller model file
  156082. */
  156083. static MODEL_LEFT_FILENAME: string;
  156084. /**
  156085. * The name of the right controller model file
  156086. */
  156087. static MODEL_RIGHT_FILENAME: string;
  156088. profileId: string;
  156089. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156090. protected _getFilenameAndPath(): {
  156091. filename: string;
  156092. path: string;
  156093. };
  156094. protected _getModelLoadingConstraints(): boolean;
  156095. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156096. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156097. protected _updateModel(): void;
  156098. }
  156099. }
  156100. declare module BABYLON {
  156101. /**
  156102. * The motion controller class for oculus touch (quest, rift).
  156103. * This class supports legacy mapping as well the standard xr mapping
  156104. */
  156105. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156106. private _forceLegacyControllers;
  156107. private _modelRootNode;
  156108. /**
  156109. * The base url used to load the left and right controller models
  156110. */
  156111. static MODEL_BASE_URL: string;
  156112. /**
  156113. * The name of the left controller model file
  156114. */
  156115. static MODEL_LEFT_FILENAME: string;
  156116. /**
  156117. * The name of the right controller model file
  156118. */
  156119. static MODEL_RIGHT_FILENAME: string;
  156120. /**
  156121. * Base Url for the Quest controller model.
  156122. */
  156123. static QUEST_MODEL_BASE_URL: string;
  156124. profileId: string;
  156125. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156126. protected _getFilenameAndPath(): {
  156127. filename: string;
  156128. path: string;
  156129. };
  156130. protected _getModelLoadingConstraints(): boolean;
  156131. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156132. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156133. protected _updateModel(): void;
  156134. /**
  156135. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156136. * between the touch and touch 2.
  156137. */
  156138. private _isQuest;
  156139. }
  156140. }
  156141. declare module BABYLON {
  156142. /**
  156143. * The motion controller class for the standard HTC-Vive controllers
  156144. */
  156145. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156146. private _modelRootNode;
  156147. /**
  156148. * The base url used to load the left and right controller models
  156149. */
  156150. static MODEL_BASE_URL: string;
  156151. /**
  156152. * File name for the controller model.
  156153. */
  156154. static MODEL_FILENAME: string;
  156155. profileId: string;
  156156. /**
  156157. * Create a new Vive motion controller object
  156158. * @param scene the scene to use to create this controller
  156159. * @param gamepadObject the corresponding gamepad object
  156160. * @param handedness the handedness of the controller
  156161. */
  156162. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156163. protected _getFilenameAndPath(): {
  156164. filename: string;
  156165. path: string;
  156166. };
  156167. protected _getModelLoadingConstraints(): boolean;
  156168. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156169. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156170. protected _updateModel(): void;
  156171. }
  156172. }
  156173. declare module BABYLON {
  156174. /**
  156175. * A cursor which tracks a point on a path
  156176. */
  156177. export class PathCursor {
  156178. private path;
  156179. /**
  156180. * Stores path cursor callbacks for when an onchange event is triggered
  156181. */
  156182. private _onchange;
  156183. /**
  156184. * The value of the path cursor
  156185. */
  156186. value: number;
  156187. /**
  156188. * The animation array of the path cursor
  156189. */
  156190. animations: Animation[];
  156191. /**
  156192. * Initializes the path cursor
  156193. * @param path The path to track
  156194. */
  156195. constructor(path: Path2);
  156196. /**
  156197. * Gets the cursor point on the path
  156198. * @returns A point on the path cursor at the cursor location
  156199. */
  156200. getPoint(): Vector3;
  156201. /**
  156202. * Moves the cursor ahead by the step amount
  156203. * @param step The amount to move the cursor forward
  156204. * @returns This path cursor
  156205. */
  156206. moveAhead(step?: number): PathCursor;
  156207. /**
  156208. * Moves the cursor behind by the step amount
  156209. * @param step The amount to move the cursor back
  156210. * @returns This path cursor
  156211. */
  156212. moveBack(step?: number): PathCursor;
  156213. /**
  156214. * Moves the cursor by the step amount
  156215. * If the step amount is greater than one, an exception is thrown
  156216. * @param step The amount to move the cursor
  156217. * @returns This path cursor
  156218. */
  156219. move(step: number): PathCursor;
  156220. /**
  156221. * Ensures that the value is limited between zero and one
  156222. * @returns This path cursor
  156223. */
  156224. private ensureLimits;
  156225. /**
  156226. * Runs onchange callbacks on change (used by the animation engine)
  156227. * @returns This path cursor
  156228. */
  156229. private raiseOnChange;
  156230. /**
  156231. * Executes a function on change
  156232. * @param f A path cursor onchange callback
  156233. * @returns This path cursor
  156234. */
  156235. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156236. }
  156237. }
  156238. declare module BABYLON {
  156239. /** @hidden */
  156240. export var blurPixelShader: {
  156241. name: string;
  156242. shader: string;
  156243. };
  156244. }
  156245. declare module BABYLON {
  156246. /** @hidden */
  156247. export var pointCloudVertexDeclaration: {
  156248. name: string;
  156249. shader: string;
  156250. };
  156251. }
  156252. // Mixins
  156253. interface Window {
  156254. mozIndexedDB: IDBFactory;
  156255. webkitIndexedDB: IDBFactory;
  156256. msIndexedDB: IDBFactory;
  156257. webkitURL: typeof URL;
  156258. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156259. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156260. WebGLRenderingContext: WebGLRenderingContext;
  156261. MSGesture: MSGesture;
  156262. CANNON: any;
  156263. AudioContext: AudioContext;
  156264. webkitAudioContext: AudioContext;
  156265. PointerEvent: any;
  156266. Math: Math;
  156267. Uint8Array: Uint8ArrayConstructor;
  156268. Float32Array: Float32ArrayConstructor;
  156269. mozURL: typeof URL;
  156270. msURL: typeof URL;
  156271. VRFrameData: any; // WebVR, from specs 1.1
  156272. DracoDecoderModule: any;
  156273. setImmediate(handler: (...args: any[]) => void): number;
  156274. }
  156275. interface HTMLCanvasElement {
  156276. requestPointerLock(): void;
  156277. msRequestPointerLock?(): void;
  156278. mozRequestPointerLock?(): void;
  156279. webkitRequestPointerLock?(): void;
  156280. /** Track wether a record is in progress */
  156281. isRecording: boolean;
  156282. /** Capture Stream method defined by some browsers */
  156283. captureStream(fps?: number): MediaStream;
  156284. }
  156285. interface CanvasRenderingContext2D {
  156286. msImageSmoothingEnabled: boolean;
  156287. }
  156288. interface MouseEvent {
  156289. mozMovementX: number;
  156290. mozMovementY: number;
  156291. webkitMovementX: number;
  156292. webkitMovementY: number;
  156293. msMovementX: number;
  156294. msMovementY: number;
  156295. }
  156296. interface Navigator {
  156297. mozGetVRDevices: (any: any) => any;
  156298. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156299. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156300. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156301. webkitGetGamepads(): Gamepad[];
  156302. msGetGamepads(): Gamepad[];
  156303. webkitGamepads(): Gamepad[];
  156304. }
  156305. interface HTMLVideoElement {
  156306. mozSrcObject: any;
  156307. }
  156308. interface Math {
  156309. fround(x: number): number;
  156310. imul(a: number, b: number): number;
  156311. }
  156312. interface WebGLRenderingContext {
  156313. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  156314. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  156315. vertexAttribDivisor(index: number, divisor: number): void;
  156316. createVertexArray(): any;
  156317. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  156318. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  156319. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  156320. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  156321. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  156322. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  156323. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  156324. // Queries
  156325. createQuery(): WebGLQuery;
  156326. deleteQuery(query: WebGLQuery): void;
  156327. beginQuery(target: number, query: WebGLQuery): void;
  156328. endQuery(target: number): void;
  156329. getQueryParameter(query: WebGLQuery, pname: number): any;
  156330. getQuery(target: number, pname: number): any;
  156331. MAX_SAMPLES: number;
  156332. RGBA8: number;
  156333. READ_FRAMEBUFFER: number;
  156334. DRAW_FRAMEBUFFER: number;
  156335. UNIFORM_BUFFER: number;
  156336. HALF_FLOAT_OES: number;
  156337. RGBA16F: number;
  156338. RGBA32F: number;
  156339. R32F: number;
  156340. RG32F: number;
  156341. RGB32F: number;
  156342. R16F: number;
  156343. RG16F: number;
  156344. RGB16F: number;
  156345. RED: number;
  156346. RG: number;
  156347. R8: number;
  156348. RG8: number;
  156349. UNSIGNED_INT_24_8: number;
  156350. DEPTH24_STENCIL8: number;
  156351. MIN: number;
  156352. MAX: number;
  156353. /* Multiple Render Targets */
  156354. drawBuffers(buffers: number[]): void;
  156355. readBuffer(src: number): void;
  156356. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  156357. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  156358. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  156359. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  156360. // Occlusion Query
  156361. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  156362. ANY_SAMPLES_PASSED: number;
  156363. QUERY_RESULT_AVAILABLE: number;
  156364. QUERY_RESULT: number;
  156365. }
  156366. interface WebGLProgram {
  156367. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  156368. }
  156369. interface EXT_disjoint_timer_query {
  156370. QUERY_COUNTER_BITS_EXT: number;
  156371. TIME_ELAPSED_EXT: number;
  156372. TIMESTAMP_EXT: number;
  156373. GPU_DISJOINT_EXT: number;
  156374. QUERY_RESULT_EXT: number;
  156375. QUERY_RESULT_AVAILABLE_EXT: number;
  156376. queryCounterEXT(query: WebGLQuery, target: number): void;
  156377. createQueryEXT(): WebGLQuery;
  156378. beginQueryEXT(target: number, query: WebGLQuery): void;
  156379. endQueryEXT(target: number): void;
  156380. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  156381. deleteQueryEXT(query: WebGLQuery): void;
  156382. }
  156383. interface WebGLUniformLocation {
  156384. _currentState: any;
  156385. }
  156386. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  156387. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  156388. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  156389. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156390. interface WebGLRenderingContext {
  156391. readonly RASTERIZER_DISCARD: number;
  156392. readonly DEPTH_COMPONENT24: number;
  156393. readonly TEXTURE_3D: number;
  156394. readonly TEXTURE_2D_ARRAY: number;
  156395. readonly TEXTURE_COMPARE_FUNC: number;
  156396. readonly TEXTURE_COMPARE_MODE: number;
  156397. readonly COMPARE_REF_TO_TEXTURE: number;
  156398. readonly TEXTURE_WRAP_R: number;
  156399. readonly HALF_FLOAT: number;
  156400. readonly RGB8: number;
  156401. readonly RED_INTEGER: number;
  156402. readonly RG_INTEGER: number;
  156403. readonly RGB_INTEGER: number;
  156404. readonly RGBA_INTEGER: number;
  156405. readonly R8_SNORM: number;
  156406. readonly RG8_SNORM: number;
  156407. readonly RGB8_SNORM: number;
  156408. readonly RGBA8_SNORM: number;
  156409. readonly R8I: number;
  156410. readonly RG8I: number;
  156411. readonly RGB8I: number;
  156412. readonly RGBA8I: number;
  156413. readonly R8UI: number;
  156414. readonly RG8UI: number;
  156415. readonly RGB8UI: number;
  156416. readonly RGBA8UI: number;
  156417. readonly R16I: number;
  156418. readonly RG16I: number;
  156419. readonly RGB16I: number;
  156420. readonly RGBA16I: number;
  156421. readonly R16UI: number;
  156422. readonly RG16UI: number;
  156423. readonly RGB16UI: number;
  156424. readonly RGBA16UI: number;
  156425. readonly R32I: number;
  156426. readonly RG32I: number;
  156427. readonly RGB32I: number;
  156428. readonly RGBA32I: number;
  156429. readonly R32UI: number;
  156430. readonly RG32UI: number;
  156431. readonly RGB32UI: number;
  156432. readonly RGBA32UI: number;
  156433. readonly RGB10_A2UI: number;
  156434. readonly R11F_G11F_B10F: number;
  156435. readonly RGB9_E5: number;
  156436. readonly RGB10_A2: number;
  156437. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  156438. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  156439. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  156440. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  156441. readonly DEPTH_COMPONENT32F: number;
  156442. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  156443. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  156444. 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;
  156445. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  156446. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  156447. readonly TRANSFORM_FEEDBACK: number;
  156448. readonly INTERLEAVED_ATTRIBS: number;
  156449. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  156450. createTransformFeedback(): WebGLTransformFeedback;
  156451. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  156452. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  156453. beginTransformFeedback(primitiveMode: number): void;
  156454. endTransformFeedback(): void;
  156455. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  156456. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156457. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156458. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156459. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  156460. }
  156461. interface ImageBitmap {
  156462. readonly width: number;
  156463. readonly height: number;
  156464. close(): void;
  156465. }
  156466. interface WebGLQuery extends WebGLObject {
  156467. }
  156468. declare var WebGLQuery: {
  156469. prototype: WebGLQuery;
  156470. new(): WebGLQuery;
  156471. };
  156472. interface WebGLSampler extends WebGLObject {
  156473. }
  156474. declare var WebGLSampler: {
  156475. prototype: WebGLSampler;
  156476. new(): WebGLSampler;
  156477. };
  156478. interface WebGLSync extends WebGLObject {
  156479. }
  156480. declare var WebGLSync: {
  156481. prototype: WebGLSync;
  156482. new(): WebGLSync;
  156483. };
  156484. interface WebGLTransformFeedback extends WebGLObject {
  156485. }
  156486. declare var WebGLTransformFeedback: {
  156487. prototype: WebGLTransformFeedback;
  156488. new(): WebGLTransformFeedback;
  156489. };
  156490. interface WebGLVertexArrayObject extends WebGLObject {
  156491. }
  156492. declare var WebGLVertexArrayObject: {
  156493. prototype: WebGLVertexArrayObject;
  156494. new(): WebGLVertexArrayObject;
  156495. };
  156496. // Type definitions for WebVR API
  156497. // Project: https://w3c.github.io/webvr/
  156498. // Definitions by: six a <https://github.com/lostfictions>
  156499. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156500. interface VRDisplay extends EventTarget {
  156501. /**
  156502. * Dictionary of capabilities describing the VRDisplay.
  156503. */
  156504. readonly capabilities: VRDisplayCapabilities;
  156505. /**
  156506. * z-depth defining the far plane of the eye view frustum
  156507. * enables mapping of values in the render target depth
  156508. * attachment to scene coordinates. Initially set to 10000.0.
  156509. */
  156510. depthFar: number;
  156511. /**
  156512. * z-depth defining the near plane of the eye view frustum
  156513. * enables mapping of values in the render target depth
  156514. * attachment to scene coordinates. Initially set to 0.01.
  156515. */
  156516. depthNear: number;
  156517. /**
  156518. * An identifier for this distinct VRDisplay. Used as an
  156519. * association point in the Gamepad API.
  156520. */
  156521. readonly displayId: number;
  156522. /**
  156523. * A display name, a user-readable name identifying it.
  156524. */
  156525. readonly displayName: string;
  156526. readonly isConnected: boolean;
  156527. readonly isPresenting: boolean;
  156528. /**
  156529. * If this VRDisplay supports room-scale experiences, the optional
  156530. * stage attribute contains details on the room-scale parameters.
  156531. */
  156532. readonly stageParameters: VRStageParameters | null;
  156533. /**
  156534. * Passing the value returned by `requestAnimationFrame` to
  156535. * `cancelAnimationFrame` will unregister the callback.
  156536. * @param handle Define the hanle of the request to cancel
  156537. */
  156538. cancelAnimationFrame(handle: number): void;
  156539. /**
  156540. * Stops presenting to the VRDisplay.
  156541. * @returns a promise to know when it stopped
  156542. */
  156543. exitPresent(): Promise<void>;
  156544. /**
  156545. * Return the current VREyeParameters for the given eye.
  156546. * @param whichEye Define the eye we want the parameter for
  156547. * @returns the eye parameters
  156548. */
  156549. getEyeParameters(whichEye: string): VREyeParameters;
  156550. /**
  156551. * Populates the passed VRFrameData with the information required to render
  156552. * the current frame.
  156553. * @param frameData Define the data structure to populate
  156554. * @returns true if ok otherwise false
  156555. */
  156556. getFrameData(frameData: VRFrameData): boolean;
  156557. /**
  156558. * Get the layers currently being presented.
  156559. * @returns the list of VR layers
  156560. */
  156561. getLayers(): VRLayer[];
  156562. /**
  156563. * Return a VRPose containing the future predicted pose of the VRDisplay
  156564. * when the current frame will be presented. The value returned will not
  156565. * change until JavaScript has returned control to the browser.
  156566. *
  156567. * The VRPose will contain the position, orientation, velocity,
  156568. * and acceleration of each of these properties.
  156569. * @returns the pose object
  156570. */
  156571. getPose(): VRPose;
  156572. /**
  156573. * Return the current instantaneous pose of the VRDisplay, with no
  156574. * prediction applied.
  156575. * @returns the current instantaneous pose
  156576. */
  156577. getImmediatePose(): VRPose;
  156578. /**
  156579. * The callback passed to `requestAnimationFrame` will be called
  156580. * any time a new frame should be rendered. When the VRDisplay is
  156581. * presenting the callback will be called at the native refresh
  156582. * rate of the HMD. When not presenting this function acts
  156583. * identically to how window.requestAnimationFrame acts. Content should
  156584. * make no assumptions of frame rate or vsync behavior as the HMD runs
  156585. * asynchronously from other displays and at differing refresh rates.
  156586. * @param callback Define the eaction to run next frame
  156587. * @returns the request handle it
  156588. */
  156589. requestAnimationFrame(callback: FrameRequestCallback): number;
  156590. /**
  156591. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  156592. * Repeat calls while already presenting will update the VRLayers being displayed.
  156593. * @param layers Define the list of layer to present
  156594. * @returns a promise to know when the request has been fulfilled
  156595. */
  156596. requestPresent(layers: VRLayer[]): Promise<void>;
  156597. /**
  156598. * Reset the pose for this display, treating its current position and
  156599. * orientation as the "origin/zero" values. VRPose.position,
  156600. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  156601. * updated when calling resetPose(). This should be called in only
  156602. * sitting-space experiences.
  156603. */
  156604. resetPose(): void;
  156605. /**
  156606. * The VRLayer provided to the VRDisplay will be captured and presented
  156607. * in the HMD. Calling this function has the same effect on the source
  156608. * canvas as any other operation that uses its source image, and canvases
  156609. * created without preserveDrawingBuffer set to true will be cleared.
  156610. * @param pose Define the pose to submit
  156611. */
  156612. submitFrame(pose?: VRPose): void;
  156613. }
  156614. declare var VRDisplay: {
  156615. prototype: VRDisplay;
  156616. new(): VRDisplay;
  156617. };
  156618. interface VRLayer {
  156619. leftBounds?: number[] | Float32Array | null;
  156620. rightBounds?: number[] | Float32Array | null;
  156621. source?: HTMLCanvasElement | null;
  156622. }
  156623. interface VRDisplayCapabilities {
  156624. readonly canPresent: boolean;
  156625. readonly hasExternalDisplay: boolean;
  156626. readonly hasOrientation: boolean;
  156627. readonly hasPosition: boolean;
  156628. readonly maxLayers: number;
  156629. }
  156630. interface VREyeParameters {
  156631. /** @deprecated */
  156632. readonly fieldOfView: VRFieldOfView;
  156633. readonly offset: Float32Array;
  156634. readonly renderHeight: number;
  156635. readonly renderWidth: number;
  156636. }
  156637. interface VRFieldOfView {
  156638. readonly downDegrees: number;
  156639. readonly leftDegrees: number;
  156640. readonly rightDegrees: number;
  156641. readonly upDegrees: number;
  156642. }
  156643. interface VRFrameData {
  156644. readonly leftProjectionMatrix: Float32Array;
  156645. readonly leftViewMatrix: Float32Array;
  156646. readonly pose: VRPose;
  156647. readonly rightProjectionMatrix: Float32Array;
  156648. readonly rightViewMatrix: Float32Array;
  156649. readonly timestamp: number;
  156650. }
  156651. interface VRPose {
  156652. readonly angularAcceleration: Float32Array | null;
  156653. readonly angularVelocity: Float32Array | null;
  156654. readonly linearAcceleration: Float32Array | null;
  156655. readonly linearVelocity: Float32Array | null;
  156656. readonly orientation: Float32Array | null;
  156657. readonly position: Float32Array | null;
  156658. readonly timestamp: number;
  156659. }
  156660. interface VRStageParameters {
  156661. sittingToStandingTransform?: Float32Array;
  156662. sizeX?: number;
  156663. sizeY?: number;
  156664. }
  156665. interface Navigator {
  156666. getVRDisplays(): Promise<VRDisplay[]>;
  156667. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  156668. }
  156669. interface Window {
  156670. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  156671. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  156672. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  156673. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156674. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156675. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  156676. }
  156677. interface Gamepad {
  156678. readonly displayId: number;
  156679. }
  156680. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  156681. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  156682. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  156683. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  156684. type XRHandedness = "none" | "left" | "right";
  156685. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  156686. type XREye = "none" | "left" | "right";
  156687. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  156688. interface XRSpace extends EventTarget {}
  156689. interface XRRenderState {
  156690. depthNear?: number;
  156691. depthFar?: number;
  156692. inlineVerticalFieldOfView?: number;
  156693. baseLayer?: XRWebGLLayer;
  156694. }
  156695. interface XRInputSource {
  156696. handedness: XRHandedness;
  156697. targetRayMode: XRTargetRayMode;
  156698. targetRaySpace: XRSpace;
  156699. gripSpace: XRSpace | undefined;
  156700. gamepad: Gamepad | undefined;
  156701. profiles: Array<string>;
  156702. hand: XRHand | undefined;
  156703. }
  156704. interface XRSessionInit {
  156705. optionalFeatures?: string[];
  156706. requiredFeatures?: string[];
  156707. }
  156708. interface XRSession {
  156709. addEventListener: Function;
  156710. removeEventListener: Function;
  156711. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  156712. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  156713. requestAnimationFrame: Function;
  156714. end(): Promise<void>;
  156715. renderState: XRRenderState;
  156716. inputSources: Array<XRInputSource>;
  156717. // hit test
  156718. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  156719. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  156720. // legacy AR hit test
  156721. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156722. // legacy plane detection
  156723. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  156724. }
  156725. interface XRReferenceSpace extends XRSpace {
  156726. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  156727. onreset: any;
  156728. }
  156729. type XRPlaneSet = Set<XRPlane>;
  156730. type XRAnchorSet = Set<XRAnchor>;
  156731. interface XRFrame {
  156732. session: XRSession;
  156733. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  156734. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  156735. // AR
  156736. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  156737. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  156738. // Anchors
  156739. trackedAnchors?: XRAnchorSet;
  156740. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  156741. // Planes
  156742. worldInformation: {
  156743. detectedPlanes?: XRPlaneSet;
  156744. };
  156745. // Hand tracking
  156746. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  156747. }
  156748. interface XRViewerPose extends XRPose {
  156749. views: Array<XRView>;
  156750. }
  156751. interface XRPose {
  156752. transform: XRRigidTransform;
  156753. emulatedPosition: boolean;
  156754. }
  156755. interface XRWebGLLayerOptions {
  156756. antialias?: boolean;
  156757. depth?: boolean;
  156758. stencil?: boolean;
  156759. alpha?: boolean;
  156760. multiview?: boolean;
  156761. framebufferScaleFactor?: number;
  156762. }
  156763. declare var XRWebGLLayer: {
  156764. prototype: XRWebGLLayer;
  156765. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  156766. };
  156767. interface XRWebGLLayer {
  156768. framebuffer: WebGLFramebuffer;
  156769. framebufferWidth: number;
  156770. framebufferHeight: number;
  156771. getViewport: Function;
  156772. }
  156773. declare class XRRigidTransform {
  156774. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  156775. position: DOMPointReadOnly;
  156776. orientation: DOMPointReadOnly;
  156777. matrix: Float32Array;
  156778. inverse: XRRigidTransform;
  156779. }
  156780. interface XRView {
  156781. eye: XREye;
  156782. projectionMatrix: Float32Array;
  156783. transform: XRRigidTransform;
  156784. }
  156785. interface XRInputSourceChangeEvent {
  156786. session: XRSession;
  156787. removed: Array<XRInputSource>;
  156788. added: Array<XRInputSource>;
  156789. }
  156790. interface XRInputSourceEvent extends Event {
  156791. readonly frame: XRFrame;
  156792. readonly inputSource: XRInputSource;
  156793. }
  156794. // Experimental(er) features
  156795. declare class XRRay {
  156796. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  156797. origin: DOMPointReadOnly;
  156798. direction: DOMPointReadOnly;
  156799. matrix: Float32Array;
  156800. }
  156801. declare enum XRHitTestTrackableType {
  156802. "point",
  156803. "plane",
  156804. "mesh",
  156805. }
  156806. interface XRHitResult {
  156807. hitMatrix: Float32Array;
  156808. }
  156809. interface XRTransientInputHitTestResult {
  156810. readonly inputSource: XRInputSource;
  156811. readonly results: Array<XRHitTestResult>;
  156812. }
  156813. interface XRHitTestResult {
  156814. getPose(baseSpace: XRSpace): XRPose | undefined;
  156815. // When anchor system is enabled
  156816. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  156817. }
  156818. interface XRHitTestSource {
  156819. cancel(): void;
  156820. }
  156821. interface XRTransientInputHitTestSource {
  156822. cancel(): void;
  156823. }
  156824. interface XRHitTestOptionsInit {
  156825. space: XRSpace;
  156826. entityTypes?: Array<XRHitTestTrackableType>;
  156827. offsetRay?: XRRay;
  156828. }
  156829. interface XRTransientInputHitTestOptionsInit {
  156830. profile: string;
  156831. entityTypes?: Array<XRHitTestTrackableType>;
  156832. offsetRay?: XRRay;
  156833. }
  156834. interface XRAnchor {
  156835. anchorSpace: XRSpace;
  156836. delete(): void;
  156837. }
  156838. interface XRPlane {
  156839. orientation: "Horizontal" | "Vertical";
  156840. planeSpace: XRSpace;
  156841. polygon: Array<DOMPointReadOnly>;
  156842. lastChangedTime: number;
  156843. }
  156844. interface XRJointSpace extends XRSpace {}
  156845. interface XRJointPose extends XRPose {
  156846. radius: number | undefined;
  156847. }
  156848. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  156849. readonly length: number;
  156850. [index: number]: XRJointSpace;
  156851. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  156852. readonly WRIST: number;
  156853. readonly THUMB_METACARPAL: number;
  156854. readonly THUMB_PHALANX_PROXIMAL: number;
  156855. readonly THUMB_PHALANX_DISTAL: number;
  156856. readonly THUMB_PHALANX_TIP: number;
  156857. readonly INDEX_METACARPAL: number;
  156858. readonly INDEX_PHALANX_PROXIMAL: number;
  156859. readonly INDEX_PHALANX_INTERMEDIATE: number;
  156860. readonly INDEX_PHALANX_DISTAL: number;
  156861. readonly INDEX_PHALANX_TIP: number;
  156862. readonly MIDDLE_METACARPAL: number;
  156863. readonly MIDDLE_PHALANX_PROXIMAL: number;
  156864. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  156865. readonly MIDDLE_PHALANX_DISTAL: number;
  156866. readonly MIDDLE_PHALANX_TIP: number;
  156867. readonly RING_METACARPAL: number;
  156868. readonly RING_PHALANX_PROXIMAL: number;
  156869. readonly RING_PHALANX_INTERMEDIATE: number;
  156870. readonly RING_PHALANX_DISTAL: number;
  156871. readonly RING_PHALANX_TIP: number;
  156872. readonly LITTLE_METACARPAL: number;
  156873. readonly LITTLE_PHALANX_PROXIMAL: number;
  156874. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  156875. readonly LITTLE_PHALANX_DISTAL: number;
  156876. readonly LITTLE_PHALANX_TIP: number;
  156877. }
  156878. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  156879. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  156880. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  156881. interface XRSession {
  156882. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  156883. }
  156884. interface XRFrame {
  156885. featurePointCloud? : Array<number>;
  156886. }